babylon.module.d.ts 6.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815157816157817157818157819157820157821157822157823157824157825157826157827157828157829157830157831157832157833157834157835157836157837157838157839157840157841157842157843157844157845157846157847157848157849157850157851157852157853157854157855157856157857157858157859157860157861157862157863157864157865157866157867157868157869157870157871157872157873157874157875157876157877157878157879157880157881157882157883157884157885157886157887157888157889157890157891157892157893157894157895157896157897157898157899157900157901157902157903157904157905157906157907157908157909157910157911157912157913157914157915157916157917157918157919157920157921157922157923157924157925157926157927157928157929157930157931157932157933157934157935157936157937157938157939157940157941157942157943157944157945157946157947157948157949157950157951157952157953157954157955157956157957157958157959157960157961157962157963157964157965157966157967157968157969157970157971157972157973157974157975157976157977157978157979157980157981157982157983157984157985157986157987157988157989157990157991157992157993157994157995157996157997157998157999158000158001158002158003158004158005158006158007158008158009158010158011158012158013158014158015158016158017158018158019158020158021158022158023158024158025158026158027158028158029158030158031158032158033158034158035158036158037158038158039158040158041158042158043158044158045158046158047158048158049158050158051158052158053158054158055158056158057158058158059158060158061158062158063158064158065158066158067158068158069158070158071158072158073158074158075158076158077158078158079158080158081158082158083158084158085158086158087158088158089158090158091158092158093158094158095158096158097158098158099158100158101158102158103158104158105158106158107158108158109158110158111158112158113158114158115158116158117158118158119158120158121158122158123158124158125158126158127158128158129158130158131158132158133158134158135158136158137158138158139158140158141158142158143158144158145158146158147158148158149158150158151158152158153158154158155158156158157158158158159158160158161158162158163158164158165158166158167158168158169158170158171158172158173158174158175158176158177158178158179158180158181158182158183158184158185158186158187158188158189158190158191158192158193158194158195158196158197158198158199158200158201158202158203158204158205158206158207158208158209158210158211158212158213158214158215158216158217158218158219158220158221158222158223158224158225158226158227158228158229158230158231158232158233158234158235158236158237158238158239158240158241158242158243158244158245158246158247158248158249158250158251158252158253158254158255158256158257158258158259158260158261158262158263158264158265158266158267158268158269158270158271158272158273158274158275158276158277158278158279158280158281158282158283158284158285158286158287158288158289158290158291158292158293158294158295158296158297158298158299158300158301158302158303158304158305158306158307158308158309158310158311158312158313158314158315158316158317158318158319158320158321158322158323158324158325158326158327158328158329158330158331158332158333158334158335158336158337158338158339158340158341158342158343158344158345158346158347158348158349158350158351158352158353158354158355158356158357158358158359158360158361158362158363158364158365158366158367158368158369158370158371158372158373158374158375158376158377158378158379158380158381158382158383158384158385158386158387158388158389158390158391158392158393158394158395158396158397158398158399158400158401158402158403158404158405158406158407158408158409158410158411158412158413158414158415158416158417158418158419158420158421158422158423158424158425158426158427158428158429158430158431158432158433158434158435158436158437158438158439158440158441158442158443158444158445158446158447158448158449158450158451158452158453158454158455158456158457158458158459158460158461158462158463158464158465158466158467158468158469158470158471158472158473158474158475158476158477158478158479158480158481158482158483158484158485158486158487158488158489158490158491158492158493158494158495158496158497158498158499158500158501158502158503158504158505158506158507158508158509158510158511158512158513158514158515158516158517158518158519158520158521158522158523158524158525158526158527158528158529158530158531158532158533158534158535158536158537158538158539158540158541158542158543158544158545158546158547158548158549158550158551158552158553158554158555158556158557158558158559158560158561158562158563158564158565158566158567158568158569158570158571158572158573158574158575158576158577158578158579158580158581158582158583158584158585158586158587158588158589158590158591158592158593158594158595158596158597158598158599158600158601158602158603158604158605158606158607158608158609158610158611158612158613158614158615158616158617158618158619158620158621158622158623158624158625158626158627158628158629158630158631158632158633158634158635158636158637158638158639158640158641158642158643158644158645158646158647158648158649158650158651158652158653158654158655158656158657158658158659158660158661158662158663158664158665158666158667158668158669158670158671158672158673158674158675158676158677158678158679158680158681158682158683158684158685158686158687158688158689158690158691158692158693158694158695158696158697158698158699158700158701158702158703158704158705158706158707158708158709158710158711158712158713158714158715158716158717158718158719158720158721158722158723158724158725158726158727158728158729158730158731158732158733158734158735158736158737158738158739158740158741158742158743158744158745158746158747158748158749158750158751158752158753158754158755158756158757158758158759158760158761158762158763158764158765158766158767158768158769158770158771158772158773158774158775158776158777158778158779158780158781158782158783158784158785158786158787158788158789158790158791158792158793158794158795158796158797158798158799158800158801158802158803158804158805158806158807158808158809158810158811158812158813158814158815158816158817158818158819158820158821158822158823158824158825158826158827158828158829158830158831158832158833158834158835158836158837158838158839158840158841158842158843158844158845158846158847158848158849158850158851158852158853158854158855158856158857158858158859158860158861158862158863158864158865158866158867158868158869158870158871158872158873158874158875158876158877158878158879158880158881158882158883158884158885158886158887158888158889158890158891158892158893158894158895158896158897158898158899158900158901158902158903158904158905158906158907158908158909158910158911158912158913158914158915158916158917158918158919158920158921158922158923158924158925158926158927158928158929158930158931158932158933158934158935158936158937158938158939158940158941158942158943158944158945158946158947158948158949158950158951158952158953158954158955158956158957158958158959158960158961158962158963158964158965158966158967158968158969158970158971158972158973158974158975158976158977158978158979158980158981158982158983158984158985158986158987158988158989158990158991158992158993158994158995158996158997158998158999159000159001159002159003159004159005159006159007159008159009159010159011159012159013159014159015159016159017159018159019159020159021159022159023159024159025159026159027159028159029159030159031159032159033159034159035159036159037159038159039159040159041159042159043159044159045159046159047159048159049159050159051159052159053159054159055159056159057159058159059159060159061159062159063159064159065159066159067159068159069159070159071159072159073159074159075159076159077159078159079159080159081159082159083159084159085159086159087159088159089159090159091159092159093159094159095159096159097159098159099159100159101159102159103159104159105159106159107159108159109159110159111159112159113159114159115159116159117159118159119159120159121159122159123159124159125159126159127159128159129159130159131159132159133159134159135159136159137159138159139159140159141159142159143159144159145159146159147159148159149159150159151159152159153159154159155159156159157159158159159159160159161159162159163159164159165159166159167159168159169159170159171159172159173159174159175159176159177159178159179159180159181159182159183159184159185159186159187159188159189159190159191159192159193159194159195159196159197159198159199159200159201159202159203159204159205159206159207159208159209159210159211159212159213159214159215159216159217159218159219159220159221159222159223159224159225159226159227159228159229159230159231159232159233159234159235159236159237159238159239159240159241159242159243159244159245159246159247159248159249159250159251159252159253159254159255159256159257159258159259159260159261159262159263159264159265159266159267159268159269159270159271159272159273159274159275159276159277159278159279159280159281159282159283159284159285159286159287159288159289159290159291159292159293159294159295159296159297159298159299159300159301159302159303159304159305159306159307159308159309159310159311159312159313159314159315159316159317159318159319159320159321159322159323159324159325159326159327159328159329159330159331159332159333159334159335159336159337159338159339159340159341159342159343159344159345159346159347159348159349159350159351159352159353159354159355159356159357159358159359159360159361159362159363159364159365159366159367159368159369159370159371159372159373159374159375159376159377159378159379159380159381159382159383159384159385159386159387159388159389159390159391159392159393159394159395159396159397159398159399159400159401159402159403159404159405159406159407159408159409159410159411159412159413159414159415159416159417
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. /**
  95. * User defined information that will be sent to observers
  96. */
  97. userInfo?: any;
  98. }
  99. /**
  100. * Represent an Observer registered to a given Observable object.
  101. */
  102. export class Observer<T> {
  103. /**
  104. * Defines the callback to call when the observer is notified
  105. */
  106. callback: (eventData: T, eventState: EventState) => void;
  107. /**
  108. * Defines the mask of the observer (used to filter notifications)
  109. */
  110. mask: number;
  111. /**
  112. * Defines the current scope used to restore the JS context
  113. */
  114. scope: any;
  115. /** @hidden */
  116. _willBeUnregistered: boolean;
  117. /**
  118. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  119. */
  120. unregisterOnNextCall: boolean;
  121. /**
  122. * Creates a new observer
  123. * @param callback defines the callback to call when the observer is notified
  124. * @param mask defines the mask of the observer (used to filter notifications)
  125. * @param scope defines the current scope used to restore the JS context
  126. */
  127. constructor(
  128. /**
  129. * Defines the callback to call when the observer is notified
  130. */
  131. callback: (eventData: T, eventState: EventState) => void,
  132. /**
  133. * Defines the mask of the observer (used to filter notifications)
  134. */
  135. mask: number,
  136. /**
  137. * Defines the current scope used to restore the JS context
  138. */
  139. scope?: any);
  140. }
  141. /**
  142. * Represent a list of observers registered to multiple Observables object.
  143. */
  144. export class MultiObserver<T> {
  145. private _observers;
  146. private _observables;
  147. /**
  148. * Release associated resources
  149. */
  150. dispose(): void;
  151. /**
  152. * Raise a callback when one of the observable will notify
  153. * @param observables defines a list of observables to watch
  154. * @param callback defines the callback to call on notification
  155. * @param mask defines the mask used to filter notifications
  156. * @param scope defines the current scope used to restore the JS context
  157. * @returns the new MultiObserver
  158. */
  159. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  160. }
  161. /**
  162. * The Observable class is a simple implementation of the Observable pattern.
  163. *
  164. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  165. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  166. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  167. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  168. */
  169. export class Observable<T> {
  170. private _observers;
  171. private _eventState;
  172. private _onObserverAdded;
  173. /**
  174. * Gets the list of observers
  175. */
  176. get observers(): Array<Observer<T>>;
  177. /**
  178. * Creates a new observable
  179. * @param onObserverAdded defines a callback to call when a new observer is added
  180. */
  181. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  182. /**
  183. * Create a new Observer with the specified callback
  184. * @param callback the callback that will be executed for that Observer
  185. * @param mask the mask used to filter observers
  186. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  187. * @param scope optional scope for the callback to be called from
  188. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  189. * @returns the new observer created for the callback
  190. */
  191. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  192. /**
  193. * Create a new Observer with the specified callback and unregisters after the next notification
  194. * @param callback the callback that will be executed for that Observer
  195. * @returns the new observer created for the callback
  196. */
  197. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  198. /**
  199. * Remove an Observer from the Observable object
  200. * @param observer the instance of the Observer to remove
  201. * @returns false if it doesn't belong to this Observable
  202. */
  203. remove(observer: Nullable<Observer<T>>): boolean;
  204. /**
  205. * Remove a callback from the Observable object
  206. * @param callback the callback to remove
  207. * @param scope optional scope. If used only the callbacks with this scope will be removed
  208. * @returns false if it doesn't belong to this Observable
  209. */
  210. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  211. private _deferUnregister;
  212. private _remove;
  213. /**
  214. * Moves the observable to the top of the observer list making it get called first when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverTopPriority(observer: Observer<T>): void;
  218. /**
  219. * Moves the observable to the bottom of the observer list making it get called last when notified
  220. * @param observer the observer to move
  221. */
  222. makeObserverBottomPriority(observer: Observer<T>): void;
  223. /**
  224. * Notify all Observers by calling their respective callback with the given data
  225. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  226. * @param eventData defines the data to send to all observers
  227. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  228. * @param target defines the original target of the state
  229. * @param currentTarget defines the current target of the state
  230. * @param userInfo defines any user info to send to observers
  231. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  232. */
  233. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  234. /**
  235. * Calling this will execute each callback, expecting it to be a promise or return a value.
  236. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  237. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  238. * and it is crucial that all callbacks will be executed.
  239. * The order of the callbacks is kept, callbacks are not executed parallel.
  240. *
  241. * @param eventData The data to be sent to each callback
  242. * @param mask is used to filter observers defaults to -1
  243. * @param target defines the callback target (see EventState)
  244. * @param currentTarget defines he current object in the bubbling phase
  245. * @param userInfo defines any user info to send to observers
  246. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  247. */
  248. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  249. /**
  250. * Notify a specific observer
  251. * @param observer defines the observer to notify
  252. * @param eventData defines the data to be sent to each callback
  253. * @param mask is used to filter observers defaults to -1
  254. */
  255. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  256. /**
  257. * Gets a boolean indicating if the observable has at least one observer
  258. * @returns true is the Observable has at least one Observer registered
  259. */
  260. hasObservers(): boolean;
  261. /**
  262. * Clear the list of observers
  263. */
  264. clear(): void;
  265. /**
  266. * Clone the current observable
  267. * @returns a new observable
  268. */
  269. clone(): Observable<T>;
  270. /**
  271. * Does this observable handles observer registered with a given mask
  272. * @param mask defines the mask to be tested
  273. * @return whether or not one observer registered with the given mask is handeled
  274. **/
  275. hasSpecificMask(mask?: number): boolean;
  276. }
  277. }
  278. declare module "babylonjs/Misc/domManagement" {
  279. /**
  280. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  281. * Babylon.js
  282. */
  283. export class DomManagement {
  284. /**
  285. * Checks if the window object exists
  286. * @returns true if the window object exists
  287. */
  288. static IsWindowObjectExist(): boolean;
  289. /**
  290. * Checks if the navigator object exists
  291. * @returns true if the navigator object exists
  292. */
  293. static IsNavigatorAvailable(): boolean;
  294. /**
  295. * Check if the document object exists
  296. * @returns true if the document object exists
  297. */
  298. static IsDocumentAvailable(): boolean;
  299. /**
  300. * Extracts text content from a DOM element hierarchy
  301. * @param element defines the root element
  302. * @returns a string
  303. */
  304. static GetDOMTextContent(element: HTMLElement): string;
  305. }
  306. }
  307. declare module "babylonjs/Misc/logger" {
  308. /**
  309. * Logger used througouht the application to allow configuration of
  310. * the log level required for the messages.
  311. */
  312. export class Logger {
  313. /**
  314. * No log
  315. */
  316. static readonly NoneLogLevel: number;
  317. /**
  318. * Only message logs
  319. */
  320. static readonly MessageLogLevel: number;
  321. /**
  322. * Only warning logs
  323. */
  324. static readonly WarningLogLevel: number;
  325. /**
  326. * Only error logs
  327. */
  328. static readonly ErrorLogLevel: number;
  329. /**
  330. * All logs
  331. */
  332. static readonly AllLogLevel: number;
  333. private static _LogCache;
  334. /**
  335. * Gets a value indicating the number of loading errors
  336. * @ignorenaming
  337. */
  338. static errorsCount: number;
  339. /**
  340. * Callback called when a new log is added
  341. */
  342. static OnNewCacheEntry: (entry: string) => void;
  343. private static _AddLogEntry;
  344. private static _FormatMessage;
  345. private static _LogDisabled;
  346. private static _LogEnabled;
  347. private static _WarnDisabled;
  348. private static _WarnEnabled;
  349. private static _ErrorDisabled;
  350. private static _ErrorEnabled;
  351. /**
  352. * Log a message to the console
  353. */
  354. static Log: (message: string) => void;
  355. /**
  356. * Write a warning message to the console
  357. */
  358. static Warn: (message: string) => void;
  359. /**
  360. * Write an error message to the console
  361. */
  362. static Error: (message: string) => void;
  363. /**
  364. * Gets current log cache (list of logs)
  365. */
  366. static get LogCache(): string;
  367. /**
  368. * Clears the log cache
  369. */
  370. static ClearLogCache(): void;
  371. /**
  372. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  373. */
  374. static set LogLevels(level: number);
  375. }
  376. }
  377. declare module "babylonjs/Misc/typeStore" {
  378. /** @hidden */
  379. export class _TypeStore {
  380. /** @hidden */
  381. static RegisteredTypes: {
  382. [key: string]: Object;
  383. };
  384. /** @hidden */
  385. static GetClass(fqdn: string): any;
  386. }
  387. }
  388. declare module "babylonjs/Misc/stringTools" {
  389. /**
  390. * Helper to manipulate strings
  391. */
  392. export class StringTools {
  393. /**
  394. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static EndsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  402. * @param str Source string
  403. * @param suffix Suffix to search for in the source string
  404. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  405. */
  406. static StartsWith(str: string, suffix: string): boolean;
  407. /**
  408. * Decodes a buffer into a string
  409. * @param buffer The buffer to decode
  410. * @returns The decoded string
  411. */
  412. static Decode(buffer: Uint8Array | Uint16Array): string;
  413. /**
  414. * Encode a buffer to a base64 string
  415. * @param buffer defines the buffer to encode
  416. * @returns the encoded string
  417. */
  418. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  419. /**
  420. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  421. * @param num the number to convert and pad
  422. * @param length the expected length of the string
  423. * @returns the padded string
  424. */
  425. static PadNumber(num: number, length: number): string;
  426. }
  427. }
  428. declare module "babylonjs/Misc/deepCopier" {
  429. /**
  430. * Class containing a set of static utilities functions for deep copy.
  431. */
  432. export class DeepCopier {
  433. /**
  434. * Tries to copy an object by duplicating every property
  435. * @param source defines the source object
  436. * @param destination defines the target object
  437. * @param doNotCopyList defines a list of properties to avoid
  438. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  439. */
  440. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  441. }
  442. }
  443. declare module "babylonjs/Misc/precisionDate" {
  444. /**
  445. * Class containing a set of static utilities functions for precision date
  446. */
  447. export class PrecisionDate {
  448. /**
  449. * Gets either window.performance.now() if supported or Date.now() else
  450. */
  451. static get Now(): number;
  452. }
  453. }
  454. declare module "babylonjs/Misc/devTools" {
  455. /** @hidden */
  456. export class _DevTools {
  457. static WarnImport(name: string): string;
  458. }
  459. }
  460. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  461. /**
  462. * Interface used to define the mechanism to get data from the network
  463. */
  464. export interface IWebRequest {
  465. /**
  466. * Returns client's response url
  467. */
  468. responseURL: string;
  469. /**
  470. * Returns client's status
  471. */
  472. status: number;
  473. /**
  474. * Returns client's status as a text
  475. */
  476. statusText: string;
  477. }
  478. }
  479. declare module "babylonjs/Misc/webRequest" {
  480. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  481. import { Nullable } from "babylonjs/types";
  482. /**
  483. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  484. */
  485. export class WebRequest implements IWebRequest {
  486. private readonly _xhr;
  487. /**
  488. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  489. * i.e. when loading files, where the server/service expects an Authorization header
  490. */
  491. static CustomRequestHeaders: {
  492. [key: string]: string;
  493. };
  494. /**
  495. * Add callback functions in this array to update all the requests before they get sent to the network
  496. */
  497. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  498. private _injectCustomRequestHeaders;
  499. /**
  500. * Gets or sets a function to be called when loading progress changes
  501. */
  502. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  503. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  504. /**
  505. * Returns client's state
  506. */
  507. get readyState(): number;
  508. /**
  509. * Returns client's status
  510. */
  511. get status(): number;
  512. /**
  513. * Returns client's status as a text
  514. */
  515. get statusText(): string;
  516. /**
  517. * Returns client's response
  518. */
  519. get response(): any;
  520. /**
  521. * Returns client's response url
  522. */
  523. get responseURL(): string;
  524. /**
  525. * Returns client's response as text
  526. */
  527. get responseText(): string;
  528. /**
  529. * Gets or sets the expected response type
  530. */
  531. get responseType(): XMLHttpRequestResponseType;
  532. set responseType(value: XMLHttpRequestResponseType);
  533. /** @hidden */
  534. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  535. /** @hidden */
  536. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  537. /**
  538. * Cancels any network activity
  539. */
  540. abort(): void;
  541. /**
  542. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  543. * @param body defines an optional request body
  544. */
  545. send(body?: Document | BodyInit | null): void;
  546. /**
  547. * Sets the request method, request URL
  548. * @param method defines the method to use (GET, POST, etc..)
  549. * @param url defines the url to connect with
  550. */
  551. open(method: string, url: string): void;
  552. /**
  553. * Sets the value of a request header.
  554. * @param name The name of the header whose value is to be set
  555. * @param value The value to set as the body of the header
  556. */
  557. setRequestHeader(name: string, value: string): void;
  558. /**
  559. * Get the string containing the text of a particular header's value.
  560. * @param name The name of the header
  561. * @returns The string containing the text of the given header name
  562. */
  563. getResponseHeader(name: string): Nullable<string>;
  564. }
  565. }
  566. declare module "babylonjs/Misc/fileRequest" {
  567. import { Observable } from "babylonjs/Misc/observable";
  568. /**
  569. * File request interface
  570. */
  571. export interface IFileRequest {
  572. /**
  573. * Raised when the request is complete (success or error).
  574. */
  575. onCompleteObservable: Observable<IFileRequest>;
  576. /**
  577. * Aborts the request for a file.
  578. */
  579. abort: () => void;
  580. }
  581. }
  582. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  583. /**
  584. * Define options used to create a render target texture
  585. */
  586. export class RenderTargetCreationOptions {
  587. /**
  588. * Specifies is mipmaps must be generated
  589. */
  590. generateMipMaps?: boolean;
  591. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  592. generateDepthBuffer?: boolean;
  593. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  594. generateStencilBuffer?: boolean;
  595. /** Defines texture type (int by default) */
  596. type?: number;
  597. /** Defines sampling mode (trilinear by default) */
  598. samplingMode?: number;
  599. /** Defines format (RGBA by default) */
  600. format?: number;
  601. }
  602. }
  603. declare module "babylonjs/Engines/constants" {
  604. /** Defines the cross module used constants to avoid circular dependncies */
  605. export class Constants {
  606. /** Defines that alpha blending is disabled */
  607. static readonly ALPHA_DISABLE: number;
  608. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  609. static readonly ALPHA_ADD: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_COMBINE: number;
  612. /** Defines that alpha blending is DEST - SRC * DEST */
  613. static readonly ALPHA_SUBTRACT: number;
  614. /** Defines that alpha blending is SRC * DEST */
  615. static readonly ALPHA_MULTIPLY: number;
  616. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  617. static readonly ALPHA_MAXIMIZED: number;
  618. /** Defines that alpha blending is SRC + DEST */
  619. static readonly ALPHA_ONEONE: number;
  620. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  621. static readonly ALPHA_PREMULTIPLIED: number;
  622. /**
  623. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  624. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  625. */
  626. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  627. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  628. static readonly ALPHA_INTERPOLATE: number;
  629. /**
  630. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  631. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  632. */
  633. static readonly ALPHA_SCREENMODE: number;
  634. /**
  635. * Defines that alpha blending is SRC + DST
  636. * Alpha will be set to SRC ALPHA + DST ALPHA
  637. */
  638. static readonly ALPHA_ONEONE_ONEONE: number;
  639. /**
  640. * Defines that alpha blending is SRC * DST ALPHA + DST
  641. * Alpha will be set to 0
  642. */
  643. static readonly ALPHA_ALPHATOCOLOR: number;
  644. /**
  645. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  646. */
  647. static readonly ALPHA_REVERSEONEMINUS: number;
  648. /**
  649. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  650. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  651. */
  652. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  653. /**
  654. * Defines that alpha blending is SRC + DST
  655. * Alpha will be set to SRC ALPHA
  656. */
  657. static readonly ALPHA_ONEONE_ONEZERO: number;
  658. /**
  659. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  660. * Alpha will be set to DST ALPHA
  661. */
  662. static readonly ALPHA_EXCLUSION: number;
  663. /** Defines that alpha blending equation a SUM */
  664. static readonly ALPHA_EQUATION_ADD: number;
  665. /** Defines that alpha blending equation a SUBSTRACTION */
  666. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  667. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  668. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  669. /** Defines that alpha blending equation a MAX operation */
  670. static readonly ALPHA_EQUATION_MAX: number;
  671. /** Defines that alpha blending equation a MIN operation */
  672. static readonly ALPHA_EQUATION_MIN: number;
  673. /**
  674. * Defines that alpha blending equation a DARKEN operation:
  675. * It takes the min of the src and sums the alpha channels.
  676. */
  677. static readonly ALPHA_EQUATION_DARKEN: number;
  678. /** Defines that the ressource is not delayed*/
  679. static readonly DELAYLOADSTATE_NONE: number;
  680. /** Defines that the ressource was successfully delay loaded */
  681. static readonly DELAYLOADSTATE_LOADED: number;
  682. /** Defines that the ressource is currently delay loading */
  683. static readonly DELAYLOADSTATE_LOADING: number;
  684. /** Defines that the ressource is delayed and has not started loading */
  685. static readonly DELAYLOADSTATE_NOTLOADED: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  687. static readonly NEVER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  689. static readonly ALWAYS: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  691. static readonly LESS: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  693. static readonly EQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  695. static readonly LEQUAL: number;
  696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  697. static readonly GREATER: number;
  698. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  699. static readonly GEQUAL: number;
  700. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  701. static readonly NOTEQUAL: number;
  702. /** Passed to stencilOperation to specify that stencil value must be kept */
  703. static readonly KEEP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be replaced */
  705. static readonly REPLACE: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented */
  707. static readonly INCR: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented */
  709. static readonly DECR: number;
  710. /** Passed to stencilOperation to specify that stencil value must be inverted */
  711. static readonly INVERT: number;
  712. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  713. static readonly INCR_WRAP: number;
  714. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  715. static readonly DECR_WRAP: number;
  716. /** Texture is not repeating outside of 0..1 UVs */
  717. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  718. /** Texture is repeating outside of 0..1 UVs */
  719. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  720. /** Texture is repeating and mirrored */
  721. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  722. /** ALPHA */
  723. static readonly TEXTUREFORMAT_ALPHA: number;
  724. /** LUMINANCE */
  725. static readonly TEXTUREFORMAT_LUMINANCE: number;
  726. /** LUMINANCE_ALPHA */
  727. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  728. /** RGB */
  729. static readonly TEXTUREFORMAT_RGB: number;
  730. /** RGBA */
  731. static readonly TEXTUREFORMAT_RGBA: number;
  732. /** RED */
  733. static readonly TEXTUREFORMAT_RED: number;
  734. /** RED (2nd reference) */
  735. static readonly TEXTUREFORMAT_R: number;
  736. /** RG */
  737. static readonly TEXTUREFORMAT_RG: number;
  738. /** RED_INTEGER */
  739. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  740. /** RED_INTEGER (2nd reference) */
  741. static readonly TEXTUREFORMAT_R_INTEGER: number;
  742. /** RG_INTEGER */
  743. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  744. /** RGB_INTEGER */
  745. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  746. /** RGBA_INTEGER */
  747. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  748. /** UNSIGNED_BYTE */
  749. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  750. /** UNSIGNED_BYTE (2nd reference) */
  751. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  752. /** FLOAT */
  753. static readonly TEXTURETYPE_FLOAT: number;
  754. /** HALF_FLOAT */
  755. static readonly TEXTURETYPE_HALF_FLOAT: number;
  756. /** BYTE */
  757. static readonly TEXTURETYPE_BYTE: number;
  758. /** SHORT */
  759. static readonly TEXTURETYPE_SHORT: number;
  760. /** UNSIGNED_SHORT */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  762. /** INT */
  763. static readonly TEXTURETYPE_INT: number;
  764. /** UNSIGNED_INT */
  765. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  766. /** UNSIGNED_SHORT_4_4_4_4 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  768. /** UNSIGNED_SHORT_5_5_5_1 */
  769. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  770. /** UNSIGNED_SHORT_5_6_5 */
  771. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  772. /** UNSIGNED_INT_2_10_10_10_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  774. /** UNSIGNED_INT_24_8 */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  776. /** UNSIGNED_INT_10F_11F_11F_REV */
  777. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  778. /** UNSIGNED_INT_5_9_9_9_REV */
  779. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  780. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  781. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  782. /** nearest is mag = nearest and min = nearest and no mip */
  783. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  784. /** mag = nearest and min = nearest and mip = none */
  785. static readonly TEXTURE_NEAREST_NEAREST: number;
  786. /** Bilinear is mag = linear and min = linear and no mip */
  787. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  788. /** mag = linear and min = linear and mip = none */
  789. static readonly TEXTURE_LINEAR_LINEAR: number;
  790. /** Trilinear is mag = linear and min = linear and mip = linear */
  791. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  792. /** Trilinear is mag = linear and min = linear and mip = linear */
  793. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = nearest and mip = nearest */
  795. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  796. /** mag = nearest and min = linear and mip = nearest */
  797. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  798. /** mag = nearest and min = linear and mip = linear */
  799. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  800. /** mag = nearest and min = linear and mip = none */
  801. static readonly TEXTURE_NEAREST_LINEAR: number;
  802. /** nearest is mag = nearest and min = nearest and mip = linear */
  803. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  804. /** mag = linear and min = nearest and mip = nearest */
  805. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = linear */
  807. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  808. /** Bilinear is mag = linear and min = linear and mip = nearest */
  809. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  810. /** mag = linear and min = nearest and mip = none */
  811. static readonly TEXTURE_LINEAR_NEAREST: number;
  812. /** Explicit coordinates mode */
  813. static readonly TEXTURE_EXPLICIT_MODE: number;
  814. /** Spherical coordinates mode */
  815. static readonly TEXTURE_SPHERICAL_MODE: number;
  816. /** Planar coordinates mode */
  817. static readonly TEXTURE_PLANAR_MODE: number;
  818. /** Cubic coordinates mode */
  819. static readonly TEXTURE_CUBIC_MODE: number;
  820. /** Projection coordinates mode */
  821. static readonly TEXTURE_PROJECTION_MODE: number;
  822. /** Skybox coordinates mode */
  823. static readonly TEXTURE_SKYBOX_MODE: number;
  824. /** Inverse Cubic coordinates mode */
  825. static readonly TEXTURE_INVCUBIC_MODE: number;
  826. /** Equirectangular coordinates mode */
  827. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  828. /** Equirectangular Fixed coordinates mode */
  829. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  830. /** Equirectangular Fixed Mirrored coordinates mode */
  831. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  832. /** Offline (baking) quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  834. /** High quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  836. /** Medium quality for texture filtering */
  837. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  838. /** Low quality for texture filtering */
  839. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  840. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  841. static readonly SCALEMODE_FLOOR: number;
  842. /** Defines that texture rescaling will look for the nearest power of 2 size */
  843. static readonly SCALEMODE_NEAREST: number;
  844. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  845. static readonly SCALEMODE_CEILING: number;
  846. /**
  847. * The dirty texture flag value
  848. */
  849. static readonly MATERIAL_TextureDirtyFlag: number;
  850. /**
  851. * The dirty light flag value
  852. */
  853. static readonly MATERIAL_LightDirtyFlag: number;
  854. /**
  855. * The dirty fresnel flag value
  856. */
  857. static readonly MATERIAL_FresnelDirtyFlag: number;
  858. /**
  859. * The dirty attribute flag value
  860. */
  861. static readonly MATERIAL_AttributesDirtyFlag: number;
  862. /**
  863. * The dirty misc flag value
  864. */
  865. static readonly MATERIAL_MiscDirtyFlag: number;
  866. /**
  867. * The dirty prepass flag value
  868. */
  869. static readonly MATERIAL_PrePassDirtyFlag: number;
  870. /**
  871. * The all dirty flag value
  872. */
  873. static readonly MATERIAL_AllDirtyFlag: number;
  874. /**
  875. * Returns the triangle fill mode
  876. */
  877. static readonly MATERIAL_TriangleFillMode: number;
  878. /**
  879. * Returns the wireframe mode
  880. */
  881. static readonly MATERIAL_WireFrameFillMode: number;
  882. /**
  883. * Returns the point fill mode
  884. */
  885. static readonly MATERIAL_PointFillMode: number;
  886. /**
  887. * Returns the point list draw mode
  888. */
  889. static readonly MATERIAL_PointListDrawMode: number;
  890. /**
  891. * Returns the line list draw mode
  892. */
  893. static readonly MATERIAL_LineListDrawMode: number;
  894. /**
  895. * Returns the line loop draw mode
  896. */
  897. static readonly MATERIAL_LineLoopDrawMode: number;
  898. /**
  899. * Returns the line strip draw mode
  900. */
  901. static readonly MATERIAL_LineStripDrawMode: number;
  902. /**
  903. * Returns the triangle strip draw mode
  904. */
  905. static readonly MATERIAL_TriangleStripDrawMode: number;
  906. /**
  907. * Returns the triangle fan draw mode
  908. */
  909. static readonly MATERIAL_TriangleFanDrawMode: number;
  910. /**
  911. * Stores the clock-wise side orientation
  912. */
  913. static readonly MATERIAL_ClockWiseSideOrientation: number;
  914. /**
  915. * Stores the counter clock-wise side orientation
  916. */
  917. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  918. /**
  919. * Nothing
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_NothingTrigger: number;
  923. /**
  924. * On pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickTrigger: number;
  928. /**
  929. * On left pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnLeftPickTrigger: number;
  933. /**
  934. * On right pick
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnRightPickTrigger: number;
  938. /**
  939. * On center pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnCenterPickTrigger: number;
  943. /**
  944. * On pick down
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickDownTrigger: number;
  948. /**
  949. * On double pick
  950. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  951. */
  952. static readonly ACTION_OnDoublePickTrigger: number;
  953. /**
  954. * On pick up
  955. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  956. */
  957. static readonly ACTION_OnPickUpTrigger: number;
  958. /**
  959. * On pick out.
  960. * This trigger will only be raised if you also declared a OnPickDown
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPickOutTrigger: number;
  964. /**
  965. * On long press
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnLongPressTrigger: number;
  969. /**
  970. * On pointer over
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnPointerOverTrigger: number;
  974. /**
  975. * On pointer out
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnPointerOutTrigger: number;
  979. /**
  980. * On every frame
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnEveryFrameTrigger: number;
  984. /**
  985. * On intersection enter
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnIntersectionEnterTrigger: number;
  989. /**
  990. * On intersection exit
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnIntersectionExitTrigger: number;
  994. /**
  995. * On key down
  996. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  997. */
  998. static readonly ACTION_OnKeyDownTrigger: number;
  999. /**
  1000. * On key up
  1001. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1002. */
  1003. static readonly ACTION_OnKeyUpTrigger: number;
  1004. /**
  1005. * Billboard mode will only apply to Y axis
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1008. /**
  1009. * Billboard mode will apply to all axes
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1012. /**
  1013. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1014. */
  1015. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1016. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1017. * Test order :
  1018. * Is the bounding sphere outside the frustum ?
  1019. * If not, are the bounding box vertices outside the frustum ?
  1020. * It not, then the cullable object is in the frustum.
  1021. */
  1022. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1023. /** Culling strategy : Bounding Sphere Only.
  1024. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1025. * It's also less accurate than the standard because some not visible objects can still be selected.
  1026. * Test : is the bounding sphere outside the frustum ?
  1027. * If not, then the cullable object is in the frustum.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1030. /** Culling strategy : Optimistic Inclusion.
  1031. * This in an inclusion test first, then the standard exclusion test.
  1032. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1033. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1034. * Anyway, it's as accurate as the standard strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the default culling strategy.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1040. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1041. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1042. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1043. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1044. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1045. * Test :
  1046. * Is the cullable object bounding sphere center in the frustum ?
  1047. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1048. */
  1049. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1050. /**
  1051. * No logging while loading
  1052. */
  1053. static readonly SCENELOADER_NO_LOGGING: number;
  1054. /**
  1055. * Minimal logging while loading
  1056. */
  1057. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1058. /**
  1059. * Summary logging while loading
  1060. */
  1061. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1062. /**
  1063. * Detailled logging while loading
  1064. */
  1065. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1066. /**
  1067. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1068. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1069. */
  1070. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1071. /**
  1072. * Constant used to retrieve the position texture index in the textures array in the prepass
  1073. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1074. */
  1075. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1076. /**
  1077. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1078. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1079. */
  1080. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1081. /**
  1082. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1083. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1084. */
  1085. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1086. /**
  1087. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1088. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1089. */
  1090. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1091. /**
  1092. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1093. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1094. */
  1095. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1096. /**
  1097. * Constant used to retrieve albedo index in the textures array in the prepass
  1098. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1099. */
  1100. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1101. }
  1102. }
  1103. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1104. import { Nullable } from "babylonjs/types";
  1105. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1106. /**
  1107. * This represents the required contract to create a new type of texture loader.
  1108. */
  1109. export interface IInternalTextureLoader {
  1110. /**
  1111. * Defines wether the loader supports cascade loading the different faces.
  1112. */
  1113. supportCascades: boolean;
  1114. /**
  1115. * This returns if the loader support the current file information.
  1116. * @param extension defines the file extension of the file being loaded
  1117. * @param mimeType defines the optional mime type of the file being loaded
  1118. * @returns true if the loader can load the specified file
  1119. */
  1120. canLoad(extension: string, mimeType?: string): boolean;
  1121. /**
  1122. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1123. * @param data contains the texture data
  1124. * @param texture defines the BabylonJS internal texture
  1125. * @param createPolynomials will be true if polynomials have been requested
  1126. * @param onLoad defines the callback to trigger once the texture is ready
  1127. * @param onError defines the callback to trigger in case of error
  1128. * @param options options to be passed to the loader
  1129. */
  1130. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1131. /**
  1132. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1133. * @param data contains the texture data
  1134. * @param texture defines the BabylonJS internal texture
  1135. * @param callback defines the method to call once ready to upload
  1136. * @param options options to be passed to the loader
  1137. */
  1138. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1139. }
  1140. }
  1141. declare module "babylonjs/Engines/IPipelineContext" {
  1142. /**
  1143. * Class used to store and describe the pipeline context associated with an effect
  1144. */
  1145. export interface IPipelineContext {
  1146. /**
  1147. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1148. */
  1149. isAsync: boolean;
  1150. /**
  1151. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1152. */
  1153. isReady: boolean;
  1154. /** @hidden */
  1155. _getVertexShaderCode(): string | null;
  1156. /** @hidden */
  1157. _getFragmentShaderCode(): string | null;
  1158. /** @hidden */
  1159. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1160. }
  1161. }
  1162. declare module "babylonjs/Meshes/dataBuffer" {
  1163. /**
  1164. * Class used to store gfx data (like WebGLBuffer)
  1165. */
  1166. export class DataBuffer {
  1167. /**
  1168. * Gets or sets the number of objects referencing this buffer
  1169. */
  1170. references: number;
  1171. /** Gets or sets the size of the underlying buffer */
  1172. capacity: number;
  1173. /**
  1174. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1175. */
  1176. is32Bits: boolean;
  1177. /**
  1178. * Gets the underlying buffer
  1179. */
  1180. get underlyingResource(): any;
  1181. }
  1182. }
  1183. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1184. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  1185. /** @hidden */
  1186. export interface IShaderProcessor {
  1187. attributeProcessor?: (attribute: string) => string;
  1188. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1189. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1190. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1191. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1192. lineProcessor?: (line: string, isFragment: boolean) => string;
  1193. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1194. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  1195. }
  1196. }
  1197. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1198. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1199. /** @hidden */
  1200. export interface ProcessingOptions {
  1201. defines: string[];
  1202. indexParameters: any;
  1203. isFragment: boolean;
  1204. shouldUseHighPrecisionShader: boolean;
  1205. supportsUniformBuffers: boolean;
  1206. shadersRepository: string;
  1207. includesShadersStore: {
  1208. [key: string]: string;
  1209. };
  1210. processor?: IShaderProcessor;
  1211. version: string;
  1212. platformName: string;
  1213. lookForClosingBracketForUniformBuffer?: boolean;
  1214. }
  1215. }
  1216. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1217. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1218. /** @hidden */
  1219. export class ShaderCodeNode {
  1220. line: string;
  1221. children: ShaderCodeNode[];
  1222. additionalDefineKey?: string;
  1223. additionalDefineValue?: string;
  1224. isValid(preprocessors: {
  1225. [key: string]: string;
  1226. }): boolean;
  1227. process(preprocessors: {
  1228. [key: string]: string;
  1229. }, options: ProcessingOptions): string;
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1233. /** @hidden */
  1234. export class ShaderCodeCursor {
  1235. private _lines;
  1236. lineIndex: number;
  1237. get currentLine(): string;
  1238. get canRead(): boolean;
  1239. set lines(value: string[]);
  1240. }
  1241. }
  1242. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1243. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1244. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1245. /** @hidden */
  1246. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1247. process(preprocessors: {
  1248. [key: string]: string;
  1249. }, options: ProcessingOptions): string;
  1250. }
  1251. }
  1252. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1253. /** @hidden */
  1254. export class ShaderDefineExpression {
  1255. isTrue(preprocessors: {
  1256. [key: string]: string;
  1257. }): boolean;
  1258. private static _OperatorPriority;
  1259. private static _Stack;
  1260. static postfixToInfix(postfix: string[]): string;
  1261. static infixToPostfix(infix: string): string[];
  1262. }
  1263. }
  1264. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1265. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1266. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1267. /** @hidden */
  1268. export class ShaderCodeTestNode extends ShaderCodeNode {
  1269. testExpression: ShaderDefineExpression;
  1270. isValid(preprocessors: {
  1271. [key: string]: string;
  1272. }): boolean;
  1273. }
  1274. }
  1275. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1276. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1277. /** @hidden */
  1278. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1279. define: string;
  1280. not: boolean;
  1281. constructor(define: string, not?: boolean);
  1282. isTrue(preprocessors: {
  1283. [key: string]: string;
  1284. }): boolean;
  1285. }
  1286. }
  1287. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1288. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1289. /** @hidden */
  1290. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1291. leftOperand: ShaderDefineExpression;
  1292. rightOperand: ShaderDefineExpression;
  1293. isTrue(preprocessors: {
  1294. [key: string]: string;
  1295. }): boolean;
  1296. }
  1297. }
  1298. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1299. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1300. /** @hidden */
  1301. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1302. leftOperand: ShaderDefineExpression;
  1303. rightOperand: ShaderDefineExpression;
  1304. isTrue(preprocessors: {
  1305. [key: string]: string;
  1306. }): boolean;
  1307. }
  1308. }
  1309. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1310. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1311. /** @hidden */
  1312. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1313. define: string;
  1314. operand: string;
  1315. testValue: string;
  1316. constructor(define: string, operand: string, testValue: string);
  1317. isTrue(preprocessors: {
  1318. [key: string]: string;
  1319. }): boolean;
  1320. }
  1321. }
  1322. declare module "babylonjs/Offline/IOfflineProvider" {
  1323. /**
  1324. * Class used to enable access to offline support
  1325. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1326. */
  1327. export interface IOfflineProvider {
  1328. /**
  1329. * Gets a boolean indicating if scene must be saved in the database
  1330. */
  1331. enableSceneOffline: boolean;
  1332. /**
  1333. * Gets a boolean indicating if textures must be saved in the database
  1334. */
  1335. enableTexturesOffline: boolean;
  1336. /**
  1337. * Open the offline support and make it available
  1338. * @param successCallback defines the callback to call on success
  1339. * @param errorCallback defines the callback to call on error
  1340. */
  1341. open(successCallback: () => void, errorCallback: () => void): void;
  1342. /**
  1343. * Loads an image from the offline support
  1344. * @param url defines the url to load from
  1345. * @param image defines the target DOM image
  1346. */
  1347. loadImage(url: string, image: HTMLImageElement): void;
  1348. /**
  1349. * Loads a file from offline support
  1350. * @param url defines the URL to load from
  1351. * @param sceneLoaded defines a callback to call on success
  1352. * @param progressCallBack defines a callback to call when progress changed
  1353. * @param errorCallback defines a callback to call on error
  1354. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1355. */
  1356. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1357. }
  1358. }
  1359. declare module "babylonjs/Misc/filesInputStore" {
  1360. /**
  1361. * Class used to help managing file picking and drag'n'drop
  1362. * File Storage
  1363. */
  1364. export class FilesInputStore {
  1365. /**
  1366. * List of files ready to be loaded
  1367. */
  1368. static FilesToLoad: {
  1369. [key: string]: File;
  1370. };
  1371. }
  1372. }
  1373. declare module "babylonjs/Misc/retryStrategy" {
  1374. import { WebRequest } from "babylonjs/Misc/webRequest";
  1375. /**
  1376. * Class used to define a retry strategy when error happens while loading assets
  1377. */
  1378. export class RetryStrategy {
  1379. /**
  1380. * Function used to defines an exponential back off strategy
  1381. * @param maxRetries defines the maximum number of retries (3 by default)
  1382. * @param baseInterval defines the interval between retries
  1383. * @returns the strategy function to use
  1384. */
  1385. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1386. }
  1387. }
  1388. declare module "babylonjs/Misc/baseError" {
  1389. /**
  1390. * @ignore
  1391. * Application error to support additional information when loading a file
  1392. */
  1393. export abstract class BaseError extends Error {
  1394. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1395. }
  1396. }
  1397. declare module "babylonjs/Misc/fileTools" {
  1398. import { WebRequest } from "babylonjs/Misc/webRequest";
  1399. import { Nullable } from "babylonjs/types";
  1400. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1401. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1402. import { BaseError } from "babylonjs/Misc/baseError";
  1403. /** @ignore */
  1404. export class LoadFileError extends BaseError {
  1405. request?: WebRequest;
  1406. file?: File;
  1407. /**
  1408. * Creates a new LoadFileError
  1409. * @param message defines the message of the error
  1410. * @param request defines the optional web request
  1411. * @param file defines the optional file
  1412. */
  1413. constructor(message: string, object?: WebRequest | File);
  1414. }
  1415. /** @ignore */
  1416. export class RequestFileError extends BaseError {
  1417. request: WebRequest;
  1418. /**
  1419. * Creates a new LoadFileError
  1420. * @param message defines the message of the error
  1421. * @param request defines the optional web request
  1422. */
  1423. constructor(message: string, request: WebRequest);
  1424. }
  1425. /** @ignore */
  1426. export class ReadFileError extends BaseError {
  1427. file: File;
  1428. /**
  1429. * Creates a new ReadFileError
  1430. * @param message defines the message of the error
  1431. * @param file defines the optional file
  1432. */
  1433. constructor(message: string, file: File);
  1434. }
  1435. /**
  1436. * @hidden
  1437. */
  1438. export class FileTools {
  1439. /**
  1440. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1441. */
  1442. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1443. /**
  1444. * Gets or sets the base URL to use to load assets
  1445. */
  1446. static BaseUrl: string;
  1447. /**
  1448. * Default behaviour for cors in the application.
  1449. * It can be a string if the expected behavior is identical in the entire app.
  1450. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1451. */
  1452. static CorsBehavior: string | ((url: string | string[]) => string);
  1453. /**
  1454. * Gets or sets a function used to pre-process url before using them to load assets
  1455. */
  1456. static PreprocessUrl: (url: string) => string;
  1457. /**
  1458. * Removes unwanted characters from an url
  1459. * @param url defines the url to clean
  1460. * @returns the cleaned url
  1461. */
  1462. private static _CleanUrl;
  1463. /**
  1464. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1465. * @param url define the url we are trying
  1466. * @param element define the dom element where to configure the cors policy
  1467. */
  1468. static SetCorsBehavior(url: string | string[], element: {
  1469. crossOrigin: string | null;
  1470. }): void;
  1471. /**
  1472. * Loads an image as an HTMLImageElement.
  1473. * @param input url string, ArrayBuffer, or Blob to load
  1474. * @param onLoad callback called when the image successfully loads
  1475. * @param onError callback called when the image fails to load
  1476. * @param offlineProvider offline provider for caching
  1477. * @param mimeType optional mime type
  1478. * @returns the HTMLImageElement of the loaded image
  1479. */
  1480. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1481. /**
  1482. * Reads a file from a File object
  1483. * @param file defines the file to load
  1484. * @param onSuccess defines the callback to call when data is loaded
  1485. * @param onProgress defines the callback to call during loading process
  1486. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1487. * @param onError defines the callback to call when an error occurs
  1488. * @returns a file request object
  1489. */
  1490. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1491. /**
  1492. * Loads a file from a url
  1493. * @param url url to load
  1494. * @param onSuccess callback called when the file successfully loads
  1495. * @param onProgress callback called while file is loading (if the server supports this mode)
  1496. * @param offlineProvider defines the offline provider for caching
  1497. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1498. * @param onError callback called when the file fails to load
  1499. * @returns a file request object
  1500. */
  1501. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1502. /**
  1503. * Loads a file
  1504. * @param url url to load
  1505. * @param onSuccess callback called when the file successfully loads
  1506. * @param onProgress callback called while file is loading (if the server supports this mode)
  1507. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1508. * @param onError callback called when the file fails to load
  1509. * @param onOpened callback called when the web request is opened
  1510. * @returns a file request object
  1511. */
  1512. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1513. /**
  1514. * Checks if the loaded document was accessed via `file:`-Protocol.
  1515. * @returns boolean
  1516. */
  1517. static IsFileURL(): boolean;
  1518. }
  1519. }
  1520. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1521. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1522. import { WebRequest } from "babylonjs/Misc/webRequest";
  1523. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1524. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1525. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1526. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  1527. /** @hidden */
  1528. export class ShaderProcessor {
  1529. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1530. private static _ProcessPrecision;
  1531. private static _ExtractOperation;
  1532. private static _BuildSubExpression;
  1533. private static _BuildExpression;
  1534. private static _MoveCursorWithinIf;
  1535. private static _MoveCursor;
  1536. private static _EvaluatePreProcessors;
  1537. private static _PreparePreProcessors;
  1538. private static _ProcessShaderConversion;
  1539. private static _ProcessIncludes;
  1540. /**
  1541. * Loads a file from a url
  1542. * @param url url to load
  1543. * @param onSuccess callback called when the file successfully loads
  1544. * @param onProgress callback called while file is loading (if the server supports this mode)
  1545. * @param offlineProvider defines the offline provider for caching
  1546. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1547. * @param onError callback called when the file fails to load
  1548. * @returns a file request object
  1549. * @hidden
  1550. */
  1551. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1552. }
  1553. }
  1554. declare module "babylonjs/Maths/math.like" {
  1555. import { float, int, DeepImmutable } from "babylonjs/types";
  1556. /**
  1557. * @hidden
  1558. */
  1559. export interface IColor4Like {
  1560. r: float;
  1561. g: float;
  1562. b: float;
  1563. a: float;
  1564. }
  1565. /**
  1566. * @hidden
  1567. */
  1568. export interface IColor3Like {
  1569. r: float;
  1570. g: float;
  1571. b: float;
  1572. }
  1573. /**
  1574. * @hidden
  1575. */
  1576. export interface IVector4Like {
  1577. x: float;
  1578. y: float;
  1579. z: float;
  1580. w: float;
  1581. }
  1582. /**
  1583. * @hidden
  1584. */
  1585. export interface IVector3Like {
  1586. x: float;
  1587. y: float;
  1588. z: float;
  1589. }
  1590. /**
  1591. * @hidden
  1592. */
  1593. export interface IVector2Like {
  1594. x: float;
  1595. y: float;
  1596. }
  1597. /**
  1598. * @hidden
  1599. */
  1600. export interface IMatrixLike {
  1601. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1602. updateFlag: int;
  1603. }
  1604. /**
  1605. * @hidden
  1606. */
  1607. export interface IViewportLike {
  1608. x: float;
  1609. y: float;
  1610. width: float;
  1611. height: float;
  1612. }
  1613. /**
  1614. * @hidden
  1615. */
  1616. export interface IPlaneLike {
  1617. normal: IVector3Like;
  1618. d: float;
  1619. normalize(): void;
  1620. }
  1621. }
  1622. declare module "babylonjs/Materials/iEffectFallbacks" {
  1623. import { Effect } from "babylonjs/Materials/effect";
  1624. /**
  1625. * Interface used to define common properties for effect fallbacks
  1626. */
  1627. export interface IEffectFallbacks {
  1628. /**
  1629. * Removes the defines that should be removed when falling back.
  1630. * @param currentDefines defines the current define statements for the shader.
  1631. * @param effect defines the current effect we try to compile
  1632. * @returns The resulting defines with defines of the current rank removed.
  1633. */
  1634. reduce(currentDefines: string, effect: Effect): string;
  1635. /**
  1636. * Removes the fallback from the bound mesh.
  1637. */
  1638. unBindMesh(): void;
  1639. /**
  1640. * Checks to see if more fallbacks are still availible.
  1641. */
  1642. hasMoreFallbacks: boolean;
  1643. }
  1644. }
  1645. declare module "babylonjs/Maths/math.size" {
  1646. /**
  1647. * Interface for the size containing width and height
  1648. */
  1649. export interface ISize {
  1650. /**
  1651. * Width
  1652. */
  1653. width: number;
  1654. /**
  1655. * Heighht
  1656. */
  1657. height: number;
  1658. }
  1659. /**
  1660. * Size containing widht and height
  1661. */
  1662. export class Size implements ISize {
  1663. /**
  1664. * Width
  1665. */
  1666. width: number;
  1667. /**
  1668. * Height
  1669. */
  1670. height: number;
  1671. /**
  1672. * Creates a Size object from the given width and height (floats).
  1673. * @param width width of the new size
  1674. * @param height height of the new size
  1675. */
  1676. constructor(width: number, height: number);
  1677. /**
  1678. * Returns a string with the Size width and height
  1679. * @returns a string with the Size width and height
  1680. */
  1681. toString(): string;
  1682. /**
  1683. * "Size"
  1684. * @returns the string "Size"
  1685. */
  1686. getClassName(): string;
  1687. /**
  1688. * Returns the Size hash code.
  1689. * @returns a hash code for a unique width and height
  1690. */
  1691. getHashCode(): number;
  1692. /**
  1693. * Updates the current size from the given one.
  1694. * @param src the given size
  1695. */
  1696. copyFrom(src: Size): void;
  1697. /**
  1698. * Updates in place the current Size from the given floats.
  1699. * @param width width of the new size
  1700. * @param height height of the new size
  1701. * @returns the updated Size.
  1702. */
  1703. copyFromFloats(width: number, height: number): Size;
  1704. /**
  1705. * Updates in place the current Size from the given floats.
  1706. * @param width width to set
  1707. * @param height height to set
  1708. * @returns the updated Size.
  1709. */
  1710. set(width: number, height: number): Size;
  1711. /**
  1712. * Multiplies the width and height by numbers
  1713. * @param w factor to multiple the width by
  1714. * @param h factor to multiple the height by
  1715. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1716. */
  1717. multiplyByFloats(w: number, h: number): Size;
  1718. /**
  1719. * Clones the size
  1720. * @returns a new Size copied from the given one.
  1721. */
  1722. clone(): Size;
  1723. /**
  1724. * True if the current Size and the given one width and height are strictly equal.
  1725. * @param other the other size to compare against
  1726. * @returns True if the current Size and the given one width and height are strictly equal.
  1727. */
  1728. equals(other: Size): boolean;
  1729. /**
  1730. * The surface of the Size : width * height (float).
  1731. */
  1732. get surface(): number;
  1733. /**
  1734. * Create a new size of zero
  1735. * @returns a new Size set to (0.0, 0.0)
  1736. */
  1737. static Zero(): Size;
  1738. /**
  1739. * Sums the width and height of two sizes
  1740. * @param otherSize size to add to this size
  1741. * @returns a new Size set as the addition result of the current Size and the given one.
  1742. */
  1743. add(otherSize: Size): Size;
  1744. /**
  1745. * Subtracts the width and height of two
  1746. * @param otherSize size to subtract to this size
  1747. * @returns a new Size set as the subtraction result of the given one from the current Size.
  1748. */
  1749. subtract(otherSize: Size): Size;
  1750. /**
  1751. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  1752. * @param start starting size to lerp between
  1753. * @param end end size to lerp between
  1754. * @param amount amount to lerp between the start and end values
  1755. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  1756. */
  1757. static Lerp(start: Size, end: Size, amount: number): Size;
  1758. }
  1759. }
  1760. declare module "babylonjs/Materials/Textures/thinTexture" {
  1761. import { Nullable } from "babylonjs/types";
  1762. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1763. import { ISize } from "babylonjs/Maths/math.size";
  1764. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  1765. /**
  1766. * Base class of all the textures in babylon.
  1767. * It groups all the common properties required to work with Thin Engine.
  1768. */
  1769. export class ThinTexture {
  1770. protected _wrapU: number;
  1771. /**
  1772. * | Value | Type | Description |
  1773. * | ----- | ------------------ | ----------- |
  1774. * | 0 | CLAMP_ADDRESSMODE | |
  1775. * | 1 | WRAP_ADDRESSMODE | |
  1776. * | 2 | MIRROR_ADDRESSMODE | |
  1777. */
  1778. get wrapU(): number;
  1779. set wrapU(value: number);
  1780. protected _wrapV: number;
  1781. /**
  1782. * | Value | Type | Description |
  1783. * | ----- | ------------------ | ----------- |
  1784. * | 0 | CLAMP_ADDRESSMODE | |
  1785. * | 1 | WRAP_ADDRESSMODE | |
  1786. * | 2 | MIRROR_ADDRESSMODE | |
  1787. */
  1788. get wrapV(): number;
  1789. set wrapV(value: number);
  1790. /**
  1791. * | Value | Type | Description |
  1792. * | ----- | ------------------ | ----------- |
  1793. * | 0 | CLAMP_ADDRESSMODE | |
  1794. * | 1 | WRAP_ADDRESSMODE | |
  1795. * | 2 | MIRROR_ADDRESSMODE | |
  1796. */
  1797. wrapR: number;
  1798. /**
  1799. * With compliant hardware and browser (supporting anisotropic filtering)
  1800. * this defines the level of anisotropic filtering in the texture.
  1801. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  1802. */
  1803. anisotropicFilteringLevel: number;
  1804. /**
  1805. * Define the current state of the loading sequence when in delayed load mode.
  1806. */
  1807. delayLoadState: number;
  1808. /**
  1809. * How a texture is mapped.
  1810. * Unused in thin texture mode.
  1811. */
  1812. get coordinatesMode(): number;
  1813. /**
  1814. * Define if the texture is a cube texture or if false a 2d texture.
  1815. */
  1816. get isCube(): boolean;
  1817. set isCube(value: boolean);
  1818. /**
  1819. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  1820. */
  1821. get is3D(): boolean;
  1822. set is3D(value: boolean);
  1823. /**
  1824. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  1825. */
  1826. get is2DArray(): boolean;
  1827. set is2DArray(value: boolean);
  1828. /**
  1829. * Get the class name of the texture.
  1830. * @returns "ThinTexture"
  1831. */
  1832. getClassName(): string;
  1833. /** @hidden */
  1834. _texture: Nullable<InternalTexture>;
  1835. protected _engine: Nullable<ThinEngine>;
  1836. private _cachedSize;
  1837. private _cachedBaseSize;
  1838. /**
  1839. * Instantiates a new ThinTexture.
  1840. * Base class of all the textures in babylon.
  1841. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  1842. * @param internalTexture Define the internalTexture to wrap
  1843. */
  1844. constructor(internalTexture: Nullable<InternalTexture>);
  1845. /**
  1846. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  1847. * @returns true if fully ready
  1848. */
  1849. isReady(): boolean;
  1850. /**
  1851. * Triggers the load sequence in delayed load mode.
  1852. */
  1853. delayLoad(): void;
  1854. /**
  1855. * Get the underlying lower level texture from Babylon.
  1856. * @returns the insternal texture
  1857. */
  1858. getInternalTexture(): Nullable<InternalTexture>;
  1859. /**
  1860. * Get the size of the texture.
  1861. * @returns the texture size.
  1862. */
  1863. getSize(): ISize;
  1864. /**
  1865. * Get the base size of the texture.
  1866. * It can be different from the size if the texture has been resized for POT for instance
  1867. * @returns the base size
  1868. */
  1869. getBaseSize(): ISize;
  1870. /**
  1871. * Update the sampling mode of the texture.
  1872. * Default is Trilinear mode.
  1873. *
  1874. * | Value | Type | Description |
  1875. * | ----- | ------------------ | ----------- |
  1876. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  1877. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  1878. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  1879. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  1880. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  1881. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  1882. * | 7 | NEAREST_LINEAR | |
  1883. * | 8 | NEAREST_NEAREST | |
  1884. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  1885. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  1886. * | 11 | LINEAR_LINEAR | |
  1887. * | 12 | LINEAR_NEAREST | |
  1888. *
  1889. * > _mag_: magnification filter (close to the viewer)
  1890. * > _min_: minification filter (far from the viewer)
  1891. * > _mip_: filter used between mip map levels
  1892. *@param samplingMode Define the new sampling mode of the texture
  1893. */
  1894. updateSamplingMode(samplingMode: number): void;
  1895. /**
  1896. * Release and destroy the underlying lower level texture aka internalTexture.
  1897. */
  1898. releaseInternalTexture(): void;
  1899. /**
  1900. * Dispose the texture and release its associated resources.
  1901. */
  1902. dispose(): void;
  1903. }
  1904. }
  1905. declare module "babylonjs/Misc/smartArray" {
  1906. /**
  1907. * Defines an array and its length.
  1908. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  1909. */
  1910. export interface ISmartArrayLike<T> {
  1911. /**
  1912. * The data of the array.
  1913. */
  1914. data: Array<T>;
  1915. /**
  1916. * The active length of the array.
  1917. */
  1918. length: number;
  1919. }
  1920. /**
  1921. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  1922. */
  1923. export class SmartArray<T> implements ISmartArrayLike<T> {
  1924. /**
  1925. * The full set of data from the array.
  1926. */
  1927. data: Array<T>;
  1928. /**
  1929. * The active length of the array.
  1930. */
  1931. length: number;
  1932. protected _id: number;
  1933. /**
  1934. * Instantiates a Smart Array.
  1935. * @param capacity defines the default capacity of the array.
  1936. */
  1937. constructor(capacity: number);
  1938. /**
  1939. * Pushes a value at the end of the active data.
  1940. * @param value defines the object to push in the array.
  1941. */
  1942. push(value: T): void;
  1943. /**
  1944. * Iterates over the active data and apply the lambda to them.
  1945. * @param func defines the action to apply on each value.
  1946. */
  1947. forEach(func: (content: T) => void): void;
  1948. /**
  1949. * Sorts the full sets of data.
  1950. * @param compareFn defines the comparison function to apply.
  1951. */
  1952. sort(compareFn: (a: T, b: T) => number): void;
  1953. /**
  1954. * Resets the active data to an empty array.
  1955. */
  1956. reset(): void;
  1957. /**
  1958. * Releases all the data from the array as well as the array.
  1959. */
  1960. dispose(): void;
  1961. /**
  1962. * Concats the active data with a given array.
  1963. * @param array defines the data to concatenate with.
  1964. */
  1965. concat(array: any): void;
  1966. /**
  1967. * Returns the position of a value in the active data.
  1968. * @param value defines the value to find the index for
  1969. * @returns the index if found in the active data otherwise -1
  1970. */
  1971. indexOf(value: T): number;
  1972. /**
  1973. * Returns whether an element is part of the active data.
  1974. * @param value defines the value to look for
  1975. * @returns true if found in the active data otherwise false
  1976. */
  1977. contains(value: T): boolean;
  1978. private static _GlobalId;
  1979. }
  1980. /**
  1981. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  1982. * The data in this array can only be present once
  1983. */
  1984. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  1985. private _duplicateId;
  1986. /**
  1987. * Pushes a value at the end of the active data.
  1988. * THIS DOES NOT PREVENT DUPPLICATE DATA
  1989. * @param value defines the object to push in the array.
  1990. */
  1991. push(value: T): void;
  1992. /**
  1993. * Pushes a value at the end of the active data.
  1994. * If the data is already present, it won t be added again
  1995. * @param value defines the object to push in the array.
  1996. * @returns true if added false if it was already present
  1997. */
  1998. pushNoDuplicate(value: T): boolean;
  1999. /**
  2000. * Resets the active data to an empty array.
  2001. */
  2002. reset(): void;
  2003. /**
  2004. * Concats the active data with a given array.
  2005. * This ensures no dupplicate will be present in the result.
  2006. * @param array defines the data to concatenate with.
  2007. */
  2008. concatWithNoDuplicate(array: any): void;
  2009. }
  2010. }
  2011. declare module "babylonjs/Misc/andOrNotEvaluator" {
  2012. /**
  2013. * Class used to evalaute queries containing `and` and `or` operators
  2014. */
  2015. export class AndOrNotEvaluator {
  2016. /**
  2017. * Evaluate a query
  2018. * @param query defines the query to evaluate
  2019. * @param evaluateCallback defines the callback used to filter result
  2020. * @returns true if the query matches
  2021. */
  2022. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  2023. private static _HandleParenthesisContent;
  2024. private static _SimplifyNegation;
  2025. }
  2026. }
  2027. declare module "babylonjs/Misc/tags" {
  2028. /**
  2029. * Class used to store custom tags
  2030. */
  2031. export class Tags {
  2032. /**
  2033. * Adds support for tags on the given object
  2034. * @param obj defines the object to use
  2035. */
  2036. static EnableFor(obj: any): void;
  2037. /**
  2038. * Removes tags support
  2039. * @param obj defines the object to use
  2040. */
  2041. static DisableFor(obj: any): void;
  2042. /**
  2043. * Gets a boolean indicating if the given object has tags
  2044. * @param obj defines the object to use
  2045. * @returns a boolean
  2046. */
  2047. static HasTags(obj: any): boolean;
  2048. /**
  2049. * Gets the tags available on a given object
  2050. * @param obj defines the object to use
  2051. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2052. * @returns the tags
  2053. */
  2054. static GetTags(obj: any, asString?: boolean): any;
  2055. /**
  2056. * Adds tags to an object
  2057. * @param obj defines the object to use
  2058. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2059. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2060. */
  2061. static AddTagsTo(obj: any, tagsString: string): void;
  2062. /**
  2063. * @hidden
  2064. */
  2065. static _AddTagTo(obj: any, tag: string): void;
  2066. /**
  2067. * Removes specific tags from a specific object
  2068. * @param obj defines the object to use
  2069. * @param tagsString defines the tags to remove
  2070. */
  2071. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2072. /**
  2073. * @hidden
  2074. */
  2075. static _RemoveTagFrom(obj: any, tag: string): void;
  2076. /**
  2077. * Defines if tags hosted on an object match a given query
  2078. * @param obj defines the object to use
  2079. * @param tagsQuery defines the tag query
  2080. * @returns a boolean
  2081. */
  2082. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2083. }
  2084. }
  2085. declare module "babylonjs/Maths/math.scalar" {
  2086. /**
  2087. * Scalar computation library
  2088. */
  2089. export class Scalar {
  2090. /**
  2091. * Two pi constants convenient for computation.
  2092. */
  2093. static TwoPi: number;
  2094. /**
  2095. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2096. * @param a number
  2097. * @param b number
  2098. * @param epsilon (default = 1.401298E-45)
  2099. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2100. */
  2101. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2102. /**
  2103. * Returns a string : the upper case translation of the number i to hexadecimal.
  2104. * @param i number
  2105. * @returns the upper case translation of the number i to hexadecimal.
  2106. */
  2107. static ToHex(i: number): string;
  2108. /**
  2109. * Returns -1 if value is negative and +1 is value is positive.
  2110. * @param value the value
  2111. * @returns the value itself if it's equal to zero.
  2112. */
  2113. static Sign(value: number): number;
  2114. /**
  2115. * Returns the value itself if it's between min and max.
  2116. * Returns min if the value is lower than min.
  2117. * Returns max if the value is greater than max.
  2118. * @param value the value to clmap
  2119. * @param min the min value to clamp to (default: 0)
  2120. * @param max the max value to clamp to (default: 1)
  2121. * @returns the clamped value
  2122. */
  2123. static Clamp(value: number, min?: number, max?: number): number;
  2124. /**
  2125. * the log2 of value.
  2126. * @param value the value to compute log2 of
  2127. * @returns the log2 of value.
  2128. */
  2129. static Log2(value: number): number;
  2130. /**
  2131. * Loops the value, so that it is never larger than length and never smaller than 0.
  2132. *
  2133. * This is similar to the modulo operator but it works with floating point numbers.
  2134. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2135. * With t = 5 and length = 2.5, the result would be 0.0.
  2136. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2137. * @param value the value
  2138. * @param length the length
  2139. * @returns the looped value
  2140. */
  2141. static Repeat(value: number, length: number): number;
  2142. /**
  2143. * Normalize the value between 0.0 and 1.0 using min and max values
  2144. * @param value value to normalize
  2145. * @param min max to normalize between
  2146. * @param max min to normalize between
  2147. * @returns the normalized value
  2148. */
  2149. static Normalize(value: number, min: number, max: number): number;
  2150. /**
  2151. * Denormalize the value from 0.0 and 1.0 using min and max values
  2152. * @param normalized value to denormalize
  2153. * @param min max to denormalize between
  2154. * @param max min to denormalize between
  2155. * @returns the denormalized value
  2156. */
  2157. static Denormalize(normalized: number, min: number, max: number): number;
  2158. /**
  2159. * Calculates the shortest difference between two given angles given in degrees.
  2160. * @param current current angle in degrees
  2161. * @param target target angle in degrees
  2162. * @returns the delta
  2163. */
  2164. static DeltaAngle(current: number, target: number): number;
  2165. /**
  2166. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2167. * @param tx value
  2168. * @param length length
  2169. * @returns The returned value will move back and forth between 0 and length
  2170. */
  2171. static PingPong(tx: number, length: number): number;
  2172. /**
  2173. * Interpolates between min and max with smoothing at the limits.
  2174. *
  2175. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2176. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2177. * @param from from
  2178. * @param to to
  2179. * @param tx value
  2180. * @returns the smooth stepped value
  2181. */
  2182. static SmoothStep(from: number, to: number, tx: number): number;
  2183. /**
  2184. * Moves a value current towards target.
  2185. *
  2186. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2187. * Negative values of maxDelta pushes the value away from target.
  2188. * @param current current value
  2189. * @param target target value
  2190. * @param maxDelta max distance to move
  2191. * @returns resulting value
  2192. */
  2193. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2194. /**
  2195. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2196. *
  2197. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2198. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2199. * @param current current value
  2200. * @param target target value
  2201. * @param maxDelta max distance to move
  2202. * @returns resulting angle
  2203. */
  2204. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2205. /**
  2206. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2207. * @param start start value
  2208. * @param end target value
  2209. * @param amount amount to lerp between
  2210. * @returns the lerped value
  2211. */
  2212. static Lerp(start: number, end: number, amount: number): number;
  2213. /**
  2214. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2215. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2216. * @param start start value
  2217. * @param end target value
  2218. * @param amount amount to lerp between
  2219. * @returns the lerped value
  2220. */
  2221. static LerpAngle(start: number, end: number, amount: number): number;
  2222. /**
  2223. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2224. * @param a start value
  2225. * @param b target value
  2226. * @param value value between a and b
  2227. * @returns the inverseLerp value
  2228. */
  2229. static InverseLerp(a: number, b: number, value: number): number;
  2230. /**
  2231. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2232. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2233. * @param value1 spline value
  2234. * @param tangent1 spline value
  2235. * @param value2 spline value
  2236. * @param tangent2 spline value
  2237. * @param amount input value
  2238. * @returns hermite result
  2239. */
  2240. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2241. /**
  2242. * Returns a random float number between and min and max values
  2243. * @param min min value of random
  2244. * @param max max value of random
  2245. * @returns random value
  2246. */
  2247. static RandomRange(min: number, max: number): number;
  2248. /**
  2249. * This function returns percentage of a number in a given range.
  2250. *
  2251. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2252. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2253. * @param number to convert to percentage
  2254. * @param min min range
  2255. * @param max max range
  2256. * @returns the percentage
  2257. */
  2258. static RangeToPercent(number: number, min: number, max: number): number;
  2259. /**
  2260. * This function returns number that corresponds to the percentage in a given range.
  2261. *
  2262. * PercentToRange(0.34,0,100) will return 34.
  2263. * @param percent to convert to number
  2264. * @param min min range
  2265. * @param max max range
  2266. * @returns the number
  2267. */
  2268. static PercentToRange(percent: number, min: number, max: number): number;
  2269. /**
  2270. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2271. * @param angle The angle to normalize in radian.
  2272. * @return The converted angle.
  2273. */
  2274. static NormalizeRadians(angle: number): number;
  2275. }
  2276. }
  2277. declare module "babylonjs/Maths/math.constants" {
  2278. /**
  2279. * Constant used to convert a value to gamma space
  2280. * @ignorenaming
  2281. */
  2282. export const ToGammaSpace: number;
  2283. /**
  2284. * Constant used to convert a value to linear space
  2285. * @ignorenaming
  2286. */
  2287. export const ToLinearSpace = 2.2;
  2288. /**
  2289. * Constant used to define the minimal number value in Babylon.js
  2290. * @ignorenaming
  2291. */
  2292. let Epsilon: number;
  2293. export { Epsilon };
  2294. }
  2295. declare module "babylonjs/Maths/math.viewport" {
  2296. /**
  2297. * Class used to represent a viewport on screen
  2298. */
  2299. export class Viewport {
  2300. /** viewport left coordinate */
  2301. x: number;
  2302. /** viewport top coordinate */
  2303. y: number;
  2304. /**viewport width */
  2305. width: number;
  2306. /** viewport height */
  2307. height: number;
  2308. /**
  2309. * Creates a Viewport object located at (x, y) and sized (width, height)
  2310. * @param x defines viewport left coordinate
  2311. * @param y defines viewport top coordinate
  2312. * @param width defines the viewport width
  2313. * @param height defines the viewport height
  2314. */
  2315. constructor(
  2316. /** viewport left coordinate */
  2317. x: number,
  2318. /** viewport top coordinate */
  2319. y: number,
  2320. /**viewport width */
  2321. width: number,
  2322. /** viewport height */
  2323. height: number);
  2324. /**
  2325. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2326. * @param renderWidth defines the rendering width
  2327. * @param renderHeight defines the rendering height
  2328. * @returns a new Viewport
  2329. */
  2330. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2331. /**
  2332. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2333. * @param renderWidth defines the rendering width
  2334. * @param renderHeight defines the rendering height
  2335. * @param ref defines the target viewport
  2336. * @returns the current viewport
  2337. */
  2338. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2339. /**
  2340. * Returns a new Viewport copied from the current one
  2341. * @returns a new Viewport
  2342. */
  2343. clone(): Viewport;
  2344. }
  2345. }
  2346. declare module "babylonjs/Misc/arrayTools" {
  2347. /**
  2348. * Class containing a set of static utilities functions for arrays.
  2349. */
  2350. export class ArrayTools {
  2351. /**
  2352. * Returns an array of the given size filled with element built from the given constructor and the paramters
  2353. * @param size the number of element to construct and put in the array
  2354. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2355. * @returns a new array filled with new objects
  2356. */
  2357. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2358. }
  2359. }
  2360. declare module "babylonjs/Maths/math.plane" {
  2361. import { DeepImmutable } from "babylonjs/types";
  2362. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  2363. /**
  2364. * Represents a plane by the equation ax + by + cz + d = 0
  2365. */
  2366. export class Plane {
  2367. private static _TmpMatrix;
  2368. /**
  2369. * Normal of the plane (a,b,c)
  2370. */
  2371. normal: Vector3;
  2372. /**
  2373. * d component of the plane
  2374. */
  2375. d: number;
  2376. /**
  2377. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2378. * @param a a component of the plane
  2379. * @param b b component of the plane
  2380. * @param c c component of the plane
  2381. * @param d d component of the plane
  2382. */
  2383. constructor(a: number, b: number, c: number, d: number);
  2384. /**
  2385. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2386. */
  2387. asArray(): number[];
  2388. /**
  2389. * @returns a new plane copied from the current Plane.
  2390. */
  2391. clone(): Plane;
  2392. /**
  2393. * @returns the string "Plane".
  2394. */
  2395. getClassName(): string;
  2396. /**
  2397. * @returns the Plane hash code.
  2398. */
  2399. getHashCode(): number;
  2400. /**
  2401. * Normalize the current Plane in place.
  2402. * @returns the updated Plane.
  2403. */
  2404. normalize(): Plane;
  2405. /**
  2406. * Applies a transformation the plane and returns the result
  2407. * @param transformation the transformation matrix to be applied to the plane
  2408. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2409. */
  2410. transform(transformation: DeepImmutable<Matrix>): Plane;
  2411. /**
  2412. * Compute the dot product between the point and the plane normal
  2413. * @param point point to calculate the dot product with
  2414. * @returns the dot product (float) of the point coordinates and the plane normal.
  2415. */
  2416. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2417. /**
  2418. * Updates the current Plane from the plane defined by the three given points.
  2419. * @param point1 one of the points used to contruct the plane
  2420. * @param point2 one of the points used to contruct the plane
  2421. * @param point3 one of the points used to contruct the plane
  2422. * @returns the updated Plane.
  2423. */
  2424. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2425. /**
  2426. * Checks if the plane is facing a given direction
  2427. * @param direction the direction to check if the plane is facing
  2428. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2429. * @returns True is the vector "direction" is the same side than the plane normal.
  2430. */
  2431. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2432. /**
  2433. * Calculates the distance to a point
  2434. * @param point point to calculate distance to
  2435. * @returns the signed distance (float) from the given point to the Plane.
  2436. */
  2437. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2438. /**
  2439. * Creates a plane from an array
  2440. * @param array the array to create a plane from
  2441. * @returns a new Plane from the given array.
  2442. */
  2443. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2444. /**
  2445. * Creates a plane from three points
  2446. * @param point1 point used to create the plane
  2447. * @param point2 point used to create the plane
  2448. * @param point3 point used to create the plane
  2449. * @returns a new Plane defined by the three given points.
  2450. */
  2451. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2452. /**
  2453. * Creates a plane from an origin point and a normal
  2454. * @param origin origin of the plane to be constructed
  2455. * @param normal normal of the plane to be constructed
  2456. * @returns a new Plane the normal vector to this plane at the given origin point.
  2457. * Note : the vector "normal" is updated because normalized.
  2458. */
  2459. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2460. /**
  2461. * Calculates the distance from a plane and a point
  2462. * @param origin origin of the plane to be constructed
  2463. * @param normal normal of the plane to be constructed
  2464. * @param point point to calculate distance to
  2465. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2466. */
  2467. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2468. }
  2469. }
  2470. declare module "babylonjs/Engines/performanceConfigurator" {
  2471. /** @hidden */
  2472. export class PerformanceConfigurator {
  2473. /** @hidden */
  2474. static MatrixUse64Bits: boolean;
  2475. /** @hidden */
  2476. static MatrixTrackPrecisionChange: boolean;
  2477. /** @hidden */
  2478. static MatrixCurrentType: any;
  2479. /** @hidden */
  2480. static MatrixTrackedMatrices: Array<any> | null;
  2481. /** @hidden */
  2482. static SetMatrixPrecision(use64bits: boolean): void;
  2483. }
  2484. }
  2485. declare module "babylonjs/Maths/math.vector" {
  2486. import { Viewport } from "babylonjs/Maths/math.viewport";
  2487. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2488. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2489. import { Plane } from "babylonjs/Maths/math.plane";
  2490. /**
  2491. * Class representing a vector containing 2 coordinates
  2492. */
  2493. export class Vector2 {
  2494. /** defines the first coordinate */
  2495. x: number;
  2496. /** defines the second coordinate */
  2497. y: number;
  2498. /**
  2499. * Creates a new Vector2 from the given x and y coordinates
  2500. * @param x defines the first coordinate
  2501. * @param y defines the second coordinate
  2502. */
  2503. constructor(
  2504. /** defines the first coordinate */
  2505. x?: number,
  2506. /** defines the second coordinate */
  2507. y?: number);
  2508. /**
  2509. * Gets a string with the Vector2 coordinates
  2510. * @returns a string with the Vector2 coordinates
  2511. */
  2512. toString(): string;
  2513. /**
  2514. * Gets class name
  2515. * @returns the string "Vector2"
  2516. */
  2517. getClassName(): string;
  2518. /**
  2519. * Gets current vector hash code
  2520. * @returns the Vector2 hash code as a number
  2521. */
  2522. getHashCode(): number;
  2523. /**
  2524. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2525. * @param array defines the source array
  2526. * @param index defines the offset in source array
  2527. * @returns the current Vector2
  2528. */
  2529. toArray(array: FloatArray, index?: number): Vector2;
  2530. /**
  2531. * Update the current vector from an array
  2532. * @param array defines the destination array
  2533. * @param index defines the offset in the destination array
  2534. * @returns the current Vector3
  2535. */
  2536. fromArray(array: FloatArray, index?: number): Vector2;
  2537. /**
  2538. * Copy the current vector to an array
  2539. * @returns a new array with 2 elements: the Vector2 coordinates.
  2540. */
  2541. asArray(): number[];
  2542. /**
  2543. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2544. * @param source defines the source Vector2
  2545. * @returns the current updated Vector2
  2546. */
  2547. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2548. /**
  2549. * Sets the Vector2 coordinates with the given floats
  2550. * @param x defines the first coordinate
  2551. * @param y defines the second coordinate
  2552. * @returns the current updated Vector2
  2553. */
  2554. copyFromFloats(x: number, y: number): Vector2;
  2555. /**
  2556. * Sets the Vector2 coordinates with the given floats
  2557. * @param x defines the first coordinate
  2558. * @param y defines the second coordinate
  2559. * @returns the current updated Vector2
  2560. */
  2561. set(x: number, y: number): Vector2;
  2562. /**
  2563. * Add another vector with the current one
  2564. * @param otherVector defines the other vector
  2565. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2566. */
  2567. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2568. /**
  2569. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2570. * @param otherVector defines the other vector
  2571. * @param result defines the target vector
  2572. * @returns the unmodified current Vector2
  2573. */
  2574. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2575. /**
  2576. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2577. * @param otherVector defines the other vector
  2578. * @returns the current updated Vector2
  2579. */
  2580. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2581. /**
  2582. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2583. * @param otherVector defines the other vector
  2584. * @returns a new Vector2
  2585. */
  2586. addVector3(otherVector: Vector3): Vector2;
  2587. /**
  2588. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2589. * @param otherVector defines the other vector
  2590. * @returns a new Vector2
  2591. */
  2592. subtract(otherVector: Vector2): Vector2;
  2593. /**
  2594. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2595. * @param otherVector defines the other vector
  2596. * @param result defines the target vector
  2597. * @returns the unmodified current Vector2
  2598. */
  2599. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2600. /**
  2601. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2602. * @param otherVector defines the other vector
  2603. * @returns the current updated Vector2
  2604. */
  2605. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2606. /**
  2607. * Multiplies in place the current Vector2 coordinates by the given ones
  2608. * @param otherVector defines the other vector
  2609. * @returns the current updated Vector2
  2610. */
  2611. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2612. /**
  2613. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2614. * @param otherVector defines the other vector
  2615. * @returns a new Vector2
  2616. */
  2617. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2618. /**
  2619. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2620. * @param otherVector defines the other vector
  2621. * @param result defines the target vector
  2622. * @returns the unmodified current Vector2
  2623. */
  2624. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2625. /**
  2626. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2627. * @param x defines the first coordinate
  2628. * @param y defines the second coordinate
  2629. * @returns a new Vector2
  2630. */
  2631. multiplyByFloats(x: number, y: number): Vector2;
  2632. /**
  2633. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2634. * @param otherVector defines the other vector
  2635. * @returns a new Vector2
  2636. */
  2637. divide(otherVector: Vector2): Vector2;
  2638. /**
  2639. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2640. * @param otherVector defines the other vector
  2641. * @param result defines the target vector
  2642. * @returns the unmodified current Vector2
  2643. */
  2644. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2645. /**
  2646. * Divides the current Vector2 coordinates by the given ones
  2647. * @param otherVector defines the other vector
  2648. * @returns the current updated Vector2
  2649. */
  2650. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2651. /**
  2652. * Gets a new Vector2 with current Vector2 negated coordinates
  2653. * @returns a new Vector2
  2654. */
  2655. negate(): Vector2;
  2656. /**
  2657. * Negate this vector in place
  2658. * @returns this
  2659. */
  2660. negateInPlace(): Vector2;
  2661. /**
  2662. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2663. * @param result defines the Vector3 object where to store the result
  2664. * @returns the current Vector2
  2665. */
  2666. negateToRef(result: Vector2): Vector2;
  2667. /**
  2668. * Multiply the Vector2 coordinates by scale
  2669. * @param scale defines the scaling factor
  2670. * @returns the current updated Vector2
  2671. */
  2672. scaleInPlace(scale: number): Vector2;
  2673. /**
  2674. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2675. * @param scale defines the scaling factor
  2676. * @returns a new Vector2
  2677. */
  2678. scale(scale: number): Vector2;
  2679. /**
  2680. * Scale the current Vector2 values by a factor to a given Vector2
  2681. * @param scale defines the scale factor
  2682. * @param result defines the Vector2 object where to store the result
  2683. * @returns the unmodified current Vector2
  2684. */
  2685. scaleToRef(scale: number, result: Vector2): Vector2;
  2686. /**
  2687. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2688. * @param scale defines the scale factor
  2689. * @param result defines the Vector2 object where to store the result
  2690. * @returns the unmodified current Vector2
  2691. */
  2692. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2693. /**
  2694. * Gets a boolean if two vectors are equals
  2695. * @param otherVector defines the other vector
  2696. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2697. */
  2698. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2699. /**
  2700. * Gets a boolean if two vectors are equals (using an epsilon value)
  2701. * @param otherVector defines the other vector
  2702. * @param epsilon defines the minimal distance to consider equality
  2703. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2704. */
  2705. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2706. /**
  2707. * Gets a new Vector2 from current Vector2 floored values
  2708. * @returns a new Vector2
  2709. */
  2710. floor(): Vector2;
  2711. /**
  2712. * Gets a new Vector2 from current Vector2 floored values
  2713. * @returns a new Vector2
  2714. */
  2715. fract(): Vector2;
  2716. /**
  2717. * Gets the length of the vector
  2718. * @returns the vector length (float)
  2719. */
  2720. length(): number;
  2721. /**
  2722. * Gets the vector squared length
  2723. * @returns the vector squared length (float)
  2724. */
  2725. lengthSquared(): number;
  2726. /**
  2727. * Normalize the vector
  2728. * @returns the current updated Vector2
  2729. */
  2730. normalize(): Vector2;
  2731. /**
  2732. * Gets a new Vector2 copied from the Vector2
  2733. * @returns a new Vector2
  2734. */
  2735. clone(): Vector2;
  2736. /**
  2737. * Gets a new Vector2(0, 0)
  2738. * @returns a new Vector2
  2739. */
  2740. static Zero(): Vector2;
  2741. /**
  2742. * Gets a new Vector2(1, 1)
  2743. * @returns a new Vector2
  2744. */
  2745. static One(): Vector2;
  2746. /**
  2747. * Gets a new Vector2 set from the given index element of the given array
  2748. * @param array defines the data source
  2749. * @param offset defines the offset in the data source
  2750. * @returns a new Vector2
  2751. */
  2752. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2753. /**
  2754. * Sets "result" from the given index element of the given array
  2755. * @param array defines the data source
  2756. * @param offset defines the offset in the data source
  2757. * @param result defines the target vector
  2758. */
  2759. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2760. /**
  2761. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2762. * @param value1 defines 1st point of control
  2763. * @param value2 defines 2nd point of control
  2764. * @param value3 defines 3rd point of control
  2765. * @param value4 defines 4th point of control
  2766. * @param amount defines the interpolation factor
  2767. * @returns a new Vector2
  2768. */
  2769. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2770. /**
  2771. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2772. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2773. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2774. * @param value defines the value to clamp
  2775. * @param min defines the lower limit
  2776. * @param max defines the upper limit
  2777. * @returns a new Vector2
  2778. */
  2779. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2780. /**
  2781. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2782. * @param value1 defines the 1st control point
  2783. * @param tangent1 defines the outgoing tangent
  2784. * @param value2 defines the 2nd control point
  2785. * @param tangent2 defines the incoming tangent
  2786. * @param amount defines the interpolation factor
  2787. * @returns a new Vector2
  2788. */
  2789. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2790. /**
  2791. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2792. * @param start defines the start vector
  2793. * @param end defines the end vector
  2794. * @param amount defines the interpolation factor
  2795. * @returns a new Vector2
  2796. */
  2797. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2798. /**
  2799. * Gets the dot product of the vector "left" and the vector "right"
  2800. * @param left defines first vector
  2801. * @param right defines second vector
  2802. * @returns the dot product (float)
  2803. */
  2804. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2805. /**
  2806. * Returns a new Vector2 equal to the normalized given vector
  2807. * @param vector defines the vector to normalize
  2808. * @returns a new Vector2
  2809. */
  2810. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2811. /**
  2812. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2813. * @param left defines 1st vector
  2814. * @param right defines 2nd vector
  2815. * @returns a new Vector2
  2816. */
  2817. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2818. /**
  2819. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2820. * @param left defines 1st vector
  2821. * @param right defines 2nd vector
  2822. * @returns a new Vector2
  2823. */
  2824. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2825. /**
  2826. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2827. * @param vector defines the vector to transform
  2828. * @param transformation defines the matrix to apply
  2829. * @returns a new Vector2
  2830. */
  2831. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2832. /**
  2833. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2834. * @param vector defines the vector to transform
  2835. * @param transformation defines the matrix to apply
  2836. * @param result defines the target vector
  2837. */
  2838. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2839. /**
  2840. * Determines if a given vector is included in a triangle
  2841. * @param p defines the vector to test
  2842. * @param p0 defines 1st triangle point
  2843. * @param p1 defines 2nd triangle point
  2844. * @param p2 defines 3rd triangle point
  2845. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2846. */
  2847. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2848. /**
  2849. * Gets the distance between the vectors "value1" and "value2"
  2850. * @param value1 defines first vector
  2851. * @param value2 defines second vector
  2852. * @returns the distance between vectors
  2853. */
  2854. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2855. /**
  2856. * Returns the squared distance between the vectors "value1" and "value2"
  2857. * @param value1 defines first vector
  2858. * @param value2 defines second vector
  2859. * @returns the squared distance between vectors
  2860. */
  2861. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2862. /**
  2863. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2864. * @param value1 defines first vector
  2865. * @param value2 defines second vector
  2866. * @returns a new Vector2
  2867. */
  2868. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2869. /**
  2870. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2871. * @param p defines the middle point
  2872. * @param segA defines one point of the segment
  2873. * @param segB defines the other point of the segment
  2874. * @returns the shortest distance
  2875. */
  2876. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2877. }
  2878. /**
  2879. * Class used to store (x,y,z) vector representation
  2880. * A Vector3 is the main object used in 3D geometry
  2881. * It can represent etiher the coordinates of a point the space, either a direction
  2882. * Reminder: js uses a left handed forward facing system
  2883. */
  2884. export class Vector3 {
  2885. private static _UpReadOnly;
  2886. private static _ZeroReadOnly;
  2887. /** @hidden */
  2888. _x: number;
  2889. /** @hidden */
  2890. _y: number;
  2891. /** @hidden */
  2892. _z: number;
  2893. /** @hidden */
  2894. _isDirty: boolean;
  2895. /** Gets or sets the x coordinate */
  2896. get x(): number;
  2897. set x(value: number);
  2898. /** Gets or sets the y coordinate */
  2899. get y(): number;
  2900. set y(value: number);
  2901. /** Gets or sets the z coordinate */
  2902. get z(): number;
  2903. set z(value: number);
  2904. /**
  2905. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2906. * @param x defines the first coordinates (on X axis)
  2907. * @param y defines the second coordinates (on Y axis)
  2908. * @param z defines the third coordinates (on Z axis)
  2909. */
  2910. constructor(x?: number, y?: number, z?: number);
  2911. /**
  2912. * Creates a string representation of the Vector3
  2913. * @returns a string with the Vector3 coordinates.
  2914. */
  2915. toString(): string;
  2916. /**
  2917. * Gets the class name
  2918. * @returns the string "Vector3"
  2919. */
  2920. getClassName(): string;
  2921. /**
  2922. * Creates the Vector3 hash code
  2923. * @returns a number which tends to be unique between Vector3 instances
  2924. */
  2925. getHashCode(): number;
  2926. /**
  2927. * Creates an array containing three elements : the coordinates of the Vector3
  2928. * @returns a new array of numbers
  2929. */
  2930. asArray(): number[];
  2931. /**
  2932. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2933. * @param array defines the destination array
  2934. * @param index defines the offset in the destination array
  2935. * @returns the current Vector3
  2936. */
  2937. toArray(array: FloatArray, index?: number): Vector3;
  2938. /**
  2939. * Update the current vector from an array
  2940. * @param array defines the destination array
  2941. * @param index defines the offset in the destination array
  2942. * @returns the current Vector3
  2943. */
  2944. fromArray(array: FloatArray, index?: number): Vector3;
  2945. /**
  2946. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2947. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2948. */
  2949. toQuaternion(): Quaternion;
  2950. /**
  2951. * Adds the given vector to the current Vector3
  2952. * @param otherVector defines the second operand
  2953. * @returns the current updated Vector3
  2954. */
  2955. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2956. /**
  2957. * Adds the given coordinates to the current Vector3
  2958. * @param x defines the x coordinate of the operand
  2959. * @param y defines the y coordinate of the operand
  2960. * @param z defines the z coordinate of the operand
  2961. * @returns the current updated Vector3
  2962. */
  2963. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2964. /**
  2965. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2966. * @param otherVector defines the second operand
  2967. * @returns the resulting Vector3
  2968. */
  2969. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2970. /**
  2971. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2972. * @param otherVector defines the second operand
  2973. * @param result defines the Vector3 object where to store the result
  2974. * @returns the current Vector3
  2975. */
  2976. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2977. /**
  2978. * Subtract the given vector from the current Vector3
  2979. * @param otherVector defines the second operand
  2980. * @returns the current updated Vector3
  2981. */
  2982. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2983. /**
  2984. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2985. * @param otherVector defines the second operand
  2986. * @returns the resulting Vector3
  2987. */
  2988. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2989. /**
  2990. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2991. * @param otherVector defines the second operand
  2992. * @param result defines the Vector3 object where to store the result
  2993. * @returns the current Vector3
  2994. */
  2995. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2996. /**
  2997. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2998. * @param x defines the x coordinate of the operand
  2999. * @param y defines the y coordinate of the operand
  3000. * @param z defines the z coordinate of the operand
  3001. * @returns the resulting Vector3
  3002. */
  3003. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3004. /**
  3005. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  3006. * @param x defines the x coordinate of the operand
  3007. * @param y defines the y coordinate of the operand
  3008. * @param z defines the z coordinate of the operand
  3009. * @param result defines the Vector3 object where to store the result
  3010. * @returns the current Vector3
  3011. */
  3012. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3013. /**
  3014. * Gets a new Vector3 set with the current Vector3 negated coordinates
  3015. * @returns a new Vector3
  3016. */
  3017. negate(): Vector3;
  3018. /**
  3019. * Negate this vector in place
  3020. * @returns this
  3021. */
  3022. negateInPlace(): Vector3;
  3023. /**
  3024. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  3025. * @param result defines the Vector3 object where to store the result
  3026. * @returns the current Vector3
  3027. */
  3028. negateToRef(result: Vector3): Vector3;
  3029. /**
  3030. * Multiplies the Vector3 coordinates by the float "scale"
  3031. * @param scale defines the multiplier factor
  3032. * @returns the current updated Vector3
  3033. */
  3034. scaleInPlace(scale: number): Vector3;
  3035. /**
  3036. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3037. * @param scale defines the multiplier factor
  3038. * @returns a new Vector3
  3039. */
  3040. scale(scale: number): Vector3;
  3041. /**
  3042. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3043. * @param scale defines the multiplier factor
  3044. * @param result defines the Vector3 object where to store the result
  3045. * @returns the current Vector3
  3046. */
  3047. scaleToRef(scale: number, result: Vector3): Vector3;
  3048. /**
  3049. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3050. * @param scale defines the scale factor
  3051. * @param result defines the Vector3 object where to store the result
  3052. * @returns the unmodified current Vector3
  3053. */
  3054. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3055. /**
  3056. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3057. * @param origin defines the origin of the projection ray
  3058. * @param plane defines the plane to project to
  3059. * @returns the projected vector3
  3060. */
  3061. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3062. /**
  3063. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3064. * @param origin defines the origin of the projection ray
  3065. * @param plane defines the plane to project to
  3066. * @param result defines the Vector3 where to store the result
  3067. */
  3068. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3069. /**
  3070. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3071. * @param otherVector defines the second operand
  3072. * @returns true if both vectors are equals
  3073. */
  3074. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3075. /**
  3076. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3077. * @param otherVector defines the second operand
  3078. * @param epsilon defines the minimal distance to define values as equals
  3079. * @returns true if both vectors are distant less than epsilon
  3080. */
  3081. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3082. /**
  3083. * Returns true if the current Vector3 coordinates equals the given floats
  3084. * @param x defines the x coordinate of the operand
  3085. * @param y defines the y coordinate of the operand
  3086. * @param z defines the z coordinate of the operand
  3087. * @returns true if both vectors are equals
  3088. */
  3089. equalsToFloats(x: number, y: number, z: number): boolean;
  3090. /**
  3091. * Multiplies the current Vector3 coordinates by the given ones
  3092. * @param otherVector defines the second operand
  3093. * @returns the current updated Vector3
  3094. */
  3095. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3096. /**
  3097. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3098. * @param otherVector defines the second operand
  3099. * @returns the new Vector3
  3100. */
  3101. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3102. /**
  3103. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3104. * @param otherVector defines the second operand
  3105. * @param result defines the Vector3 object where to store the result
  3106. * @returns the current Vector3
  3107. */
  3108. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3109. /**
  3110. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3111. * @param x defines the x coordinate of the operand
  3112. * @param y defines the y coordinate of the operand
  3113. * @param z defines the z coordinate of the operand
  3114. * @returns the new Vector3
  3115. */
  3116. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3117. /**
  3118. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3119. * @param otherVector defines the second operand
  3120. * @returns the new Vector3
  3121. */
  3122. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3123. /**
  3124. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3125. * @param otherVector defines the second operand
  3126. * @param result defines the Vector3 object where to store the result
  3127. * @returns the current Vector3
  3128. */
  3129. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3130. /**
  3131. * Divides the current Vector3 coordinates by the given ones.
  3132. * @param otherVector defines the second operand
  3133. * @returns the current updated Vector3
  3134. */
  3135. divideInPlace(otherVector: Vector3): Vector3;
  3136. /**
  3137. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3138. * @param other defines the second operand
  3139. * @returns the current updated Vector3
  3140. */
  3141. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3142. /**
  3143. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3144. * @param other defines the second operand
  3145. * @returns the current updated Vector3
  3146. */
  3147. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3148. /**
  3149. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3150. * @param x defines the x coordinate of the operand
  3151. * @param y defines the y coordinate of the operand
  3152. * @param z defines the z coordinate of the operand
  3153. * @returns the current updated Vector3
  3154. */
  3155. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3156. /**
  3157. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3158. * @param x defines the x coordinate of the operand
  3159. * @param y defines the y coordinate of the operand
  3160. * @param z defines the z coordinate of the operand
  3161. * @returns the current updated Vector3
  3162. */
  3163. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3164. /**
  3165. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3166. * Check if is non uniform within a certain amount of decimal places to account for this
  3167. * @param epsilon the amount the values can differ
  3168. * @returns if the the vector is non uniform to a certain number of decimal places
  3169. */
  3170. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3171. /**
  3172. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3173. */
  3174. get isNonUniform(): boolean;
  3175. /**
  3176. * Gets a new Vector3 from current Vector3 floored values
  3177. * @returns a new Vector3
  3178. */
  3179. floor(): Vector3;
  3180. /**
  3181. * Gets a new Vector3 from current Vector3 floored values
  3182. * @returns a new Vector3
  3183. */
  3184. fract(): Vector3;
  3185. /**
  3186. * Gets the length of the Vector3
  3187. * @returns the length of the Vector3
  3188. */
  3189. length(): number;
  3190. /**
  3191. * Gets the squared length of the Vector3
  3192. * @returns squared length of the Vector3
  3193. */
  3194. lengthSquared(): number;
  3195. /**
  3196. * Normalize the current Vector3.
  3197. * Please note that this is an in place operation.
  3198. * @returns the current updated Vector3
  3199. */
  3200. normalize(): Vector3;
  3201. /**
  3202. * Reorders the x y z properties of the vector in place
  3203. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3204. * @returns the current updated vector
  3205. */
  3206. reorderInPlace(order: string): this;
  3207. /**
  3208. * Rotates the vector around 0,0,0 by a quaternion
  3209. * @param quaternion the rotation quaternion
  3210. * @param result vector to store the result
  3211. * @returns the resulting vector
  3212. */
  3213. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3214. /**
  3215. * Rotates a vector around a given point
  3216. * @param quaternion the rotation quaternion
  3217. * @param point the point to rotate around
  3218. * @param result vector to store the result
  3219. * @returns the resulting vector
  3220. */
  3221. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3222. /**
  3223. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3224. * The cross product is then orthogonal to both current and "other"
  3225. * @param other defines the right operand
  3226. * @returns the cross product
  3227. */
  3228. cross(other: Vector3): Vector3;
  3229. /**
  3230. * Normalize the current Vector3 with the given input length.
  3231. * Please note that this is an in place operation.
  3232. * @param len the length of the vector
  3233. * @returns the current updated Vector3
  3234. */
  3235. normalizeFromLength(len: number): Vector3;
  3236. /**
  3237. * Normalize the current Vector3 to a new vector
  3238. * @returns the new Vector3
  3239. */
  3240. normalizeToNew(): Vector3;
  3241. /**
  3242. * Normalize the current Vector3 to the reference
  3243. * @param reference define the Vector3 to update
  3244. * @returns the updated Vector3
  3245. */
  3246. normalizeToRef(reference: Vector3): Vector3;
  3247. /**
  3248. * Creates a new Vector3 copied from the current Vector3
  3249. * @returns the new Vector3
  3250. */
  3251. clone(): Vector3;
  3252. /**
  3253. * Copies the given vector coordinates to the current Vector3 ones
  3254. * @param source defines the source Vector3
  3255. * @returns the current updated Vector3
  3256. */
  3257. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3258. /**
  3259. * Copies the given floats to the current Vector3 coordinates
  3260. * @param x defines the x coordinate of the operand
  3261. * @param y defines the y coordinate of the operand
  3262. * @param z defines the z coordinate of the operand
  3263. * @returns the current updated Vector3
  3264. */
  3265. copyFromFloats(x: number, y: number, z: number): Vector3;
  3266. /**
  3267. * Copies the given floats to the current Vector3 coordinates
  3268. * @param x defines the x coordinate of the operand
  3269. * @param y defines the y coordinate of the operand
  3270. * @param z defines the z coordinate of the operand
  3271. * @returns the current updated Vector3
  3272. */
  3273. set(x: number, y: number, z: number): Vector3;
  3274. /**
  3275. * Copies the given float to the current Vector3 coordinates
  3276. * @param v defines the x, y and z coordinates of the operand
  3277. * @returns the current updated Vector3
  3278. */
  3279. setAll(v: number): Vector3;
  3280. /**
  3281. * Get the clip factor between two vectors
  3282. * @param vector0 defines the first operand
  3283. * @param vector1 defines the second operand
  3284. * @param axis defines the axis to use
  3285. * @param size defines the size along the axis
  3286. * @returns the clip factor
  3287. */
  3288. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3289. /**
  3290. * Get angle between two vectors
  3291. * @param vector0 angle between vector0 and vector1
  3292. * @param vector1 angle between vector0 and vector1
  3293. * @param normal direction of the normal
  3294. * @return the angle between vector0 and vector1
  3295. */
  3296. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3297. /**
  3298. * Returns a new Vector3 set from the index "offset" of the given array
  3299. * @param array defines the source array
  3300. * @param offset defines the offset in the source array
  3301. * @returns the new Vector3
  3302. */
  3303. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3304. /**
  3305. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3306. * @param array defines the source array
  3307. * @param offset defines the offset in the source array
  3308. * @returns the new Vector3
  3309. * @deprecated Please use FromArray instead.
  3310. */
  3311. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3312. /**
  3313. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3314. * @param array defines the source array
  3315. * @param offset defines the offset in the source array
  3316. * @param result defines the Vector3 where to store the result
  3317. */
  3318. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3319. /**
  3320. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3321. * @param array defines the source array
  3322. * @param offset defines the offset in the source array
  3323. * @param result defines the Vector3 where to store the result
  3324. * @deprecated Please use FromArrayToRef instead.
  3325. */
  3326. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3327. /**
  3328. * Sets the given vector "result" with the given floats.
  3329. * @param x defines the x coordinate of the source
  3330. * @param y defines the y coordinate of the source
  3331. * @param z defines the z coordinate of the source
  3332. * @param result defines the Vector3 where to store the result
  3333. */
  3334. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3335. /**
  3336. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3337. * @returns a new empty Vector3
  3338. */
  3339. static Zero(): Vector3;
  3340. /**
  3341. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3342. * @returns a new unit Vector3
  3343. */
  3344. static One(): Vector3;
  3345. /**
  3346. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3347. * @returns a new up Vector3
  3348. */
  3349. static Up(): Vector3;
  3350. /**
  3351. * Gets a up Vector3 that must not be updated
  3352. */
  3353. static get UpReadOnly(): DeepImmutable<Vector3>;
  3354. /**
  3355. * Gets a zero Vector3 that must not be updated
  3356. */
  3357. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3358. /**
  3359. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3360. * @returns a new down Vector3
  3361. */
  3362. static Down(): Vector3;
  3363. /**
  3364. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3365. * @param rightHandedSystem is the scene right-handed (negative z)
  3366. * @returns a new forward Vector3
  3367. */
  3368. static Forward(rightHandedSystem?: boolean): Vector3;
  3369. /**
  3370. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3371. * @param rightHandedSystem is the scene right-handed (negative-z)
  3372. * @returns a new forward Vector3
  3373. */
  3374. static Backward(rightHandedSystem?: boolean): Vector3;
  3375. /**
  3376. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3377. * @returns a new right Vector3
  3378. */
  3379. static Right(): Vector3;
  3380. /**
  3381. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3382. * @returns a new left Vector3
  3383. */
  3384. static Left(): Vector3;
  3385. /**
  3386. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3387. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3388. * @param vector defines the Vector3 to transform
  3389. * @param transformation defines the transformation matrix
  3390. * @returns the transformed Vector3
  3391. */
  3392. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3393. /**
  3394. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3395. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3396. * @param vector defines the Vector3 to transform
  3397. * @param transformation defines the transformation matrix
  3398. * @param result defines the Vector3 where to store the result
  3399. */
  3400. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3401. /**
  3402. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3403. * This method computes tranformed coordinates only, not transformed direction vectors
  3404. * @param x define the x coordinate of the source vector
  3405. * @param y define the y coordinate of the source vector
  3406. * @param z define the z coordinate of the source vector
  3407. * @param transformation defines the transformation matrix
  3408. * @param result defines the Vector3 where to store the result
  3409. */
  3410. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3411. /**
  3412. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3413. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3414. * @param vector defines the Vector3 to transform
  3415. * @param transformation defines the transformation matrix
  3416. * @returns the new Vector3
  3417. */
  3418. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3419. /**
  3420. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3421. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3422. * @param vector defines the Vector3 to transform
  3423. * @param transformation defines the transformation matrix
  3424. * @param result defines the Vector3 where to store the result
  3425. */
  3426. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3427. /**
  3428. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3429. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3430. * @param x define the x coordinate of the source vector
  3431. * @param y define the y coordinate of the source vector
  3432. * @param z define the z coordinate of the source vector
  3433. * @param transformation defines the transformation matrix
  3434. * @param result defines the Vector3 where to store the result
  3435. */
  3436. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3437. /**
  3438. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3439. * @param value1 defines the first control point
  3440. * @param value2 defines the second control point
  3441. * @param value3 defines the third control point
  3442. * @param value4 defines the fourth control point
  3443. * @param amount defines the amount on the spline to use
  3444. * @returns the new Vector3
  3445. */
  3446. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3447. /**
  3448. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3449. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3450. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3451. * @param value defines the current value
  3452. * @param min defines the lower range value
  3453. * @param max defines the upper range value
  3454. * @returns the new Vector3
  3455. */
  3456. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3457. /**
  3458. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3459. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3460. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3461. * @param value defines the current value
  3462. * @param min defines the lower range value
  3463. * @param max defines the upper range value
  3464. * @param result defines the Vector3 where to store the result
  3465. */
  3466. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3467. /**
  3468. * Checks if a given vector is inside a specific range
  3469. * @param v defines the vector to test
  3470. * @param min defines the minimum range
  3471. * @param max defines the maximum range
  3472. */
  3473. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3474. /**
  3475. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3476. * @param value1 defines the first control point
  3477. * @param tangent1 defines the first tangent vector
  3478. * @param value2 defines the second control point
  3479. * @param tangent2 defines the second tangent vector
  3480. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3481. * @returns the new Vector3
  3482. */
  3483. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3484. /**
  3485. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3486. * @param start defines the start value
  3487. * @param end defines the end value
  3488. * @param amount max defines amount between both (between 0 and 1)
  3489. * @returns the new Vector3
  3490. */
  3491. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3492. /**
  3493. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3494. * @param start defines the start value
  3495. * @param end defines the end value
  3496. * @param amount max defines amount between both (between 0 and 1)
  3497. * @param result defines the Vector3 where to store the result
  3498. */
  3499. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3500. /**
  3501. * Returns the dot product (float) between the vectors "left" and "right"
  3502. * @param left defines the left operand
  3503. * @param right defines the right operand
  3504. * @returns the dot product
  3505. */
  3506. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3507. /**
  3508. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3509. * The cross product is then orthogonal to both "left" and "right"
  3510. * @param left defines the left operand
  3511. * @param right defines the right operand
  3512. * @returns the cross product
  3513. */
  3514. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3515. /**
  3516. * Sets the given vector "result" with the cross product of "left" and "right"
  3517. * The cross product is then orthogonal to both "left" and "right"
  3518. * @param left defines the left operand
  3519. * @param right defines the right operand
  3520. * @param result defines the Vector3 where to store the result
  3521. */
  3522. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3523. /**
  3524. * Returns a new Vector3 as the normalization of the given vector
  3525. * @param vector defines the Vector3 to normalize
  3526. * @returns the new Vector3
  3527. */
  3528. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3529. /**
  3530. * Sets the given vector "result" with the normalization of the given first vector
  3531. * @param vector defines the Vector3 to normalize
  3532. * @param result defines the Vector3 where to store the result
  3533. */
  3534. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3535. /**
  3536. * Project a Vector3 onto screen space
  3537. * @param vector defines the Vector3 to project
  3538. * @param world defines the world matrix to use
  3539. * @param transform defines the transform (view x projection) matrix to use
  3540. * @param viewport defines the screen viewport to use
  3541. * @returns the new Vector3
  3542. */
  3543. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3544. /**
  3545. * Project a Vector3 onto screen space to reference
  3546. * @param vector defines the Vector3 to project
  3547. * @param world defines the world matrix to use
  3548. * @param transform defines the transform (view x projection) matrix to use
  3549. * @param viewport defines the screen viewport to use
  3550. * @param result the vector in which the screen space will be stored
  3551. * @returns the new Vector3
  3552. */
  3553. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3554. /** @hidden */
  3555. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3556. /**
  3557. * Unproject from screen space to object space
  3558. * @param source defines the screen space Vector3 to use
  3559. * @param viewportWidth defines the current width of the viewport
  3560. * @param viewportHeight defines the current height of the viewport
  3561. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3562. * @param transform defines the transform (view x projection) matrix to use
  3563. * @returns the new Vector3
  3564. */
  3565. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3566. /**
  3567. * Unproject from screen space to object space
  3568. * @param source defines the screen space Vector3 to use
  3569. * @param viewportWidth defines the current width of the viewport
  3570. * @param viewportHeight defines the current height of the viewport
  3571. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3572. * @param view defines the view matrix to use
  3573. * @param projection defines the projection matrix to use
  3574. * @returns the new Vector3
  3575. */
  3576. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3577. /**
  3578. * Unproject from screen space to object space
  3579. * @param source defines the screen space Vector3 to use
  3580. * @param viewportWidth defines the current width of the viewport
  3581. * @param viewportHeight defines the current height of the viewport
  3582. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3583. * @param view defines the view matrix to use
  3584. * @param projection defines the projection matrix to use
  3585. * @param result defines the Vector3 where to store the result
  3586. */
  3587. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3588. /**
  3589. * Unproject from screen space to object space
  3590. * @param sourceX defines the screen space x coordinate to use
  3591. * @param sourceY defines the screen space y coordinate to use
  3592. * @param sourceZ defines the screen space z coordinate to use
  3593. * @param viewportWidth defines the current width of the viewport
  3594. * @param viewportHeight defines the current height of the viewport
  3595. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3596. * @param view defines the view matrix to use
  3597. * @param projection defines the projection matrix to use
  3598. * @param result defines the Vector3 where to store the result
  3599. */
  3600. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3601. /**
  3602. * Gets the minimal coordinate values between two Vector3
  3603. * @param left defines the first operand
  3604. * @param right defines the second operand
  3605. * @returns the new Vector3
  3606. */
  3607. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3608. /**
  3609. * Gets the maximal coordinate values between two Vector3
  3610. * @param left defines the first operand
  3611. * @param right defines the second operand
  3612. * @returns the new Vector3
  3613. */
  3614. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3615. /**
  3616. * Returns the distance between the vectors "value1" and "value2"
  3617. * @param value1 defines the first operand
  3618. * @param value2 defines the second operand
  3619. * @returns the distance
  3620. */
  3621. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3622. /**
  3623. * Returns the squared distance between the vectors "value1" and "value2"
  3624. * @param value1 defines the first operand
  3625. * @param value2 defines the second operand
  3626. * @returns the squared distance
  3627. */
  3628. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3629. /**
  3630. * Returns a new Vector3 located at the center between "value1" and "value2"
  3631. * @param value1 defines the first operand
  3632. * @param value2 defines the second operand
  3633. * @returns the new Vector3
  3634. */
  3635. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3636. /**
  3637. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3638. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3639. * to something in order to rotate it from its local system to the given target system
  3640. * Note: axis1, axis2 and axis3 are normalized during this operation
  3641. * @param axis1 defines the first axis
  3642. * @param axis2 defines the second axis
  3643. * @param axis3 defines the third axis
  3644. * @returns a new Vector3
  3645. */
  3646. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3647. /**
  3648. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3649. * @param axis1 defines the first axis
  3650. * @param axis2 defines the second axis
  3651. * @param axis3 defines the third axis
  3652. * @param ref defines the Vector3 where to store the result
  3653. */
  3654. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3655. }
  3656. /**
  3657. * Vector4 class created for EulerAngle class conversion to Quaternion
  3658. */
  3659. export class Vector4 {
  3660. /** x value of the vector */
  3661. x: number;
  3662. /** y value of the vector */
  3663. y: number;
  3664. /** z value of the vector */
  3665. z: number;
  3666. /** w value of the vector */
  3667. w: number;
  3668. /**
  3669. * Creates a Vector4 object from the given floats.
  3670. * @param x x value of the vector
  3671. * @param y y value of the vector
  3672. * @param z z value of the vector
  3673. * @param w w value of the vector
  3674. */
  3675. constructor(
  3676. /** x value of the vector */
  3677. x: number,
  3678. /** y value of the vector */
  3679. y: number,
  3680. /** z value of the vector */
  3681. z: number,
  3682. /** w value of the vector */
  3683. w: number);
  3684. /**
  3685. * Returns the string with the Vector4 coordinates.
  3686. * @returns a string containing all the vector values
  3687. */
  3688. toString(): string;
  3689. /**
  3690. * Returns the string "Vector4".
  3691. * @returns "Vector4"
  3692. */
  3693. getClassName(): string;
  3694. /**
  3695. * Returns the Vector4 hash code.
  3696. * @returns a unique hash code
  3697. */
  3698. getHashCode(): number;
  3699. /**
  3700. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3701. * @returns the resulting array
  3702. */
  3703. asArray(): number[];
  3704. /**
  3705. * Populates the given array from the given index with the Vector4 coordinates.
  3706. * @param array array to populate
  3707. * @param index index of the array to start at (default: 0)
  3708. * @returns the Vector4.
  3709. */
  3710. toArray(array: FloatArray, index?: number): Vector4;
  3711. /**
  3712. * Update the current vector from an array
  3713. * @param array defines the destination array
  3714. * @param index defines the offset in the destination array
  3715. * @returns the current Vector3
  3716. */
  3717. fromArray(array: FloatArray, index?: number): Vector4;
  3718. /**
  3719. * Adds the given vector to the current Vector4.
  3720. * @param otherVector the vector to add
  3721. * @returns the updated Vector4.
  3722. */
  3723. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3724. /**
  3725. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3726. * @param otherVector the vector to add
  3727. * @returns the resulting vector
  3728. */
  3729. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3730. /**
  3731. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3732. * @param otherVector the vector to add
  3733. * @param result the vector to store the result
  3734. * @returns the current Vector4.
  3735. */
  3736. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3737. /**
  3738. * Subtract in place the given vector from the current Vector4.
  3739. * @param otherVector the vector to subtract
  3740. * @returns the updated Vector4.
  3741. */
  3742. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3743. /**
  3744. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3745. * @param otherVector the vector to add
  3746. * @returns the new vector with the result
  3747. */
  3748. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3749. /**
  3750. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3751. * @param otherVector the vector to subtract
  3752. * @param result the vector to store the result
  3753. * @returns the current Vector4.
  3754. */
  3755. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3756. /**
  3757. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3758. */
  3759. /**
  3760. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3761. * @param x value to subtract
  3762. * @param y value to subtract
  3763. * @param z value to subtract
  3764. * @param w value to subtract
  3765. * @returns new vector containing the result
  3766. */
  3767. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3768. /**
  3769. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3770. * @param x value to subtract
  3771. * @param y value to subtract
  3772. * @param z value to subtract
  3773. * @param w value to subtract
  3774. * @param result the vector to store the result in
  3775. * @returns the current Vector4.
  3776. */
  3777. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3778. /**
  3779. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3780. * @returns a new vector with the negated values
  3781. */
  3782. negate(): Vector4;
  3783. /**
  3784. * Negate this vector in place
  3785. * @returns this
  3786. */
  3787. negateInPlace(): Vector4;
  3788. /**
  3789. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3790. * @param result defines the Vector3 object where to store the result
  3791. * @returns the current Vector4
  3792. */
  3793. negateToRef(result: Vector4): Vector4;
  3794. /**
  3795. * Multiplies the current Vector4 coordinates by scale (float).
  3796. * @param scale the number to scale with
  3797. * @returns the updated Vector4.
  3798. */
  3799. scaleInPlace(scale: number): Vector4;
  3800. /**
  3801. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3802. * @param scale the number to scale with
  3803. * @returns a new vector with the result
  3804. */
  3805. scale(scale: number): Vector4;
  3806. /**
  3807. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3808. * @param scale the number to scale with
  3809. * @param result a vector to store the result in
  3810. * @returns the current Vector4.
  3811. */
  3812. scaleToRef(scale: number, result: Vector4): Vector4;
  3813. /**
  3814. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3815. * @param scale defines the scale factor
  3816. * @param result defines the Vector4 object where to store the result
  3817. * @returns the unmodified current Vector4
  3818. */
  3819. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3820. /**
  3821. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3822. * @param otherVector the vector to compare against
  3823. * @returns true if they are equal
  3824. */
  3825. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3826. /**
  3827. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3828. * @param otherVector vector to compare against
  3829. * @param epsilon (Default: very small number)
  3830. * @returns true if they are equal
  3831. */
  3832. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3833. /**
  3834. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3835. * @param x x value to compare against
  3836. * @param y y value to compare against
  3837. * @param z z value to compare against
  3838. * @param w w value to compare against
  3839. * @returns true if equal
  3840. */
  3841. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3842. /**
  3843. * Multiplies in place the current Vector4 by the given one.
  3844. * @param otherVector vector to multiple with
  3845. * @returns the updated Vector4.
  3846. */
  3847. multiplyInPlace(otherVector: Vector4): Vector4;
  3848. /**
  3849. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3850. * @param otherVector vector to multiple with
  3851. * @returns resulting new vector
  3852. */
  3853. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3854. /**
  3855. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3856. * @param otherVector vector to multiple with
  3857. * @param result vector to store the result
  3858. * @returns the current Vector4.
  3859. */
  3860. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3861. /**
  3862. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3863. * @param x x value multiply with
  3864. * @param y y value multiply with
  3865. * @param z z value multiply with
  3866. * @param w w value multiply with
  3867. * @returns resulting new vector
  3868. */
  3869. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3870. /**
  3871. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3872. * @param otherVector vector to devide with
  3873. * @returns resulting new vector
  3874. */
  3875. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3876. /**
  3877. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3878. * @param otherVector vector to devide with
  3879. * @param result vector to store the result
  3880. * @returns the current Vector4.
  3881. */
  3882. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3883. /**
  3884. * Divides the current Vector3 coordinates by the given ones.
  3885. * @param otherVector vector to devide with
  3886. * @returns the updated Vector3.
  3887. */
  3888. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3889. /**
  3890. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3891. * @param other defines the second operand
  3892. * @returns the current updated Vector4
  3893. */
  3894. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3895. /**
  3896. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3897. * @param other defines the second operand
  3898. * @returns the current updated Vector4
  3899. */
  3900. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3901. /**
  3902. * Gets a new Vector4 from current Vector4 floored values
  3903. * @returns a new Vector4
  3904. */
  3905. floor(): Vector4;
  3906. /**
  3907. * Gets a new Vector4 from current Vector3 floored values
  3908. * @returns a new Vector4
  3909. */
  3910. fract(): Vector4;
  3911. /**
  3912. * Returns the Vector4 length (float).
  3913. * @returns the length
  3914. */
  3915. length(): number;
  3916. /**
  3917. * Returns the Vector4 squared length (float).
  3918. * @returns the length squared
  3919. */
  3920. lengthSquared(): number;
  3921. /**
  3922. * Normalizes in place the Vector4.
  3923. * @returns the updated Vector4.
  3924. */
  3925. normalize(): Vector4;
  3926. /**
  3927. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3928. * @returns this converted to a new vector3
  3929. */
  3930. toVector3(): Vector3;
  3931. /**
  3932. * Returns a new Vector4 copied from the current one.
  3933. * @returns the new cloned vector
  3934. */
  3935. clone(): Vector4;
  3936. /**
  3937. * Updates the current Vector4 with the given one coordinates.
  3938. * @param source the source vector to copy from
  3939. * @returns the updated Vector4.
  3940. */
  3941. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3942. /**
  3943. * Updates the current Vector4 coordinates with the given floats.
  3944. * @param x float to copy from
  3945. * @param y float to copy from
  3946. * @param z float to copy from
  3947. * @param w float to copy from
  3948. * @returns the updated Vector4.
  3949. */
  3950. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3951. /**
  3952. * Updates the current Vector4 coordinates with the given floats.
  3953. * @param x float to set from
  3954. * @param y float to set from
  3955. * @param z float to set from
  3956. * @param w float to set from
  3957. * @returns the updated Vector4.
  3958. */
  3959. set(x: number, y: number, z: number, w: number): Vector4;
  3960. /**
  3961. * Copies the given float to the current Vector3 coordinates
  3962. * @param v defines the x, y, z and w coordinates of the operand
  3963. * @returns the current updated Vector3
  3964. */
  3965. setAll(v: number): Vector4;
  3966. /**
  3967. * Returns a new Vector4 set from the starting index of the given array.
  3968. * @param array the array to pull values from
  3969. * @param offset the offset into the array to start at
  3970. * @returns the new vector
  3971. */
  3972. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3973. /**
  3974. * Updates the given vector "result" from the starting index of the given array.
  3975. * @param array the array to pull values from
  3976. * @param offset the offset into the array to start at
  3977. * @param result the vector to store the result in
  3978. */
  3979. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3980. /**
  3981. * Updates the given vector "result" from the starting index of the given Float32Array.
  3982. * @param array the array to pull values from
  3983. * @param offset the offset into the array to start at
  3984. * @param result the vector to store the result in
  3985. */
  3986. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3987. /**
  3988. * Updates the given vector "result" coordinates from the given floats.
  3989. * @param x float to set from
  3990. * @param y float to set from
  3991. * @param z float to set from
  3992. * @param w float to set from
  3993. * @param result the vector to the floats in
  3994. */
  3995. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3996. /**
  3997. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3998. * @returns the new vector
  3999. */
  4000. static Zero(): Vector4;
  4001. /**
  4002. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  4003. * @returns the new vector
  4004. */
  4005. static One(): Vector4;
  4006. /**
  4007. * Returns a new normalized Vector4 from the given one.
  4008. * @param vector the vector to normalize
  4009. * @returns the vector
  4010. */
  4011. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  4012. /**
  4013. * Updates the given vector "result" from the normalization of the given one.
  4014. * @param vector the vector to normalize
  4015. * @param result the vector to store the result in
  4016. */
  4017. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  4018. /**
  4019. * Returns a vector with the minimum values from the left and right vectors
  4020. * @param left left vector to minimize
  4021. * @param right right vector to minimize
  4022. * @returns a new vector with the minimum of the left and right vector values
  4023. */
  4024. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4025. /**
  4026. * Returns a vector with the maximum values from the left and right vectors
  4027. * @param left left vector to maximize
  4028. * @param right right vector to maximize
  4029. * @returns a new vector with the maximum of the left and right vector values
  4030. */
  4031. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4032. /**
  4033. * Returns the distance (float) between the vectors "value1" and "value2".
  4034. * @param value1 value to calulate the distance between
  4035. * @param value2 value to calulate the distance between
  4036. * @return the distance between the two vectors
  4037. */
  4038. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4039. /**
  4040. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4041. * @param value1 value to calulate the distance between
  4042. * @param value2 value to calulate the distance between
  4043. * @return the distance between the two vectors squared
  4044. */
  4045. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4046. /**
  4047. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4048. * @param value1 value to calulate the center between
  4049. * @param value2 value to calulate the center between
  4050. * @return the center between the two vectors
  4051. */
  4052. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4053. /**
  4054. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4055. * This methods computes transformed normalized direction vectors only.
  4056. * @param vector the vector to transform
  4057. * @param transformation the transformation matrix to apply
  4058. * @returns the new vector
  4059. */
  4060. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4061. /**
  4062. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4063. * This methods computes transformed normalized direction vectors only.
  4064. * @param vector the vector to transform
  4065. * @param transformation the transformation matrix to apply
  4066. * @param result the vector to store the result in
  4067. */
  4068. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4069. /**
  4070. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4071. * This methods computes transformed normalized direction vectors only.
  4072. * @param x value to transform
  4073. * @param y value to transform
  4074. * @param z value to transform
  4075. * @param w value to transform
  4076. * @param transformation the transformation matrix to apply
  4077. * @param result the vector to store the results in
  4078. */
  4079. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4080. /**
  4081. * Creates a new Vector4 from a Vector3
  4082. * @param source defines the source data
  4083. * @param w defines the 4th component (default is 0)
  4084. * @returns a new Vector4
  4085. */
  4086. static FromVector3(source: Vector3, w?: number): Vector4;
  4087. }
  4088. /**
  4089. * Class used to store quaternion data
  4090. * @see https://en.wikipedia.org/wiki/Quaternion
  4091. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4092. */
  4093. export class Quaternion {
  4094. /** @hidden */
  4095. _x: number;
  4096. /** @hidden */
  4097. _y: number;
  4098. /** @hidden */
  4099. _z: number;
  4100. /** @hidden */
  4101. _w: number;
  4102. /** @hidden */
  4103. _isDirty: boolean;
  4104. /** Gets or sets the x coordinate */
  4105. get x(): number;
  4106. set x(value: number);
  4107. /** Gets or sets the y coordinate */
  4108. get y(): number;
  4109. set y(value: number);
  4110. /** Gets or sets the z coordinate */
  4111. get z(): number;
  4112. set z(value: number);
  4113. /** Gets or sets the w coordinate */
  4114. get w(): number;
  4115. set w(value: number);
  4116. /**
  4117. * Creates a new Quaternion from the given floats
  4118. * @param x defines the first component (0 by default)
  4119. * @param y defines the second component (0 by default)
  4120. * @param z defines the third component (0 by default)
  4121. * @param w defines the fourth component (1.0 by default)
  4122. */
  4123. constructor(x?: number, y?: number, z?: number, w?: number);
  4124. /**
  4125. * Gets a string representation for the current quaternion
  4126. * @returns a string with the Quaternion coordinates
  4127. */
  4128. toString(): string;
  4129. /**
  4130. * Gets the class name of the quaternion
  4131. * @returns the string "Quaternion"
  4132. */
  4133. getClassName(): string;
  4134. /**
  4135. * Gets a hash code for this quaternion
  4136. * @returns the quaternion hash code
  4137. */
  4138. getHashCode(): number;
  4139. /**
  4140. * Copy the quaternion to an array
  4141. * @returns a new array populated with 4 elements from the quaternion coordinates
  4142. */
  4143. asArray(): number[];
  4144. /**
  4145. * Check if two quaternions are equals
  4146. * @param otherQuaternion defines the second operand
  4147. * @return true if the current quaternion and the given one coordinates are strictly equals
  4148. */
  4149. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4150. /**
  4151. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4152. * @param otherQuaternion defines the other quaternion
  4153. * @param epsilon defines the minimal distance to consider equality
  4154. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4155. */
  4156. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4157. /**
  4158. * Clone the current quaternion
  4159. * @returns a new quaternion copied from the current one
  4160. */
  4161. clone(): Quaternion;
  4162. /**
  4163. * Copy a quaternion to the current one
  4164. * @param other defines the other quaternion
  4165. * @returns the updated current quaternion
  4166. */
  4167. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4168. /**
  4169. * Updates the current quaternion with the given float coordinates
  4170. * @param x defines the x coordinate
  4171. * @param y defines the y coordinate
  4172. * @param z defines the z coordinate
  4173. * @param w defines the w coordinate
  4174. * @returns the updated current quaternion
  4175. */
  4176. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4177. /**
  4178. * Updates the current quaternion from the given float coordinates
  4179. * @param x defines the x coordinate
  4180. * @param y defines the y coordinate
  4181. * @param z defines the z coordinate
  4182. * @param w defines the w coordinate
  4183. * @returns the updated current quaternion
  4184. */
  4185. set(x: number, y: number, z: number, w: number): Quaternion;
  4186. /**
  4187. * Adds two quaternions
  4188. * @param other defines the second operand
  4189. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4190. */
  4191. add(other: DeepImmutable<Quaternion>): Quaternion;
  4192. /**
  4193. * Add a quaternion to the current one
  4194. * @param other defines the quaternion to add
  4195. * @returns the current quaternion
  4196. */
  4197. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4198. /**
  4199. * Subtract two quaternions
  4200. * @param other defines the second operand
  4201. * @returns a new quaternion as the subtraction result of the given one from the current one
  4202. */
  4203. subtract(other: Quaternion): Quaternion;
  4204. /**
  4205. * Multiplies the current quaternion by a scale factor
  4206. * @param value defines the scale factor
  4207. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4208. */
  4209. scale(value: number): Quaternion;
  4210. /**
  4211. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4212. * @param scale defines the scale factor
  4213. * @param result defines the Quaternion object where to store the result
  4214. * @returns the unmodified current quaternion
  4215. */
  4216. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4217. /**
  4218. * Multiplies in place the current quaternion by a scale factor
  4219. * @param value defines the scale factor
  4220. * @returns the current modified quaternion
  4221. */
  4222. scaleInPlace(value: number): Quaternion;
  4223. /**
  4224. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4225. * @param scale defines the scale factor
  4226. * @param result defines the Quaternion object where to store the result
  4227. * @returns the unmodified current quaternion
  4228. */
  4229. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4230. /**
  4231. * Multiplies two quaternions
  4232. * @param q1 defines the second operand
  4233. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4234. */
  4235. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4236. /**
  4237. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4238. * @param q1 defines the second operand
  4239. * @param result defines the target quaternion
  4240. * @returns the current quaternion
  4241. */
  4242. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4243. /**
  4244. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4245. * @param q1 defines the second operand
  4246. * @returns the currentupdated quaternion
  4247. */
  4248. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4249. /**
  4250. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4251. * @param ref defines the target quaternion
  4252. * @returns the current quaternion
  4253. */
  4254. conjugateToRef(ref: Quaternion): Quaternion;
  4255. /**
  4256. * Conjugates in place (1-q) the current quaternion
  4257. * @returns the current updated quaternion
  4258. */
  4259. conjugateInPlace(): Quaternion;
  4260. /**
  4261. * Conjugates in place (1-q) the current quaternion
  4262. * @returns a new quaternion
  4263. */
  4264. conjugate(): Quaternion;
  4265. /**
  4266. * Gets length of current quaternion
  4267. * @returns the quaternion length (float)
  4268. */
  4269. length(): number;
  4270. /**
  4271. * Normalize in place the current quaternion
  4272. * @returns the current updated quaternion
  4273. */
  4274. normalize(): Quaternion;
  4275. /**
  4276. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4277. * @param order is a reserved parameter and is ignored for now
  4278. * @returns a new Vector3 containing the Euler angles
  4279. */
  4280. toEulerAngles(order?: string): Vector3;
  4281. /**
  4282. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4283. * @param result defines the vector which will be filled with the Euler angles
  4284. * @returns the current unchanged quaternion
  4285. */
  4286. toEulerAnglesToRef(result: Vector3): Quaternion;
  4287. /**
  4288. * Updates the given rotation matrix with the current quaternion values
  4289. * @param result defines the target matrix
  4290. * @returns the current unchanged quaternion
  4291. */
  4292. toRotationMatrix(result: Matrix): Quaternion;
  4293. /**
  4294. * Updates the current quaternion from the given rotation matrix values
  4295. * @param matrix defines the source matrix
  4296. * @returns the current updated quaternion
  4297. */
  4298. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4299. /**
  4300. * Creates a new quaternion from a rotation matrix
  4301. * @param matrix defines the source matrix
  4302. * @returns a new quaternion created from the given rotation matrix values
  4303. */
  4304. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4305. /**
  4306. * Updates the given quaternion with the given rotation matrix values
  4307. * @param matrix defines the source matrix
  4308. * @param result defines the target quaternion
  4309. */
  4310. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4311. /**
  4312. * Returns the dot product (float) between the quaternions "left" and "right"
  4313. * @param left defines the left operand
  4314. * @param right defines the right operand
  4315. * @returns the dot product
  4316. */
  4317. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4318. /**
  4319. * Checks if the two quaternions are close to each other
  4320. * @param quat0 defines the first quaternion to check
  4321. * @param quat1 defines the second quaternion to check
  4322. * @returns true if the two quaternions are close to each other
  4323. */
  4324. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4325. /**
  4326. * Creates an empty quaternion
  4327. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4328. */
  4329. static Zero(): Quaternion;
  4330. /**
  4331. * Inverse a given quaternion
  4332. * @param q defines the source quaternion
  4333. * @returns a new quaternion as the inverted current quaternion
  4334. */
  4335. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4336. /**
  4337. * Inverse a given quaternion
  4338. * @param q defines the source quaternion
  4339. * @param result the quaternion the result will be stored in
  4340. * @returns the result quaternion
  4341. */
  4342. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4343. /**
  4344. * Creates an identity quaternion
  4345. * @returns the identity quaternion
  4346. */
  4347. static Identity(): Quaternion;
  4348. /**
  4349. * Gets a boolean indicating if the given quaternion is identity
  4350. * @param quaternion defines the quaternion to check
  4351. * @returns true if the quaternion is identity
  4352. */
  4353. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4354. /**
  4355. * Creates a quaternion from a rotation around an axis
  4356. * @param axis defines the axis to use
  4357. * @param angle defines the angle to use
  4358. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4359. */
  4360. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4361. /**
  4362. * Creates a rotation around an axis and stores it into the given quaternion
  4363. * @param axis defines the axis to use
  4364. * @param angle defines the angle to use
  4365. * @param result defines the target quaternion
  4366. * @returns the target quaternion
  4367. */
  4368. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4369. /**
  4370. * Creates a new quaternion from data stored into an array
  4371. * @param array defines the data source
  4372. * @param offset defines the offset in the source array where the data starts
  4373. * @returns a new quaternion
  4374. */
  4375. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4376. /**
  4377. * Updates the given quaternion "result" from the starting index of the given array.
  4378. * @param array the array to pull values from
  4379. * @param offset the offset into the array to start at
  4380. * @param result the quaternion to store the result in
  4381. */
  4382. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4383. /**
  4384. * Create a quaternion from Euler rotation angles
  4385. * @param x Pitch
  4386. * @param y Yaw
  4387. * @param z Roll
  4388. * @returns the new Quaternion
  4389. */
  4390. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4391. /**
  4392. * Updates a quaternion from Euler rotation angles
  4393. * @param x Pitch
  4394. * @param y Yaw
  4395. * @param z Roll
  4396. * @param result the quaternion to store the result
  4397. * @returns the updated quaternion
  4398. */
  4399. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4400. /**
  4401. * Create a quaternion from Euler rotation vector
  4402. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4403. * @returns the new Quaternion
  4404. */
  4405. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4406. /**
  4407. * Updates a quaternion from Euler rotation vector
  4408. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4409. * @param result the quaternion to store the result
  4410. * @returns the updated quaternion
  4411. */
  4412. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4413. /**
  4414. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4415. * @param yaw defines the rotation around Y axis
  4416. * @param pitch defines the rotation around X axis
  4417. * @param roll defines the rotation around Z axis
  4418. * @returns the new quaternion
  4419. */
  4420. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4421. /**
  4422. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4423. * @param yaw defines the rotation around Y axis
  4424. * @param pitch defines the rotation around X axis
  4425. * @param roll defines the rotation around Z axis
  4426. * @param result defines the target quaternion
  4427. */
  4428. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4429. /**
  4430. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4431. * @param alpha defines the rotation around first axis
  4432. * @param beta defines the rotation around second axis
  4433. * @param gamma defines the rotation around third axis
  4434. * @returns the new quaternion
  4435. */
  4436. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4437. /**
  4438. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4439. * @param alpha defines the rotation around first axis
  4440. * @param beta defines the rotation around second axis
  4441. * @param gamma defines the rotation around third axis
  4442. * @param result defines the target quaternion
  4443. */
  4444. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4445. /**
  4446. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4447. * @param axis1 defines the first axis
  4448. * @param axis2 defines the second axis
  4449. * @param axis3 defines the third axis
  4450. * @returns the new quaternion
  4451. */
  4452. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4453. /**
  4454. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4455. * @param axis1 defines the first axis
  4456. * @param axis2 defines the second axis
  4457. * @param axis3 defines the third axis
  4458. * @param ref defines the target quaternion
  4459. */
  4460. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4461. /**
  4462. * Interpolates between two quaternions
  4463. * @param left defines first quaternion
  4464. * @param right defines second quaternion
  4465. * @param amount defines the gradient to use
  4466. * @returns the new interpolated quaternion
  4467. */
  4468. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4469. /**
  4470. * Interpolates between two quaternions and stores it into a target quaternion
  4471. * @param left defines first quaternion
  4472. * @param right defines second quaternion
  4473. * @param amount defines the gradient to use
  4474. * @param result defines the target quaternion
  4475. */
  4476. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4477. /**
  4478. * Interpolate between two quaternions using Hermite interpolation
  4479. * @param value1 defines first quaternion
  4480. * @param tangent1 defines the incoming tangent
  4481. * @param value2 defines second quaternion
  4482. * @param tangent2 defines the outgoing tangent
  4483. * @param amount defines the target quaternion
  4484. * @returns the new interpolated quaternion
  4485. */
  4486. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4487. }
  4488. /**
  4489. * Class used to store matrix data (4x4)
  4490. */
  4491. export class Matrix {
  4492. /**
  4493. * Gets the precision of matrix computations
  4494. */
  4495. static get Use64Bits(): boolean;
  4496. private static _updateFlagSeed;
  4497. private static _identityReadOnly;
  4498. private _isIdentity;
  4499. private _isIdentityDirty;
  4500. private _isIdentity3x2;
  4501. private _isIdentity3x2Dirty;
  4502. /**
  4503. * Gets the update flag of the matrix which is an unique number for the matrix.
  4504. * It will be incremented every time the matrix data change.
  4505. * You can use it to speed the comparison between two versions of the same matrix.
  4506. */
  4507. updateFlag: number;
  4508. private readonly _m;
  4509. /**
  4510. * Gets the internal data of the matrix
  4511. */
  4512. get m(): DeepImmutable<Float32Array | Array<number>>;
  4513. /** @hidden */
  4514. _markAsUpdated(): void;
  4515. /** @hidden */
  4516. private _updateIdentityStatus;
  4517. /**
  4518. * Creates an empty matrix (filled with zeros)
  4519. */
  4520. constructor();
  4521. /**
  4522. * Check if the current matrix is identity
  4523. * @returns true is the matrix is the identity matrix
  4524. */
  4525. isIdentity(): boolean;
  4526. /**
  4527. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4528. * @returns true is the matrix is the identity matrix
  4529. */
  4530. isIdentityAs3x2(): boolean;
  4531. /**
  4532. * Gets the determinant of the matrix
  4533. * @returns the matrix determinant
  4534. */
  4535. determinant(): number;
  4536. /**
  4537. * Returns the matrix as a Float32Array or Array<number>
  4538. * @returns the matrix underlying array
  4539. */
  4540. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4541. /**
  4542. * Returns the matrix as a Float32Array or Array<number>
  4543. * @returns the matrix underlying array.
  4544. */
  4545. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4546. /**
  4547. * Inverts the current matrix in place
  4548. * @returns the current inverted matrix
  4549. */
  4550. invert(): Matrix;
  4551. /**
  4552. * Sets all the matrix elements to zero
  4553. * @returns the current matrix
  4554. */
  4555. reset(): Matrix;
  4556. /**
  4557. * Adds the current matrix with a second one
  4558. * @param other defines the matrix to add
  4559. * @returns a new matrix as the addition of the current matrix and the given one
  4560. */
  4561. add(other: DeepImmutable<Matrix>): Matrix;
  4562. /**
  4563. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4564. * @param other defines the matrix to add
  4565. * @param result defines the target matrix
  4566. * @returns the current matrix
  4567. */
  4568. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4569. /**
  4570. * Adds in place the given matrix to the current matrix
  4571. * @param other defines the second operand
  4572. * @returns the current updated matrix
  4573. */
  4574. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4575. /**
  4576. * Sets the given matrix to the current inverted Matrix
  4577. * @param other defines the target matrix
  4578. * @returns the unmodified current matrix
  4579. */
  4580. invertToRef(other: Matrix): Matrix;
  4581. /**
  4582. * add a value at the specified position in the current Matrix
  4583. * @param index the index of the value within the matrix. between 0 and 15.
  4584. * @param value the value to be added
  4585. * @returns the current updated matrix
  4586. */
  4587. addAtIndex(index: number, value: number): Matrix;
  4588. /**
  4589. * mutiply the specified position in the current Matrix by a value
  4590. * @param index the index of the value within the matrix. between 0 and 15.
  4591. * @param value the value to be added
  4592. * @returns the current updated matrix
  4593. */
  4594. multiplyAtIndex(index: number, value: number): Matrix;
  4595. /**
  4596. * Inserts the translation vector (using 3 floats) in the current matrix
  4597. * @param x defines the 1st component of the translation
  4598. * @param y defines the 2nd component of the translation
  4599. * @param z defines the 3rd component of the translation
  4600. * @returns the current updated matrix
  4601. */
  4602. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4603. /**
  4604. * Adds the translation vector (using 3 floats) in the current matrix
  4605. * @param x defines the 1st component of the translation
  4606. * @param y defines the 2nd component of the translation
  4607. * @param z defines the 3rd component of the translation
  4608. * @returns the current updated matrix
  4609. */
  4610. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4611. /**
  4612. * Inserts the translation vector in the current matrix
  4613. * @param vector3 defines the translation to insert
  4614. * @returns the current updated matrix
  4615. */
  4616. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4617. /**
  4618. * Gets the translation value of the current matrix
  4619. * @returns a new Vector3 as the extracted translation from the matrix
  4620. */
  4621. getTranslation(): Vector3;
  4622. /**
  4623. * Fill a Vector3 with the extracted translation from the matrix
  4624. * @param result defines the Vector3 where to store the translation
  4625. * @returns the current matrix
  4626. */
  4627. getTranslationToRef(result: Vector3): Matrix;
  4628. /**
  4629. * Remove rotation and scaling part from the matrix
  4630. * @returns the updated matrix
  4631. */
  4632. removeRotationAndScaling(): Matrix;
  4633. /**
  4634. * Multiply two matrices
  4635. * @param other defines the second operand
  4636. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4637. */
  4638. multiply(other: DeepImmutable<Matrix>): Matrix;
  4639. /**
  4640. * Copy the current matrix from the given one
  4641. * @param other defines the source matrix
  4642. * @returns the current updated matrix
  4643. */
  4644. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4645. /**
  4646. * Populates the given array from the starting index with the current matrix values
  4647. * @param array defines the target array
  4648. * @param offset defines the offset in the target array where to start storing values
  4649. * @returns the current matrix
  4650. */
  4651. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4652. /**
  4653. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4654. * @param other defines the second operand
  4655. * @param result defines the matrix where to store the multiplication
  4656. * @returns the current matrix
  4657. */
  4658. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4659. /**
  4660. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4661. * @param other defines the second operand
  4662. * @param result defines the array where to store the multiplication
  4663. * @param offset defines the offset in the target array where to start storing values
  4664. * @returns the current matrix
  4665. */
  4666. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4667. /**
  4668. * Check equality between this matrix and a second one
  4669. * @param value defines the second matrix to compare
  4670. * @returns true is the current matrix and the given one values are strictly equal
  4671. */
  4672. equals(value: DeepImmutable<Matrix>): boolean;
  4673. /**
  4674. * Clone the current matrix
  4675. * @returns a new matrix from the current matrix
  4676. */
  4677. clone(): Matrix;
  4678. /**
  4679. * Returns the name of the current matrix class
  4680. * @returns the string "Matrix"
  4681. */
  4682. getClassName(): string;
  4683. /**
  4684. * Gets the hash code of the current matrix
  4685. * @returns the hash code
  4686. */
  4687. getHashCode(): number;
  4688. /**
  4689. * Decomposes the current Matrix into a translation, rotation and scaling components
  4690. * @param scale defines the scale vector3 given as a reference to update
  4691. * @param rotation defines the rotation quaternion given as a reference to update
  4692. * @param translation defines the translation vector3 given as a reference to update
  4693. * @returns true if operation was successful
  4694. */
  4695. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4696. /**
  4697. * Gets specific row of the matrix
  4698. * @param index defines the number of the row to get
  4699. * @returns the index-th row of the current matrix as a new Vector4
  4700. */
  4701. getRow(index: number): Nullable<Vector4>;
  4702. /**
  4703. * Sets the index-th row of the current matrix to the vector4 values
  4704. * @param index defines the number of the row to set
  4705. * @param row defines the target vector4
  4706. * @returns the updated current matrix
  4707. */
  4708. setRow(index: number, row: Vector4): Matrix;
  4709. /**
  4710. * Compute the transpose of the matrix
  4711. * @returns the new transposed matrix
  4712. */
  4713. transpose(): Matrix;
  4714. /**
  4715. * Compute the transpose of the matrix and store it in a given matrix
  4716. * @param result defines the target matrix
  4717. * @returns the current matrix
  4718. */
  4719. transposeToRef(result: Matrix): Matrix;
  4720. /**
  4721. * Sets the index-th row of the current matrix with the given 4 x float values
  4722. * @param index defines the row index
  4723. * @param x defines the x component to set
  4724. * @param y defines the y component to set
  4725. * @param z defines the z component to set
  4726. * @param w defines the w component to set
  4727. * @returns the updated current matrix
  4728. */
  4729. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4730. /**
  4731. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4732. * @param scale defines the scale factor
  4733. * @returns a new matrix
  4734. */
  4735. scale(scale: number): Matrix;
  4736. /**
  4737. * Scale the current matrix values by a factor to a given result matrix
  4738. * @param scale defines the scale factor
  4739. * @param result defines the matrix to store the result
  4740. * @returns the current matrix
  4741. */
  4742. scaleToRef(scale: number, result: Matrix): Matrix;
  4743. /**
  4744. * Scale the current matrix values by a factor and add the result to a given matrix
  4745. * @param scale defines the scale factor
  4746. * @param result defines the Matrix to store the result
  4747. * @returns the current matrix
  4748. */
  4749. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4750. /**
  4751. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4752. * @param ref matrix to store the result
  4753. */
  4754. toNormalMatrix(ref: Matrix): void;
  4755. /**
  4756. * Gets only rotation part of the current matrix
  4757. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4758. */
  4759. getRotationMatrix(): Matrix;
  4760. /**
  4761. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4762. * @param result defines the target matrix to store data to
  4763. * @returns the current matrix
  4764. */
  4765. getRotationMatrixToRef(result: Matrix): Matrix;
  4766. /**
  4767. * Toggles model matrix from being right handed to left handed in place and vice versa
  4768. */
  4769. toggleModelMatrixHandInPlace(): void;
  4770. /**
  4771. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4772. */
  4773. toggleProjectionMatrixHandInPlace(): void;
  4774. /**
  4775. * Creates a matrix from an array
  4776. * @param array defines the source array
  4777. * @param offset defines an offset in the source array
  4778. * @returns a new Matrix set from the starting index of the given array
  4779. */
  4780. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4781. /**
  4782. * Copy the content of an array into a given matrix
  4783. * @param array defines the source array
  4784. * @param offset defines an offset in the source array
  4785. * @param result defines the target matrix
  4786. */
  4787. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4788. /**
  4789. * Stores an array into a matrix after having multiplied each component by a given factor
  4790. * @param array defines the source array
  4791. * @param offset defines the offset in the source array
  4792. * @param scale defines the scaling factor
  4793. * @param result defines the target matrix
  4794. */
  4795. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4796. /**
  4797. * Gets an identity matrix that must not be updated
  4798. */
  4799. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4800. /**
  4801. * Stores a list of values (16) inside a given matrix
  4802. * @param initialM11 defines 1st value of 1st row
  4803. * @param initialM12 defines 2nd value of 1st row
  4804. * @param initialM13 defines 3rd value of 1st row
  4805. * @param initialM14 defines 4th value of 1st row
  4806. * @param initialM21 defines 1st value of 2nd row
  4807. * @param initialM22 defines 2nd value of 2nd row
  4808. * @param initialM23 defines 3rd value of 2nd row
  4809. * @param initialM24 defines 4th value of 2nd row
  4810. * @param initialM31 defines 1st value of 3rd row
  4811. * @param initialM32 defines 2nd value of 3rd row
  4812. * @param initialM33 defines 3rd value of 3rd row
  4813. * @param initialM34 defines 4th value of 3rd row
  4814. * @param initialM41 defines 1st value of 4th row
  4815. * @param initialM42 defines 2nd value of 4th row
  4816. * @param initialM43 defines 3rd value of 4th row
  4817. * @param initialM44 defines 4th value of 4th row
  4818. * @param result defines the target matrix
  4819. */
  4820. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4821. /**
  4822. * Creates new matrix from a list of values (16)
  4823. * @param initialM11 defines 1st value of 1st row
  4824. * @param initialM12 defines 2nd value of 1st row
  4825. * @param initialM13 defines 3rd value of 1st row
  4826. * @param initialM14 defines 4th value of 1st row
  4827. * @param initialM21 defines 1st value of 2nd row
  4828. * @param initialM22 defines 2nd value of 2nd row
  4829. * @param initialM23 defines 3rd value of 2nd row
  4830. * @param initialM24 defines 4th value of 2nd row
  4831. * @param initialM31 defines 1st value of 3rd row
  4832. * @param initialM32 defines 2nd value of 3rd row
  4833. * @param initialM33 defines 3rd value of 3rd row
  4834. * @param initialM34 defines 4th value of 3rd row
  4835. * @param initialM41 defines 1st value of 4th row
  4836. * @param initialM42 defines 2nd value of 4th row
  4837. * @param initialM43 defines 3rd value of 4th row
  4838. * @param initialM44 defines 4th value of 4th row
  4839. * @returns the new matrix
  4840. */
  4841. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4842. /**
  4843. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4844. * @param scale defines the scale vector3
  4845. * @param rotation defines the rotation quaternion
  4846. * @param translation defines the translation vector3
  4847. * @returns a new matrix
  4848. */
  4849. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4850. /**
  4851. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4852. * @param scale defines the scale vector3
  4853. * @param rotation defines the rotation quaternion
  4854. * @param translation defines the translation vector3
  4855. * @param result defines the target matrix
  4856. */
  4857. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4858. /**
  4859. * Creates a new identity matrix
  4860. * @returns a new identity matrix
  4861. */
  4862. static Identity(): Matrix;
  4863. /**
  4864. * Creates a new identity matrix and stores the result in a given matrix
  4865. * @param result defines the target matrix
  4866. */
  4867. static IdentityToRef(result: Matrix): void;
  4868. /**
  4869. * Creates a new zero matrix
  4870. * @returns a new zero matrix
  4871. */
  4872. static Zero(): Matrix;
  4873. /**
  4874. * Creates a new rotation matrix for "angle" radians around the X axis
  4875. * @param angle defines the angle (in radians) to use
  4876. * @return the new matrix
  4877. */
  4878. static RotationX(angle: number): Matrix;
  4879. /**
  4880. * Creates a new matrix as the invert of a given matrix
  4881. * @param source defines the source matrix
  4882. * @returns the new matrix
  4883. */
  4884. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4885. /**
  4886. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4887. * @param angle defines the angle (in radians) to use
  4888. * @param result defines the target matrix
  4889. */
  4890. static RotationXToRef(angle: number, result: Matrix): void;
  4891. /**
  4892. * Creates a new rotation matrix for "angle" radians around the Y axis
  4893. * @param angle defines the angle (in radians) to use
  4894. * @return the new matrix
  4895. */
  4896. static RotationY(angle: number): Matrix;
  4897. /**
  4898. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4899. * @param angle defines the angle (in radians) to use
  4900. * @param result defines the target matrix
  4901. */
  4902. static RotationYToRef(angle: number, result: Matrix): void;
  4903. /**
  4904. * Creates a new rotation matrix for "angle" radians around the Z axis
  4905. * @param angle defines the angle (in radians) to use
  4906. * @return the new matrix
  4907. */
  4908. static RotationZ(angle: number): Matrix;
  4909. /**
  4910. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4911. * @param angle defines the angle (in radians) to use
  4912. * @param result defines the target matrix
  4913. */
  4914. static RotationZToRef(angle: number, result: Matrix): void;
  4915. /**
  4916. * Creates a new rotation matrix for "angle" radians around the given axis
  4917. * @param axis defines the axis to use
  4918. * @param angle defines the angle (in radians) to use
  4919. * @return the new matrix
  4920. */
  4921. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4922. /**
  4923. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4924. * @param axis defines the axis to use
  4925. * @param angle defines the angle (in radians) to use
  4926. * @param result defines the target matrix
  4927. */
  4928. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4929. /**
  4930. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4931. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4932. * @param from defines the vector to align
  4933. * @param to defines the vector to align to
  4934. * @param result defines the target matrix
  4935. */
  4936. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4937. /**
  4938. * Creates a rotation matrix
  4939. * @param yaw defines the yaw angle in radians (Y axis)
  4940. * @param pitch defines the pitch angle in radians (X axis)
  4941. * @param roll defines the roll angle in radians (Z axis)
  4942. * @returns the new rotation matrix
  4943. */
  4944. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4945. /**
  4946. * Creates a rotation matrix and stores it in a given matrix
  4947. * @param yaw defines the yaw angle in radians (Y axis)
  4948. * @param pitch defines the pitch angle in radians (X axis)
  4949. * @param roll defines the roll angle in radians (Z axis)
  4950. * @param result defines the target matrix
  4951. */
  4952. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4953. /**
  4954. * Creates a scaling matrix
  4955. * @param x defines the scale factor on X axis
  4956. * @param y defines the scale factor on Y axis
  4957. * @param z defines the scale factor on Z axis
  4958. * @returns the new matrix
  4959. */
  4960. static Scaling(x: number, y: number, z: number): Matrix;
  4961. /**
  4962. * Creates a scaling matrix and stores it in a given matrix
  4963. * @param x defines the scale factor on X axis
  4964. * @param y defines the scale factor on Y axis
  4965. * @param z defines the scale factor on Z axis
  4966. * @param result defines the target matrix
  4967. */
  4968. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4969. /**
  4970. * Creates a translation matrix
  4971. * @param x defines the translation on X axis
  4972. * @param y defines the translation on Y axis
  4973. * @param z defines the translationon Z axis
  4974. * @returns the new matrix
  4975. */
  4976. static Translation(x: number, y: number, z: number): Matrix;
  4977. /**
  4978. * Creates a translation matrix and stores it in a given matrix
  4979. * @param x defines the translation on X axis
  4980. * @param y defines the translation on Y axis
  4981. * @param z defines the translationon Z axis
  4982. * @param result defines the target matrix
  4983. */
  4984. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4985. /**
  4986. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4987. * @param startValue defines the start value
  4988. * @param endValue defines the end value
  4989. * @param gradient defines the gradient factor
  4990. * @returns the new matrix
  4991. */
  4992. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4993. /**
  4994. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4995. * @param startValue defines the start value
  4996. * @param endValue defines the end value
  4997. * @param gradient defines the gradient factor
  4998. * @param result defines the Matrix object where to store data
  4999. */
  5000. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5001. /**
  5002. * Builds a new matrix whose values are computed by:
  5003. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5004. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5005. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5006. * @param startValue defines the first matrix
  5007. * @param endValue defines the second matrix
  5008. * @param gradient defines the gradient between the two matrices
  5009. * @returns the new matrix
  5010. */
  5011. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5012. /**
  5013. * Update a matrix to values which are computed by:
  5014. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5015. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5016. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5017. * @param startValue defines the first matrix
  5018. * @param endValue defines the second matrix
  5019. * @param gradient defines the gradient between the two matrices
  5020. * @param result defines the target matrix
  5021. */
  5022. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5023. /**
  5024. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  5025. * This function works in left handed mode
  5026. * @param eye defines the final position of the entity
  5027. * @param target defines where the entity should look at
  5028. * @param up defines the up vector for the entity
  5029. * @returns the new matrix
  5030. */
  5031. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5032. /**
  5033. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  5034. * This function works in left handed mode
  5035. * @param eye defines the final position of the entity
  5036. * @param target defines where the entity should look at
  5037. * @param up defines the up vector for the entity
  5038. * @param result defines the target matrix
  5039. */
  5040. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5041. /**
  5042. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  5043. * This function works in right handed mode
  5044. * @param eye defines the final position of the entity
  5045. * @param target defines where the entity should look at
  5046. * @param up defines the up vector for the entity
  5047. * @returns the new matrix
  5048. */
  5049. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5050. /**
  5051. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  5052. * This function works in right handed mode
  5053. * @param eye defines the final position of the entity
  5054. * @param target defines where the entity should look at
  5055. * @param up defines the up vector for the entity
  5056. * @param result defines the target matrix
  5057. */
  5058. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5059. /**
  5060. * Create a left-handed orthographic projection matrix
  5061. * @param width defines the viewport width
  5062. * @param height defines the viewport height
  5063. * @param znear defines the near clip plane
  5064. * @param zfar defines the far clip plane
  5065. * @returns a new matrix as a left-handed orthographic projection matrix
  5066. */
  5067. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5068. /**
  5069. * Store a left-handed orthographic projection to a given matrix
  5070. * @param width defines the viewport width
  5071. * @param height defines the viewport height
  5072. * @param znear defines the near clip plane
  5073. * @param zfar defines the far clip plane
  5074. * @param result defines the target matrix
  5075. */
  5076. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5077. /**
  5078. * Create a left-handed orthographic projection matrix
  5079. * @param left defines the viewport left coordinate
  5080. * @param right defines the viewport right coordinate
  5081. * @param bottom defines the viewport bottom coordinate
  5082. * @param top defines the viewport top coordinate
  5083. * @param znear defines the near clip plane
  5084. * @param zfar defines the far clip plane
  5085. * @returns a new matrix as a left-handed orthographic projection matrix
  5086. */
  5087. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5088. /**
  5089. * Stores a left-handed orthographic projection into a given matrix
  5090. * @param left defines the viewport left coordinate
  5091. * @param right defines the viewport right coordinate
  5092. * @param bottom defines the viewport bottom coordinate
  5093. * @param top defines the viewport top coordinate
  5094. * @param znear defines the near clip plane
  5095. * @param zfar defines the far clip plane
  5096. * @param result defines the target matrix
  5097. */
  5098. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5099. /**
  5100. * Creates a right-handed orthographic projection matrix
  5101. * @param left defines the viewport left coordinate
  5102. * @param right defines the viewport right coordinate
  5103. * @param bottom defines the viewport bottom coordinate
  5104. * @param top defines the viewport top coordinate
  5105. * @param znear defines the near clip plane
  5106. * @param zfar defines the far clip plane
  5107. * @returns a new matrix as a right-handed orthographic projection matrix
  5108. */
  5109. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5110. /**
  5111. * Stores a right-handed orthographic projection into a given matrix
  5112. * @param left defines the viewport left coordinate
  5113. * @param right defines the viewport right coordinate
  5114. * @param bottom defines the viewport bottom coordinate
  5115. * @param top defines the viewport top coordinate
  5116. * @param znear defines the near clip plane
  5117. * @param zfar defines the far clip plane
  5118. * @param result defines the target matrix
  5119. */
  5120. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5121. /**
  5122. * Creates a left-handed perspective projection matrix
  5123. * @param width defines the viewport width
  5124. * @param height defines the viewport height
  5125. * @param znear defines the near clip plane
  5126. * @param zfar defines the far clip plane
  5127. * @returns a new matrix as a left-handed perspective projection matrix
  5128. */
  5129. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5130. /**
  5131. * Creates a left-handed perspective projection matrix
  5132. * @param fov defines the horizontal field of view
  5133. * @param aspect defines the aspect ratio
  5134. * @param znear defines the near clip plane
  5135. * @param zfar defines the far clip plane
  5136. * @returns a new matrix as a left-handed perspective projection matrix
  5137. */
  5138. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5139. /**
  5140. * Stores a left-handed perspective projection into a given matrix
  5141. * @param fov defines the horizontal field of view
  5142. * @param aspect defines the aspect ratio
  5143. * @param znear defines the near clip plane
  5144. * @param zfar defines the far clip plane
  5145. * @param result defines the target matrix
  5146. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5147. */
  5148. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5149. /**
  5150. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5151. * @param fov defines the horizontal field of view
  5152. * @param aspect defines the aspect ratio
  5153. * @param znear defines the near clip plane
  5154. * @param zfar not used as infinity is used as far clip
  5155. * @param result defines the target matrix
  5156. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5157. */
  5158. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5159. /**
  5160. * Creates a right-handed perspective projection matrix
  5161. * @param fov defines the horizontal field of view
  5162. * @param aspect defines the aspect ratio
  5163. * @param znear defines the near clip plane
  5164. * @param zfar defines the far clip plane
  5165. * @returns a new matrix as a right-handed perspective projection matrix
  5166. */
  5167. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5168. /**
  5169. * Stores a right-handed perspective projection into a given matrix
  5170. * @param fov defines the horizontal field of view
  5171. * @param aspect defines the aspect ratio
  5172. * @param znear defines the near clip plane
  5173. * @param zfar defines the far clip plane
  5174. * @param result defines the target matrix
  5175. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5176. */
  5177. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5178. /**
  5179. * Stores a right-handed perspective projection into a given matrix
  5180. * @param fov defines the horizontal field of view
  5181. * @param aspect defines the aspect ratio
  5182. * @param znear defines the near clip plane
  5183. * @param zfar not used as infinity is used as far clip
  5184. * @param result defines the target matrix
  5185. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5186. */
  5187. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5188. /**
  5189. * Stores a perspective projection for WebVR info a given matrix
  5190. * @param fov defines the field of view
  5191. * @param znear defines the near clip plane
  5192. * @param zfar defines the far clip plane
  5193. * @param result defines the target matrix
  5194. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5195. */
  5196. static PerspectiveFovWebVRToRef(fov: {
  5197. upDegrees: number;
  5198. downDegrees: number;
  5199. leftDegrees: number;
  5200. rightDegrees: number;
  5201. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5202. /**
  5203. * Computes a complete transformation matrix
  5204. * @param viewport defines the viewport to use
  5205. * @param world defines the world matrix
  5206. * @param view defines the view matrix
  5207. * @param projection defines the projection matrix
  5208. * @param zmin defines the near clip plane
  5209. * @param zmax defines the far clip plane
  5210. * @returns the transformation matrix
  5211. */
  5212. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5213. /**
  5214. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5215. * @param matrix defines the matrix to use
  5216. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5217. */
  5218. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5219. /**
  5220. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5221. * @param matrix defines the matrix to use
  5222. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5223. */
  5224. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5225. /**
  5226. * Compute the transpose of a given matrix
  5227. * @param matrix defines the matrix to transpose
  5228. * @returns the new matrix
  5229. */
  5230. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5231. /**
  5232. * Compute the transpose of a matrix and store it in a target matrix
  5233. * @param matrix defines the matrix to transpose
  5234. * @param result defines the target matrix
  5235. */
  5236. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5237. /**
  5238. * Computes a reflection matrix from a plane
  5239. * @param plane defines the reflection plane
  5240. * @returns a new matrix
  5241. */
  5242. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5243. /**
  5244. * Computes a reflection matrix from a plane
  5245. * @param plane defines the reflection plane
  5246. * @param result defines the target matrix
  5247. */
  5248. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5249. /**
  5250. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5251. * @param xaxis defines the value of the 1st axis
  5252. * @param yaxis defines the value of the 2nd axis
  5253. * @param zaxis defines the value of the 3rd axis
  5254. * @param result defines the target matrix
  5255. */
  5256. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5257. /**
  5258. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5259. * @param quat defines the quaternion to use
  5260. * @param result defines the target matrix
  5261. */
  5262. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5263. }
  5264. /**
  5265. * @hidden
  5266. */
  5267. export class TmpVectors {
  5268. static Vector2: Vector2[];
  5269. static Vector3: Vector3[];
  5270. static Vector4: Vector4[];
  5271. static Quaternion: Quaternion[];
  5272. static Matrix: Matrix[];
  5273. }
  5274. }
  5275. declare module "babylonjs/Maths/math.path" {
  5276. import { DeepImmutable, Nullable } from "babylonjs/types";
  5277. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5278. /**
  5279. * Defines potential orientation for back face culling
  5280. */
  5281. export enum Orientation {
  5282. /**
  5283. * Clockwise
  5284. */
  5285. CW = 0,
  5286. /** Counter clockwise */
  5287. CCW = 1
  5288. }
  5289. /** Class used to represent a Bezier curve */
  5290. export class BezierCurve {
  5291. /**
  5292. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5293. * @param t defines the time
  5294. * @param x1 defines the left coordinate on X axis
  5295. * @param y1 defines the left coordinate on Y axis
  5296. * @param x2 defines the right coordinate on X axis
  5297. * @param y2 defines the right coordinate on Y axis
  5298. * @returns the interpolated value
  5299. */
  5300. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5301. }
  5302. /**
  5303. * Defines angle representation
  5304. */
  5305. export class Angle {
  5306. private _radians;
  5307. /**
  5308. * Creates an Angle object of "radians" radians (float).
  5309. * @param radians the angle in radians
  5310. */
  5311. constructor(radians: number);
  5312. /**
  5313. * Get value in degrees
  5314. * @returns the Angle value in degrees (float)
  5315. */
  5316. degrees(): number;
  5317. /**
  5318. * Get value in radians
  5319. * @returns the Angle value in radians (float)
  5320. */
  5321. radians(): number;
  5322. /**
  5323. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5324. * @param a defines first point as the origin
  5325. * @param b defines point
  5326. * @returns a new Angle
  5327. */
  5328. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5329. /**
  5330. * Gets a new Angle object from the given float in radians
  5331. * @param radians defines the angle value in radians
  5332. * @returns a new Angle
  5333. */
  5334. static FromRadians(radians: number): Angle;
  5335. /**
  5336. * Gets a new Angle object from the given float in degrees
  5337. * @param degrees defines the angle value in degrees
  5338. * @returns a new Angle
  5339. */
  5340. static FromDegrees(degrees: number): Angle;
  5341. }
  5342. /**
  5343. * This represents an arc in a 2d space.
  5344. */
  5345. export class Arc2 {
  5346. /** Defines the start point of the arc */
  5347. startPoint: Vector2;
  5348. /** Defines the mid point of the arc */
  5349. midPoint: Vector2;
  5350. /** Defines the end point of the arc */
  5351. endPoint: Vector2;
  5352. /**
  5353. * Defines the center point of the arc.
  5354. */
  5355. centerPoint: Vector2;
  5356. /**
  5357. * Defines the radius of the arc.
  5358. */
  5359. radius: number;
  5360. /**
  5361. * Defines the angle of the arc (from mid point to end point).
  5362. */
  5363. angle: Angle;
  5364. /**
  5365. * Defines the start angle of the arc (from start point to middle point).
  5366. */
  5367. startAngle: Angle;
  5368. /**
  5369. * Defines the orientation of the arc (clock wise/counter clock wise).
  5370. */
  5371. orientation: Orientation;
  5372. /**
  5373. * Creates an Arc object from the three given points : start, middle and end.
  5374. * @param startPoint Defines the start point of the arc
  5375. * @param midPoint Defines the midlle point of the arc
  5376. * @param endPoint Defines the end point of the arc
  5377. */
  5378. constructor(
  5379. /** Defines the start point of the arc */
  5380. startPoint: Vector2,
  5381. /** Defines the mid point of the arc */
  5382. midPoint: Vector2,
  5383. /** Defines the end point of the arc */
  5384. endPoint: Vector2);
  5385. }
  5386. /**
  5387. * Represents a 2D path made up of multiple 2D points
  5388. */
  5389. export class Path2 {
  5390. private _points;
  5391. private _length;
  5392. /**
  5393. * If the path start and end point are the same
  5394. */
  5395. closed: boolean;
  5396. /**
  5397. * Creates a Path2 object from the starting 2D coordinates x and y.
  5398. * @param x the starting points x value
  5399. * @param y the starting points y value
  5400. */
  5401. constructor(x: number, y: number);
  5402. /**
  5403. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5404. * @param x the added points x value
  5405. * @param y the added points y value
  5406. * @returns the updated Path2.
  5407. */
  5408. addLineTo(x: number, y: number): Path2;
  5409. /**
  5410. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5411. * @param midX middle point x value
  5412. * @param midY middle point y value
  5413. * @param endX end point x value
  5414. * @param endY end point y value
  5415. * @param numberOfSegments (default: 36)
  5416. * @returns the updated Path2.
  5417. */
  5418. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5419. /**
  5420. * Closes the Path2.
  5421. * @returns the Path2.
  5422. */
  5423. close(): Path2;
  5424. /**
  5425. * Gets the sum of the distance between each sequential point in the path
  5426. * @returns the Path2 total length (float).
  5427. */
  5428. length(): number;
  5429. /**
  5430. * Gets the points which construct the path
  5431. * @returns the Path2 internal array of points.
  5432. */
  5433. getPoints(): Vector2[];
  5434. /**
  5435. * Retreives the point at the distance aways from the starting point
  5436. * @param normalizedLengthPosition the length along the path to retreive the point from
  5437. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5438. */
  5439. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5440. /**
  5441. * Creates a new path starting from an x and y position
  5442. * @param x starting x value
  5443. * @param y starting y value
  5444. * @returns a new Path2 starting at the coordinates (x, y).
  5445. */
  5446. static StartingAt(x: number, y: number): Path2;
  5447. }
  5448. /**
  5449. * Represents a 3D path made up of multiple 3D points
  5450. */
  5451. export class Path3D {
  5452. /**
  5453. * an array of Vector3, the curve axis of the Path3D
  5454. */
  5455. path: Vector3[];
  5456. private _curve;
  5457. private _distances;
  5458. private _tangents;
  5459. private _normals;
  5460. private _binormals;
  5461. private _raw;
  5462. private _alignTangentsWithPath;
  5463. private readonly _pointAtData;
  5464. /**
  5465. * new Path3D(path, normal, raw)
  5466. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5467. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5468. * @param path an array of Vector3, the curve axis of the Path3D
  5469. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5470. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5471. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5472. */
  5473. constructor(
  5474. /**
  5475. * an array of Vector3, the curve axis of the Path3D
  5476. */
  5477. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5478. /**
  5479. * Returns the Path3D array of successive Vector3 designing its curve.
  5480. * @returns the Path3D array of successive Vector3 designing its curve.
  5481. */
  5482. getCurve(): Vector3[];
  5483. /**
  5484. * Returns the Path3D array of successive Vector3 designing its curve.
  5485. * @returns the Path3D array of successive Vector3 designing its curve.
  5486. */
  5487. getPoints(): Vector3[];
  5488. /**
  5489. * @returns the computed length (float) of the path.
  5490. */
  5491. length(): number;
  5492. /**
  5493. * Returns an array populated with tangent vectors on each Path3D curve point.
  5494. * @returns an array populated with tangent vectors on each Path3D curve point.
  5495. */
  5496. getTangents(): Vector3[];
  5497. /**
  5498. * Returns an array populated with normal vectors on each Path3D curve point.
  5499. * @returns an array populated with normal vectors on each Path3D curve point.
  5500. */
  5501. getNormals(): Vector3[];
  5502. /**
  5503. * Returns an array populated with binormal vectors on each Path3D curve point.
  5504. * @returns an array populated with binormal vectors on each Path3D curve point.
  5505. */
  5506. getBinormals(): Vector3[];
  5507. /**
  5508. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5509. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5510. */
  5511. getDistances(): number[];
  5512. /**
  5513. * Returns an interpolated point along this path
  5514. * @param position the position of the point along this path, from 0.0 to 1.0
  5515. * @returns a new Vector3 as the point
  5516. */
  5517. getPointAt(position: number): Vector3;
  5518. /**
  5519. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5520. * @param position the position of the point along this path, from 0.0 to 1.0
  5521. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5522. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5523. */
  5524. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5525. /**
  5526. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5527. * @param position the position of the point along this path, from 0.0 to 1.0
  5528. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5529. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5530. */
  5531. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5532. /**
  5533. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5534. * @param position the position of the point along this path, from 0.0 to 1.0
  5535. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5536. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5537. */
  5538. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5539. /**
  5540. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5541. * @param position the position of the point along this path, from 0.0 to 1.0
  5542. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5543. */
  5544. getDistanceAt(position: number): number;
  5545. /**
  5546. * Returns the array index of the previous point of an interpolated point along this path
  5547. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5548. * @returns the array index
  5549. */
  5550. getPreviousPointIndexAt(position: number): number;
  5551. /**
  5552. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5553. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5554. * @returns the sub position
  5555. */
  5556. getSubPositionAt(position: number): number;
  5557. /**
  5558. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5559. * @param target the vector of which to get the closest position to
  5560. * @returns the position of the closest virtual point on this path to the target vector
  5561. */
  5562. getClosestPositionTo(target: Vector3): number;
  5563. /**
  5564. * Returns a sub path (slice) of this path
  5565. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5566. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5567. * @returns a sub path (slice) of this path
  5568. */
  5569. slice(start?: number, end?: number): Path3D;
  5570. /**
  5571. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5572. * @param path path which all values are copied into the curves points
  5573. * @param firstNormal which should be projected onto the curve
  5574. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5575. * @returns the same object updated.
  5576. */
  5577. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5578. private _compute;
  5579. private _getFirstNonNullVector;
  5580. private _getLastNonNullVector;
  5581. private _normalVector;
  5582. /**
  5583. * Updates the point at data for an interpolated point along this curve
  5584. * @param position the position of the point along this curve, from 0.0 to 1.0
  5585. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5586. * @returns the (updated) point at data
  5587. */
  5588. private _updatePointAtData;
  5589. /**
  5590. * Updates the point at data from the specified parameters
  5591. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5592. * @param point the interpolated point
  5593. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5594. */
  5595. private _setPointAtData;
  5596. /**
  5597. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5598. */
  5599. private _updateInterpolationMatrix;
  5600. }
  5601. /**
  5602. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5603. * A Curve3 is designed from a series of successive Vector3.
  5604. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5605. */
  5606. export class Curve3 {
  5607. private _points;
  5608. private _length;
  5609. /**
  5610. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5611. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5612. * @param v1 (Vector3) the control point
  5613. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5614. * @param nbPoints (integer) the wanted number of points in the curve
  5615. * @returns the created Curve3
  5616. */
  5617. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5618. /**
  5619. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5620. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5621. * @param v1 (Vector3) the first control point
  5622. * @param v2 (Vector3) the second control point
  5623. * @param v3 (Vector3) the end point of the Cubic Bezier
  5624. * @param nbPoints (integer) the wanted number of points in the curve
  5625. * @returns the created Curve3
  5626. */
  5627. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5628. /**
  5629. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5630. * @param p1 (Vector3) the origin point of the Hermite Spline
  5631. * @param t1 (Vector3) the tangent vector at the origin point
  5632. * @param p2 (Vector3) the end point of the Hermite Spline
  5633. * @param t2 (Vector3) the tangent vector at the end point
  5634. * @param nbPoints (integer) the wanted number of points in the curve
  5635. * @returns the created Curve3
  5636. */
  5637. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5638. /**
  5639. * Returns a Curve3 object along a CatmullRom Spline curve :
  5640. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5641. * @param nbPoints (integer) the wanted number of points between each curve control points
  5642. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5643. * @returns the created Curve3
  5644. */
  5645. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5646. /**
  5647. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5648. * A Curve3 is designed from a series of successive Vector3.
  5649. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5650. * @param points points which make up the curve
  5651. */
  5652. constructor(points: Vector3[]);
  5653. /**
  5654. * @returns the Curve3 stored array of successive Vector3
  5655. */
  5656. getPoints(): Vector3[];
  5657. /**
  5658. * @returns the computed length (float) of the curve.
  5659. */
  5660. length(): number;
  5661. /**
  5662. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5663. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5664. * curveA and curveB keep unchanged.
  5665. * @param curve the curve to continue from this curve
  5666. * @returns the newly constructed curve
  5667. */
  5668. continue(curve: DeepImmutable<Curve3>): Curve3;
  5669. private _computeLength;
  5670. }
  5671. }
  5672. declare module "babylonjs/Animations/easing" {
  5673. /**
  5674. * This represents the main contract an easing function should follow.
  5675. * Easing functions are used throughout the animation system.
  5676. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5677. */
  5678. export interface IEasingFunction {
  5679. /**
  5680. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5681. * of the easing function.
  5682. * The link below provides some of the most common examples of easing functions.
  5683. * @see https://easings.net/
  5684. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5685. * @returns the corresponding value on the curve defined by the easing function
  5686. */
  5687. ease(gradient: number): number;
  5688. }
  5689. /**
  5690. * Base class used for every default easing function.
  5691. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5692. */
  5693. export class EasingFunction implements IEasingFunction {
  5694. /**
  5695. * Interpolation follows the mathematical formula associated with the easing function.
  5696. */
  5697. static readonly EASINGMODE_EASEIN: number;
  5698. /**
  5699. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5700. */
  5701. static readonly EASINGMODE_EASEOUT: number;
  5702. /**
  5703. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5704. */
  5705. static readonly EASINGMODE_EASEINOUT: number;
  5706. private _easingMode;
  5707. /**
  5708. * Sets the easing mode of the current function.
  5709. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5710. */
  5711. setEasingMode(easingMode: number): void;
  5712. /**
  5713. * Gets the current easing mode.
  5714. * @returns the easing mode
  5715. */
  5716. getEasingMode(): number;
  5717. /**
  5718. * @hidden
  5719. */
  5720. easeInCore(gradient: number): number;
  5721. /**
  5722. * Given an input gradient between 0 and 1, this returns the corresponding value
  5723. * of the easing function.
  5724. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5725. * @returns the corresponding value on the curve defined by the easing function
  5726. */
  5727. ease(gradient: number): number;
  5728. }
  5729. /**
  5730. * Easing function with a circle shape (see link below).
  5731. * @see https://easings.net/#easeInCirc
  5732. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5733. */
  5734. export class CircleEase extends EasingFunction implements IEasingFunction {
  5735. /** @hidden */
  5736. easeInCore(gradient: number): number;
  5737. }
  5738. /**
  5739. * Easing function with a ease back shape (see link below).
  5740. * @see https://easings.net/#easeInBack
  5741. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5742. */
  5743. export class BackEase extends EasingFunction implements IEasingFunction {
  5744. /** Defines the amplitude of the function */
  5745. amplitude: number;
  5746. /**
  5747. * Instantiates a back ease easing
  5748. * @see https://easings.net/#easeInBack
  5749. * @param amplitude Defines the amplitude of the function
  5750. */
  5751. constructor(
  5752. /** Defines the amplitude of the function */
  5753. amplitude?: number);
  5754. /** @hidden */
  5755. easeInCore(gradient: number): number;
  5756. }
  5757. /**
  5758. * Easing function with a bouncing shape (see link below).
  5759. * @see https://easings.net/#easeInBounce
  5760. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5761. */
  5762. export class BounceEase extends EasingFunction implements IEasingFunction {
  5763. /** Defines the number of bounces */
  5764. bounces: number;
  5765. /** Defines the amplitude of the bounce */
  5766. bounciness: number;
  5767. /**
  5768. * Instantiates a bounce easing
  5769. * @see https://easings.net/#easeInBounce
  5770. * @param bounces Defines the number of bounces
  5771. * @param bounciness Defines the amplitude of the bounce
  5772. */
  5773. constructor(
  5774. /** Defines the number of bounces */
  5775. bounces?: number,
  5776. /** Defines the amplitude of the bounce */
  5777. bounciness?: number);
  5778. /** @hidden */
  5779. easeInCore(gradient: number): number;
  5780. }
  5781. /**
  5782. * Easing function with a power of 3 shape (see link below).
  5783. * @see https://easings.net/#easeInCubic
  5784. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5785. */
  5786. export class CubicEase extends EasingFunction implements IEasingFunction {
  5787. /** @hidden */
  5788. easeInCore(gradient: number): number;
  5789. }
  5790. /**
  5791. * Easing function with an elastic shape (see link below).
  5792. * @see https://easings.net/#easeInElastic
  5793. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5794. */
  5795. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5796. /** Defines the number of oscillations*/
  5797. oscillations: number;
  5798. /** Defines the amplitude of the oscillations*/
  5799. springiness: number;
  5800. /**
  5801. * Instantiates an elastic easing function
  5802. * @see https://easings.net/#easeInElastic
  5803. * @param oscillations Defines the number of oscillations
  5804. * @param springiness Defines the amplitude of the oscillations
  5805. */
  5806. constructor(
  5807. /** Defines the number of oscillations*/
  5808. oscillations?: number,
  5809. /** Defines the amplitude of the oscillations*/
  5810. springiness?: number);
  5811. /** @hidden */
  5812. easeInCore(gradient: number): number;
  5813. }
  5814. /**
  5815. * Easing function with an exponential shape (see link below).
  5816. * @see https://easings.net/#easeInExpo
  5817. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5818. */
  5819. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5820. /** Defines the exponent of the function */
  5821. exponent: number;
  5822. /**
  5823. * Instantiates an exponential easing function
  5824. * @see https://easings.net/#easeInExpo
  5825. * @param exponent Defines the exponent of the function
  5826. */
  5827. constructor(
  5828. /** Defines the exponent of the function */
  5829. exponent?: number);
  5830. /** @hidden */
  5831. easeInCore(gradient: number): number;
  5832. }
  5833. /**
  5834. * Easing function with a power shape (see link below).
  5835. * @see https://easings.net/#easeInQuad
  5836. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5837. */
  5838. export class PowerEase extends EasingFunction implements IEasingFunction {
  5839. /** Defines the power of the function */
  5840. power: number;
  5841. /**
  5842. * Instantiates an power base easing function
  5843. * @see https://easings.net/#easeInQuad
  5844. * @param power Defines the power of the function
  5845. */
  5846. constructor(
  5847. /** Defines the power of the function */
  5848. power?: number);
  5849. /** @hidden */
  5850. easeInCore(gradient: number): number;
  5851. }
  5852. /**
  5853. * Easing function with a power of 2 shape (see link below).
  5854. * @see https://easings.net/#easeInQuad
  5855. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5856. */
  5857. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5858. /** @hidden */
  5859. easeInCore(gradient: number): number;
  5860. }
  5861. /**
  5862. * Easing function with a power of 4 shape (see link below).
  5863. * @see https://easings.net/#easeInQuart
  5864. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5865. */
  5866. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5867. /** @hidden */
  5868. easeInCore(gradient: number): number;
  5869. }
  5870. /**
  5871. * Easing function with a power of 5 shape (see link below).
  5872. * @see https://easings.net/#easeInQuint
  5873. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5874. */
  5875. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5876. /** @hidden */
  5877. easeInCore(gradient: number): number;
  5878. }
  5879. /**
  5880. * Easing function with a sin shape (see link below).
  5881. * @see https://easings.net/#easeInSine
  5882. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5883. */
  5884. export class SineEase extends EasingFunction implements IEasingFunction {
  5885. /** @hidden */
  5886. easeInCore(gradient: number): number;
  5887. }
  5888. /**
  5889. * Easing function with a bezier shape (see link below).
  5890. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5891. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5892. */
  5893. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5894. /** Defines the x component of the start tangent in the bezier curve */
  5895. x1: number;
  5896. /** Defines the y component of the start tangent in the bezier curve */
  5897. y1: number;
  5898. /** Defines the x component of the end tangent in the bezier curve */
  5899. x2: number;
  5900. /** Defines the y component of the end tangent in the bezier curve */
  5901. y2: number;
  5902. /**
  5903. * Instantiates a bezier function
  5904. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5905. * @param x1 Defines the x component of the start tangent in the bezier curve
  5906. * @param y1 Defines the y component of the start tangent in the bezier curve
  5907. * @param x2 Defines the x component of the end tangent in the bezier curve
  5908. * @param y2 Defines the y component of the end tangent in the bezier curve
  5909. */
  5910. constructor(
  5911. /** Defines the x component of the start tangent in the bezier curve */
  5912. x1?: number,
  5913. /** Defines the y component of the start tangent in the bezier curve */
  5914. y1?: number,
  5915. /** Defines the x component of the end tangent in the bezier curve */
  5916. x2?: number,
  5917. /** Defines the y component of the end tangent in the bezier curve */
  5918. y2?: number);
  5919. /** @hidden */
  5920. easeInCore(gradient: number): number;
  5921. }
  5922. }
  5923. declare module "babylonjs/Maths/math.color" {
  5924. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5925. /**
  5926. * Class used to hold a RBG color
  5927. */
  5928. export class Color3 {
  5929. /**
  5930. * Defines the red component (between 0 and 1, default is 0)
  5931. */
  5932. r: number;
  5933. /**
  5934. * Defines the green component (between 0 and 1, default is 0)
  5935. */
  5936. g: number;
  5937. /**
  5938. * Defines the blue component (between 0 and 1, default is 0)
  5939. */
  5940. b: number;
  5941. /**
  5942. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5943. * @param r defines the red component (between 0 and 1, default is 0)
  5944. * @param g defines the green component (between 0 and 1, default is 0)
  5945. * @param b defines the blue component (between 0 and 1, default is 0)
  5946. */
  5947. constructor(
  5948. /**
  5949. * Defines the red component (between 0 and 1, default is 0)
  5950. */
  5951. r?: number,
  5952. /**
  5953. * Defines the green component (between 0 and 1, default is 0)
  5954. */
  5955. g?: number,
  5956. /**
  5957. * Defines the blue component (between 0 and 1, default is 0)
  5958. */
  5959. b?: number);
  5960. /**
  5961. * Creates a string with the Color3 current values
  5962. * @returns the string representation of the Color3 object
  5963. */
  5964. toString(): string;
  5965. /**
  5966. * Returns the string "Color3"
  5967. * @returns "Color3"
  5968. */
  5969. getClassName(): string;
  5970. /**
  5971. * Compute the Color3 hash code
  5972. * @returns an unique number that can be used to hash Color3 objects
  5973. */
  5974. getHashCode(): number;
  5975. /**
  5976. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5977. * @param array defines the array where to store the r,g,b components
  5978. * @param index defines an optional index in the target array to define where to start storing values
  5979. * @returns the current Color3 object
  5980. */
  5981. toArray(array: FloatArray, index?: number): Color3;
  5982. /**
  5983. * Update the current color with values stored in an array from the starting index of the given array
  5984. * @param array defines the source array
  5985. * @param offset defines an offset in the source array
  5986. * @returns the current Color3 object
  5987. */
  5988. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5989. /**
  5990. * Returns a new Color4 object from the current Color3 and the given alpha
  5991. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5992. * @returns a new Color4 object
  5993. */
  5994. toColor4(alpha?: number): Color4;
  5995. /**
  5996. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5997. * @returns the new array
  5998. */
  5999. asArray(): number[];
  6000. /**
  6001. * Returns the luminance value
  6002. * @returns a float value
  6003. */
  6004. toLuminance(): number;
  6005. /**
  6006. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6007. * @param otherColor defines the second operand
  6008. * @returns the new Color3 object
  6009. */
  6010. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6011. /**
  6012. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6013. * @param otherColor defines the second operand
  6014. * @param result defines the Color3 object where to store the result
  6015. * @returns the current Color3
  6016. */
  6017. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6018. /**
  6019. * Determines equality between Color3 objects
  6020. * @param otherColor defines the second operand
  6021. * @returns true if the rgb values are equal to the given ones
  6022. */
  6023. equals(otherColor: DeepImmutable<Color3>): boolean;
  6024. /**
  6025. * Determines equality between the current Color3 object and a set of r,b,g values
  6026. * @param r defines the red component to check
  6027. * @param g defines the green component to check
  6028. * @param b defines the blue component to check
  6029. * @returns true if the rgb values are equal to the given ones
  6030. */
  6031. equalsFloats(r: number, g: number, b: number): boolean;
  6032. /**
  6033. * Multiplies in place each rgb value by scale
  6034. * @param scale defines the scaling factor
  6035. * @returns the updated Color3
  6036. */
  6037. scale(scale: number): Color3;
  6038. /**
  6039. * Multiplies the rgb values by scale and stores the result into "result"
  6040. * @param scale defines the scaling factor
  6041. * @param result defines the Color3 object where to store the result
  6042. * @returns the unmodified current Color3
  6043. */
  6044. scaleToRef(scale: number, result: Color3): Color3;
  6045. /**
  6046. * Scale the current Color3 values by a factor and add the result to a given Color3
  6047. * @param scale defines the scale factor
  6048. * @param result defines color to store the result into
  6049. * @returns the unmodified current Color3
  6050. */
  6051. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6052. /**
  6053. * Clamps the rgb values by the min and max values and stores the result into "result"
  6054. * @param min defines minimum clamping value (default is 0)
  6055. * @param max defines maximum clamping value (default is 1)
  6056. * @param result defines color to store the result into
  6057. * @returns the original Color3
  6058. */
  6059. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6060. /**
  6061. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6062. * @param otherColor defines the second operand
  6063. * @returns the new Color3
  6064. */
  6065. add(otherColor: DeepImmutable<Color3>): Color3;
  6066. /**
  6067. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6068. * @param otherColor defines the second operand
  6069. * @param result defines Color3 object to store the result into
  6070. * @returns the unmodified current Color3
  6071. */
  6072. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6073. /**
  6074. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6075. * @param otherColor defines the second operand
  6076. * @returns the new Color3
  6077. */
  6078. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6079. /**
  6080. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6081. * @param otherColor defines the second operand
  6082. * @param result defines Color3 object to store the result into
  6083. * @returns the unmodified current Color3
  6084. */
  6085. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6086. /**
  6087. * Copy the current object
  6088. * @returns a new Color3 copied the current one
  6089. */
  6090. clone(): Color3;
  6091. /**
  6092. * Copies the rgb values from the source in the current Color3
  6093. * @param source defines the source Color3 object
  6094. * @returns the updated Color3 object
  6095. */
  6096. copyFrom(source: DeepImmutable<Color3>): Color3;
  6097. /**
  6098. * Updates the Color3 rgb values from the given floats
  6099. * @param r defines the red component to read from
  6100. * @param g defines the green component to read from
  6101. * @param b defines the blue component to read from
  6102. * @returns the current Color3 object
  6103. */
  6104. copyFromFloats(r: number, g: number, b: number): Color3;
  6105. /**
  6106. * Updates the Color3 rgb values from the given floats
  6107. * @param r defines the red component to read from
  6108. * @param g defines the green component to read from
  6109. * @param b defines the blue component to read from
  6110. * @returns the current Color3 object
  6111. */
  6112. set(r: number, g: number, b: number): Color3;
  6113. /**
  6114. * Compute the Color3 hexadecimal code as a string
  6115. * @returns a string containing the hexadecimal representation of the Color3 object
  6116. */
  6117. toHexString(): string;
  6118. /**
  6119. * Computes a new Color3 converted from the current one to linear space
  6120. * @returns a new Color3 object
  6121. */
  6122. toLinearSpace(): Color3;
  6123. /**
  6124. * Converts current color in rgb space to HSV values
  6125. * @returns a new color3 representing the HSV values
  6126. */
  6127. toHSV(): Color3;
  6128. /**
  6129. * Converts current color in rgb space to HSV values
  6130. * @param result defines the Color3 where to store the HSV values
  6131. */
  6132. toHSVToRef(result: Color3): void;
  6133. /**
  6134. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6135. * @param convertedColor defines the Color3 object where to store the linear space version
  6136. * @returns the unmodified Color3
  6137. */
  6138. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6139. /**
  6140. * Computes a new Color3 converted from the current one to gamma space
  6141. * @returns a new Color3 object
  6142. */
  6143. toGammaSpace(): Color3;
  6144. /**
  6145. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6146. * @param convertedColor defines the Color3 object where to store the gamma space version
  6147. * @returns the unmodified Color3
  6148. */
  6149. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6150. private static _BlackReadOnly;
  6151. /**
  6152. * Convert Hue, saturation and value to a Color3 (RGB)
  6153. * @param hue defines the hue
  6154. * @param saturation defines the saturation
  6155. * @param value defines the value
  6156. * @param result defines the Color3 where to store the RGB values
  6157. */
  6158. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6159. /**
  6160. * Creates a new Color3 from the string containing valid hexadecimal values
  6161. * @param hex defines a string containing valid hexadecimal values
  6162. * @returns a new Color3 object
  6163. */
  6164. static FromHexString(hex: string): Color3;
  6165. /**
  6166. * Creates a new Color3 from the starting index of the given array
  6167. * @param array defines the source array
  6168. * @param offset defines an offset in the source array
  6169. * @returns a new Color3 object
  6170. */
  6171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6172. /**
  6173. * Creates a new Color3 from the starting index element of the given array
  6174. * @param array defines the source array to read from
  6175. * @param offset defines the offset in the source array
  6176. * @param result defines the target Color3 object
  6177. */
  6178. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6179. /**
  6180. * Creates a new Color3 from integer values (< 256)
  6181. * @param r defines the red component to read from (value between 0 and 255)
  6182. * @param g defines the green component to read from (value between 0 and 255)
  6183. * @param b defines the blue component to read from (value between 0 and 255)
  6184. * @returns a new Color3 object
  6185. */
  6186. static FromInts(r: number, g: number, b: number): Color3;
  6187. /**
  6188. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6189. * @param start defines the start Color3 value
  6190. * @param end defines the end Color3 value
  6191. * @param amount defines the gradient value between start and end
  6192. * @returns a new Color3 object
  6193. */
  6194. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6195. /**
  6196. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6197. * @param left defines the start value
  6198. * @param right defines the end value
  6199. * @param amount defines the gradient factor
  6200. * @param result defines the Color3 object where to store the result
  6201. */
  6202. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6203. /**
  6204. * Returns a Color3 value containing a red color
  6205. * @returns a new Color3 object
  6206. */
  6207. static Red(): Color3;
  6208. /**
  6209. * Returns a Color3 value containing a green color
  6210. * @returns a new Color3 object
  6211. */
  6212. static Green(): Color3;
  6213. /**
  6214. * Returns a Color3 value containing a blue color
  6215. * @returns a new Color3 object
  6216. */
  6217. static Blue(): Color3;
  6218. /**
  6219. * Returns a Color3 value containing a black color
  6220. * @returns a new Color3 object
  6221. */
  6222. static Black(): Color3;
  6223. /**
  6224. * Gets a Color3 value containing a black color that must not be updated
  6225. */
  6226. static get BlackReadOnly(): DeepImmutable<Color3>;
  6227. /**
  6228. * Returns a Color3 value containing a white color
  6229. * @returns a new Color3 object
  6230. */
  6231. static White(): Color3;
  6232. /**
  6233. * Returns a Color3 value containing a purple color
  6234. * @returns a new Color3 object
  6235. */
  6236. static Purple(): Color3;
  6237. /**
  6238. * Returns a Color3 value containing a magenta color
  6239. * @returns a new Color3 object
  6240. */
  6241. static Magenta(): Color3;
  6242. /**
  6243. * Returns a Color3 value containing a yellow color
  6244. * @returns a new Color3 object
  6245. */
  6246. static Yellow(): Color3;
  6247. /**
  6248. * Returns a Color3 value containing a gray color
  6249. * @returns a new Color3 object
  6250. */
  6251. static Gray(): Color3;
  6252. /**
  6253. * Returns a Color3 value containing a teal color
  6254. * @returns a new Color3 object
  6255. */
  6256. static Teal(): Color3;
  6257. /**
  6258. * Returns a Color3 value containing a random color
  6259. * @returns a new Color3 object
  6260. */
  6261. static Random(): Color3;
  6262. }
  6263. /**
  6264. * Class used to hold a RBGA color
  6265. */
  6266. export class Color4 {
  6267. /**
  6268. * Defines the red component (between 0 and 1, default is 0)
  6269. */
  6270. r: number;
  6271. /**
  6272. * Defines the green component (between 0 and 1, default is 0)
  6273. */
  6274. g: number;
  6275. /**
  6276. * Defines the blue component (between 0 and 1, default is 0)
  6277. */
  6278. b: number;
  6279. /**
  6280. * Defines the alpha component (between 0 and 1, default is 1)
  6281. */
  6282. a: number;
  6283. /**
  6284. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6285. * @param r defines the red component (between 0 and 1, default is 0)
  6286. * @param g defines the green component (between 0 and 1, default is 0)
  6287. * @param b defines the blue component (between 0 and 1, default is 0)
  6288. * @param a defines the alpha component (between 0 and 1, default is 1)
  6289. */
  6290. constructor(
  6291. /**
  6292. * Defines the red component (between 0 and 1, default is 0)
  6293. */
  6294. r?: number,
  6295. /**
  6296. * Defines the green component (between 0 and 1, default is 0)
  6297. */
  6298. g?: number,
  6299. /**
  6300. * Defines the blue component (between 0 and 1, default is 0)
  6301. */
  6302. b?: number,
  6303. /**
  6304. * Defines the alpha component (between 0 and 1, default is 1)
  6305. */
  6306. a?: number);
  6307. /**
  6308. * Adds in place the given Color4 values to the current Color4 object
  6309. * @param right defines the second operand
  6310. * @returns the current updated Color4 object
  6311. */
  6312. addInPlace(right: DeepImmutable<Color4>): Color4;
  6313. /**
  6314. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6315. * @returns the new array
  6316. */
  6317. asArray(): number[];
  6318. /**
  6319. * Stores from the starting index in the given array the Color4 successive values
  6320. * @param array defines the array where to store the r,g,b components
  6321. * @param index defines an optional index in the target array to define where to start storing values
  6322. * @returns the current Color4 object
  6323. */
  6324. toArray(array: number[], index?: number): Color4;
  6325. /**
  6326. * Update the current color with values stored in an array from the starting index of the given array
  6327. * @param array defines the source array
  6328. * @param offset defines an offset in the source array
  6329. * @returns the current Color4 object
  6330. */
  6331. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6332. /**
  6333. * Determines equality between Color4 objects
  6334. * @param otherColor defines the second operand
  6335. * @returns true if the rgba values are equal to the given ones
  6336. */
  6337. equals(otherColor: DeepImmutable<Color4>): boolean;
  6338. /**
  6339. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6340. * @param right defines the second operand
  6341. * @returns a new Color4 object
  6342. */
  6343. add(right: DeepImmutable<Color4>): Color4;
  6344. /**
  6345. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6346. * @param right defines the second operand
  6347. * @returns a new Color4 object
  6348. */
  6349. subtract(right: DeepImmutable<Color4>): Color4;
  6350. /**
  6351. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6352. * @param right defines the second operand
  6353. * @param result defines the Color4 object where to store the result
  6354. * @returns the current Color4 object
  6355. */
  6356. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6357. /**
  6358. * Creates a new Color4 with the current Color4 values multiplied by scale
  6359. * @param scale defines the scaling factor to apply
  6360. * @returns a new Color4 object
  6361. */
  6362. scale(scale: number): Color4;
  6363. /**
  6364. * Multiplies the current Color4 values by scale and stores the result in "result"
  6365. * @param scale defines the scaling factor to apply
  6366. * @param result defines the Color4 object where to store the result
  6367. * @returns the current unmodified Color4
  6368. */
  6369. scaleToRef(scale: number, result: Color4): Color4;
  6370. /**
  6371. * Scale the current Color4 values by a factor and add the result to a given Color4
  6372. * @param scale defines the scale factor
  6373. * @param result defines the Color4 object where to store the result
  6374. * @returns the unmodified current Color4
  6375. */
  6376. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6377. /**
  6378. * Clamps the rgb values by the min and max values and stores the result into "result"
  6379. * @param min defines minimum clamping value (default is 0)
  6380. * @param max defines maximum clamping value (default is 1)
  6381. * @param result defines color to store the result into.
  6382. * @returns the cuurent Color4
  6383. */
  6384. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6385. /**
  6386. * Multipy an Color4 value by another and return a new Color4 object
  6387. * @param color defines the Color4 value to multiply by
  6388. * @returns a new Color4 object
  6389. */
  6390. multiply(color: Color4): Color4;
  6391. /**
  6392. * Multipy a Color4 value by another and push the result in a reference value
  6393. * @param color defines the Color4 value to multiply by
  6394. * @param result defines the Color4 to fill the result in
  6395. * @returns the result Color4
  6396. */
  6397. multiplyToRef(color: Color4, result: Color4): Color4;
  6398. /**
  6399. * Creates a string with the Color4 current values
  6400. * @returns the string representation of the Color4 object
  6401. */
  6402. toString(): string;
  6403. /**
  6404. * Returns the string "Color4"
  6405. * @returns "Color4"
  6406. */
  6407. getClassName(): string;
  6408. /**
  6409. * Compute the Color4 hash code
  6410. * @returns an unique number that can be used to hash Color4 objects
  6411. */
  6412. getHashCode(): number;
  6413. /**
  6414. * Creates a new Color4 copied from the current one
  6415. * @returns a new Color4 object
  6416. */
  6417. clone(): Color4;
  6418. /**
  6419. * Copies the given Color4 values into the current one
  6420. * @param source defines the source Color4 object
  6421. * @returns the current updated Color4 object
  6422. */
  6423. copyFrom(source: Color4): Color4;
  6424. /**
  6425. * Copies the given float values into the current one
  6426. * @param r defines the red component to read from
  6427. * @param g defines the green component to read from
  6428. * @param b defines the blue component to read from
  6429. * @param a defines the alpha component to read from
  6430. * @returns the current updated Color4 object
  6431. */
  6432. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6433. /**
  6434. * Copies the given float values into the current one
  6435. * @param r defines the red component to read from
  6436. * @param g defines the green component to read from
  6437. * @param b defines the blue component to read from
  6438. * @param a defines the alpha component to read from
  6439. * @returns the current updated Color4 object
  6440. */
  6441. set(r: number, g: number, b: number, a: number): Color4;
  6442. /**
  6443. * Compute the Color4 hexadecimal code as a string
  6444. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6445. * @returns a string containing the hexadecimal representation of the Color4 object
  6446. */
  6447. toHexString(returnAsColor3?: boolean): string;
  6448. /**
  6449. * Computes a new Color4 converted from the current one to linear space
  6450. * @returns a new Color4 object
  6451. */
  6452. toLinearSpace(): Color4;
  6453. /**
  6454. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6455. * @param convertedColor defines the Color4 object where to store the linear space version
  6456. * @returns the unmodified Color4
  6457. */
  6458. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6459. /**
  6460. * Computes a new Color4 converted from the current one to gamma space
  6461. * @returns a new Color4 object
  6462. */
  6463. toGammaSpace(): Color4;
  6464. /**
  6465. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6466. * @param convertedColor defines the Color4 object where to store the gamma space version
  6467. * @returns the unmodified Color4
  6468. */
  6469. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6470. /**
  6471. * Creates a new Color4 from the string containing valid hexadecimal values
  6472. * @param hex defines a string containing valid hexadecimal values
  6473. * @returns a new Color4 object
  6474. */
  6475. static FromHexString(hex: string): Color4;
  6476. /**
  6477. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6478. * @param left defines the start value
  6479. * @param right defines the end value
  6480. * @param amount defines the gradient factor
  6481. * @returns a new Color4 object
  6482. */
  6483. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6484. /**
  6485. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6486. * @param left defines the start value
  6487. * @param right defines the end value
  6488. * @param amount defines the gradient factor
  6489. * @param result defines the Color4 object where to store data
  6490. */
  6491. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6492. /**
  6493. * Creates a new Color4 from a Color3 and an alpha value
  6494. * @param color3 defines the source Color3 to read from
  6495. * @param alpha defines the alpha component (1.0 by default)
  6496. * @returns a new Color4 object
  6497. */
  6498. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6499. /**
  6500. * Creates a new Color4 from the starting index element of the given array
  6501. * @param array defines the source array to read from
  6502. * @param offset defines the offset in the source array
  6503. * @returns a new Color4 object
  6504. */
  6505. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6506. /**
  6507. * Creates a new Color4 from the starting index element of the given array
  6508. * @param array defines the source array to read from
  6509. * @param offset defines the offset in the source array
  6510. * @param result defines the target Color4 object
  6511. */
  6512. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6513. /**
  6514. * Creates a new Color3 from integer values (< 256)
  6515. * @param r defines the red component to read from (value between 0 and 255)
  6516. * @param g defines the green component to read from (value between 0 and 255)
  6517. * @param b defines the blue component to read from (value between 0 and 255)
  6518. * @param a defines the alpha component to read from (value between 0 and 255)
  6519. * @returns a new Color3 object
  6520. */
  6521. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6522. /**
  6523. * Check the content of a given array and convert it to an array containing RGBA data
  6524. * If the original array was already containing count * 4 values then it is returned directly
  6525. * @param colors defines the array to check
  6526. * @param count defines the number of RGBA data to expect
  6527. * @returns an array containing count * 4 values (RGBA)
  6528. */
  6529. static CheckColors4(colors: number[], count: number): number[];
  6530. }
  6531. /**
  6532. * @hidden
  6533. */
  6534. export class TmpColors {
  6535. static Color3: Color3[];
  6536. static Color4: Color4[];
  6537. }
  6538. }
  6539. declare module "babylonjs/Animations/animationKey" {
  6540. /**
  6541. * Defines an interface which represents an animation key frame
  6542. */
  6543. export interface IAnimationKey {
  6544. /**
  6545. * Frame of the key frame
  6546. */
  6547. frame: number;
  6548. /**
  6549. * Value at the specifies key frame
  6550. */
  6551. value: any;
  6552. /**
  6553. * The input tangent for the cubic hermite spline
  6554. */
  6555. inTangent?: any;
  6556. /**
  6557. * The output tangent for the cubic hermite spline
  6558. */
  6559. outTangent?: any;
  6560. /**
  6561. * The animation interpolation type
  6562. */
  6563. interpolation?: AnimationKeyInterpolation;
  6564. }
  6565. /**
  6566. * Enum for the animation key frame interpolation type
  6567. */
  6568. export enum AnimationKeyInterpolation {
  6569. /**
  6570. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6571. */
  6572. STEP = 1
  6573. }
  6574. }
  6575. declare module "babylonjs/Animations/animationRange" {
  6576. /**
  6577. * Represents the range of an animation
  6578. */
  6579. export class AnimationRange {
  6580. /**The name of the animation range**/
  6581. name: string;
  6582. /**The starting frame of the animation */
  6583. from: number;
  6584. /**The ending frame of the animation*/
  6585. to: number;
  6586. /**
  6587. * Initializes the range of an animation
  6588. * @param name The name of the animation range
  6589. * @param from The starting frame of the animation
  6590. * @param to The ending frame of the animation
  6591. */
  6592. constructor(
  6593. /**The name of the animation range**/
  6594. name: string,
  6595. /**The starting frame of the animation */
  6596. from: number,
  6597. /**The ending frame of the animation*/
  6598. to: number);
  6599. /**
  6600. * Makes a copy of the animation range
  6601. * @returns A copy of the animation range
  6602. */
  6603. clone(): AnimationRange;
  6604. }
  6605. }
  6606. declare module "babylonjs/Animations/animationEvent" {
  6607. /**
  6608. * Composed of a frame, and an action function
  6609. */
  6610. export class AnimationEvent {
  6611. /** The frame for which the event is triggered **/
  6612. frame: number;
  6613. /** The event to perform when triggered **/
  6614. action: (currentFrame: number) => void;
  6615. /** Specifies if the event should be triggered only once**/
  6616. onlyOnce?: boolean | undefined;
  6617. /**
  6618. * Specifies if the animation event is done
  6619. */
  6620. isDone: boolean;
  6621. /**
  6622. * Initializes the animation event
  6623. * @param frame The frame for which the event is triggered
  6624. * @param action The event to perform when triggered
  6625. * @param onlyOnce Specifies if the event should be triggered only once
  6626. */
  6627. constructor(
  6628. /** The frame for which the event is triggered **/
  6629. frame: number,
  6630. /** The event to perform when triggered **/
  6631. action: (currentFrame: number) => void,
  6632. /** Specifies if the event should be triggered only once**/
  6633. onlyOnce?: boolean | undefined);
  6634. /** @hidden */
  6635. _clone(): AnimationEvent;
  6636. }
  6637. }
  6638. declare module "babylonjs/Behaviors/behavior" {
  6639. import { Nullable } from "babylonjs/types";
  6640. /**
  6641. * Interface used to define a behavior
  6642. */
  6643. export interface Behavior<T> {
  6644. /** gets or sets behavior's name */
  6645. name: string;
  6646. /**
  6647. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6648. */
  6649. init(): void;
  6650. /**
  6651. * Called when the behavior is attached to a target
  6652. * @param target defines the target where the behavior is attached to
  6653. */
  6654. attach(target: T): void;
  6655. /**
  6656. * Called when the behavior is detached from its target
  6657. */
  6658. detach(): void;
  6659. }
  6660. /**
  6661. * Interface implemented by classes supporting behaviors
  6662. */
  6663. export interface IBehaviorAware<T> {
  6664. /**
  6665. * Attach a behavior
  6666. * @param behavior defines the behavior to attach
  6667. * @returns the current host
  6668. */
  6669. addBehavior(behavior: Behavior<T>): T;
  6670. /**
  6671. * Remove a behavior from the current object
  6672. * @param behavior defines the behavior to detach
  6673. * @returns the current host
  6674. */
  6675. removeBehavior(behavior: Behavior<T>): T;
  6676. /**
  6677. * Gets a behavior using its name to search
  6678. * @param name defines the name to search
  6679. * @returns the behavior or null if not found
  6680. */
  6681. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6682. }
  6683. }
  6684. declare module "babylonjs/Meshes/buffer" {
  6685. import { Nullable, DataArray } from "babylonjs/types";
  6686. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6687. /**
  6688. * Class used to store data that will be store in GPU memory
  6689. */
  6690. export class Buffer {
  6691. private _engine;
  6692. private _buffer;
  6693. /** @hidden */
  6694. _data: Nullable<DataArray>;
  6695. private _updatable;
  6696. private _instanced;
  6697. private _divisor;
  6698. /**
  6699. * Gets the byte stride.
  6700. */
  6701. readonly byteStride: number;
  6702. /**
  6703. * Constructor
  6704. * @param engine the engine
  6705. * @param data the data to use for this buffer
  6706. * @param updatable whether the data is updatable
  6707. * @param stride the stride (optional)
  6708. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6709. * @param instanced whether the buffer is instanced (optional)
  6710. * @param useBytes set to true if the stride in in bytes (optional)
  6711. * @param divisor sets an optional divisor for instances (1 by default)
  6712. */
  6713. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6714. /**
  6715. * Create a new VertexBuffer based on the current buffer
  6716. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6717. * @param offset defines offset in the buffer (0 by default)
  6718. * @param size defines the size in floats of attributes (position is 3 for instance)
  6719. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6720. * @param instanced defines if the vertex buffer contains indexed data
  6721. * @param useBytes defines if the offset and stride are in bytes *
  6722. * @param divisor sets an optional divisor for instances (1 by default)
  6723. * @returns the new vertex buffer
  6724. */
  6725. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6726. /**
  6727. * Gets a boolean indicating if the Buffer is updatable?
  6728. * @returns true if the buffer is updatable
  6729. */
  6730. isUpdatable(): boolean;
  6731. /**
  6732. * Gets current buffer's data
  6733. * @returns a DataArray or null
  6734. */
  6735. getData(): Nullable<DataArray>;
  6736. /**
  6737. * Gets underlying native buffer
  6738. * @returns underlying native buffer
  6739. */
  6740. getBuffer(): Nullable<DataBuffer>;
  6741. /**
  6742. * Gets the stride in float32 units (i.e. byte stride / 4).
  6743. * May not be an integer if the byte stride is not divisible by 4.
  6744. * @returns the stride in float32 units
  6745. * @deprecated Please use byteStride instead.
  6746. */
  6747. getStrideSize(): number;
  6748. /**
  6749. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6750. * @param data defines the data to store
  6751. */
  6752. create(data?: Nullable<DataArray>): void;
  6753. /** @hidden */
  6754. _rebuild(): void;
  6755. /**
  6756. * Update current buffer data
  6757. * @param data defines the data to store
  6758. */
  6759. update(data: DataArray): void;
  6760. /**
  6761. * Updates the data directly.
  6762. * @param data the new data
  6763. * @param offset the new offset
  6764. * @param vertexCount the vertex count (optional)
  6765. * @param useBytes set to true if the offset is in bytes
  6766. */
  6767. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6768. /**
  6769. * Release all resources
  6770. */
  6771. dispose(): void;
  6772. }
  6773. /**
  6774. * Specialized buffer used to store vertex data
  6775. */
  6776. export class VertexBuffer {
  6777. /** @hidden */
  6778. _buffer: Buffer;
  6779. private _kind;
  6780. private _size;
  6781. private _ownsBuffer;
  6782. private _instanced;
  6783. private _instanceDivisor;
  6784. /**
  6785. * The byte type.
  6786. */
  6787. static readonly BYTE: number;
  6788. /**
  6789. * The unsigned byte type.
  6790. */
  6791. static readonly UNSIGNED_BYTE: number;
  6792. /**
  6793. * The short type.
  6794. */
  6795. static readonly SHORT: number;
  6796. /**
  6797. * The unsigned short type.
  6798. */
  6799. static readonly UNSIGNED_SHORT: number;
  6800. /**
  6801. * The integer type.
  6802. */
  6803. static readonly INT: number;
  6804. /**
  6805. * The unsigned integer type.
  6806. */
  6807. static readonly UNSIGNED_INT: number;
  6808. /**
  6809. * The float type.
  6810. */
  6811. static readonly FLOAT: number;
  6812. /**
  6813. * Gets or sets the instance divisor when in instanced mode
  6814. */
  6815. get instanceDivisor(): number;
  6816. set instanceDivisor(value: number);
  6817. /**
  6818. * Gets the byte stride.
  6819. */
  6820. readonly byteStride: number;
  6821. /**
  6822. * Gets the byte offset.
  6823. */
  6824. readonly byteOffset: number;
  6825. /**
  6826. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6827. */
  6828. readonly normalized: boolean;
  6829. /**
  6830. * Gets the data type of each component in the array.
  6831. */
  6832. readonly type: number;
  6833. /**
  6834. * Constructor
  6835. * @param engine the engine
  6836. * @param data the data to use for this vertex buffer
  6837. * @param kind the vertex buffer kind
  6838. * @param updatable whether the data is updatable
  6839. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6840. * @param stride the stride (optional)
  6841. * @param instanced whether the buffer is instanced (optional)
  6842. * @param offset the offset of the data (optional)
  6843. * @param size the number of components (optional)
  6844. * @param type the type of the component (optional)
  6845. * @param normalized whether the data contains normalized data (optional)
  6846. * @param useBytes set to true if stride and offset are in bytes (optional)
  6847. * @param divisor defines the instance divisor to use (1 by default)
  6848. */
  6849. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6850. /** @hidden */
  6851. _rebuild(): void;
  6852. /**
  6853. * Returns the kind of the VertexBuffer (string)
  6854. * @returns a string
  6855. */
  6856. getKind(): string;
  6857. /**
  6858. * Gets a boolean indicating if the VertexBuffer is updatable?
  6859. * @returns true if the buffer is updatable
  6860. */
  6861. isUpdatable(): boolean;
  6862. /**
  6863. * Gets current buffer's data
  6864. * @returns a DataArray or null
  6865. */
  6866. getData(): Nullable<DataArray>;
  6867. /**
  6868. * Gets underlying native buffer
  6869. * @returns underlying native buffer
  6870. */
  6871. getBuffer(): Nullable<DataBuffer>;
  6872. /**
  6873. * Gets the stride in float32 units (i.e. byte stride / 4).
  6874. * May not be an integer if the byte stride is not divisible by 4.
  6875. * @returns the stride in float32 units
  6876. * @deprecated Please use byteStride instead.
  6877. */
  6878. getStrideSize(): number;
  6879. /**
  6880. * Returns the offset as a multiple of the type byte length.
  6881. * @returns the offset in bytes
  6882. * @deprecated Please use byteOffset instead.
  6883. */
  6884. getOffset(): number;
  6885. /**
  6886. * Returns the number of components per vertex attribute (integer)
  6887. * @returns the size in float
  6888. */
  6889. getSize(): number;
  6890. /**
  6891. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6892. * @returns true if this buffer is instanced
  6893. */
  6894. getIsInstanced(): boolean;
  6895. /**
  6896. * Returns the instancing divisor, zero for non-instanced (integer).
  6897. * @returns a number
  6898. */
  6899. getInstanceDivisor(): number;
  6900. /**
  6901. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6902. * @param data defines the data to store
  6903. */
  6904. create(data?: DataArray): void;
  6905. /**
  6906. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6907. * This function will create a new buffer if the current one is not updatable
  6908. * @param data defines the data to store
  6909. */
  6910. update(data: DataArray): void;
  6911. /**
  6912. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6913. * Returns the directly updated WebGLBuffer.
  6914. * @param data the new data
  6915. * @param offset the new offset
  6916. * @param useBytes set to true if the offset is in bytes
  6917. */
  6918. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6919. /**
  6920. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6921. */
  6922. dispose(): void;
  6923. /**
  6924. * Enumerates each value of this vertex buffer as numbers.
  6925. * @param count the number of values to enumerate
  6926. * @param callback the callback function called for each value
  6927. */
  6928. forEach(count: number, callback: (value: number, index: number) => void): void;
  6929. /**
  6930. * Positions
  6931. */
  6932. static readonly PositionKind: string;
  6933. /**
  6934. * Normals
  6935. */
  6936. static readonly NormalKind: string;
  6937. /**
  6938. * Tangents
  6939. */
  6940. static readonly TangentKind: string;
  6941. /**
  6942. * Texture coordinates
  6943. */
  6944. static readonly UVKind: string;
  6945. /**
  6946. * Texture coordinates 2
  6947. */
  6948. static readonly UV2Kind: string;
  6949. /**
  6950. * Texture coordinates 3
  6951. */
  6952. static readonly UV3Kind: string;
  6953. /**
  6954. * Texture coordinates 4
  6955. */
  6956. static readonly UV4Kind: string;
  6957. /**
  6958. * Texture coordinates 5
  6959. */
  6960. static readonly UV5Kind: string;
  6961. /**
  6962. * Texture coordinates 6
  6963. */
  6964. static readonly UV6Kind: string;
  6965. /**
  6966. * Colors
  6967. */
  6968. static readonly ColorKind: string;
  6969. /**
  6970. * Matrix indices (for bones)
  6971. */
  6972. static readonly MatricesIndicesKind: string;
  6973. /**
  6974. * Matrix weights (for bones)
  6975. */
  6976. static readonly MatricesWeightsKind: string;
  6977. /**
  6978. * Additional matrix indices (for bones)
  6979. */
  6980. static readonly MatricesIndicesExtraKind: string;
  6981. /**
  6982. * Additional matrix weights (for bones)
  6983. */
  6984. static readonly MatricesWeightsExtraKind: string;
  6985. /**
  6986. * Deduces the stride given a kind.
  6987. * @param kind The kind string to deduce
  6988. * @returns The deduced stride
  6989. */
  6990. static DeduceStride(kind: string): number;
  6991. /**
  6992. * Gets the byte length of the given type.
  6993. * @param type the type
  6994. * @returns the number of bytes
  6995. */
  6996. static GetTypeByteLength(type: number): number;
  6997. /**
  6998. * Enumerates each value of the given parameters as numbers.
  6999. * @param data the data to enumerate
  7000. * @param byteOffset the byte offset of the data
  7001. * @param byteStride the byte stride of the data
  7002. * @param componentCount the number of components per element
  7003. * @param componentType the type of the component
  7004. * @param count the number of values to enumerate
  7005. * @param normalized whether the data is normalized
  7006. * @param callback the callback function called for each value
  7007. */
  7008. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7009. private static _GetFloatValue;
  7010. }
  7011. }
  7012. declare module "babylonjs/Collisions/intersectionInfo" {
  7013. import { Nullable } from "babylonjs/types";
  7014. /**
  7015. * @hidden
  7016. */
  7017. export class IntersectionInfo {
  7018. bu: Nullable<number>;
  7019. bv: Nullable<number>;
  7020. distance: number;
  7021. faceId: number;
  7022. subMeshId: number;
  7023. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7024. }
  7025. }
  7026. declare module "babylonjs/Culling/boundingSphere" {
  7027. import { DeepImmutable } from "babylonjs/types";
  7028. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7029. import { Plane } from "babylonjs/Maths/math.plane";
  7030. /**
  7031. * Class used to store bounding sphere information
  7032. */
  7033. export class BoundingSphere {
  7034. /**
  7035. * Gets the center of the bounding sphere in local space
  7036. */
  7037. readonly center: Vector3;
  7038. /**
  7039. * Radius of the bounding sphere in local space
  7040. */
  7041. radius: number;
  7042. /**
  7043. * Gets the center of the bounding sphere in world space
  7044. */
  7045. readonly centerWorld: Vector3;
  7046. /**
  7047. * Radius of the bounding sphere in world space
  7048. */
  7049. radiusWorld: number;
  7050. /**
  7051. * Gets the minimum vector in local space
  7052. */
  7053. readonly minimum: Vector3;
  7054. /**
  7055. * Gets the maximum vector in local space
  7056. */
  7057. readonly maximum: Vector3;
  7058. private _worldMatrix;
  7059. private static readonly TmpVector3;
  7060. /**
  7061. * Creates a new bounding sphere
  7062. * @param min defines the minimum vector (in local space)
  7063. * @param max defines the maximum vector (in local space)
  7064. * @param worldMatrix defines the new world matrix
  7065. */
  7066. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7067. /**
  7068. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7069. * @param min defines the new minimum vector (in local space)
  7070. * @param max defines the new maximum vector (in local space)
  7071. * @param worldMatrix defines the new world matrix
  7072. */
  7073. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7074. /**
  7075. * Scale the current bounding sphere by applying a scale factor
  7076. * @param factor defines the scale factor to apply
  7077. * @returns the current bounding box
  7078. */
  7079. scale(factor: number): BoundingSphere;
  7080. /**
  7081. * Gets the world matrix of the bounding box
  7082. * @returns a matrix
  7083. */
  7084. getWorldMatrix(): DeepImmutable<Matrix>;
  7085. /** @hidden */
  7086. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7087. /**
  7088. * Tests if the bounding sphere is intersecting the frustum planes
  7089. * @param frustumPlanes defines the frustum planes to test
  7090. * @returns true if there is an intersection
  7091. */
  7092. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7093. /**
  7094. * Tests if the bounding sphere center is in between the frustum planes.
  7095. * Used for optimistic fast inclusion.
  7096. * @param frustumPlanes defines the frustum planes to test
  7097. * @returns true if the sphere center is in between the frustum planes
  7098. */
  7099. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7100. /**
  7101. * Tests if a point is inside the bounding sphere
  7102. * @param point defines the point to test
  7103. * @returns true if the point is inside the bounding sphere
  7104. */
  7105. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7106. /**
  7107. * Checks if two sphere intersct
  7108. * @param sphere0 sphere 0
  7109. * @param sphere1 sphere 1
  7110. * @returns true if the speres intersect
  7111. */
  7112. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7113. }
  7114. }
  7115. declare module "babylonjs/Culling/boundingBox" {
  7116. import { DeepImmutable } from "babylonjs/types";
  7117. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7118. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7119. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7120. import { Plane } from "babylonjs/Maths/math.plane";
  7121. /**
  7122. * Class used to store bounding box information
  7123. */
  7124. export class BoundingBox implements ICullable {
  7125. /**
  7126. * Gets the 8 vectors representing the bounding box in local space
  7127. */
  7128. readonly vectors: Vector3[];
  7129. /**
  7130. * Gets the center of the bounding box in local space
  7131. */
  7132. readonly center: Vector3;
  7133. /**
  7134. * Gets the center of the bounding box in world space
  7135. */
  7136. readonly centerWorld: Vector3;
  7137. /**
  7138. * Gets the extend size in local space
  7139. */
  7140. readonly extendSize: Vector3;
  7141. /**
  7142. * Gets the extend size in world space
  7143. */
  7144. readonly extendSizeWorld: Vector3;
  7145. /**
  7146. * Gets the OBB (object bounding box) directions
  7147. */
  7148. readonly directions: Vector3[];
  7149. /**
  7150. * Gets the 8 vectors representing the bounding box in world space
  7151. */
  7152. readonly vectorsWorld: Vector3[];
  7153. /**
  7154. * Gets the minimum vector in world space
  7155. */
  7156. readonly minimumWorld: Vector3;
  7157. /**
  7158. * Gets the maximum vector in world space
  7159. */
  7160. readonly maximumWorld: Vector3;
  7161. /**
  7162. * Gets the minimum vector in local space
  7163. */
  7164. readonly minimum: Vector3;
  7165. /**
  7166. * Gets the maximum vector in local space
  7167. */
  7168. readonly maximum: Vector3;
  7169. private _worldMatrix;
  7170. private static readonly TmpVector3;
  7171. /**
  7172. * @hidden
  7173. */
  7174. _tag: number;
  7175. /**
  7176. * Creates a new bounding box
  7177. * @param min defines the minimum vector (in local space)
  7178. * @param max defines the maximum vector (in local space)
  7179. * @param worldMatrix defines the new world matrix
  7180. */
  7181. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7182. /**
  7183. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7184. * @param min defines the new minimum vector (in local space)
  7185. * @param max defines the new maximum vector (in local space)
  7186. * @param worldMatrix defines the new world matrix
  7187. */
  7188. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7189. /**
  7190. * Scale the current bounding box by applying a scale factor
  7191. * @param factor defines the scale factor to apply
  7192. * @returns the current bounding box
  7193. */
  7194. scale(factor: number): BoundingBox;
  7195. /**
  7196. * Gets the world matrix of the bounding box
  7197. * @returns a matrix
  7198. */
  7199. getWorldMatrix(): DeepImmutable<Matrix>;
  7200. /** @hidden */
  7201. _update(world: DeepImmutable<Matrix>): void;
  7202. /**
  7203. * Tests if the bounding box is intersecting the frustum planes
  7204. * @param frustumPlanes defines the frustum planes to test
  7205. * @returns true if there is an intersection
  7206. */
  7207. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7208. /**
  7209. * Tests if the bounding box is entirely inside the frustum planes
  7210. * @param frustumPlanes defines the frustum planes to test
  7211. * @returns true if there is an inclusion
  7212. */
  7213. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7214. /**
  7215. * Tests if a point is inside the bounding box
  7216. * @param point defines the point to test
  7217. * @returns true if the point is inside the bounding box
  7218. */
  7219. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7220. /**
  7221. * Tests if the bounding box intersects with a bounding sphere
  7222. * @param sphere defines the sphere to test
  7223. * @returns true if there is an intersection
  7224. */
  7225. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7226. /**
  7227. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7228. * @param min defines the min vector to use
  7229. * @param max defines the max vector to use
  7230. * @returns true if there is an intersection
  7231. */
  7232. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7233. /**
  7234. * Tests if two bounding boxes are intersections
  7235. * @param box0 defines the first box to test
  7236. * @param box1 defines the second box to test
  7237. * @returns true if there is an intersection
  7238. */
  7239. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7240. /**
  7241. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7242. * @param minPoint defines the minimum vector of the bounding box
  7243. * @param maxPoint defines the maximum vector of the bounding box
  7244. * @param sphereCenter defines the sphere center
  7245. * @param sphereRadius defines the sphere radius
  7246. * @returns true if there is an intersection
  7247. */
  7248. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7249. /**
  7250. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7251. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7252. * @param frustumPlanes defines the frustum planes to test
  7253. * @return true if there is an inclusion
  7254. */
  7255. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7256. /**
  7257. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7258. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7259. * @param frustumPlanes defines the frustum planes to test
  7260. * @return true if there is an intersection
  7261. */
  7262. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7263. }
  7264. }
  7265. declare module "babylonjs/Collisions/collider" {
  7266. import { Nullable, IndicesArray } from "babylonjs/types";
  7267. import { Vector3 } from "babylonjs/Maths/math.vector";
  7268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7269. import { Plane } from "babylonjs/Maths/math.plane";
  7270. /** @hidden */
  7271. export class Collider {
  7272. /** Define if a collision was found */
  7273. collisionFound: boolean;
  7274. /**
  7275. * Define last intersection point in local space
  7276. */
  7277. intersectionPoint: Vector3;
  7278. /**
  7279. * Define last collided mesh
  7280. */
  7281. collidedMesh: Nullable<AbstractMesh>;
  7282. private _collisionPoint;
  7283. private _planeIntersectionPoint;
  7284. private _tempVector;
  7285. private _tempVector2;
  7286. private _tempVector3;
  7287. private _tempVector4;
  7288. private _edge;
  7289. private _baseToVertex;
  7290. private _destinationPoint;
  7291. private _slidePlaneNormal;
  7292. private _displacementVector;
  7293. /** @hidden */
  7294. _radius: Vector3;
  7295. /** @hidden */
  7296. _retry: number;
  7297. private _velocity;
  7298. private _basePoint;
  7299. private _epsilon;
  7300. /** @hidden */
  7301. _velocityWorldLength: number;
  7302. /** @hidden */
  7303. _basePointWorld: Vector3;
  7304. private _velocityWorld;
  7305. private _normalizedVelocity;
  7306. /** @hidden */
  7307. _initialVelocity: Vector3;
  7308. /** @hidden */
  7309. _initialPosition: Vector3;
  7310. private _nearestDistance;
  7311. private _collisionMask;
  7312. get collisionMask(): number;
  7313. set collisionMask(mask: number);
  7314. /**
  7315. * Gets the plane normal used to compute the sliding response (in local space)
  7316. */
  7317. get slidePlaneNormal(): Vector3;
  7318. /** @hidden */
  7319. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7320. /** @hidden */
  7321. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7322. /** @hidden */
  7323. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7324. /** @hidden */
  7325. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7326. /** @hidden */
  7327. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7328. /** @hidden */
  7329. _getResponse(pos: Vector3, vel: Vector3): void;
  7330. }
  7331. }
  7332. declare module "babylonjs/Culling/boundingInfo" {
  7333. import { DeepImmutable } from "babylonjs/types";
  7334. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7335. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7336. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7337. import { Plane } from "babylonjs/Maths/math.plane";
  7338. import { Collider } from "babylonjs/Collisions/collider";
  7339. /**
  7340. * Interface for cullable objects
  7341. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7342. */
  7343. export interface ICullable {
  7344. /**
  7345. * Checks if the object or part of the object is in the frustum
  7346. * @param frustumPlanes Camera near/planes
  7347. * @returns true if the object is in frustum otherwise false
  7348. */
  7349. isInFrustum(frustumPlanes: Plane[]): boolean;
  7350. /**
  7351. * Checks if a cullable object (mesh...) is in the camera frustum
  7352. * Unlike isInFrustum this cheks the full bounding box
  7353. * @param frustumPlanes Camera near/planes
  7354. * @returns true if the object is in frustum otherwise false
  7355. */
  7356. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7357. }
  7358. /**
  7359. * Info for a bounding data of a mesh
  7360. */
  7361. export class BoundingInfo implements ICullable {
  7362. /**
  7363. * Bounding box for the mesh
  7364. */
  7365. readonly boundingBox: BoundingBox;
  7366. /**
  7367. * Bounding sphere for the mesh
  7368. */
  7369. readonly boundingSphere: BoundingSphere;
  7370. private _isLocked;
  7371. private static readonly TmpVector3;
  7372. /**
  7373. * Constructs bounding info
  7374. * @param minimum min vector of the bounding box/sphere
  7375. * @param maximum max vector of the bounding box/sphere
  7376. * @param worldMatrix defines the new world matrix
  7377. */
  7378. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7379. /**
  7380. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7381. * @param min defines the new minimum vector (in local space)
  7382. * @param max defines the new maximum vector (in local space)
  7383. * @param worldMatrix defines the new world matrix
  7384. */
  7385. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7386. /**
  7387. * min vector of the bounding box/sphere
  7388. */
  7389. get minimum(): Vector3;
  7390. /**
  7391. * max vector of the bounding box/sphere
  7392. */
  7393. get maximum(): Vector3;
  7394. /**
  7395. * If the info is locked and won't be updated to avoid perf overhead
  7396. */
  7397. get isLocked(): boolean;
  7398. set isLocked(value: boolean);
  7399. /**
  7400. * Updates the bounding sphere and box
  7401. * @param world world matrix to be used to update
  7402. */
  7403. update(world: DeepImmutable<Matrix>): void;
  7404. /**
  7405. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7406. * @param center New center of the bounding info
  7407. * @param extend New extend of the bounding info
  7408. * @returns the current bounding info
  7409. */
  7410. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7411. /**
  7412. * Scale the current bounding info by applying a scale factor
  7413. * @param factor defines the scale factor to apply
  7414. * @returns the current bounding info
  7415. */
  7416. scale(factor: number): BoundingInfo;
  7417. /**
  7418. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7419. * @param frustumPlanes defines the frustum to test
  7420. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7421. * @returns true if the bounding info is in the frustum planes
  7422. */
  7423. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7424. /**
  7425. * Gets the world distance between the min and max points of the bounding box
  7426. */
  7427. get diagonalLength(): number;
  7428. /**
  7429. * Checks if a cullable object (mesh...) is in the camera frustum
  7430. * Unlike isInFrustum this cheks the full bounding box
  7431. * @param frustumPlanes Camera near/planes
  7432. * @returns true if the object is in frustum otherwise false
  7433. */
  7434. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7435. /** @hidden */
  7436. _checkCollision(collider: Collider): boolean;
  7437. /**
  7438. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7439. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7440. * @param point the point to check intersection with
  7441. * @returns if the point intersects
  7442. */
  7443. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7444. /**
  7445. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7446. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7447. * @param boundingInfo the bounding info to check intersection with
  7448. * @param precise if the intersection should be done using OBB
  7449. * @returns if the bounding info intersects
  7450. */
  7451. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7452. }
  7453. }
  7454. declare module "babylonjs/Maths/math.functions" {
  7455. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7456. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7457. /**
  7458. * Extracts minimum and maximum values from a list of indexed positions
  7459. * @param positions defines the positions to use
  7460. * @param indices defines the indices to the positions
  7461. * @param indexStart defines the start index
  7462. * @param indexCount defines the end index
  7463. * @param bias defines bias value to add to the result
  7464. * @return minimum and maximum values
  7465. */
  7466. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7467. minimum: Vector3;
  7468. maximum: Vector3;
  7469. };
  7470. /**
  7471. * Extracts minimum and maximum values from a list of positions
  7472. * @param positions defines the positions to use
  7473. * @param start defines the start index in the positions array
  7474. * @param count defines the number of positions to handle
  7475. * @param bias defines bias value to add to the result
  7476. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7477. * @return minimum and maximum values
  7478. */
  7479. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7480. minimum: Vector3;
  7481. maximum: Vector3;
  7482. };
  7483. }
  7484. declare module "babylonjs/Misc/guid" {
  7485. /**
  7486. * Class used to manipulate GUIDs
  7487. */
  7488. export class GUID {
  7489. /**
  7490. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7491. * Be aware Math.random() could cause collisions, but:
  7492. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  7493. * @returns a pseudo random id
  7494. */
  7495. static RandomId(): string;
  7496. }
  7497. }
  7498. declare module "babylonjs/Materials/Textures/baseTexture" {
  7499. import { Observable } from "babylonjs/Misc/observable";
  7500. import { Nullable } from "babylonjs/types";
  7501. import { Scene } from "babylonjs/scene";
  7502. import { Matrix } from "babylonjs/Maths/math.vector";
  7503. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7504. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  7505. import "babylonjs/Misc/fileTools";
  7506. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7507. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  7508. /**
  7509. * Base class of all the textures in babylon.
  7510. * It groups all the common properties the materials, post process, lights... might need
  7511. * in order to make a correct use of the texture.
  7512. */
  7513. export class BaseTexture extends ThinTexture implements IAnimatable {
  7514. /**
  7515. * Default anisotropic filtering level for the application.
  7516. * It is set to 4 as a good tradeoff between perf and quality.
  7517. */
  7518. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7519. /**
  7520. * Gets or sets the unique id of the texture
  7521. */
  7522. uniqueId: number;
  7523. /**
  7524. * Define the name of the texture.
  7525. */
  7526. name: string;
  7527. /**
  7528. * Gets or sets an object used to store user defined information.
  7529. */
  7530. metadata: any;
  7531. /**
  7532. * For internal use only. Please do not use.
  7533. */
  7534. reservedDataStore: any;
  7535. private _hasAlpha;
  7536. /**
  7537. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7538. */
  7539. set hasAlpha(value: boolean);
  7540. get hasAlpha(): boolean;
  7541. /**
  7542. * Defines if the alpha value should be determined via the rgb values.
  7543. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7544. */
  7545. getAlphaFromRGB: boolean;
  7546. /**
  7547. * Intensity or strength of the texture.
  7548. * It is commonly used by materials to fine tune the intensity of the texture
  7549. */
  7550. level: number;
  7551. /**
  7552. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7553. * This is part of the texture as textures usually maps to one uv set.
  7554. */
  7555. coordinatesIndex: number;
  7556. protected _coordinatesMode: number;
  7557. /**
  7558. * How a texture is mapped.
  7559. *
  7560. * | Value | Type | Description |
  7561. * | ----- | ----------------------------------- | ----------- |
  7562. * | 0 | EXPLICIT_MODE | |
  7563. * | 1 | SPHERICAL_MODE | |
  7564. * | 2 | PLANAR_MODE | |
  7565. * | 3 | CUBIC_MODE | |
  7566. * | 4 | PROJECTION_MODE | |
  7567. * | 5 | SKYBOX_MODE | |
  7568. * | 6 | INVCUBIC_MODE | |
  7569. * | 7 | EQUIRECTANGULAR_MODE | |
  7570. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7571. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7572. */
  7573. set coordinatesMode(value: number);
  7574. get coordinatesMode(): number;
  7575. /**
  7576. * | Value | Type | Description |
  7577. * | ----- | ------------------ | ----------- |
  7578. * | 0 | CLAMP_ADDRESSMODE | |
  7579. * | 1 | WRAP_ADDRESSMODE | |
  7580. * | 2 | MIRROR_ADDRESSMODE | |
  7581. */
  7582. get wrapU(): number;
  7583. set wrapU(value: number);
  7584. /**
  7585. * | Value | Type | Description |
  7586. * | ----- | ------------------ | ----------- |
  7587. * | 0 | CLAMP_ADDRESSMODE | |
  7588. * | 1 | WRAP_ADDRESSMODE | |
  7589. * | 2 | MIRROR_ADDRESSMODE | |
  7590. */
  7591. get wrapV(): number;
  7592. set wrapV(value: number);
  7593. /**
  7594. * | Value | Type | Description |
  7595. * | ----- | ------------------ | ----------- |
  7596. * | 0 | CLAMP_ADDRESSMODE | |
  7597. * | 1 | WRAP_ADDRESSMODE | |
  7598. * | 2 | MIRROR_ADDRESSMODE | |
  7599. */
  7600. wrapR: number;
  7601. /**
  7602. * With compliant hardware and browser (supporting anisotropic filtering)
  7603. * this defines the level of anisotropic filtering in the texture.
  7604. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7605. */
  7606. anisotropicFilteringLevel: number;
  7607. private _isCube;
  7608. /**
  7609. * Define if the texture is a cube texture or if false a 2d texture.
  7610. */
  7611. get isCube(): boolean;
  7612. set isCube(value: boolean);
  7613. /**
  7614. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7615. */
  7616. get is3D(): boolean;
  7617. set is3D(value: boolean);
  7618. /**
  7619. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7620. */
  7621. get is2DArray(): boolean;
  7622. set is2DArray(value: boolean);
  7623. private _gammaSpace;
  7624. /**
  7625. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7626. * HDR texture are usually stored in linear space.
  7627. * This only impacts the PBR and Background materials
  7628. */
  7629. get gammaSpace(): boolean;
  7630. set gammaSpace(gamma: boolean);
  7631. /**
  7632. * Gets or sets whether or not the texture contains RGBD data.
  7633. */
  7634. get isRGBD(): boolean;
  7635. set isRGBD(value: boolean);
  7636. /**
  7637. * Is Z inverted in the texture (useful in a cube texture).
  7638. */
  7639. invertZ: boolean;
  7640. /**
  7641. * Are mip maps generated for this texture or not.
  7642. */
  7643. get noMipmap(): boolean;
  7644. /**
  7645. * @hidden
  7646. */
  7647. lodLevelInAlpha: boolean;
  7648. /**
  7649. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7650. */
  7651. get lodGenerationOffset(): number;
  7652. set lodGenerationOffset(value: number);
  7653. /**
  7654. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7655. */
  7656. get lodGenerationScale(): number;
  7657. set lodGenerationScale(value: number);
  7658. /**
  7659. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7660. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7661. * average roughness values.
  7662. */
  7663. get linearSpecularLOD(): boolean;
  7664. set linearSpecularLOD(value: boolean);
  7665. /**
  7666. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7667. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7668. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7669. */
  7670. get irradianceTexture(): Nullable<BaseTexture>;
  7671. set irradianceTexture(value: Nullable<BaseTexture>);
  7672. /**
  7673. * Define if the texture is a render target.
  7674. */
  7675. isRenderTarget: boolean;
  7676. /**
  7677. * Define the unique id of the texture in the scene.
  7678. */
  7679. get uid(): string;
  7680. /** @hidden */
  7681. _prefiltered: boolean;
  7682. /**
  7683. * Return a string representation of the texture.
  7684. * @returns the texture as a string
  7685. */
  7686. toString(): string;
  7687. /**
  7688. * Get the class name of the texture.
  7689. * @returns "BaseTexture"
  7690. */
  7691. getClassName(): string;
  7692. /**
  7693. * Define the list of animation attached to the texture.
  7694. */
  7695. animations: import("babylonjs/Animations/animation").Animation[];
  7696. /**
  7697. * An event triggered when the texture is disposed.
  7698. */
  7699. onDisposeObservable: Observable<BaseTexture>;
  7700. private _onDisposeObserver;
  7701. /**
  7702. * Callback triggered when the texture has been disposed.
  7703. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7704. */
  7705. set onDispose(callback: () => void);
  7706. protected _scene: Nullable<Scene>;
  7707. /** @hidden */
  7708. _texture: Nullable<InternalTexture>;
  7709. private _uid;
  7710. /**
  7711. * Define if the texture is preventinga material to render or not.
  7712. * If not and the texture is not ready, the engine will use a default black texture instead.
  7713. */
  7714. get isBlocking(): boolean;
  7715. /**
  7716. * Instantiates a new BaseTexture.
  7717. * Base class of all the textures in babylon.
  7718. * It groups all the common properties the materials, post process, lights... might need
  7719. * in order to make a correct use of the texture.
  7720. * @param sceneOrEngine Define the scene or engine the texture blongs to
  7721. */
  7722. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  7723. /**
  7724. * Get the scene the texture belongs to.
  7725. * @returns the scene or null if undefined
  7726. */
  7727. getScene(): Nullable<Scene>;
  7728. /** @hidden */
  7729. protected _getEngine(): Nullable<ThinEngine>;
  7730. /**
  7731. * Checks if the texture has the same transform matrix than another texture
  7732. * @param texture texture to check against
  7733. * @returns true if the transforms are the same, else false
  7734. */
  7735. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  7736. /**
  7737. * Get the texture transform matrix used to offset tile the texture for istance.
  7738. * @returns the transformation matrix
  7739. */
  7740. getTextureMatrix(): Matrix;
  7741. /**
  7742. * Get the texture reflection matrix used to rotate/transform the reflection.
  7743. * @returns the reflection matrix
  7744. */
  7745. getReflectionTextureMatrix(): Matrix;
  7746. /**
  7747. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  7748. * @returns true if ready or not blocking
  7749. */
  7750. isReadyOrNotBlocking(): boolean;
  7751. /**
  7752. * Scales the texture if is `canRescale()`
  7753. * @param ratio the resize factor we want to use to rescale
  7754. */
  7755. scale(ratio: number): void;
  7756. /**
  7757. * Get if the texture can rescale.
  7758. */
  7759. get canRescale(): boolean;
  7760. /** @hidden */
  7761. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  7762. /** @hidden */
  7763. _rebuild(): void;
  7764. /**
  7765. * Clones the texture.
  7766. * @returns the cloned texture
  7767. */
  7768. clone(): Nullable<BaseTexture>;
  7769. /**
  7770. * Get the texture underlying type (INT, FLOAT...)
  7771. */
  7772. get textureType(): number;
  7773. /**
  7774. * Get the texture underlying format (RGB, RGBA...)
  7775. */
  7776. get textureFormat(): number;
  7777. /**
  7778. * Indicates that textures need to be re-calculated for all materials
  7779. */
  7780. protected _markAllSubMeshesAsTexturesDirty(): void;
  7781. /**
  7782. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  7783. * This will returns an RGBA array buffer containing either in values (0-255) or
  7784. * float values (0-1) depending of the underlying buffer type.
  7785. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  7786. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  7787. * @param buffer defines a user defined buffer to fill with data (can be null)
  7788. * @returns The Array buffer containing the pixels data.
  7789. */
  7790. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  7791. /** @hidden */
  7792. get _lodTextureHigh(): Nullable<BaseTexture>;
  7793. /** @hidden */
  7794. get _lodTextureMid(): Nullable<BaseTexture>;
  7795. /** @hidden */
  7796. get _lodTextureLow(): Nullable<BaseTexture>;
  7797. /**
  7798. * Dispose the texture and release its associated resources.
  7799. */
  7800. dispose(): void;
  7801. /**
  7802. * Serialize the texture into a JSON representation that can be parsed later on.
  7803. * @returns the JSON representation of the texture
  7804. */
  7805. serialize(): any;
  7806. /**
  7807. * Helper function to be called back once a list of texture contains only ready textures.
  7808. * @param textures Define the list of textures to wait for
  7809. * @param callback Define the callback triggered once the entire list will be ready
  7810. */
  7811. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  7812. private static _isScene;
  7813. }
  7814. }
  7815. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7816. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7817. /** @hidden */
  7818. export class WebGLDataBuffer extends DataBuffer {
  7819. private _buffer;
  7820. constructor(resource: WebGLBuffer);
  7821. get underlyingResource(): any;
  7822. }
  7823. }
  7824. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7825. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7826. import { Nullable } from "babylonjs/types";
  7827. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7828. /** @hidden */
  7829. export class WebGLPipelineContext implements IPipelineContext {
  7830. engine: ThinEngine;
  7831. program: Nullable<WebGLProgram>;
  7832. context?: WebGLRenderingContext;
  7833. vertexShader?: WebGLShader;
  7834. fragmentShader?: WebGLShader;
  7835. isParallelCompiled: boolean;
  7836. onCompiled?: () => void;
  7837. transformFeedback?: WebGLTransformFeedback | null;
  7838. vertexCompilationError: Nullable<string>;
  7839. fragmentCompilationError: Nullable<string>;
  7840. programLinkError: Nullable<string>;
  7841. programValidationError: Nullable<string>;
  7842. get isAsync(): boolean;
  7843. get isReady(): boolean;
  7844. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7845. _getVertexShaderCode(): string | null;
  7846. _getFragmentShaderCode(): string | null;
  7847. }
  7848. }
  7849. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7850. import { FloatArray, Nullable } from "babylonjs/types";
  7851. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7852. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7853. module "babylonjs/Engines/thinEngine" {
  7854. interface ThinEngine {
  7855. /**
  7856. * Create an uniform buffer
  7857. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7858. * @param elements defines the content of the uniform buffer
  7859. * @returns the webGL uniform buffer
  7860. */
  7861. createUniformBuffer(elements: FloatArray): DataBuffer;
  7862. /**
  7863. * Create a dynamic uniform buffer
  7864. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7865. * @param elements defines the content of the uniform buffer
  7866. * @returns the webGL uniform buffer
  7867. */
  7868. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7869. /**
  7870. * Update an existing uniform buffer
  7871. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7872. * @param uniformBuffer defines the target uniform buffer
  7873. * @param elements defines the content to update
  7874. * @param offset defines the offset in the uniform buffer where update should start
  7875. * @param count defines the size of the data to update
  7876. */
  7877. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7878. /**
  7879. * Bind an uniform buffer to the current webGL context
  7880. * @param buffer defines the buffer to bind
  7881. */
  7882. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7883. /**
  7884. * Bind a buffer to the current webGL context at a given location
  7885. * @param buffer defines the buffer to bind
  7886. * @param location defines the index where to bind the buffer
  7887. */
  7888. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7889. /**
  7890. * Bind a specific block at a given index in a specific shader program
  7891. * @param pipelineContext defines the pipeline context to use
  7892. * @param blockName defines the block name
  7893. * @param index defines the index where to bind the block
  7894. */
  7895. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7896. }
  7897. }
  7898. }
  7899. declare module "babylonjs/Materials/uniformBuffer" {
  7900. import { Nullable, FloatArray } from "babylonjs/types";
  7901. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7902. import { Engine } from "babylonjs/Engines/engine";
  7903. import { Effect } from "babylonjs/Materials/effect";
  7904. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7905. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7906. import { Color3 } from "babylonjs/Maths/math.color";
  7907. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7908. /**
  7909. * Uniform buffer objects.
  7910. *
  7911. * Handles blocks of uniform on the GPU.
  7912. *
  7913. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7914. *
  7915. * For more information, please refer to :
  7916. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7917. */
  7918. export class UniformBuffer {
  7919. private _engine;
  7920. private _buffer;
  7921. private _data;
  7922. private _bufferData;
  7923. private _dynamic?;
  7924. private _uniformLocations;
  7925. private _uniformSizes;
  7926. private _uniformLocationPointer;
  7927. private _needSync;
  7928. private _noUBO;
  7929. private _currentEffect;
  7930. /** @hidden */
  7931. _alreadyBound: boolean;
  7932. private static _MAX_UNIFORM_SIZE;
  7933. private static _tempBuffer;
  7934. /**
  7935. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7936. * This is dynamic to allow compat with webgl 1 and 2.
  7937. * You will need to pass the name of the uniform as well as the value.
  7938. */
  7939. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7940. /**
  7941. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7942. * This is dynamic to allow compat with webgl 1 and 2.
  7943. * You will need to pass the name of the uniform as well as the value.
  7944. */
  7945. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7946. /**
  7947. * Lambda to Update a single float in a uniform buffer.
  7948. * This is dynamic to allow compat with webgl 1 and 2.
  7949. * You will need to pass the name of the uniform as well as the value.
  7950. */
  7951. updateFloat: (name: string, x: number) => void;
  7952. /**
  7953. * Lambda to Update a vec2 of float in a uniform buffer.
  7954. * This is dynamic to allow compat with webgl 1 and 2.
  7955. * You will need to pass the name of the uniform as well as the value.
  7956. */
  7957. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7958. /**
  7959. * Lambda to Update a vec3 of float in a uniform buffer.
  7960. * This is dynamic to allow compat with webgl 1 and 2.
  7961. * You will need to pass the name of the uniform as well as the value.
  7962. */
  7963. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7964. /**
  7965. * Lambda to Update a vec4 of float in a uniform buffer.
  7966. * This is dynamic to allow compat with webgl 1 and 2.
  7967. * You will need to pass the name of the uniform as well as the value.
  7968. */
  7969. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7970. /**
  7971. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7972. * This is dynamic to allow compat with webgl 1 and 2.
  7973. * You will need to pass the name of the uniform as well as the value.
  7974. */
  7975. updateMatrix: (name: string, mat: Matrix) => void;
  7976. /**
  7977. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7978. * This is dynamic to allow compat with webgl 1 and 2.
  7979. * You will need to pass the name of the uniform as well as the value.
  7980. */
  7981. updateVector3: (name: string, vector: Vector3) => void;
  7982. /**
  7983. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7984. * This is dynamic to allow compat with webgl 1 and 2.
  7985. * You will need to pass the name of the uniform as well as the value.
  7986. */
  7987. updateVector4: (name: string, vector: Vector4) => void;
  7988. /**
  7989. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7990. * This is dynamic to allow compat with webgl 1 and 2.
  7991. * You will need to pass the name of the uniform as well as the value.
  7992. */
  7993. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7994. /**
  7995. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7996. * This is dynamic to allow compat with webgl 1 and 2.
  7997. * You will need to pass the name of the uniform as well as the value.
  7998. */
  7999. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8000. /**
  8001. * Instantiates a new Uniform buffer objects.
  8002. *
  8003. * Handles blocks of uniform on the GPU.
  8004. *
  8005. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8006. *
  8007. * For more information, please refer to :
  8008. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8009. * @param engine Define the engine the buffer is associated with
  8010. * @param data Define the data contained in the buffer
  8011. * @param dynamic Define if the buffer is updatable
  8012. */
  8013. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  8014. /**
  8015. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8016. * or just falling back on setUniformXXX calls.
  8017. */
  8018. get useUbo(): boolean;
  8019. /**
  8020. * Indicates if the WebGL underlying uniform buffer is in sync
  8021. * with the javascript cache data.
  8022. */
  8023. get isSync(): boolean;
  8024. /**
  8025. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8026. * Also, a dynamic UniformBuffer will disable cache verification and always
  8027. * update the underlying WebGL uniform buffer to the GPU.
  8028. * @returns if Dynamic, otherwise false
  8029. */
  8030. isDynamic(): boolean;
  8031. /**
  8032. * The data cache on JS side.
  8033. * @returns the underlying data as a float array
  8034. */
  8035. getData(): Float32Array;
  8036. /**
  8037. * The underlying WebGL Uniform buffer.
  8038. * @returns the webgl buffer
  8039. */
  8040. getBuffer(): Nullable<DataBuffer>;
  8041. /**
  8042. * std140 layout specifies how to align data within an UBO structure.
  8043. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8044. * for specs.
  8045. */
  8046. private _fillAlignment;
  8047. /**
  8048. * Adds an uniform in the buffer.
  8049. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8050. * for the layout to be correct !
  8051. * @param name Name of the uniform, as used in the uniform block in the shader.
  8052. * @param size Data size, or data directly.
  8053. */
  8054. addUniform(name: string, size: number | number[]): void;
  8055. /**
  8056. * Adds a Matrix 4x4 to the uniform buffer.
  8057. * @param name Name of the uniform, as used in the uniform block in the shader.
  8058. * @param mat A 4x4 matrix.
  8059. */
  8060. addMatrix(name: string, mat: Matrix): void;
  8061. /**
  8062. * Adds a vec2 to the uniform buffer.
  8063. * @param name Name of the uniform, as used in the uniform block in the shader.
  8064. * @param x Define the x component value of the vec2
  8065. * @param y Define the y component value of the vec2
  8066. */
  8067. addFloat2(name: string, x: number, y: number): void;
  8068. /**
  8069. * Adds a vec3 to the uniform buffer.
  8070. * @param name Name of the uniform, as used in the uniform block in the shader.
  8071. * @param x Define the x component value of the vec3
  8072. * @param y Define the y component value of the vec3
  8073. * @param z Define the z component value of the vec3
  8074. */
  8075. addFloat3(name: string, x: number, y: number, z: number): void;
  8076. /**
  8077. * Adds a vec3 to the uniform buffer.
  8078. * @param name Name of the uniform, as used in the uniform block in the shader.
  8079. * @param color Define the vec3 from a Color
  8080. */
  8081. addColor3(name: string, color: Color3): void;
  8082. /**
  8083. * Adds a vec4 to the uniform buffer.
  8084. * @param name Name of the uniform, as used in the uniform block in the shader.
  8085. * @param color Define the rgb components from a Color
  8086. * @param alpha Define the a component of the vec4
  8087. */
  8088. addColor4(name: string, color: Color3, alpha: number): void;
  8089. /**
  8090. * Adds a vec3 to the uniform buffer.
  8091. * @param name Name of the uniform, as used in the uniform block in the shader.
  8092. * @param vector Define the vec3 components from a Vector
  8093. */
  8094. addVector3(name: string, vector: Vector3): void;
  8095. /**
  8096. * Adds a Matrix 3x3 to the uniform buffer.
  8097. * @param name Name of the uniform, as used in the uniform block in the shader.
  8098. */
  8099. addMatrix3x3(name: string): void;
  8100. /**
  8101. * Adds a Matrix 2x2 to the uniform buffer.
  8102. * @param name Name of the uniform, as used in the uniform block in the shader.
  8103. */
  8104. addMatrix2x2(name: string): void;
  8105. /**
  8106. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8107. */
  8108. create(): void;
  8109. /** @hidden */
  8110. _rebuild(): void;
  8111. /**
  8112. * Updates the WebGL Uniform Buffer on the GPU.
  8113. * If the `dynamic` flag is set to true, no cache comparison is done.
  8114. * Otherwise, the buffer will be updated only if the cache differs.
  8115. */
  8116. update(): void;
  8117. /**
  8118. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8119. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8120. * @param data Define the flattened data
  8121. * @param size Define the size of the data.
  8122. */
  8123. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8124. private _valueCache;
  8125. private _cacheMatrix;
  8126. private _updateMatrix3x3ForUniform;
  8127. private _updateMatrix3x3ForEffect;
  8128. private _updateMatrix2x2ForEffect;
  8129. private _updateMatrix2x2ForUniform;
  8130. private _updateFloatForEffect;
  8131. private _updateFloatForUniform;
  8132. private _updateFloat2ForEffect;
  8133. private _updateFloat2ForUniform;
  8134. private _updateFloat3ForEffect;
  8135. private _updateFloat3ForUniform;
  8136. private _updateFloat4ForEffect;
  8137. private _updateFloat4ForUniform;
  8138. private _updateMatrixForEffect;
  8139. private _updateMatrixForUniform;
  8140. private _updateVector3ForEffect;
  8141. private _updateVector3ForUniform;
  8142. private _updateVector4ForEffect;
  8143. private _updateVector4ForUniform;
  8144. private _updateColor3ForEffect;
  8145. private _updateColor3ForUniform;
  8146. private _updateColor4ForEffect;
  8147. private _updateColor4ForUniform;
  8148. /**
  8149. * Sets a sampler uniform on the effect.
  8150. * @param name Define the name of the sampler.
  8151. * @param texture Define the texture to set in the sampler
  8152. */
  8153. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8154. /**
  8155. * Directly updates the value of the uniform in the cache AND on the GPU.
  8156. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8157. * @param data Define the flattened data
  8158. */
  8159. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8160. /**
  8161. * Binds this uniform buffer to an effect.
  8162. * @param effect Define the effect to bind the buffer to
  8163. * @param name Name of the uniform block in the shader.
  8164. */
  8165. bindToEffect(effect: Effect, name: string): void;
  8166. /**
  8167. * Disposes the uniform buffer.
  8168. */
  8169. dispose(): void;
  8170. }
  8171. }
  8172. declare module "babylonjs/Materials/materialDefines" {
  8173. /**
  8174. * Manages the defines for the Material
  8175. */
  8176. export class MaterialDefines {
  8177. /** @hidden */
  8178. protected _keys: string[];
  8179. private _isDirty;
  8180. /** @hidden */
  8181. _renderId: number;
  8182. /** @hidden */
  8183. _areLightsDirty: boolean;
  8184. /** @hidden */
  8185. _areLightsDisposed: boolean;
  8186. /** @hidden */
  8187. _areAttributesDirty: boolean;
  8188. /** @hidden */
  8189. _areTexturesDirty: boolean;
  8190. /** @hidden */
  8191. _areFresnelDirty: boolean;
  8192. /** @hidden */
  8193. _areMiscDirty: boolean;
  8194. /** @hidden */
  8195. _arePrePassDirty: boolean;
  8196. /** @hidden */
  8197. _areImageProcessingDirty: boolean;
  8198. /** @hidden */
  8199. _normals: boolean;
  8200. /** @hidden */
  8201. _uvs: boolean;
  8202. /** @hidden */
  8203. _needNormals: boolean;
  8204. /** @hidden */
  8205. _needUVs: boolean;
  8206. [id: string]: any;
  8207. /**
  8208. * Specifies if the material needs to be re-calculated
  8209. */
  8210. get isDirty(): boolean;
  8211. /**
  8212. * Marks the material to indicate that it has been re-calculated
  8213. */
  8214. markAsProcessed(): void;
  8215. /**
  8216. * Marks the material to indicate that it needs to be re-calculated
  8217. */
  8218. markAsUnprocessed(): void;
  8219. /**
  8220. * Marks the material to indicate all of its defines need to be re-calculated
  8221. */
  8222. markAllAsDirty(): void;
  8223. /**
  8224. * Marks the material to indicate that image processing needs to be re-calculated
  8225. */
  8226. markAsImageProcessingDirty(): void;
  8227. /**
  8228. * Marks the material to indicate the lights need to be re-calculated
  8229. * @param disposed Defines whether the light is dirty due to dispose or not
  8230. */
  8231. markAsLightDirty(disposed?: boolean): void;
  8232. /**
  8233. * Marks the attribute state as changed
  8234. */
  8235. markAsAttributesDirty(): void;
  8236. /**
  8237. * Marks the texture state as changed
  8238. */
  8239. markAsTexturesDirty(): void;
  8240. /**
  8241. * Marks the fresnel state as changed
  8242. */
  8243. markAsFresnelDirty(): void;
  8244. /**
  8245. * Marks the misc state as changed
  8246. */
  8247. markAsMiscDirty(): void;
  8248. /**
  8249. * Marks the prepass state as changed
  8250. */
  8251. markAsPrePassDirty(): void;
  8252. /**
  8253. * Rebuilds the material defines
  8254. */
  8255. rebuild(): void;
  8256. /**
  8257. * Specifies if two material defines are equal
  8258. * @param other - A material define instance to compare to
  8259. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8260. */
  8261. isEqual(other: MaterialDefines): boolean;
  8262. /**
  8263. * Clones this instance's defines to another instance
  8264. * @param other - material defines to clone values to
  8265. */
  8266. cloneTo(other: MaterialDefines): void;
  8267. /**
  8268. * Resets the material define values
  8269. */
  8270. reset(): void;
  8271. /**
  8272. * Converts the material define values to a string
  8273. * @returns - String of material define information
  8274. */
  8275. toString(): string;
  8276. }
  8277. }
  8278. declare module "babylonjs/Misc/iInspectable" {
  8279. /**
  8280. * Enum that determines the text-wrapping mode to use.
  8281. */
  8282. export enum InspectableType {
  8283. /**
  8284. * Checkbox for booleans
  8285. */
  8286. Checkbox = 0,
  8287. /**
  8288. * Sliders for numbers
  8289. */
  8290. Slider = 1,
  8291. /**
  8292. * Vector3
  8293. */
  8294. Vector3 = 2,
  8295. /**
  8296. * Quaternions
  8297. */
  8298. Quaternion = 3,
  8299. /**
  8300. * Color3
  8301. */
  8302. Color3 = 4,
  8303. /**
  8304. * String
  8305. */
  8306. String = 5
  8307. }
  8308. /**
  8309. * Interface used to define custom inspectable properties.
  8310. * This interface is used by the inspector to display custom property grids
  8311. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8312. */
  8313. export interface IInspectable {
  8314. /**
  8315. * Gets the label to display
  8316. */
  8317. label: string;
  8318. /**
  8319. * Gets the name of the property to edit
  8320. */
  8321. propertyName: string;
  8322. /**
  8323. * Gets the type of the editor to use
  8324. */
  8325. type: InspectableType;
  8326. /**
  8327. * Gets the minimum value of the property when using in "slider" mode
  8328. */
  8329. min?: number;
  8330. /**
  8331. * Gets the maximum value of the property when using in "slider" mode
  8332. */
  8333. max?: number;
  8334. /**
  8335. * Gets the setp to use when using in "slider" mode
  8336. */
  8337. step?: number;
  8338. }
  8339. }
  8340. declare module "babylonjs/Lights/light" {
  8341. import { Nullable } from "babylonjs/types";
  8342. import { Scene } from "babylonjs/scene";
  8343. import { Vector3 } from "babylonjs/Maths/math.vector";
  8344. import { Color3 } from "babylonjs/Maths/math.color";
  8345. import { Node } from "babylonjs/node";
  8346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8347. import { Effect } from "babylonjs/Materials/effect";
  8348. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8349. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  8350. /**
  8351. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8352. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8353. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  8354. */
  8355. export abstract class Light extends Node {
  8356. /**
  8357. * Falloff Default: light is falling off following the material specification:
  8358. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8359. */
  8360. static readonly FALLOFF_DEFAULT: number;
  8361. /**
  8362. * Falloff Physical: light is falling off following the inverse squared distance law.
  8363. */
  8364. static readonly FALLOFF_PHYSICAL: number;
  8365. /**
  8366. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8367. * to enhance interoperability with other engines.
  8368. */
  8369. static readonly FALLOFF_GLTF: number;
  8370. /**
  8371. * Falloff Standard: light is falling off like in the standard material
  8372. * to enhance interoperability with other materials.
  8373. */
  8374. static readonly FALLOFF_STANDARD: number;
  8375. /**
  8376. * If every light affecting the material is in this lightmapMode,
  8377. * material.lightmapTexture adds or multiplies
  8378. * (depends on material.useLightmapAsShadowmap)
  8379. * after every other light calculations.
  8380. */
  8381. static readonly LIGHTMAP_DEFAULT: number;
  8382. /**
  8383. * material.lightmapTexture as only diffuse lighting from this light
  8384. * adds only specular lighting from this light
  8385. * adds dynamic shadows
  8386. */
  8387. static readonly LIGHTMAP_SPECULAR: number;
  8388. /**
  8389. * material.lightmapTexture as only lighting
  8390. * no light calculation from this light
  8391. * only adds dynamic shadows from this light
  8392. */
  8393. static readonly LIGHTMAP_SHADOWSONLY: number;
  8394. /**
  8395. * Each light type uses the default quantity according to its type:
  8396. * point/spot lights use luminous intensity
  8397. * directional lights use illuminance
  8398. */
  8399. static readonly INTENSITYMODE_AUTOMATIC: number;
  8400. /**
  8401. * lumen (lm)
  8402. */
  8403. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8404. /**
  8405. * candela (lm/sr)
  8406. */
  8407. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8408. /**
  8409. * lux (lm/m^2)
  8410. */
  8411. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8412. /**
  8413. * nit (cd/m^2)
  8414. */
  8415. static readonly INTENSITYMODE_LUMINANCE: number;
  8416. /**
  8417. * Light type const id of the point light.
  8418. */
  8419. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8420. /**
  8421. * Light type const id of the directional light.
  8422. */
  8423. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8424. /**
  8425. * Light type const id of the spot light.
  8426. */
  8427. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8428. /**
  8429. * Light type const id of the hemispheric light.
  8430. */
  8431. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8432. /**
  8433. * Diffuse gives the basic color to an object.
  8434. */
  8435. diffuse: Color3;
  8436. /**
  8437. * Specular produces a highlight color on an object.
  8438. * Note: This is note affecting PBR materials.
  8439. */
  8440. specular: Color3;
  8441. /**
  8442. * Defines the falloff type for this light. This lets overrriding how punctual light are
  8443. * falling off base on range or angle.
  8444. * This can be set to any values in Light.FALLOFF_x.
  8445. *
  8446. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8447. * other types of materials.
  8448. */
  8449. falloffType: number;
  8450. /**
  8451. * Strength of the light.
  8452. * Note: By default it is define in the framework own unit.
  8453. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8454. */
  8455. intensity: number;
  8456. private _range;
  8457. protected _inverseSquaredRange: number;
  8458. /**
  8459. * Defines how far from the source the light is impacting in scene units.
  8460. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8461. */
  8462. get range(): number;
  8463. /**
  8464. * Defines how far from the source the light is impacting in scene units.
  8465. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8466. */
  8467. set range(value: number);
  8468. /**
  8469. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  8470. * of light.
  8471. */
  8472. private _photometricScale;
  8473. private _intensityMode;
  8474. /**
  8475. * Gets the photometric scale used to interpret the intensity.
  8476. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8477. */
  8478. get intensityMode(): number;
  8479. /**
  8480. * Sets the photometric scale used to interpret the intensity.
  8481. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8482. */
  8483. set intensityMode(value: number);
  8484. private _radius;
  8485. /**
  8486. * Gets the light radius used by PBR Materials to simulate soft area lights.
  8487. */
  8488. get radius(): number;
  8489. /**
  8490. * sets the light radius used by PBR Materials to simulate soft area lights.
  8491. */
  8492. set radius(value: number);
  8493. private _renderPriority;
  8494. /**
  8495. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  8496. * exceeding the number allowed of the materials.
  8497. */
  8498. renderPriority: number;
  8499. private _shadowEnabled;
  8500. /**
  8501. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8502. * the current shadow generator.
  8503. */
  8504. get shadowEnabled(): boolean;
  8505. /**
  8506. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8507. * the current shadow generator.
  8508. */
  8509. set shadowEnabled(value: boolean);
  8510. private _includedOnlyMeshes;
  8511. /**
  8512. * Gets the only meshes impacted by this light.
  8513. */
  8514. get includedOnlyMeshes(): AbstractMesh[];
  8515. /**
  8516. * Sets the only meshes impacted by this light.
  8517. */
  8518. set includedOnlyMeshes(value: AbstractMesh[]);
  8519. private _excludedMeshes;
  8520. /**
  8521. * Gets the meshes not impacted by this light.
  8522. */
  8523. get excludedMeshes(): AbstractMesh[];
  8524. /**
  8525. * Sets the meshes not impacted by this light.
  8526. */
  8527. set excludedMeshes(value: AbstractMesh[]);
  8528. private _excludeWithLayerMask;
  8529. /**
  8530. * Gets the layer id use to find what meshes are not impacted by the light.
  8531. * Inactive if 0
  8532. */
  8533. get excludeWithLayerMask(): number;
  8534. /**
  8535. * Sets the layer id use to find what meshes are not impacted by the light.
  8536. * Inactive if 0
  8537. */
  8538. set excludeWithLayerMask(value: number);
  8539. private _includeOnlyWithLayerMask;
  8540. /**
  8541. * Gets the layer id use to find what meshes are impacted by the light.
  8542. * Inactive if 0
  8543. */
  8544. get includeOnlyWithLayerMask(): number;
  8545. /**
  8546. * Sets the layer id use to find what meshes are impacted by the light.
  8547. * Inactive if 0
  8548. */
  8549. set includeOnlyWithLayerMask(value: number);
  8550. private _lightmapMode;
  8551. /**
  8552. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8553. */
  8554. get lightmapMode(): number;
  8555. /**
  8556. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8557. */
  8558. set lightmapMode(value: number);
  8559. /**
  8560. * Shadow generator associted to the light.
  8561. * @hidden Internal use only.
  8562. */
  8563. _shadowGenerator: Nullable<IShadowGenerator>;
  8564. /**
  8565. * @hidden Internal use only.
  8566. */
  8567. _excludedMeshesIds: string[];
  8568. /**
  8569. * @hidden Internal use only.
  8570. */
  8571. _includedOnlyMeshesIds: string[];
  8572. /**
  8573. * The current light unifom buffer.
  8574. * @hidden Internal use only.
  8575. */
  8576. _uniformBuffer: UniformBuffer;
  8577. /** @hidden */
  8578. _renderId: number;
  8579. /**
  8580. * Creates a Light object in the scene.
  8581. * Documentation : https://doc.babylonjs.com/babylon101/lights
  8582. * @param name The firendly name of the light
  8583. * @param scene The scene the light belongs too
  8584. */
  8585. constructor(name: string, scene: Scene);
  8586. protected abstract _buildUniformLayout(): void;
  8587. /**
  8588. * Sets the passed Effect "effect" with the Light information.
  8589. * @param effect The effect to update
  8590. * @param lightIndex The index of the light in the effect to update
  8591. * @returns The light
  8592. */
  8593. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  8594. /**
  8595. * Sets the passed Effect "effect" with the Light textures.
  8596. * @param effect The effect to update
  8597. * @param lightIndex The index of the light in the effect to update
  8598. * @returns The light
  8599. */
  8600. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  8601. /**
  8602. * Binds the lights information from the scene to the effect for the given mesh.
  8603. * @param lightIndex Light index
  8604. * @param scene The scene where the light belongs to
  8605. * @param effect The effect we are binding the data to
  8606. * @param useSpecular Defines if specular is supported
  8607. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8608. */
  8609. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  8610. /**
  8611. * Sets the passed Effect "effect" with the Light information.
  8612. * @param effect The effect to update
  8613. * @param lightDataUniformName The uniform used to store light data (position or direction)
  8614. * @returns The light
  8615. */
  8616. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  8617. /**
  8618. * Returns the string "Light".
  8619. * @returns the class name
  8620. */
  8621. getClassName(): string;
  8622. /** @hidden */
  8623. readonly _isLight: boolean;
  8624. /**
  8625. * Converts the light information to a readable string for debug purpose.
  8626. * @param fullDetails Supports for multiple levels of logging within scene loading
  8627. * @returns the human readable light info
  8628. */
  8629. toString(fullDetails?: boolean): string;
  8630. /** @hidden */
  8631. protected _syncParentEnabledState(): void;
  8632. /**
  8633. * Set the enabled state of this node.
  8634. * @param value - the new enabled state
  8635. */
  8636. setEnabled(value: boolean): void;
  8637. /**
  8638. * Returns the Light associated shadow generator if any.
  8639. * @return the associated shadow generator.
  8640. */
  8641. getShadowGenerator(): Nullable<IShadowGenerator>;
  8642. /**
  8643. * Returns a Vector3, the absolute light position in the World.
  8644. * @returns the world space position of the light
  8645. */
  8646. getAbsolutePosition(): Vector3;
  8647. /**
  8648. * Specifies if the light will affect the passed mesh.
  8649. * @param mesh The mesh to test against the light
  8650. * @return true the mesh is affected otherwise, false.
  8651. */
  8652. canAffectMesh(mesh: AbstractMesh): boolean;
  8653. /**
  8654. * Sort function to order lights for rendering.
  8655. * @param a First Light object to compare to second.
  8656. * @param b Second Light object to compare first.
  8657. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  8658. */
  8659. static CompareLightsPriority(a: Light, b: Light): number;
  8660. /**
  8661. * Releases resources associated with this node.
  8662. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8663. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8664. */
  8665. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8666. /**
  8667. * Returns the light type ID (integer).
  8668. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  8669. */
  8670. getTypeID(): number;
  8671. /**
  8672. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  8673. * @returns the scaled intensity in intensity mode unit
  8674. */
  8675. getScaledIntensity(): number;
  8676. /**
  8677. * Returns a new Light object, named "name", from the current one.
  8678. * @param name The name of the cloned light
  8679. * @param newParent The parent of this light, if it has one
  8680. * @returns the new created light
  8681. */
  8682. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  8683. /**
  8684. * Serializes the current light into a Serialization object.
  8685. * @returns the serialized object.
  8686. */
  8687. serialize(): any;
  8688. /**
  8689. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  8690. * This new light is named "name" and added to the passed scene.
  8691. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  8692. * @param name The friendly name of the light
  8693. * @param scene The scene the new light will belong to
  8694. * @returns the constructor function
  8695. */
  8696. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  8697. /**
  8698. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  8699. * @param parsedLight The JSON representation of the light
  8700. * @param scene The scene to create the parsed light in
  8701. * @returns the created light after parsing
  8702. */
  8703. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  8704. private _hookArrayForExcluded;
  8705. private _hookArrayForIncludedOnly;
  8706. private _resyncMeshes;
  8707. /**
  8708. * Forces the meshes to update their light related information in their rendering used effects
  8709. * @hidden Internal Use Only
  8710. */
  8711. _markMeshesAsLightDirty(): void;
  8712. /**
  8713. * Recomputes the cached photometric scale if needed.
  8714. */
  8715. private _computePhotometricScale;
  8716. /**
  8717. * Returns the Photometric Scale according to the light type and intensity mode.
  8718. */
  8719. private _getPhotometricScale;
  8720. /**
  8721. * Reorder the light in the scene according to their defined priority.
  8722. * @hidden Internal Use Only
  8723. */
  8724. _reorderLightsInScene(): void;
  8725. /**
  8726. * Prepares the list of defines specific to the light type.
  8727. * @param defines the list of defines
  8728. * @param lightIndex defines the index of the light for the effect
  8729. */
  8730. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  8731. }
  8732. }
  8733. declare module "babylonjs/Maths/math.axis" {
  8734. import { Vector3 } from "babylonjs/Maths/math.vector";
  8735. /** Defines supported spaces */
  8736. export enum Space {
  8737. /** Local (object) space */
  8738. LOCAL = 0,
  8739. /** World space */
  8740. WORLD = 1,
  8741. /** Bone space */
  8742. BONE = 2
  8743. }
  8744. /** Defines the 3 main axes */
  8745. export class Axis {
  8746. /** X axis */
  8747. static X: Vector3;
  8748. /** Y axis */
  8749. static Y: Vector3;
  8750. /** Z axis */
  8751. static Z: Vector3;
  8752. }
  8753. /**
  8754. * Defines cartesian components.
  8755. */
  8756. export enum Coordinate {
  8757. /** X axis */
  8758. X = 0,
  8759. /** Y axis */
  8760. Y = 1,
  8761. /** Z axis */
  8762. Z = 2
  8763. }
  8764. }
  8765. declare module "babylonjs/Lights/shadowLight" {
  8766. import { Camera } from "babylonjs/Cameras/camera";
  8767. import { Scene } from "babylonjs/scene";
  8768. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8770. import { Light } from "babylonjs/Lights/light";
  8771. /**
  8772. * Interface describing all the common properties and methods a shadow light needs to implement.
  8773. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8774. * as well as binding the different shadow properties to the effects.
  8775. */
  8776. export interface IShadowLight extends Light {
  8777. /**
  8778. * The light id in the scene (used in scene.findLighById for instance)
  8779. */
  8780. id: string;
  8781. /**
  8782. * The position the shdow will be casted from.
  8783. */
  8784. position: Vector3;
  8785. /**
  8786. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8787. */
  8788. direction: Vector3;
  8789. /**
  8790. * The transformed position. Position of the light in world space taking parenting in account.
  8791. */
  8792. transformedPosition: Vector3;
  8793. /**
  8794. * The transformed direction. Direction of the light in world space taking parenting in account.
  8795. */
  8796. transformedDirection: Vector3;
  8797. /**
  8798. * The friendly name of the light in the scene.
  8799. */
  8800. name: string;
  8801. /**
  8802. * Defines the shadow projection clipping minimum z value.
  8803. */
  8804. shadowMinZ: number;
  8805. /**
  8806. * Defines the shadow projection clipping maximum z value.
  8807. */
  8808. shadowMaxZ: number;
  8809. /**
  8810. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8811. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8812. */
  8813. computeTransformedInformation(): boolean;
  8814. /**
  8815. * Gets the scene the light belongs to.
  8816. * @returns The scene
  8817. */
  8818. getScene(): Scene;
  8819. /**
  8820. * Callback defining a custom Projection Matrix Builder.
  8821. * This can be used to override the default projection matrix computation.
  8822. */
  8823. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8824. /**
  8825. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8826. * @param matrix The materix to updated with the projection information
  8827. * @param viewMatrix The transform matrix of the light
  8828. * @param renderList The list of mesh to render in the map
  8829. * @returns The current light
  8830. */
  8831. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8832. /**
  8833. * Gets the current depth scale used in ESM.
  8834. * @returns The scale
  8835. */
  8836. getDepthScale(): number;
  8837. /**
  8838. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8839. * @returns true if a cube texture needs to be use
  8840. */
  8841. needCube(): boolean;
  8842. /**
  8843. * Detects if the projection matrix requires to be recomputed this frame.
  8844. * @returns true if it requires to be recomputed otherwise, false.
  8845. */
  8846. needProjectionMatrixCompute(): boolean;
  8847. /**
  8848. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8849. */
  8850. forceProjectionMatrixCompute(): void;
  8851. /**
  8852. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8853. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8854. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8855. */
  8856. getShadowDirection(faceIndex?: number): Vector3;
  8857. /**
  8858. * Gets the minZ used for shadow according to both the scene and the light.
  8859. * @param activeCamera The camera we are returning the min for
  8860. * @returns the depth min z
  8861. */
  8862. getDepthMinZ(activeCamera: Camera): number;
  8863. /**
  8864. * Gets the maxZ used for shadow according to both the scene and the light.
  8865. * @param activeCamera The camera we are returning the max for
  8866. * @returns the depth max z
  8867. */
  8868. getDepthMaxZ(activeCamera: Camera): number;
  8869. }
  8870. /**
  8871. * Base implementation IShadowLight
  8872. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8873. */
  8874. export abstract class ShadowLight extends Light implements IShadowLight {
  8875. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8876. protected _position: Vector3;
  8877. protected _setPosition(value: Vector3): void;
  8878. /**
  8879. * Sets the position the shadow will be casted from. Also use as the light position for both
  8880. * point and spot lights.
  8881. */
  8882. get position(): Vector3;
  8883. /**
  8884. * Sets the position the shadow will be casted from. Also use as the light position for both
  8885. * point and spot lights.
  8886. */
  8887. set position(value: Vector3);
  8888. protected _direction: Vector3;
  8889. protected _setDirection(value: Vector3): void;
  8890. /**
  8891. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8892. * Also use as the light direction on spot and directional lights.
  8893. */
  8894. get direction(): Vector3;
  8895. /**
  8896. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8897. * Also use as the light direction on spot and directional lights.
  8898. */
  8899. set direction(value: Vector3);
  8900. protected _shadowMinZ: number;
  8901. /**
  8902. * Gets the shadow projection clipping minimum z value.
  8903. */
  8904. get shadowMinZ(): number;
  8905. /**
  8906. * Sets the shadow projection clipping minimum z value.
  8907. */
  8908. set shadowMinZ(value: number);
  8909. protected _shadowMaxZ: number;
  8910. /**
  8911. * Sets the shadow projection clipping maximum z value.
  8912. */
  8913. get shadowMaxZ(): number;
  8914. /**
  8915. * Gets the shadow projection clipping maximum z value.
  8916. */
  8917. set shadowMaxZ(value: number);
  8918. /**
  8919. * Callback defining a custom Projection Matrix Builder.
  8920. * This can be used to override the default projection matrix computation.
  8921. */
  8922. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8923. /**
  8924. * The transformed position. Position of the light in world space taking parenting in account.
  8925. */
  8926. transformedPosition: Vector3;
  8927. /**
  8928. * The transformed direction. Direction of the light in world space taking parenting in account.
  8929. */
  8930. transformedDirection: Vector3;
  8931. private _needProjectionMatrixCompute;
  8932. /**
  8933. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8934. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8935. */
  8936. computeTransformedInformation(): boolean;
  8937. /**
  8938. * Return the depth scale used for the shadow map.
  8939. * @returns the depth scale.
  8940. */
  8941. getDepthScale(): number;
  8942. /**
  8943. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8944. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8945. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8946. */
  8947. getShadowDirection(faceIndex?: number): Vector3;
  8948. /**
  8949. * Returns the ShadowLight absolute position in the World.
  8950. * @returns the position vector in world space
  8951. */
  8952. getAbsolutePosition(): Vector3;
  8953. /**
  8954. * Sets the ShadowLight direction toward the passed target.
  8955. * @param target The point to target in local space
  8956. * @returns the updated ShadowLight direction
  8957. */
  8958. setDirectionToTarget(target: Vector3): Vector3;
  8959. /**
  8960. * Returns the light rotation in euler definition.
  8961. * @returns the x y z rotation in local space.
  8962. */
  8963. getRotation(): Vector3;
  8964. /**
  8965. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8966. * @returns true if a cube texture needs to be use
  8967. */
  8968. needCube(): boolean;
  8969. /**
  8970. * Detects if the projection matrix requires to be recomputed this frame.
  8971. * @returns true if it requires to be recomputed otherwise, false.
  8972. */
  8973. needProjectionMatrixCompute(): boolean;
  8974. /**
  8975. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8976. */
  8977. forceProjectionMatrixCompute(): void;
  8978. /** @hidden */
  8979. _initCache(): void;
  8980. /** @hidden */
  8981. _isSynchronized(): boolean;
  8982. /**
  8983. * Computes the world matrix of the node
  8984. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8985. * @returns the world matrix
  8986. */
  8987. computeWorldMatrix(force?: boolean): Matrix;
  8988. /**
  8989. * Gets the minZ used for shadow according to both the scene and the light.
  8990. * @param activeCamera The camera we are returning the min for
  8991. * @returns the depth min z
  8992. */
  8993. getDepthMinZ(activeCamera: Camera): number;
  8994. /**
  8995. * Gets the maxZ used for shadow according to both the scene and the light.
  8996. * @param activeCamera The camera we are returning the max for
  8997. * @returns the depth max z
  8998. */
  8999. getDepthMaxZ(activeCamera: Camera): number;
  9000. /**
  9001. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9002. * @param matrix The materix to updated with the projection information
  9003. * @param viewMatrix The transform matrix of the light
  9004. * @param renderList The list of mesh to render in the map
  9005. * @returns The current light
  9006. */
  9007. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9008. }
  9009. }
  9010. declare module "babylonjs/Materials/prePassConfiguration" {
  9011. import { Matrix } from "babylonjs/Maths/math.vector";
  9012. import { Mesh } from "babylonjs/Meshes/mesh";
  9013. import { Scene } from "babylonjs/scene";
  9014. import { Effect } from "babylonjs/Materials/effect";
  9015. /**
  9016. * Configuration needed for prepass-capable materials
  9017. */
  9018. export class PrePassConfiguration {
  9019. /**
  9020. * Previous world matrices of meshes carrying this material
  9021. * Used for computing velocity
  9022. */
  9023. previousWorldMatrices: {
  9024. [index: number]: Matrix;
  9025. };
  9026. /**
  9027. * Previous view project matrix
  9028. * Used for computing velocity
  9029. */
  9030. previousViewProjection: Matrix;
  9031. /**
  9032. * Previous bones of meshes carrying this material
  9033. * Used for computing velocity
  9034. */
  9035. previousBones: {
  9036. [index: number]: Float32Array;
  9037. };
  9038. /**
  9039. * Add the required uniforms to the current list.
  9040. * @param uniforms defines the current uniform list.
  9041. */
  9042. static AddUniforms(uniforms: string[]): void;
  9043. /**
  9044. * Add the required samplers to the current list.
  9045. * @param samplers defines the current sampler list.
  9046. */
  9047. static AddSamplers(samplers: string[]): void;
  9048. /**
  9049. * Binds the material data.
  9050. * @param effect defines the effect to update
  9051. * @param scene defines the scene the material belongs to.
  9052. * @param mesh The mesh
  9053. * @param world World matrix of this mesh
  9054. * @param isFrozen Is the material frozen
  9055. */
  9056. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9057. }
  9058. }
  9059. declare module "babylonjs/Cameras/targetCamera" {
  9060. import { Nullable } from "babylonjs/types";
  9061. import { Camera } from "babylonjs/Cameras/camera";
  9062. import { Scene } from "babylonjs/scene";
  9063. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9064. /**
  9065. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9066. * This is the base of the follow, arc rotate cameras and Free camera
  9067. * @see https://doc.babylonjs.com/features/cameras
  9068. */
  9069. export class TargetCamera extends Camera {
  9070. private static _RigCamTransformMatrix;
  9071. private static _TargetTransformMatrix;
  9072. private static _TargetFocalPoint;
  9073. private _tmpUpVector;
  9074. private _tmpTargetVector;
  9075. /**
  9076. * Define the current direction the camera is moving to
  9077. */
  9078. cameraDirection: Vector3;
  9079. /**
  9080. * Define the current rotation the camera is rotating to
  9081. */
  9082. cameraRotation: Vector2;
  9083. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9084. ignoreParentScaling: boolean;
  9085. /**
  9086. * When set, the up vector of the camera will be updated by the rotation of the camera
  9087. */
  9088. updateUpVectorFromRotation: boolean;
  9089. private _tmpQuaternion;
  9090. /**
  9091. * Define the current rotation of the camera
  9092. */
  9093. rotation: Vector3;
  9094. /**
  9095. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9096. */
  9097. rotationQuaternion: Quaternion;
  9098. /**
  9099. * Define the current speed of the camera
  9100. */
  9101. speed: number;
  9102. /**
  9103. * Add constraint to the camera to prevent it to move freely in all directions and
  9104. * around all axis.
  9105. */
  9106. noRotationConstraint: boolean;
  9107. /**
  9108. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9109. * panning
  9110. */
  9111. invertRotation: boolean;
  9112. /**
  9113. * Speed multiplier for inverse camera panning
  9114. */
  9115. inverseRotationSpeed: number;
  9116. /**
  9117. * Define the current target of the camera as an object or a position.
  9118. */
  9119. lockedTarget: any;
  9120. /** @hidden */
  9121. _currentTarget: Vector3;
  9122. /** @hidden */
  9123. _initialFocalDistance: number;
  9124. /** @hidden */
  9125. _viewMatrix: Matrix;
  9126. /** @hidden */
  9127. _camMatrix: Matrix;
  9128. /** @hidden */
  9129. _cameraTransformMatrix: Matrix;
  9130. /** @hidden */
  9131. _cameraRotationMatrix: Matrix;
  9132. /** @hidden */
  9133. _referencePoint: Vector3;
  9134. /** @hidden */
  9135. _transformedReferencePoint: Vector3;
  9136. /** @hidden */
  9137. _reset: () => void;
  9138. private _defaultUp;
  9139. /**
  9140. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9141. * This is the base of the follow, arc rotate cameras and Free camera
  9142. * @see https://doc.babylonjs.com/features/cameras
  9143. * @param name Defines the name of the camera in the scene
  9144. * @param position Defines the start position of the camera in the scene
  9145. * @param scene Defines the scene the camera belongs to
  9146. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9147. */
  9148. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9149. /**
  9150. * Gets the position in front of the camera at a given distance.
  9151. * @param distance The distance from the camera we want the position to be
  9152. * @returns the position
  9153. */
  9154. getFrontPosition(distance: number): Vector3;
  9155. /** @hidden */
  9156. _getLockedTargetPosition(): Nullable<Vector3>;
  9157. private _storedPosition;
  9158. private _storedRotation;
  9159. private _storedRotationQuaternion;
  9160. /**
  9161. * Store current camera state of the camera (fov, position, rotation, etc..)
  9162. * @returns the camera
  9163. */
  9164. storeState(): Camera;
  9165. /**
  9166. * Restored camera state. You must call storeState() first
  9167. * @returns whether it was successful or not
  9168. * @hidden
  9169. */
  9170. _restoreStateValues(): boolean;
  9171. /** @hidden */
  9172. _initCache(): void;
  9173. /** @hidden */
  9174. _updateCache(ignoreParentClass?: boolean): void;
  9175. /** @hidden */
  9176. _isSynchronizedViewMatrix(): boolean;
  9177. /** @hidden */
  9178. _computeLocalCameraSpeed(): number;
  9179. /**
  9180. * Defines the target the camera should look at.
  9181. * @param target Defines the new target as a Vector or a mesh
  9182. */
  9183. setTarget(target: Vector3): void;
  9184. /**
  9185. * Defines the target point of the camera.
  9186. * The camera looks towards it form the radius distance.
  9187. */
  9188. get target(): Vector3;
  9189. set target(value: Vector3);
  9190. /**
  9191. * Return the current target position of the camera. This value is expressed in local space.
  9192. * @returns the target position
  9193. */
  9194. getTarget(): Vector3;
  9195. /** @hidden */
  9196. _decideIfNeedsToMove(): boolean;
  9197. /** @hidden */
  9198. _updatePosition(): void;
  9199. /** @hidden */
  9200. _checkInputs(): void;
  9201. protected _updateCameraRotationMatrix(): void;
  9202. /**
  9203. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  9204. * @returns the current camera
  9205. */
  9206. private _rotateUpVectorWithCameraRotationMatrix;
  9207. private _cachedRotationZ;
  9208. private _cachedQuaternionRotationZ;
  9209. /** @hidden */
  9210. _getViewMatrix(): Matrix;
  9211. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9212. /**
  9213. * @hidden
  9214. */
  9215. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9216. /**
  9217. * @hidden
  9218. */
  9219. _updateRigCameras(): void;
  9220. private _getRigCamPositionAndTarget;
  9221. /**
  9222. * Gets the current object class name.
  9223. * @return the class name
  9224. */
  9225. getClassName(): string;
  9226. }
  9227. }
  9228. declare module "babylonjs/Cameras/cameraInputsManager" {
  9229. import { Nullable } from "babylonjs/types";
  9230. import { Camera } from "babylonjs/Cameras/camera";
  9231. /**
  9232. * @ignore
  9233. * This is a list of all the different input types that are available in the application.
  9234. * Fo instance: ArcRotateCameraGamepadInput...
  9235. */
  9236. export var CameraInputTypes: {};
  9237. /**
  9238. * This is the contract to implement in order to create a new input class.
  9239. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9240. */
  9241. export interface ICameraInput<TCamera extends Camera> {
  9242. /**
  9243. * Defines the camera the input is attached to.
  9244. */
  9245. camera: Nullable<TCamera>;
  9246. /**
  9247. * Gets the class name of the current intput.
  9248. * @returns the class name
  9249. */
  9250. getClassName(): string;
  9251. /**
  9252. * Get the friendly name associated with the input class.
  9253. * @returns the input friendly name
  9254. */
  9255. getSimpleName(): string;
  9256. /**
  9257. * Attach the input controls to a specific dom element to get the input from.
  9258. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9259. */
  9260. attachControl(noPreventDefault?: boolean): void;
  9261. /**
  9262. * Detach the current controls from the specified dom element.
  9263. */
  9264. detachControl(): void;
  9265. /**
  9266. * Update the current camera state depending on the inputs that have been used this frame.
  9267. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9268. */
  9269. checkInputs?: () => void;
  9270. }
  9271. /**
  9272. * Represents a map of input types to input instance or input index to input instance.
  9273. */
  9274. export interface CameraInputsMap<TCamera extends Camera> {
  9275. /**
  9276. * Accessor to the input by input type.
  9277. */
  9278. [name: string]: ICameraInput<TCamera>;
  9279. /**
  9280. * Accessor to the input by input index.
  9281. */
  9282. [idx: number]: ICameraInput<TCamera>;
  9283. }
  9284. /**
  9285. * This represents the input manager used within a camera.
  9286. * It helps dealing with all the different kind of input attached to a camera.
  9287. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9288. */
  9289. export class CameraInputsManager<TCamera extends Camera> {
  9290. /**
  9291. * Defines the list of inputs attahed to the camera.
  9292. */
  9293. attached: CameraInputsMap<TCamera>;
  9294. /**
  9295. * Defines the dom element the camera is collecting inputs from.
  9296. * This is null if the controls have not been attached.
  9297. */
  9298. attachedToElement: boolean;
  9299. /**
  9300. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9301. */
  9302. noPreventDefault: boolean;
  9303. /**
  9304. * Defined the camera the input manager belongs to.
  9305. */
  9306. camera: TCamera;
  9307. /**
  9308. * Update the current camera state depending on the inputs that have been used this frame.
  9309. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9310. */
  9311. checkInputs: () => void;
  9312. /**
  9313. * Instantiate a new Camera Input Manager.
  9314. * @param camera Defines the camera the input manager blongs to
  9315. */
  9316. constructor(camera: TCamera);
  9317. /**
  9318. * Add an input method to a camera
  9319. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9320. * @param input camera input method
  9321. */
  9322. add(input: ICameraInput<TCamera>): void;
  9323. /**
  9324. * Remove a specific input method from a camera
  9325. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9326. * @param inputToRemove camera input method
  9327. */
  9328. remove(inputToRemove: ICameraInput<TCamera>): void;
  9329. /**
  9330. * Remove a specific input type from a camera
  9331. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9332. * @param inputType the type of the input to remove
  9333. */
  9334. removeByType(inputType: string): void;
  9335. private _addCheckInputs;
  9336. /**
  9337. * Attach the input controls to the currently attached dom element to listen the events from.
  9338. * @param input Defines the input to attach
  9339. */
  9340. attachInput(input: ICameraInput<TCamera>): void;
  9341. /**
  9342. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9343. * @param element Defines the dom element to collect the events from
  9344. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9345. */
  9346. attachElement(noPreventDefault?: boolean): void;
  9347. /**
  9348. * Detach the current manager inputs controls from a specific dom element.
  9349. * @param element Defines the dom element to collect the events from
  9350. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9351. */
  9352. detachElement(disconnect?: boolean): void;
  9353. /**
  9354. * Rebuild the dynamic inputCheck function from the current list of
  9355. * defined inputs in the manager.
  9356. */
  9357. rebuildInputCheck(): void;
  9358. /**
  9359. * Remove all attached input methods from a camera
  9360. */
  9361. clear(): void;
  9362. /**
  9363. * Serialize the current input manager attached to a camera.
  9364. * This ensures than once parsed,
  9365. * the input associated to the camera will be identical to the current ones
  9366. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9367. */
  9368. serialize(serializedCamera: any): void;
  9369. /**
  9370. * Parses an input manager serialized JSON to restore the previous list of inputs
  9371. * and states associated to a camera.
  9372. * @param parsedCamera Defines the JSON to parse
  9373. */
  9374. parse(parsedCamera: any): void;
  9375. }
  9376. }
  9377. declare module "babylonjs/Events/keyboardEvents" {
  9378. /**
  9379. * Gather the list of keyboard event types as constants.
  9380. */
  9381. export class KeyboardEventTypes {
  9382. /**
  9383. * The keydown event is fired when a key becomes active (pressed).
  9384. */
  9385. static readonly KEYDOWN: number;
  9386. /**
  9387. * The keyup event is fired when a key has been released.
  9388. */
  9389. static readonly KEYUP: number;
  9390. }
  9391. /**
  9392. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9393. */
  9394. export class KeyboardInfo {
  9395. /**
  9396. * Defines the type of event (KeyboardEventTypes)
  9397. */
  9398. type: number;
  9399. /**
  9400. * Defines the related dom event
  9401. */
  9402. event: KeyboardEvent;
  9403. /**
  9404. * Instantiates a new keyboard info.
  9405. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9406. * @param type Defines the type of event (KeyboardEventTypes)
  9407. * @param event Defines the related dom event
  9408. */
  9409. constructor(
  9410. /**
  9411. * Defines the type of event (KeyboardEventTypes)
  9412. */
  9413. type: number,
  9414. /**
  9415. * Defines the related dom event
  9416. */
  9417. event: KeyboardEvent);
  9418. }
  9419. /**
  9420. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9421. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9422. */
  9423. export class KeyboardInfoPre extends KeyboardInfo {
  9424. /**
  9425. * Defines the type of event (KeyboardEventTypes)
  9426. */
  9427. type: number;
  9428. /**
  9429. * Defines the related dom event
  9430. */
  9431. event: KeyboardEvent;
  9432. /**
  9433. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9434. */
  9435. skipOnPointerObservable: boolean;
  9436. /**
  9437. * Instantiates a new keyboard pre info.
  9438. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9439. * @param type Defines the type of event (KeyboardEventTypes)
  9440. * @param event Defines the related dom event
  9441. */
  9442. constructor(
  9443. /**
  9444. * Defines the type of event (KeyboardEventTypes)
  9445. */
  9446. type: number,
  9447. /**
  9448. * Defines the related dom event
  9449. */
  9450. event: KeyboardEvent);
  9451. }
  9452. }
  9453. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9454. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9455. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9456. /**
  9457. * Manage the keyboard inputs to control the movement of a free camera.
  9458. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9459. */
  9460. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9461. /**
  9462. * Defines the camera the input is attached to.
  9463. */
  9464. camera: FreeCamera;
  9465. /**
  9466. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9467. */
  9468. keysUp: number[];
  9469. /**
  9470. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  9471. */
  9472. keysUpward: number[];
  9473. /**
  9474. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9475. */
  9476. keysDown: number[];
  9477. /**
  9478. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  9479. */
  9480. keysDownward: number[];
  9481. /**
  9482. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9483. */
  9484. keysLeft: number[];
  9485. /**
  9486. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9487. */
  9488. keysRight: number[];
  9489. private _keys;
  9490. private _onCanvasBlurObserver;
  9491. private _onKeyboardObserver;
  9492. private _engine;
  9493. private _scene;
  9494. /**
  9495. * Attach the input controls to a specific dom element to get the input from.
  9496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9497. */
  9498. attachControl(noPreventDefault?: boolean): void;
  9499. /**
  9500. * Detach the current controls from the specified dom element.
  9501. */
  9502. detachControl(): void;
  9503. /**
  9504. * Update the current camera state depending on the inputs that have been used this frame.
  9505. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9506. */
  9507. checkInputs(): void;
  9508. /**
  9509. * Gets the class name of the current intput.
  9510. * @returns the class name
  9511. */
  9512. getClassName(): string;
  9513. /** @hidden */
  9514. _onLostFocus(): void;
  9515. /**
  9516. * Get the friendly name associated with the input class.
  9517. * @returns the input friendly name
  9518. */
  9519. getSimpleName(): string;
  9520. }
  9521. }
  9522. declare module "babylonjs/Actions/action" {
  9523. import { Observable } from "babylonjs/Misc/observable";
  9524. import { Condition } from "babylonjs/Actions/condition";
  9525. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9526. import { Nullable } from "babylonjs/types";
  9527. import { Scene } from "babylonjs/scene";
  9528. import { ActionManager } from "babylonjs/Actions/actionManager";
  9529. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9530. import { Node } from "babylonjs/node";
  9531. /**
  9532. * Interface used to define Action
  9533. */
  9534. export interface IAction {
  9535. /**
  9536. * Trigger for the action
  9537. */
  9538. trigger: number;
  9539. /** Options of the trigger */
  9540. triggerOptions: any;
  9541. /**
  9542. * Gets the trigger parameters
  9543. * @returns the trigger parameters
  9544. */
  9545. getTriggerParameter(): any;
  9546. /**
  9547. * Internal only - executes current action event
  9548. * @hidden
  9549. */
  9550. _executeCurrent(evt?: ActionEvent): void;
  9551. /**
  9552. * Serialize placeholder for child classes
  9553. * @param parent of child
  9554. * @returns the serialized object
  9555. */
  9556. serialize(parent: any): any;
  9557. /**
  9558. * Internal only
  9559. * @hidden
  9560. */
  9561. _prepare(): void;
  9562. /**
  9563. * Internal only - manager for action
  9564. * @hidden
  9565. */
  9566. _actionManager: Nullable<AbstractActionManager>;
  9567. /**
  9568. * Adds action to chain of actions, may be a DoNothingAction
  9569. * @param action defines the next action to execute
  9570. * @returns The action passed in
  9571. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9572. */
  9573. then(action: IAction): IAction;
  9574. }
  9575. /**
  9576. * The action to be carried out following a trigger
  9577. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9578. */
  9579. export class Action implements IAction {
  9580. /** the trigger, with or without parameters, for the action */
  9581. triggerOptions: any;
  9582. /**
  9583. * Trigger for the action
  9584. */
  9585. trigger: number;
  9586. /**
  9587. * Internal only - manager for action
  9588. * @hidden
  9589. */
  9590. _actionManager: ActionManager;
  9591. private _nextActiveAction;
  9592. private _child;
  9593. private _condition?;
  9594. private _triggerParameter;
  9595. /**
  9596. * An event triggered prior to action being executed.
  9597. */
  9598. onBeforeExecuteObservable: Observable<Action>;
  9599. /**
  9600. * Creates a new Action
  9601. * @param triggerOptions the trigger, with or without parameters, for the action
  9602. * @param condition an optional determinant of action
  9603. */
  9604. constructor(
  9605. /** the trigger, with or without parameters, for the action */
  9606. triggerOptions: any, condition?: Condition);
  9607. /**
  9608. * Internal only
  9609. * @hidden
  9610. */
  9611. _prepare(): void;
  9612. /**
  9613. * Gets the trigger parameters
  9614. * @returns the trigger parameters
  9615. */
  9616. getTriggerParameter(): any;
  9617. /**
  9618. * Internal only - executes current action event
  9619. * @hidden
  9620. */
  9621. _executeCurrent(evt?: ActionEvent): void;
  9622. /**
  9623. * Execute placeholder for child classes
  9624. * @param evt optional action event
  9625. */
  9626. execute(evt?: ActionEvent): void;
  9627. /**
  9628. * Skips to next active action
  9629. */
  9630. skipToNextActiveAction(): void;
  9631. /**
  9632. * Adds action to chain of actions, may be a DoNothingAction
  9633. * @param action defines the next action to execute
  9634. * @returns The action passed in
  9635. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9636. */
  9637. then(action: Action): Action;
  9638. /**
  9639. * Internal only
  9640. * @hidden
  9641. */
  9642. _getProperty(propertyPath: string): string;
  9643. /**
  9644. * Internal only
  9645. * @hidden
  9646. */
  9647. _getEffectiveTarget(target: any, propertyPath: string): any;
  9648. /**
  9649. * Serialize placeholder for child classes
  9650. * @param parent of child
  9651. * @returns the serialized object
  9652. */
  9653. serialize(parent: any): any;
  9654. /**
  9655. * Internal only called by serialize
  9656. * @hidden
  9657. */
  9658. protected _serialize(serializedAction: any, parent?: any): any;
  9659. /**
  9660. * Internal only
  9661. * @hidden
  9662. */
  9663. static _SerializeValueAsString: (value: any) => string;
  9664. /**
  9665. * Internal only
  9666. * @hidden
  9667. */
  9668. static _GetTargetProperty: (target: Scene | Node) => {
  9669. name: string;
  9670. targetType: string;
  9671. value: string;
  9672. };
  9673. }
  9674. }
  9675. declare module "babylonjs/Actions/condition" {
  9676. import { ActionManager } from "babylonjs/Actions/actionManager";
  9677. /**
  9678. * A Condition applied to an Action
  9679. */
  9680. export class Condition {
  9681. /**
  9682. * Internal only - manager for action
  9683. * @hidden
  9684. */
  9685. _actionManager: ActionManager;
  9686. /**
  9687. * Internal only
  9688. * @hidden
  9689. */
  9690. _evaluationId: number;
  9691. /**
  9692. * Internal only
  9693. * @hidden
  9694. */
  9695. _currentResult: boolean;
  9696. /**
  9697. * Creates a new Condition
  9698. * @param actionManager the manager of the action the condition is applied to
  9699. */
  9700. constructor(actionManager: ActionManager);
  9701. /**
  9702. * Check if the current condition is valid
  9703. * @returns a boolean
  9704. */
  9705. isValid(): boolean;
  9706. /**
  9707. * Internal only
  9708. * @hidden
  9709. */
  9710. _getProperty(propertyPath: string): string;
  9711. /**
  9712. * Internal only
  9713. * @hidden
  9714. */
  9715. _getEffectiveTarget(target: any, propertyPath: string): any;
  9716. /**
  9717. * Serialize placeholder for child classes
  9718. * @returns the serialized object
  9719. */
  9720. serialize(): any;
  9721. /**
  9722. * Internal only
  9723. * @hidden
  9724. */
  9725. protected _serialize(serializedCondition: any): any;
  9726. }
  9727. /**
  9728. * Defines specific conditional operators as extensions of Condition
  9729. */
  9730. export class ValueCondition extends Condition {
  9731. /** path to specify the property of the target the conditional operator uses */
  9732. propertyPath: string;
  9733. /** the value compared by the conditional operator against the current value of the property */
  9734. value: any;
  9735. /** the conditional operator, default ValueCondition.IsEqual */
  9736. operator: number;
  9737. /**
  9738. * Internal only
  9739. * @hidden
  9740. */
  9741. private static _IsEqual;
  9742. /**
  9743. * Internal only
  9744. * @hidden
  9745. */
  9746. private static _IsDifferent;
  9747. /**
  9748. * Internal only
  9749. * @hidden
  9750. */
  9751. private static _IsGreater;
  9752. /**
  9753. * Internal only
  9754. * @hidden
  9755. */
  9756. private static _IsLesser;
  9757. /**
  9758. * returns the number for IsEqual
  9759. */
  9760. static get IsEqual(): number;
  9761. /**
  9762. * Returns the number for IsDifferent
  9763. */
  9764. static get IsDifferent(): number;
  9765. /**
  9766. * Returns the number for IsGreater
  9767. */
  9768. static get IsGreater(): number;
  9769. /**
  9770. * Returns the number for IsLesser
  9771. */
  9772. static get IsLesser(): number;
  9773. /**
  9774. * Internal only The action manager for the condition
  9775. * @hidden
  9776. */
  9777. _actionManager: ActionManager;
  9778. /**
  9779. * Internal only
  9780. * @hidden
  9781. */
  9782. private _target;
  9783. /**
  9784. * Internal only
  9785. * @hidden
  9786. */
  9787. private _effectiveTarget;
  9788. /**
  9789. * Internal only
  9790. * @hidden
  9791. */
  9792. private _property;
  9793. /**
  9794. * Creates a new ValueCondition
  9795. * @param actionManager manager for the action the condition applies to
  9796. * @param target for the action
  9797. * @param propertyPath path to specify the property of the target the conditional operator uses
  9798. * @param value the value compared by the conditional operator against the current value of the property
  9799. * @param operator the conditional operator, default ValueCondition.IsEqual
  9800. */
  9801. constructor(actionManager: ActionManager, target: any,
  9802. /** path to specify the property of the target the conditional operator uses */
  9803. propertyPath: string,
  9804. /** the value compared by the conditional operator against the current value of the property */
  9805. value: any,
  9806. /** the conditional operator, default ValueCondition.IsEqual */
  9807. operator?: number);
  9808. /**
  9809. * Compares the given value with the property value for the specified conditional operator
  9810. * @returns the result of the comparison
  9811. */
  9812. isValid(): boolean;
  9813. /**
  9814. * Serialize the ValueCondition into a JSON compatible object
  9815. * @returns serialization object
  9816. */
  9817. serialize(): any;
  9818. /**
  9819. * Gets the name of the conditional operator for the ValueCondition
  9820. * @param operator the conditional operator
  9821. * @returns the name
  9822. */
  9823. static GetOperatorName(operator: number): string;
  9824. }
  9825. /**
  9826. * Defines a predicate condition as an extension of Condition
  9827. */
  9828. export class PredicateCondition extends Condition {
  9829. /** defines the predicate function used to validate the condition */
  9830. predicate: () => boolean;
  9831. /**
  9832. * Internal only - manager for action
  9833. * @hidden
  9834. */
  9835. _actionManager: ActionManager;
  9836. /**
  9837. * Creates a new PredicateCondition
  9838. * @param actionManager manager for the action the condition applies to
  9839. * @param predicate defines the predicate function used to validate the condition
  9840. */
  9841. constructor(actionManager: ActionManager,
  9842. /** defines the predicate function used to validate the condition */
  9843. predicate: () => boolean);
  9844. /**
  9845. * @returns the validity of the predicate condition
  9846. */
  9847. isValid(): boolean;
  9848. }
  9849. /**
  9850. * Defines a state condition as an extension of Condition
  9851. */
  9852. export class StateCondition extends Condition {
  9853. /** Value to compare with target state */
  9854. value: string;
  9855. /**
  9856. * Internal only - manager for action
  9857. * @hidden
  9858. */
  9859. _actionManager: ActionManager;
  9860. /**
  9861. * Internal only
  9862. * @hidden
  9863. */
  9864. private _target;
  9865. /**
  9866. * Creates a new StateCondition
  9867. * @param actionManager manager for the action the condition applies to
  9868. * @param target of the condition
  9869. * @param value to compare with target state
  9870. */
  9871. constructor(actionManager: ActionManager, target: any,
  9872. /** Value to compare with target state */
  9873. value: string);
  9874. /**
  9875. * Gets a boolean indicating if the current condition is met
  9876. * @returns the validity of the state
  9877. */
  9878. isValid(): boolean;
  9879. /**
  9880. * Serialize the StateCondition into a JSON compatible object
  9881. * @returns serialization object
  9882. */
  9883. serialize(): any;
  9884. }
  9885. }
  9886. declare module "babylonjs/Actions/directActions" {
  9887. import { Action } from "babylonjs/Actions/action";
  9888. import { Condition } from "babylonjs/Actions/condition";
  9889. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9890. /**
  9891. * This defines an action responsible to toggle a boolean once triggered.
  9892. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9893. */
  9894. export class SwitchBooleanAction extends Action {
  9895. /**
  9896. * The path to the boolean property in the target object
  9897. */
  9898. propertyPath: string;
  9899. private _target;
  9900. private _effectiveTarget;
  9901. private _property;
  9902. /**
  9903. * Instantiate the action
  9904. * @param triggerOptions defines the trigger options
  9905. * @param target defines the object containing the boolean
  9906. * @param propertyPath defines the path to the boolean property in the target object
  9907. * @param condition defines the trigger related conditions
  9908. */
  9909. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9910. /** @hidden */
  9911. _prepare(): void;
  9912. /**
  9913. * Execute the action toggle the boolean value.
  9914. */
  9915. execute(): void;
  9916. /**
  9917. * Serializes the actions and its related information.
  9918. * @param parent defines the object to serialize in
  9919. * @returns the serialized object
  9920. */
  9921. serialize(parent: any): any;
  9922. }
  9923. /**
  9924. * This defines an action responsible to set a the state field of the target
  9925. * to a desired value once triggered.
  9926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9927. */
  9928. export class SetStateAction extends Action {
  9929. /**
  9930. * The value to store in the state field.
  9931. */
  9932. value: string;
  9933. private _target;
  9934. /**
  9935. * Instantiate the action
  9936. * @param triggerOptions defines the trigger options
  9937. * @param target defines the object containing the state property
  9938. * @param value defines the value to store in the state field
  9939. * @param condition defines the trigger related conditions
  9940. */
  9941. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9942. /**
  9943. * Execute the action and store the value on the target state property.
  9944. */
  9945. execute(): void;
  9946. /**
  9947. * Serializes the actions and its related information.
  9948. * @param parent defines the object to serialize in
  9949. * @returns the serialized object
  9950. */
  9951. serialize(parent: any): any;
  9952. }
  9953. /**
  9954. * This defines an action responsible to set a property of the target
  9955. * to a desired value once triggered.
  9956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9957. */
  9958. export class SetValueAction extends Action {
  9959. /**
  9960. * The path of the property to set in the target.
  9961. */
  9962. propertyPath: string;
  9963. /**
  9964. * The value to set in the property
  9965. */
  9966. value: any;
  9967. private _target;
  9968. private _effectiveTarget;
  9969. private _property;
  9970. /**
  9971. * Instantiate the action
  9972. * @param triggerOptions defines the trigger options
  9973. * @param target defines the object containing the property
  9974. * @param propertyPath defines the path of the property to set in the target
  9975. * @param value defines the value to set in the property
  9976. * @param condition defines the trigger related conditions
  9977. */
  9978. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9979. /** @hidden */
  9980. _prepare(): void;
  9981. /**
  9982. * Execute the action and set the targetted property to the desired value.
  9983. */
  9984. execute(): void;
  9985. /**
  9986. * Serializes the actions and its related information.
  9987. * @param parent defines the object to serialize in
  9988. * @returns the serialized object
  9989. */
  9990. serialize(parent: any): any;
  9991. }
  9992. /**
  9993. * This defines an action responsible to increment the target value
  9994. * to a desired value once triggered.
  9995. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9996. */
  9997. export class IncrementValueAction extends Action {
  9998. /**
  9999. * The path of the property to increment in the target.
  10000. */
  10001. propertyPath: string;
  10002. /**
  10003. * The value we should increment the property by.
  10004. */
  10005. value: any;
  10006. private _target;
  10007. private _effectiveTarget;
  10008. private _property;
  10009. /**
  10010. * Instantiate the action
  10011. * @param triggerOptions defines the trigger options
  10012. * @param target defines the object containing the property
  10013. * @param propertyPath defines the path of the property to increment in the target
  10014. * @param value defines the value value we should increment the property by
  10015. * @param condition defines the trigger related conditions
  10016. */
  10017. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10018. /** @hidden */
  10019. _prepare(): void;
  10020. /**
  10021. * Execute the action and increment the target of the value amount.
  10022. */
  10023. execute(): void;
  10024. /**
  10025. * Serializes the actions and its related information.
  10026. * @param parent defines the object to serialize in
  10027. * @returns the serialized object
  10028. */
  10029. serialize(parent: any): any;
  10030. }
  10031. /**
  10032. * This defines an action responsible to start an animation once triggered.
  10033. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10034. */
  10035. export class PlayAnimationAction extends Action {
  10036. /**
  10037. * Where the animation should start (animation frame)
  10038. */
  10039. from: number;
  10040. /**
  10041. * Where the animation should stop (animation frame)
  10042. */
  10043. to: number;
  10044. /**
  10045. * Define if the animation should loop or stop after the first play.
  10046. */
  10047. loop?: boolean;
  10048. private _target;
  10049. /**
  10050. * Instantiate the action
  10051. * @param triggerOptions defines the trigger options
  10052. * @param target defines the target animation or animation name
  10053. * @param from defines from where the animation should start (animation frame)
  10054. * @param end defines where the animation should stop (animation frame)
  10055. * @param loop defines if the animation should loop or stop after the first play
  10056. * @param condition defines the trigger related conditions
  10057. */
  10058. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10059. /** @hidden */
  10060. _prepare(): void;
  10061. /**
  10062. * Execute the action and play the animation.
  10063. */
  10064. execute(): void;
  10065. /**
  10066. * Serializes the actions and its related information.
  10067. * @param parent defines the object to serialize in
  10068. * @returns the serialized object
  10069. */
  10070. serialize(parent: any): any;
  10071. }
  10072. /**
  10073. * This defines an action responsible to stop an animation once triggered.
  10074. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10075. */
  10076. export class StopAnimationAction extends Action {
  10077. private _target;
  10078. /**
  10079. * Instantiate the action
  10080. * @param triggerOptions defines the trigger options
  10081. * @param target defines the target animation or animation name
  10082. * @param condition defines the trigger related conditions
  10083. */
  10084. constructor(triggerOptions: any, target: any, condition?: Condition);
  10085. /** @hidden */
  10086. _prepare(): void;
  10087. /**
  10088. * Execute the action and stop the animation.
  10089. */
  10090. execute(): void;
  10091. /**
  10092. * Serializes the actions and its related information.
  10093. * @param parent defines the object to serialize in
  10094. * @returns the serialized object
  10095. */
  10096. serialize(parent: any): any;
  10097. }
  10098. /**
  10099. * This defines an action responsible that does nothing once triggered.
  10100. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10101. */
  10102. export class DoNothingAction extends Action {
  10103. /**
  10104. * Instantiate the action
  10105. * @param triggerOptions defines the trigger options
  10106. * @param condition defines the trigger related conditions
  10107. */
  10108. constructor(triggerOptions?: any, condition?: Condition);
  10109. /**
  10110. * Execute the action and do nothing.
  10111. */
  10112. execute(): void;
  10113. /**
  10114. * Serializes the actions and its related information.
  10115. * @param parent defines the object to serialize in
  10116. * @returns the serialized object
  10117. */
  10118. serialize(parent: any): any;
  10119. }
  10120. /**
  10121. * This defines an action responsible to trigger several actions once triggered.
  10122. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10123. */
  10124. export class CombineAction extends Action {
  10125. /**
  10126. * The list of aggregated animations to run.
  10127. */
  10128. children: Action[];
  10129. /**
  10130. * Instantiate the action
  10131. * @param triggerOptions defines the trigger options
  10132. * @param children defines the list of aggregated animations to run
  10133. * @param condition defines the trigger related conditions
  10134. */
  10135. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10136. /** @hidden */
  10137. _prepare(): void;
  10138. /**
  10139. * Execute the action and executes all the aggregated actions.
  10140. */
  10141. execute(evt: ActionEvent): void;
  10142. /**
  10143. * Serializes the actions and its related information.
  10144. * @param parent defines the object to serialize in
  10145. * @returns the serialized object
  10146. */
  10147. serialize(parent: any): any;
  10148. }
  10149. /**
  10150. * This defines an action responsible to run code (external event) once triggered.
  10151. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10152. */
  10153. export class ExecuteCodeAction extends Action {
  10154. /**
  10155. * The callback function to run.
  10156. */
  10157. func: (evt: ActionEvent) => void;
  10158. /**
  10159. * Instantiate the action
  10160. * @param triggerOptions defines the trigger options
  10161. * @param func defines the callback function to run
  10162. * @param condition defines the trigger related conditions
  10163. */
  10164. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10165. /**
  10166. * Execute the action and run the attached code.
  10167. */
  10168. execute(evt: ActionEvent): void;
  10169. }
  10170. /**
  10171. * This defines an action responsible to set the parent property of the target once triggered.
  10172. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10173. */
  10174. export class SetParentAction extends Action {
  10175. private _parent;
  10176. private _target;
  10177. /**
  10178. * Instantiate the action
  10179. * @param triggerOptions defines the trigger options
  10180. * @param target defines the target containing the parent property
  10181. * @param parent defines from where the animation should start (animation frame)
  10182. * @param condition defines the trigger related conditions
  10183. */
  10184. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10185. /** @hidden */
  10186. _prepare(): void;
  10187. /**
  10188. * Execute the action and set the parent property.
  10189. */
  10190. execute(): void;
  10191. /**
  10192. * Serializes the actions and its related information.
  10193. * @param parent defines the object to serialize in
  10194. * @returns the serialized object
  10195. */
  10196. serialize(parent: any): any;
  10197. }
  10198. }
  10199. declare module "babylonjs/Actions/actionManager" {
  10200. import { Nullable } from "babylonjs/types";
  10201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10202. import { Scene } from "babylonjs/scene";
  10203. import { IAction } from "babylonjs/Actions/action";
  10204. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10205. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10206. /**
  10207. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10208. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10209. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10210. */
  10211. export class ActionManager extends AbstractActionManager {
  10212. /**
  10213. * Nothing
  10214. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10215. */
  10216. static readonly NothingTrigger: number;
  10217. /**
  10218. * On pick
  10219. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10220. */
  10221. static readonly OnPickTrigger: number;
  10222. /**
  10223. * On left pick
  10224. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10225. */
  10226. static readonly OnLeftPickTrigger: number;
  10227. /**
  10228. * On right pick
  10229. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10230. */
  10231. static readonly OnRightPickTrigger: number;
  10232. /**
  10233. * On center pick
  10234. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10235. */
  10236. static readonly OnCenterPickTrigger: number;
  10237. /**
  10238. * On pick down
  10239. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10240. */
  10241. static readonly OnPickDownTrigger: number;
  10242. /**
  10243. * On double pick
  10244. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10245. */
  10246. static readonly OnDoublePickTrigger: number;
  10247. /**
  10248. * On pick up
  10249. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10250. */
  10251. static readonly OnPickUpTrigger: number;
  10252. /**
  10253. * On pick out.
  10254. * This trigger will only be raised if you also declared a OnPickDown
  10255. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10256. */
  10257. static readonly OnPickOutTrigger: number;
  10258. /**
  10259. * On long press
  10260. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10261. */
  10262. static readonly OnLongPressTrigger: number;
  10263. /**
  10264. * On pointer over
  10265. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10266. */
  10267. static readonly OnPointerOverTrigger: number;
  10268. /**
  10269. * On pointer out
  10270. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10271. */
  10272. static readonly OnPointerOutTrigger: number;
  10273. /**
  10274. * On every frame
  10275. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10276. */
  10277. static readonly OnEveryFrameTrigger: number;
  10278. /**
  10279. * On intersection enter
  10280. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10281. */
  10282. static readonly OnIntersectionEnterTrigger: number;
  10283. /**
  10284. * On intersection exit
  10285. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10286. */
  10287. static readonly OnIntersectionExitTrigger: number;
  10288. /**
  10289. * On key down
  10290. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10291. */
  10292. static readonly OnKeyDownTrigger: number;
  10293. /**
  10294. * On key up
  10295. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10296. */
  10297. static readonly OnKeyUpTrigger: number;
  10298. private _scene;
  10299. /**
  10300. * Creates a new action manager
  10301. * @param scene defines the hosting scene
  10302. */
  10303. constructor(scene: Scene);
  10304. /**
  10305. * Releases all associated resources
  10306. */
  10307. dispose(): void;
  10308. /**
  10309. * Gets hosting scene
  10310. * @returns the hosting scene
  10311. */
  10312. getScene(): Scene;
  10313. /**
  10314. * Does this action manager handles actions of any of the given triggers
  10315. * @param triggers defines the triggers to be tested
  10316. * @return a boolean indicating whether one (or more) of the triggers is handled
  10317. */
  10318. hasSpecificTriggers(triggers: number[]): boolean;
  10319. /**
  10320. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10321. * speed.
  10322. * @param triggerA defines the trigger to be tested
  10323. * @param triggerB defines the trigger to be tested
  10324. * @return a boolean indicating whether one (or more) of the triggers is handled
  10325. */
  10326. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10327. /**
  10328. * Does this action manager handles actions of a given trigger
  10329. * @param trigger defines the trigger to be tested
  10330. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10331. * @return whether the trigger is handled
  10332. */
  10333. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10334. /**
  10335. * Does this action manager has pointer triggers
  10336. */
  10337. get hasPointerTriggers(): boolean;
  10338. /**
  10339. * Does this action manager has pick triggers
  10340. */
  10341. get hasPickTriggers(): boolean;
  10342. /**
  10343. * Registers an action to this action manager
  10344. * @param action defines the action to be registered
  10345. * @return the action amended (prepared) after registration
  10346. */
  10347. registerAction(action: IAction): Nullable<IAction>;
  10348. /**
  10349. * Unregisters an action to this action manager
  10350. * @param action defines the action to be unregistered
  10351. * @return a boolean indicating whether the action has been unregistered
  10352. */
  10353. unregisterAction(action: IAction): Boolean;
  10354. /**
  10355. * Process a specific trigger
  10356. * @param trigger defines the trigger to process
  10357. * @param evt defines the event details to be processed
  10358. */
  10359. processTrigger(trigger: number, evt?: IActionEvent): void;
  10360. /** @hidden */
  10361. _getEffectiveTarget(target: any, propertyPath: string): any;
  10362. /** @hidden */
  10363. _getProperty(propertyPath: string): string;
  10364. /**
  10365. * Serialize this manager to a JSON object
  10366. * @param name defines the property name to store this manager
  10367. * @returns a JSON representation of this manager
  10368. */
  10369. serialize(name: string): any;
  10370. /**
  10371. * Creates a new ActionManager from a JSON data
  10372. * @param parsedActions defines the JSON data to read from
  10373. * @param object defines the hosting mesh
  10374. * @param scene defines the hosting scene
  10375. */
  10376. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10377. /**
  10378. * Get a trigger name by index
  10379. * @param trigger defines the trigger index
  10380. * @returns a trigger name
  10381. */
  10382. static GetTriggerName(trigger: number): string;
  10383. }
  10384. }
  10385. declare module "babylonjs/Culling/ray" {
  10386. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10387. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10389. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10390. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10391. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10392. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10393. import { Plane } from "babylonjs/Maths/math.plane";
  10394. /**
  10395. * Class representing a ray with position and direction
  10396. */
  10397. export class Ray {
  10398. /** origin point */
  10399. origin: Vector3;
  10400. /** direction */
  10401. direction: Vector3;
  10402. /** length of the ray */
  10403. length: number;
  10404. private static readonly _TmpVector3;
  10405. private _tmpRay;
  10406. /**
  10407. * Creates a new ray
  10408. * @param origin origin point
  10409. * @param direction direction
  10410. * @param length length of the ray
  10411. */
  10412. constructor(
  10413. /** origin point */
  10414. origin: Vector3,
  10415. /** direction */
  10416. direction: Vector3,
  10417. /** length of the ray */
  10418. length?: number);
  10419. /**
  10420. * Checks if the ray intersects a box
  10421. * This does not account for the ray lenght by design to improve perfs.
  10422. * @param minimum bound of the box
  10423. * @param maximum bound of the box
  10424. * @param intersectionTreshold extra extend to be added to the box in all direction
  10425. * @returns if the box was hit
  10426. */
  10427. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10428. /**
  10429. * Checks if the ray intersects a box
  10430. * This does not account for the ray lenght by design to improve perfs.
  10431. * @param box the bounding box to check
  10432. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10433. * @returns if the box was hit
  10434. */
  10435. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10436. /**
  10437. * If the ray hits a sphere
  10438. * @param sphere the bounding sphere to check
  10439. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10440. * @returns true if it hits the sphere
  10441. */
  10442. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10443. /**
  10444. * If the ray hits a triange
  10445. * @param vertex0 triangle vertex
  10446. * @param vertex1 triangle vertex
  10447. * @param vertex2 triangle vertex
  10448. * @returns intersection information if hit
  10449. */
  10450. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10451. /**
  10452. * Checks if ray intersects a plane
  10453. * @param plane the plane to check
  10454. * @returns the distance away it was hit
  10455. */
  10456. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10457. /**
  10458. * Calculate the intercept of a ray on a given axis
  10459. * @param axis to check 'x' | 'y' | 'z'
  10460. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10461. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10462. */
  10463. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10464. /**
  10465. * Checks if ray intersects a mesh
  10466. * @param mesh the mesh to check
  10467. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10468. * @returns picking info of the intersecton
  10469. */
  10470. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10471. /**
  10472. * Checks if ray intersects a mesh
  10473. * @param meshes the meshes to check
  10474. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10475. * @param results array to store result in
  10476. * @returns Array of picking infos
  10477. */
  10478. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10479. private _comparePickingInfo;
  10480. private static smallnum;
  10481. private static rayl;
  10482. /**
  10483. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10484. * @param sega the first point of the segment to test the intersection against
  10485. * @param segb the second point of the segment to test the intersection against
  10486. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10487. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10488. */
  10489. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10490. /**
  10491. * Update the ray from viewport position
  10492. * @param x position
  10493. * @param y y position
  10494. * @param viewportWidth viewport width
  10495. * @param viewportHeight viewport height
  10496. * @param world world matrix
  10497. * @param view view matrix
  10498. * @param projection projection matrix
  10499. * @returns this ray updated
  10500. */
  10501. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10502. /**
  10503. * Creates a ray with origin and direction of 0,0,0
  10504. * @returns the new ray
  10505. */
  10506. static Zero(): Ray;
  10507. /**
  10508. * Creates a new ray from screen space and viewport
  10509. * @param x position
  10510. * @param y y position
  10511. * @param viewportWidth viewport width
  10512. * @param viewportHeight viewport height
  10513. * @param world world matrix
  10514. * @param view view matrix
  10515. * @param projection projection matrix
  10516. * @returns new ray
  10517. */
  10518. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10519. /**
  10520. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10521. * transformed to the given world matrix.
  10522. * @param origin The origin point
  10523. * @param end The end point
  10524. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10525. * @returns the new ray
  10526. */
  10527. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10528. /**
  10529. * Transforms a ray by a matrix
  10530. * @param ray ray to transform
  10531. * @param matrix matrix to apply
  10532. * @returns the resulting new ray
  10533. */
  10534. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10535. /**
  10536. * Transforms a ray by a matrix
  10537. * @param ray ray to transform
  10538. * @param matrix matrix to apply
  10539. * @param result ray to store result in
  10540. */
  10541. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10542. /**
  10543. * Unproject a ray from screen space to object space
  10544. * @param sourceX defines the screen space x coordinate to use
  10545. * @param sourceY defines the screen space y coordinate to use
  10546. * @param viewportWidth defines the current width of the viewport
  10547. * @param viewportHeight defines the current height of the viewport
  10548. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10549. * @param view defines the view matrix to use
  10550. * @param projection defines the projection matrix to use
  10551. */
  10552. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10553. }
  10554. /**
  10555. * Type used to define predicate used to select faces when a mesh intersection is detected
  10556. */
  10557. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10558. module "babylonjs/scene" {
  10559. interface Scene {
  10560. /** @hidden */
  10561. _tempPickingRay: Nullable<Ray>;
  10562. /** @hidden */
  10563. _cachedRayForTransform: Ray;
  10564. /** @hidden */
  10565. _pickWithRayInverseMatrix: Matrix;
  10566. /** @hidden */
  10567. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10568. /** @hidden */
  10569. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10570. /** @hidden */
  10571. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  10572. }
  10573. }
  10574. }
  10575. declare module "babylonjs/sceneComponent" {
  10576. import { Scene } from "babylonjs/scene";
  10577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10578. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10579. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10580. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10581. import { Nullable } from "babylonjs/types";
  10582. import { Camera } from "babylonjs/Cameras/camera";
  10583. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10584. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10585. import { AbstractScene } from "babylonjs/abstractScene";
  10586. import { Mesh } from "babylonjs/Meshes/mesh";
  10587. /**
  10588. * Groups all the scene component constants in one place to ease maintenance.
  10589. * @hidden
  10590. */
  10591. export class SceneComponentConstants {
  10592. static readonly NAME_EFFECTLAYER: string;
  10593. static readonly NAME_LAYER: string;
  10594. static readonly NAME_LENSFLARESYSTEM: string;
  10595. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10596. static readonly NAME_PARTICLESYSTEM: string;
  10597. static readonly NAME_GAMEPAD: string;
  10598. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10599. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10600. static readonly NAME_PREPASSRENDERER: string;
  10601. static readonly NAME_DEPTHRENDERER: string;
  10602. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10603. static readonly NAME_SPRITE: string;
  10604. static readonly NAME_SUBSURFACE: string;
  10605. static readonly NAME_OUTLINERENDERER: string;
  10606. static readonly NAME_PROCEDURALTEXTURE: string;
  10607. static readonly NAME_SHADOWGENERATOR: string;
  10608. static readonly NAME_OCTREE: string;
  10609. static readonly NAME_PHYSICSENGINE: string;
  10610. static readonly NAME_AUDIO: string;
  10611. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10612. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10613. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10614. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10615. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10616. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10617. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10618. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10619. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10620. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10621. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10622. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10623. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10624. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10625. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10626. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10627. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10628. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10629. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10630. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10631. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10632. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10633. static readonly STEP_AFTERRENDER_AUDIO: number;
  10634. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10635. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10636. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10637. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10638. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10639. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10640. static readonly STEP_POINTERMOVE_SPRITE: number;
  10641. static readonly STEP_POINTERDOWN_SPRITE: number;
  10642. static readonly STEP_POINTERUP_SPRITE: number;
  10643. }
  10644. /**
  10645. * This represents a scene component.
  10646. *
  10647. * This is used to decouple the dependency the scene is having on the different workloads like
  10648. * layers, post processes...
  10649. */
  10650. export interface ISceneComponent {
  10651. /**
  10652. * The name of the component. Each component must have a unique name.
  10653. */
  10654. name: string;
  10655. /**
  10656. * The scene the component belongs to.
  10657. */
  10658. scene: Scene;
  10659. /**
  10660. * Register the component to one instance of a scene.
  10661. */
  10662. register(): void;
  10663. /**
  10664. * Rebuilds the elements related to this component in case of
  10665. * context lost for instance.
  10666. */
  10667. rebuild(): void;
  10668. /**
  10669. * Disposes the component and the associated ressources.
  10670. */
  10671. dispose(): void;
  10672. }
  10673. /**
  10674. * This represents a SERIALIZABLE scene component.
  10675. *
  10676. * This extends Scene Component to add Serialization methods on top.
  10677. */
  10678. export interface ISceneSerializableComponent extends ISceneComponent {
  10679. /**
  10680. * Adds all the elements from the container to the scene
  10681. * @param container the container holding the elements
  10682. */
  10683. addFromContainer(container: AbstractScene): void;
  10684. /**
  10685. * Removes all the elements in the container from the scene
  10686. * @param container contains the elements to remove
  10687. * @param dispose if the removed element should be disposed (default: false)
  10688. */
  10689. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10690. /**
  10691. * Serializes the component data to the specified json object
  10692. * @param serializationObject The object to serialize to
  10693. */
  10694. serialize(serializationObject: any): void;
  10695. }
  10696. /**
  10697. * Strong typing of a Mesh related stage step action
  10698. */
  10699. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10700. /**
  10701. * Strong typing of a Evaluate Sub Mesh related stage step action
  10702. */
  10703. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10704. /**
  10705. * Strong typing of a pre active Mesh related stage step action
  10706. */
  10707. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  10708. /**
  10709. * Strong typing of a Camera related stage step action
  10710. */
  10711. export type CameraStageAction = (camera: Camera) => void;
  10712. /**
  10713. * Strong typing of a Camera Frame buffer related stage step action
  10714. */
  10715. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10716. /**
  10717. * Strong typing of a Render Target related stage step action
  10718. */
  10719. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10720. /**
  10721. * Strong typing of a RenderingGroup related stage step action
  10722. */
  10723. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10724. /**
  10725. * Strong typing of a Mesh Render related stage step action
  10726. */
  10727. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10728. /**
  10729. * Strong typing of a simple stage step action
  10730. */
  10731. export type SimpleStageAction = () => void;
  10732. /**
  10733. * Strong typing of a render target action.
  10734. */
  10735. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10736. /**
  10737. * Strong typing of a pointer move action.
  10738. */
  10739. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10740. /**
  10741. * Strong typing of a pointer up/down action.
  10742. */
  10743. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10744. /**
  10745. * Representation of a stage in the scene (Basically a list of ordered steps)
  10746. * @hidden
  10747. */
  10748. export class Stage<T extends Function> extends Array<{
  10749. index: number;
  10750. component: ISceneComponent;
  10751. action: T;
  10752. }> {
  10753. /**
  10754. * Hide ctor from the rest of the world.
  10755. * @param items The items to add.
  10756. */
  10757. private constructor();
  10758. /**
  10759. * Creates a new Stage.
  10760. * @returns A new instance of a Stage
  10761. */
  10762. static Create<T extends Function>(): Stage<T>;
  10763. /**
  10764. * Registers a step in an ordered way in the targeted stage.
  10765. * @param index Defines the position to register the step in
  10766. * @param component Defines the component attached to the step
  10767. * @param action Defines the action to launch during the step
  10768. */
  10769. registerStep(index: number, component: ISceneComponent, action: T): void;
  10770. /**
  10771. * Clears all the steps from the stage.
  10772. */
  10773. clear(): void;
  10774. }
  10775. }
  10776. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10777. import { Nullable } from "babylonjs/types";
  10778. import { Observable } from "babylonjs/Misc/observable";
  10779. import { Scene } from "babylonjs/scene";
  10780. import { Sprite } from "babylonjs/Sprites/sprite";
  10781. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10782. import { Ray } from "babylonjs/Culling/ray";
  10783. import { Camera } from "babylonjs/Cameras/camera";
  10784. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10785. import { ISceneComponent } from "babylonjs/sceneComponent";
  10786. module "babylonjs/scene" {
  10787. interface Scene {
  10788. /** @hidden */
  10789. _pointerOverSprite: Nullable<Sprite>;
  10790. /** @hidden */
  10791. _pickedDownSprite: Nullable<Sprite>;
  10792. /** @hidden */
  10793. _tempSpritePickingRay: Nullable<Ray>;
  10794. /**
  10795. * All of the sprite managers added to this scene
  10796. * @see https://doc.babylonjs.com/babylon101/sprites
  10797. */
  10798. spriteManagers: Array<ISpriteManager>;
  10799. /**
  10800. * An event triggered when sprites rendering is about to start
  10801. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10802. */
  10803. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10804. /**
  10805. * An event triggered when sprites rendering is done
  10806. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10807. */
  10808. onAfterSpritesRenderingObservable: Observable<Scene>;
  10809. /** @hidden */
  10810. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10811. /** Launch a ray to try to pick a sprite in the scene
  10812. * @param x position on screen
  10813. * @param y position on screen
  10814. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10815. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10816. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10817. * @returns a PickingInfo
  10818. */
  10819. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10820. /** Use the given ray to pick a sprite in the scene
  10821. * @param ray The ray (in world space) to use to pick meshes
  10822. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10823. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10824. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10825. * @returns a PickingInfo
  10826. */
  10827. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10828. /** @hidden */
  10829. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10830. /** Launch a ray to try to pick sprites in the scene
  10831. * @param x position on screen
  10832. * @param y position on screen
  10833. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10834. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10835. * @returns a PickingInfo array
  10836. */
  10837. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10838. /** Use the given ray to pick sprites in the scene
  10839. * @param ray The ray (in world space) to use to pick meshes
  10840. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10841. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10842. * @returns a PickingInfo array
  10843. */
  10844. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10845. /**
  10846. * Force the sprite under the pointer
  10847. * @param sprite defines the sprite to use
  10848. */
  10849. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10850. /**
  10851. * Gets the sprite under the pointer
  10852. * @returns a Sprite or null if no sprite is under the pointer
  10853. */
  10854. getPointerOverSprite(): Nullable<Sprite>;
  10855. }
  10856. }
  10857. /**
  10858. * Defines the sprite scene component responsible to manage sprites
  10859. * in a given scene.
  10860. */
  10861. export class SpriteSceneComponent implements ISceneComponent {
  10862. /**
  10863. * The component name helpfull to identify the component in the list of scene components.
  10864. */
  10865. readonly name: string;
  10866. /**
  10867. * The scene the component belongs to.
  10868. */
  10869. scene: Scene;
  10870. /** @hidden */
  10871. private _spritePredicate;
  10872. /**
  10873. * Creates a new instance of the component for the given scene
  10874. * @param scene Defines the scene to register the component in
  10875. */
  10876. constructor(scene: Scene);
  10877. /**
  10878. * Registers the component in a given scene
  10879. */
  10880. register(): void;
  10881. /**
  10882. * Rebuilds the elements related to this component in case of
  10883. * context lost for instance.
  10884. */
  10885. rebuild(): void;
  10886. /**
  10887. * Disposes the component and the associated ressources.
  10888. */
  10889. dispose(): void;
  10890. private _pickSpriteButKeepRay;
  10891. private _pointerMove;
  10892. private _pointerDown;
  10893. private _pointerUp;
  10894. }
  10895. }
  10896. declare module "babylonjs/Misc/timingTools" {
  10897. /**
  10898. * Class used to provide helper for timing
  10899. */
  10900. export class TimingTools {
  10901. /**
  10902. * Polyfill for setImmediate
  10903. * @param action defines the action to execute after the current execution block
  10904. */
  10905. static SetImmediate(action: () => void): void;
  10906. }
  10907. }
  10908. declare module "babylonjs/Misc/instantiationTools" {
  10909. /**
  10910. * Class used to enable instatition of objects by class name
  10911. */
  10912. export class InstantiationTools {
  10913. /**
  10914. * Use this object to register external classes like custom textures or material
  10915. * to allow the laoders to instantiate them
  10916. */
  10917. static RegisteredExternalClasses: {
  10918. [key: string]: Object;
  10919. };
  10920. /**
  10921. * Tries to instantiate a new object from a given class name
  10922. * @param className defines the class name to instantiate
  10923. * @returns the new object or null if the system was not able to do the instantiation
  10924. */
  10925. static Instantiate(className: string): any;
  10926. }
  10927. }
  10928. declare module "babylonjs/Misc/copyTools" {
  10929. import { Nullable } from "babylonjs/types";
  10930. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  10931. /**
  10932. * Class used to host copy specific utilities
  10933. */
  10934. export class CopyTools {
  10935. /**
  10936. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  10937. * @param texture defines the texture to read pixels from
  10938. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  10939. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  10940. * @returns The base64 encoded string or null
  10941. */
  10942. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  10943. }
  10944. }
  10945. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  10946. /**
  10947. * Define options used to create a depth texture
  10948. */
  10949. export class DepthTextureCreationOptions {
  10950. /** Specifies whether or not a stencil should be allocated in the texture */
  10951. generateStencil?: boolean;
  10952. /** Specifies whether or not bilinear filtering is enable on the texture */
  10953. bilinearFiltering?: boolean;
  10954. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  10955. comparisonFunction?: number;
  10956. /** Specifies if the created texture is a cube texture */
  10957. isCube?: boolean;
  10958. }
  10959. }
  10960. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  10961. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10962. import { Nullable } from "babylonjs/types";
  10963. import { Scene } from "babylonjs/scene";
  10964. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  10965. module "babylonjs/Engines/thinEngine" {
  10966. interface ThinEngine {
  10967. /**
  10968. * Creates a depth stencil cube texture.
  10969. * This is only available in WebGL 2.
  10970. * @param size The size of face edge in the cube texture.
  10971. * @param options The options defining the cube texture.
  10972. * @returns The cube texture
  10973. */
  10974. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  10975. /**
  10976. * Creates a cube texture
  10977. * @param rootUrl defines the url where the files to load is located
  10978. * @param scene defines the current scene
  10979. * @param files defines the list of files to load (1 per face)
  10980. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10981. * @param onLoad defines an optional callback raised when the texture is loaded
  10982. * @param onError defines an optional callback raised if there is an issue to load the texture
  10983. * @param format defines the format of the data
  10984. * @param forcedExtension defines the extension to use to pick the right loader
  10985. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10986. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10987. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10988. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  10989. * @param loaderOptions options to be passed to the loader
  10990. * @returns the cube texture as an InternalTexture
  10991. */
  10992. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any): InternalTexture;
  10993. /**
  10994. * Creates a cube texture
  10995. * @param rootUrl defines the url where the files to load is located
  10996. * @param scene defines the current scene
  10997. * @param files defines the list of files to load (1 per face)
  10998. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10999. * @param onLoad defines an optional callback raised when the texture is loaded
  11000. * @param onError defines an optional callback raised if there is an issue to load the texture
  11001. * @param format defines the format of the data
  11002. * @param forcedExtension defines the extension to use to pick the right loader
  11003. * @returns the cube texture as an InternalTexture
  11004. */
  11005. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  11006. /**
  11007. * Creates a cube texture
  11008. * @param rootUrl defines the url where the files to load is located
  11009. * @param scene defines the current scene
  11010. * @param files defines the list of files to load (1 per face)
  11011. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11012. * @param onLoad defines an optional callback raised when the texture is loaded
  11013. * @param onError defines an optional callback raised if there is an issue to load the texture
  11014. * @param format defines the format of the data
  11015. * @param forcedExtension defines the extension to use to pick the right loader
  11016. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11017. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11018. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11019. * @returns the cube texture as an InternalTexture
  11020. */
  11021. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  11022. /** @hidden */
  11023. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11024. /** @hidden */
  11025. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11026. /** @hidden */
  11027. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11028. /** @hidden */
  11029. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11030. /**
  11031. * @hidden
  11032. */
  11033. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11034. }
  11035. }
  11036. }
  11037. declare module "babylonjs/Materials/Textures/cubeTexture" {
  11038. import { Nullable } from "babylonjs/types";
  11039. import { Scene } from "babylonjs/scene";
  11040. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11041. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11042. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11043. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  11044. import { Observable } from "babylonjs/Misc/observable";
  11045. /**
  11046. * Class for creating a cube texture
  11047. */
  11048. export class CubeTexture extends BaseTexture {
  11049. private _delayedOnLoad;
  11050. /**
  11051. * Observable triggered once the texture has been loaded.
  11052. */
  11053. onLoadObservable: Observable<CubeTexture>;
  11054. /**
  11055. * The url of the texture
  11056. */
  11057. url: string;
  11058. /**
  11059. * Gets or sets the center of the bounding box associated with the cube texture.
  11060. * It must define where the camera used to render the texture was set
  11061. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11062. */
  11063. boundingBoxPosition: Vector3;
  11064. private _boundingBoxSize;
  11065. /**
  11066. * Gets or sets the size of the bounding box associated with the cube texture
  11067. * When defined, the cubemap will switch to local mode
  11068. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11069. * @example https://www.babylonjs-playground.com/#RNASML
  11070. */
  11071. set boundingBoxSize(value: Vector3);
  11072. /**
  11073. * Returns the bounding box size
  11074. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11075. */
  11076. get boundingBoxSize(): Vector3;
  11077. protected _rotationY: number;
  11078. /**
  11079. * Sets texture matrix rotation angle around Y axis in radians.
  11080. */
  11081. set rotationY(value: number);
  11082. /**
  11083. * Gets texture matrix rotation angle around Y axis radians.
  11084. */
  11085. get rotationY(): number;
  11086. /**
  11087. * Are mip maps generated for this texture or not.
  11088. */
  11089. get noMipmap(): boolean;
  11090. private _noMipmap;
  11091. private _files;
  11092. protected _forcedExtension: Nullable<string>;
  11093. private _extensions;
  11094. private _textureMatrix;
  11095. private _format;
  11096. private _createPolynomials;
  11097. private _loaderOptions;
  11098. /**
  11099. * Creates a cube texture from an array of image urls
  11100. * @param files defines an array of image urls
  11101. * @param scene defines the hosting scene
  11102. * @param noMipmap specifies if mip maps are not used
  11103. * @returns a cube texture
  11104. */
  11105. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11106. /**
  11107. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11108. * @param url defines the url of the prefiltered texture
  11109. * @param scene defines the scene the texture is attached to
  11110. * @param forcedExtension defines the extension of the file if different from the url
  11111. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11112. * @return the prefiltered texture
  11113. */
  11114. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11115. /**
  11116. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11117. * as prefiltered data.
  11118. * @param rootUrl defines the url of the texture or the root name of the six images
  11119. * @param null defines the scene or engine the texture is attached to
  11120. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11121. * @param noMipmap defines if mipmaps should be created or not
  11122. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11123. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  11124. * @param onError defines a callback triggered in case of error during load
  11125. * @param format defines the internal format to use for the texture once loaded
  11126. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11127. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11128. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11129. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11130. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11131. * @param loaderOptions options to be passed to the loader
  11132. * @return the cube texture
  11133. */
  11134. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, loaderOptions?: any);
  11135. /**
  11136. * Get the current class name of the texture useful for serialization or dynamic coding.
  11137. * @returns "CubeTexture"
  11138. */
  11139. getClassName(): string;
  11140. /**
  11141. * Update the url (and optional buffer) of this texture if url was null during construction.
  11142. * @param url the url of the texture
  11143. * @param forcedExtension defines the extension to use
  11144. * @param onLoad callback called when the texture is loaded (defaults to null)
  11145. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11146. */
  11147. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11148. /**
  11149. * Delays loading of the cube texture
  11150. * @param forcedExtension defines the extension to use
  11151. */
  11152. delayLoad(forcedExtension?: string): void;
  11153. /**
  11154. * Returns the reflection texture matrix
  11155. * @returns the reflection texture matrix
  11156. */
  11157. getReflectionTextureMatrix(): Matrix;
  11158. /**
  11159. * Sets the reflection texture matrix
  11160. * @param value Reflection texture matrix
  11161. */
  11162. setReflectionTextureMatrix(value: Matrix): void;
  11163. /**
  11164. * Parses text to create a cube texture
  11165. * @param parsedTexture define the serialized text to read from
  11166. * @param scene defines the hosting scene
  11167. * @param rootUrl defines the root url of the cube texture
  11168. * @returns a cube texture
  11169. */
  11170. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11171. /**
  11172. * Makes a clone, or deep copy, of the cube texture
  11173. * @returns a new cube texture
  11174. */
  11175. clone(): CubeTexture;
  11176. }
  11177. }
  11178. declare module "babylonjs/Materials/colorCurves" {
  11179. import { Effect } from "babylonjs/Materials/effect";
  11180. /**
  11181. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11182. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11183. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  11184. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11185. */
  11186. export class ColorCurves {
  11187. private _dirty;
  11188. private _tempColor;
  11189. private _globalCurve;
  11190. private _highlightsCurve;
  11191. private _midtonesCurve;
  11192. private _shadowsCurve;
  11193. private _positiveCurve;
  11194. private _negativeCurve;
  11195. private _globalHue;
  11196. private _globalDensity;
  11197. private _globalSaturation;
  11198. private _globalExposure;
  11199. /**
  11200. * Gets the global Hue value.
  11201. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11202. */
  11203. get globalHue(): number;
  11204. /**
  11205. * Sets the global Hue value.
  11206. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11207. */
  11208. set globalHue(value: number);
  11209. /**
  11210. * Gets the global Density value.
  11211. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11212. * Values less than zero provide a filter of opposite hue.
  11213. */
  11214. get globalDensity(): number;
  11215. /**
  11216. * Sets the global Density value.
  11217. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11218. * Values less than zero provide a filter of opposite hue.
  11219. */
  11220. set globalDensity(value: number);
  11221. /**
  11222. * Gets the global Saturation value.
  11223. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11224. */
  11225. get globalSaturation(): number;
  11226. /**
  11227. * Sets the global Saturation value.
  11228. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11229. */
  11230. set globalSaturation(value: number);
  11231. /**
  11232. * Gets the global Exposure value.
  11233. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11234. */
  11235. get globalExposure(): number;
  11236. /**
  11237. * Sets the global Exposure value.
  11238. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11239. */
  11240. set globalExposure(value: number);
  11241. private _highlightsHue;
  11242. private _highlightsDensity;
  11243. private _highlightsSaturation;
  11244. private _highlightsExposure;
  11245. /**
  11246. * Gets the highlights Hue value.
  11247. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11248. */
  11249. get highlightsHue(): number;
  11250. /**
  11251. * Sets the highlights Hue value.
  11252. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11253. */
  11254. set highlightsHue(value: number);
  11255. /**
  11256. * Gets the highlights Density value.
  11257. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11258. * Values less than zero provide a filter of opposite hue.
  11259. */
  11260. get highlightsDensity(): number;
  11261. /**
  11262. * Sets the highlights Density value.
  11263. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11264. * Values less than zero provide a filter of opposite hue.
  11265. */
  11266. set highlightsDensity(value: number);
  11267. /**
  11268. * Gets the highlights Saturation value.
  11269. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11270. */
  11271. get highlightsSaturation(): number;
  11272. /**
  11273. * Sets the highlights Saturation value.
  11274. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11275. */
  11276. set highlightsSaturation(value: number);
  11277. /**
  11278. * Gets the highlights Exposure value.
  11279. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11280. */
  11281. get highlightsExposure(): number;
  11282. /**
  11283. * Sets the highlights Exposure value.
  11284. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11285. */
  11286. set highlightsExposure(value: number);
  11287. private _midtonesHue;
  11288. private _midtonesDensity;
  11289. private _midtonesSaturation;
  11290. private _midtonesExposure;
  11291. /**
  11292. * Gets the midtones Hue value.
  11293. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11294. */
  11295. get midtonesHue(): number;
  11296. /**
  11297. * Sets the midtones Hue value.
  11298. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11299. */
  11300. set midtonesHue(value: number);
  11301. /**
  11302. * Gets the midtones Density value.
  11303. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11304. * Values less than zero provide a filter of opposite hue.
  11305. */
  11306. get midtonesDensity(): number;
  11307. /**
  11308. * Sets the midtones Density value.
  11309. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11310. * Values less than zero provide a filter of opposite hue.
  11311. */
  11312. set midtonesDensity(value: number);
  11313. /**
  11314. * Gets the midtones Saturation value.
  11315. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11316. */
  11317. get midtonesSaturation(): number;
  11318. /**
  11319. * Sets the midtones Saturation value.
  11320. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11321. */
  11322. set midtonesSaturation(value: number);
  11323. /**
  11324. * Gets the midtones Exposure value.
  11325. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11326. */
  11327. get midtonesExposure(): number;
  11328. /**
  11329. * Sets the midtones Exposure value.
  11330. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11331. */
  11332. set midtonesExposure(value: number);
  11333. private _shadowsHue;
  11334. private _shadowsDensity;
  11335. private _shadowsSaturation;
  11336. private _shadowsExposure;
  11337. /**
  11338. * Gets the shadows Hue value.
  11339. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11340. */
  11341. get shadowsHue(): number;
  11342. /**
  11343. * Sets the shadows Hue value.
  11344. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11345. */
  11346. set shadowsHue(value: number);
  11347. /**
  11348. * Gets the shadows Density value.
  11349. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11350. * Values less than zero provide a filter of opposite hue.
  11351. */
  11352. get shadowsDensity(): number;
  11353. /**
  11354. * Sets the shadows Density value.
  11355. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11356. * Values less than zero provide a filter of opposite hue.
  11357. */
  11358. set shadowsDensity(value: number);
  11359. /**
  11360. * Gets the shadows Saturation value.
  11361. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11362. */
  11363. get shadowsSaturation(): number;
  11364. /**
  11365. * Sets the shadows Saturation value.
  11366. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11367. */
  11368. set shadowsSaturation(value: number);
  11369. /**
  11370. * Gets the shadows Exposure value.
  11371. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11372. */
  11373. get shadowsExposure(): number;
  11374. /**
  11375. * Sets the shadows Exposure value.
  11376. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11377. */
  11378. set shadowsExposure(value: number);
  11379. /**
  11380. * Returns the class name
  11381. * @returns The class name
  11382. */
  11383. getClassName(): string;
  11384. /**
  11385. * Binds the color curves to the shader.
  11386. * @param colorCurves The color curve to bind
  11387. * @param effect The effect to bind to
  11388. * @param positiveUniform The positive uniform shader parameter
  11389. * @param neutralUniform The neutral uniform shader parameter
  11390. * @param negativeUniform The negative uniform shader parameter
  11391. */
  11392. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11393. /**
  11394. * Prepare the list of uniforms associated with the ColorCurves effects.
  11395. * @param uniformsList The list of uniforms used in the effect
  11396. */
  11397. static PrepareUniforms(uniformsList: string[]): void;
  11398. /**
  11399. * Returns color grading data based on a hue, density, saturation and exposure value.
  11400. * @param filterHue The hue of the color filter.
  11401. * @param filterDensity The density of the color filter.
  11402. * @param saturation The saturation.
  11403. * @param exposure The exposure.
  11404. * @param result The result data container.
  11405. */
  11406. private getColorGradingDataToRef;
  11407. /**
  11408. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11409. * @param value The input slider value in range [-100,100].
  11410. * @returns Adjusted value.
  11411. */
  11412. private static applyColorGradingSliderNonlinear;
  11413. /**
  11414. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11415. * @param hue The hue (H) input.
  11416. * @param saturation The saturation (S) input.
  11417. * @param brightness The brightness (B) input.
  11418. * @result An RGBA color represented as Vector4.
  11419. */
  11420. private static fromHSBToRef;
  11421. /**
  11422. * Returns a value clamped between min and max
  11423. * @param value The value to clamp
  11424. * @param min The minimum of value
  11425. * @param max The maximum of value
  11426. * @returns The clamped value.
  11427. */
  11428. private static clamp;
  11429. /**
  11430. * Clones the current color curve instance.
  11431. * @return The cloned curves
  11432. */
  11433. clone(): ColorCurves;
  11434. /**
  11435. * Serializes the current color curve instance to a json representation.
  11436. * @return a JSON representation
  11437. */
  11438. serialize(): any;
  11439. /**
  11440. * Parses the color curve from a json representation.
  11441. * @param source the JSON source to parse
  11442. * @return The parsed curves
  11443. */
  11444. static Parse(source: any): ColorCurves;
  11445. }
  11446. }
  11447. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  11448. import { Observable } from "babylonjs/Misc/observable";
  11449. import { Nullable } from "babylonjs/types";
  11450. import { Color4 } from "babylonjs/Maths/math.color";
  11451. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11452. import { Effect } from "babylonjs/Materials/effect";
  11453. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11454. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  11455. /**
  11456. * Interface to follow in your material defines to integrate easily the
  11457. * Image proccessing functions.
  11458. * @hidden
  11459. */
  11460. export interface IImageProcessingConfigurationDefines {
  11461. IMAGEPROCESSING: boolean;
  11462. VIGNETTE: boolean;
  11463. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11464. VIGNETTEBLENDMODEOPAQUE: boolean;
  11465. TONEMAPPING: boolean;
  11466. TONEMAPPING_ACES: boolean;
  11467. CONTRAST: boolean;
  11468. EXPOSURE: boolean;
  11469. COLORCURVES: boolean;
  11470. COLORGRADING: boolean;
  11471. COLORGRADING3D: boolean;
  11472. SAMPLER3DGREENDEPTH: boolean;
  11473. SAMPLER3DBGRMAP: boolean;
  11474. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11475. }
  11476. /**
  11477. * @hidden
  11478. */
  11479. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11480. IMAGEPROCESSING: boolean;
  11481. VIGNETTE: boolean;
  11482. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11483. VIGNETTEBLENDMODEOPAQUE: boolean;
  11484. TONEMAPPING: boolean;
  11485. TONEMAPPING_ACES: boolean;
  11486. CONTRAST: boolean;
  11487. COLORCURVES: boolean;
  11488. COLORGRADING: boolean;
  11489. COLORGRADING3D: boolean;
  11490. SAMPLER3DGREENDEPTH: boolean;
  11491. SAMPLER3DBGRMAP: boolean;
  11492. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11493. EXPOSURE: boolean;
  11494. constructor();
  11495. }
  11496. /**
  11497. * This groups together the common properties used for image processing either in direct forward pass
  11498. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11499. * or not.
  11500. */
  11501. export class ImageProcessingConfiguration {
  11502. /**
  11503. * Default tone mapping applied in BabylonJS.
  11504. */
  11505. static readonly TONEMAPPING_STANDARD: number;
  11506. /**
  11507. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11508. * to other engines rendering to increase portability.
  11509. */
  11510. static readonly TONEMAPPING_ACES: number;
  11511. /**
  11512. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11513. */
  11514. colorCurves: Nullable<ColorCurves>;
  11515. private _colorCurvesEnabled;
  11516. /**
  11517. * Gets wether the color curves effect is enabled.
  11518. */
  11519. get colorCurvesEnabled(): boolean;
  11520. /**
  11521. * Sets wether the color curves effect is enabled.
  11522. */
  11523. set colorCurvesEnabled(value: boolean);
  11524. private _colorGradingTexture;
  11525. /**
  11526. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11527. */
  11528. get colorGradingTexture(): Nullable<BaseTexture>;
  11529. /**
  11530. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11531. */
  11532. set colorGradingTexture(value: Nullable<BaseTexture>);
  11533. private _colorGradingEnabled;
  11534. /**
  11535. * Gets wether the color grading effect is enabled.
  11536. */
  11537. get colorGradingEnabled(): boolean;
  11538. /**
  11539. * Sets wether the color grading effect is enabled.
  11540. */
  11541. set colorGradingEnabled(value: boolean);
  11542. private _colorGradingWithGreenDepth;
  11543. /**
  11544. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11545. */
  11546. get colorGradingWithGreenDepth(): boolean;
  11547. /**
  11548. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11549. */
  11550. set colorGradingWithGreenDepth(value: boolean);
  11551. private _colorGradingBGR;
  11552. /**
  11553. * Gets wether the color grading texture contains BGR values.
  11554. */
  11555. get colorGradingBGR(): boolean;
  11556. /**
  11557. * Sets wether the color grading texture contains BGR values.
  11558. */
  11559. set colorGradingBGR(value: boolean);
  11560. /** @hidden */
  11561. _exposure: number;
  11562. /**
  11563. * Gets the Exposure used in the effect.
  11564. */
  11565. get exposure(): number;
  11566. /**
  11567. * Sets the Exposure used in the effect.
  11568. */
  11569. set exposure(value: number);
  11570. private _toneMappingEnabled;
  11571. /**
  11572. * Gets wether the tone mapping effect is enabled.
  11573. */
  11574. get toneMappingEnabled(): boolean;
  11575. /**
  11576. * Sets wether the tone mapping effect is enabled.
  11577. */
  11578. set toneMappingEnabled(value: boolean);
  11579. private _toneMappingType;
  11580. /**
  11581. * Gets the type of tone mapping effect.
  11582. */
  11583. get toneMappingType(): number;
  11584. /**
  11585. * Sets the type of tone mapping effect used in BabylonJS.
  11586. */
  11587. set toneMappingType(value: number);
  11588. protected _contrast: number;
  11589. /**
  11590. * Gets the contrast used in the effect.
  11591. */
  11592. get contrast(): number;
  11593. /**
  11594. * Sets the contrast used in the effect.
  11595. */
  11596. set contrast(value: number);
  11597. /**
  11598. * Vignette stretch size.
  11599. */
  11600. vignetteStretch: number;
  11601. /**
  11602. * Vignette centre X Offset.
  11603. */
  11604. vignetteCentreX: number;
  11605. /**
  11606. * Vignette centre Y Offset.
  11607. */
  11608. vignetteCentreY: number;
  11609. /**
  11610. * Vignette weight or intensity of the vignette effect.
  11611. */
  11612. vignetteWeight: number;
  11613. /**
  11614. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  11615. * if vignetteEnabled is set to true.
  11616. */
  11617. vignetteColor: Color4;
  11618. /**
  11619. * Camera field of view used by the Vignette effect.
  11620. */
  11621. vignetteCameraFov: number;
  11622. private _vignetteBlendMode;
  11623. /**
  11624. * Gets the vignette blend mode allowing different kind of effect.
  11625. */
  11626. get vignetteBlendMode(): number;
  11627. /**
  11628. * Sets the vignette blend mode allowing different kind of effect.
  11629. */
  11630. set vignetteBlendMode(value: number);
  11631. private _vignetteEnabled;
  11632. /**
  11633. * Gets wether the vignette effect is enabled.
  11634. */
  11635. get vignetteEnabled(): boolean;
  11636. /**
  11637. * Sets wether the vignette effect is enabled.
  11638. */
  11639. set vignetteEnabled(value: boolean);
  11640. private _applyByPostProcess;
  11641. /**
  11642. * Gets wether the image processing is applied through a post process or not.
  11643. */
  11644. get applyByPostProcess(): boolean;
  11645. /**
  11646. * Sets wether the image processing is applied through a post process or not.
  11647. */
  11648. set applyByPostProcess(value: boolean);
  11649. private _isEnabled;
  11650. /**
  11651. * Gets wether the image processing is enabled or not.
  11652. */
  11653. get isEnabled(): boolean;
  11654. /**
  11655. * Sets wether the image processing is enabled or not.
  11656. */
  11657. set isEnabled(value: boolean);
  11658. /**
  11659. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  11660. */
  11661. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  11662. /**
  11663. * Method called each time the image processing information changes requires to recompile the effect.
  11664. */
  11665. protected _updateParameters(): void;
  11666. /**
  11667. * Gets the current class name.
  11668. * @return "ImageProcessingConfiguration"
  11669. */
  11670. getClassName(): string;
  11671. /**
  11672. * Prepare the list of uniforms associated with the Image Processing effects.
  11673. * @param uniforms The list of uniforms used in the effect
  11674. * @param defines the list of defines currently in use
  11675. */
  11676. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  11677. /**
  11678. * Prepare the list of samplers associated with the Image Processing effects.
  11679. * @param samplersList The list of uniforms used in the effect
  11680. * @param defines the list of defines currently in use
  11681. */
  11682. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  11683. /**
  11684. * Prepare the list of defines associated to the shader.
  11685. * @param defines the list of defines to complete
  11686. * @param forPostProcess Define if we are currently in post process mode or not
  11687. */
  11688. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  11689. /**
  11690. * Returns true if all the image processing information are ready.
  11691. * @returns True if ready, otherwise, false
  11692. */
  11693. isReady(): boolean;
  11694. /**
  11695. * Binds the image processing to the shader.
  11696. * @param effect The effect to bind to
  11697. * @param overrideAspectRatio Override the aspect ratio of the effect
  11698. */
  11699. bind(effect: Effect, overrideAspectRatio?: number): void;
  11700. /**
  11701. * Clones the current image processing instance.
  11702. * @return The cloned image processing
  11703. */
  11704. clone(): ImageProcessingConfiguration;
  11705. /**
  11706. * Serializes the current image processing instance to a json representation.
  11707. * @return a JSON representation
  11708. */
  11709. serialize(): any;
  11710. /**
  11711. * Parses the image processing from a json representation.
  11712. * @param source the JSON source to parse
  11713. * @return The parsed image processing
  11714. */
  11715. static Parse(source: any): ImageProcessingConfiguration;
  11716. private static _VIGNETTEMODE_MULTIPLY;
  11717. private static _VIGNETTEMODE_OPAQUE;
  11718. /**
  11719. * Used to apply the vignette as a mix with the pixel color.
  11720. */
  11721. static get VIGNETTEMODE_MULTIPLY(): number;
  11722. /**
  11723. * Used to apply the vignette as a replacement of the pixel color.
  11724. */
  11725. static get VIGNETTEMODE_OPAQUE(): number;
  11726. }
  11727. }
  11728. declare module "babylonjs/Shaders/postprocess.vertex" {
  11729. /** @hidden */
  11730. export var postprocessVertexShader: {
  11731. name: string;
  11732. shader: string;
  11733. };
  11734. }
  11735. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  11736. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11737. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11738. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  11739. /**
  11740. * Type used to define a render target texture size (either with a number or with a rect width and height)
  11741. */
  11742. export type RenderTargetTextureSize = number | {
  11743. width: number;
  11744. height: number;
  11745. layers?: number;
  11746. };
  11747. module "babylonjs/Engines/thinEngine" {
  11748. interface ThinEngine {
  11749. /**
  11750. * Creates a new render target texture
  11751. * @param size defines the size of the texture
  11752. * @param options defines the options used to create the texture
  11753. * @returns a new render target texture stored in an InternalTexture
  11754. */
  11755. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11756. /**
  11757. * Creates a depth stencil texture.
  11758. * This is only available in WebGL 2 or with the depth texture extension available.
  11759. * @param size The size of face edge in the texture.
  11760. * @param options The options defining the texture.
  11761. * @returns The texture
  11762. */
  11763. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11764. /** @hidden */
  11765. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11766. }
  11767. }
  11768. }
  11769. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  11770. /**
  11771. * Defines the kind of connection point for node based material
  11772. */
  11773. export enum NodeMaterialBlockConnectionPointTypes {
  11774. /** Float */
  11775. Float = 1,
  11776. /** Int */
  11777. Int = 2,
  11778. /** Vector2 */
  11779. Vector2 = 4,
  11780. /** Vector3 */
  11781. Vector3 = 8,
  11782. /** Vector4 */
  11783. Vector4 = 16,
  11784. /** Color3 */
  11785. Color3 = 32,
  11786. /** Color4 */
  11787. Color4 = 64,
  11788. /** Matrix */
  11789. Matrix = 128,
  11790. /** Custom object */
  11791. Object = 256,
  11792. /** Detect type based on connection */
  11793. AutoDetect = 1024,
  11794. /** Output type that will be defined by input type */
  11795. BasedOnInput = 2048
  11796. }
  11797. }
  11798. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  11799. /**
  11800. * Enum used to define the target of a block
  11801. */
  11802. export enum NodeMaterialBlockTargets {
  11803. /** Vertex shader */
  11804. Vertex = 1,
  11805. /** Fragment shader */
  11806. Fragment = 2,
  11807. /** Neutral */
  11808. Neutral = 4,
  11809. /** Vertex and Fragment */
  11810. VertexAndFragment = 3
  11811. }
  11812. }
  11813. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  11814. /**
  11815. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  11816. */
  11817. export enum NodeMaterialBlockConnectionPointMode {
  11818. /** Value is an uniform */
  11819. Uniform = 0,
  11820. /** Value is a mesh attribute */
  11821. Attribute = 1,
  11822. /** Value is a varying between vertex and fragment shaders */
  11823. Varying = 2,
  11824. /** Mode is undefined */
  11825. Undefined = 3
  11826. }
  11827. }
  11828. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  11829. /**
  11830. * Enum used to define system values e.g. values automatically provided by the system
  11831. */
  11832. export enum NodeMaterialSystemValues {
  11833. /** World */
  11834. World = 1,
  11835. /** View */
  11836. View = 2,
  11837. /** Projection */
  11838. Projection = 3,
  11839. /** ViewProjection */
  11840. ViewProjection = 4,
  11841. /** WorldView */
  11842. WorldView = 5,
  11843. /** WorldViewProjection */
  11844. WorldViewProjection = 6,
  11845. /** CameraPosition */
  11846. CameraPosition = 7,
  11847. /** Fog Color */
  11848. FogColor = 8,
  11849. /** Delta time */
  11850. DeltaTime = 9
  11851. }
  11852. }
  11853. declare module "babylonjs/Maths/math.frustum" {
  11854. import { Matrix } from "babylonjs/Maths/math.vector";
  11855. import { DeepImmutable } from "babylonjs/types";
  11856. import { Plane } from "babylonjs/Maths/math.plane";
  11857. /**
  11858. * Represents a camera frustum
  11859. */
  11860. export class Frustum {
  11861. /**
  11862. * Gets the planes representing the frustum
  11863. * @param transform matrix to be applied to the returned planes
  11864. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  11865. */
  11866. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  11867. /**
  11868. * Gets the near frustum plane transformed by the transform matrix
  11869. * @param transform transformation matrix to be applied to the resulting frustum plane
  11870. * @param frustumPlane the resuling frustum plane
  11871. */
  11872. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11873. /**
  11874. * Gets the far frustum plane transformed by the transform matrix
  11875. * @param transform transformation matrix to be applied to the resulting frustum plane
  11876. * @param frustumPlane the resuling frustum plane
  11877. */
  11878. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11879. /**
  11880. * Gets the left frustum plane transformed by the transform matrix
  11881. * @param transform transformation matrix to be applied to the resulting frustum plane
  11882. * @param frustumPlane the resuling frustum plane
  11883. */
  11884. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11885. /**
  11886. * Gets the right frustum plane transformed by the transform matrix
  11887. * @param transform transformation matrix to be applied to the resulting frustum plane
  11888. * @param frustumPlane the resuling frustum plane
  11889. */
  11890. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11891. /**
  11892. * Gets the top frustum plane transformed by the transform matrix
  11893. * @param transform transformation matrix to be applied to the resulting frustum plane
  11894. * @param frustumPlane the resuling frustum plane
  11895. */
  11896. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11897. /**
  11898. * Gets the bottom frustum plane transformed by the transform matrix
  11899. * @param transform transformation matrix to be applied to the resulting frustum plane
  11900. * @param frustumPlane the resuling frustum plane
  11901. */
  11902. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11903. /**
  11904. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  11905. * @param transform transformation matrix to be applied to the resulting frustum planes
  11906. * @param frustumPlanes the resuling frustum planes
  11907. */
  11908. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  11909. }
  11910. }
  11911. declare module "babylonjs/Maths/math.vertexFormat" {
  11912. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11913. /**
  11914. * Contains position and normal vectors for a vertex
  11915. */
  11916. export class PositionNormalVertex {
  11917. /** the position of the vertex (defaut: 0,0,0) */
  11918. position: Vector3;
  11919. /** the normal of the vertex (defaut: 0,1,0) */
  11920. normal: Vector3;
  11921. /**
  11922. * Creates a PositionNormalVertex
  11923. * @param position the position of the vertex (defaut: 0,0,0)
  11924. * @param normal the normal of the vertex (defaut: 0,1,0)
  11925. */
  11926. constructor(
  11927. /** the position of the vertex (defaut: 0,0,0) */
  11928. position?: Vector3,
  11929. /** the normal of the vertex (defaut: 0,1,0) */
  11930. normal?: Vector3);
  11931. /**
  11932. * Clones the PositionNormalVertex
  11933. * @returns the cloned PositionNormalVertex
  11934. */
  11935. clone(): PositionNormalVertex;
  11936. }
  11937. /**
  11938. * Contains position, normal and uv vectors for a vertex
  11939. */
  11940. export class PositionNormalTextureVertex {
  11941. /** the position of the vertex (defaut: 0,0,0) */
  11942. position: Vector3;
  11943. /** the normal of the vertex (defaut: 0,1,0) */
  11944. normal: Vector3;
  11945. /** the uv of the vertex (default: 0,0) */
  11946. uv: Vector2;
  11947. /**
  11948. * Creates a PositionNormalTextureVertex
  11949. * @param position the position of the vertex (defaut: 0,0,0)
  11950. * @param normal the normal of the vertex (defaut: 0,1,0)
  11951. * @param uv the uv of the vertex (default: 0,0)
  11952. */
  11953. constructor(
  11954. /** the position of the vertex (defaut: 0,0,0) */
  11955. position?: Vector3,
  11956. /** the normal of the vertex (defaut: 0,1,0) */
  11957. normal?: Vector3,
  11958. /** the uv of the vertex (default: 0,0) */
  11959. uv?: Vector2);
  11960. /**
  11961. * Clones the PositionNormalTextureVertex
  11962. * @returns the cloned PositionNormalTextureVertex
  11963. */
  11964. clone(): PositionNormalTextureVertex;
  11965. }
  11966. }
  11967. declare module "babylonjs/Maths/math" {
  11968. export * from "babylonjs/Maths/math.axis";
  11969. export * from "babylonjs/Maths/math.color";
  11970. export * from "babylonjs/Maths/math.constants";
  11971. export * from "babylonjs/Maths/math.frustum";
  11972. export * from "babylonjs/Maths/math.path";
  11973. export * from "babylonjs/Maths/math.plane";
  11974. export * from "babylonjs/Maths/math.size";
  11975. export * from "babylonjs/Maths/math.vector";
  11976. export * from "babylonjs/Maths/math.vertexFormat";
  11977. export * from "babylonjs/Maths/math.viewport";
  11978. }
  11979. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  11980. /**
  11981. * Enum defining the type of animations supported by InputBlock
  11982. */
  11983. export enum AnimatedInputBlockTypes {
  11984. /** No animation */
  11985. None = 0,
  11986. /** Time based animation. Will only work for floats */
  11987. Time = 1
  11988. }
  11989. }
  11990. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  11991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  11992. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  11993. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  11994. import { Nullable } from "babylonjs/types";
  11995. import { Effect } from "babylonjs/Materials/effect";
  11996. import { Matrix } from "babylonjs/Maths/math.vector";
  11997. import { Scene } from "babylonjs/scene";
  11998. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  11999. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12000. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12001. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  12002. import { Observable } from "babylonjs/Misc/observable";
  12003. /**
  12004. * Block used to expose an input value
  12005. */
  12006. export class InputBlock extends NodeMaterialBlock {
  12007. private _mode;
  12008. private _associatedVariableName;
  12009. private _storedValue;
  12010. private _valueCallback;
  12011. private _type;
  12012. private _animationType;
  12013. /** Gets or set a value used to limit the range of float values */
  12014. min: number;
  12015. /** Gets or set a value used to limit the range of float values */
  12016. max: number;
  12017. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12018. isBoolean: boolean;
  12019. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12020. matrixMode: number;
  12021. /** @hidden */
  12022. _systemValue: Nullable<NodeMaterialSystemValues>;
  12023. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12024. isConstant: boolean;
  12025. /** Gets or sets the group to use to display this block in the Inspector */
  12026. groupInInspector: string;
  12027. /** Gets an observable raised when the value is changed */
  12028. onValueChangedObservable: Observable<InputBlock>;
  12029. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12030. convertToGammaSpace: boolean;
  12031. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12032. convertToLinearSpace: boolean;
  12033. /**
  12034. * Gets or sets the connection point type (default is float)
  12035. */
  12036. get type(): NodeMaterialBlockConnectionPointTypes;
  12037. /**
  12038. * Creates a new InputBlock
  12039. * @param name defines the block name
  12040. * @param target defines the target of that block (Vertex by default)
  12041. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12042. */
  12043. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12044. /**
  12045. * Validates if a name is a reserve word.
  12046. * @param newName the new name to be given to the node.
  12047. * @returns false if the name is a reserve word, else true.
  12048. */
  12049. validateBlockName(newName: string): boolean;
  12050. /**
  12051. * Gets the output component
  12052. */
  12053. get output(): NodeMaterialConnectionPoint;
  12054. /**
  12055. * Set the source of this connection point to a vertex attribute
  12056. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12057. * @returns the current connection point
  12058. */
  12059. setAsAttribute(attributeName?: string): InputBlock;
  12060. /**
  12061. * Set the source of this connection point to a system value
  12062. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12063. * @returns the current connection point
  12064. */
  12065. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12066. /**
  12067. * Gets or sets the value of that point.
  12068. * Please note that this value will be ignored if valueCallback is defined
  12069. */
  12070. get value(): any;
  12071. set value(value: any);
  12072. /**
  12073. * Gets or sets a callback used to get the value of that point.
  12074. * Please note that setting this value will force the connection point to ignore the value property
  12075. */
  12076. get valueCallback(): () => any;
  12077. set valueCallback(value: () => any);
  12078. /**
  12079. * Gets or sets the associated variable name in the shader
  12080. */
  12081. get associatedVariableName(): string;
  12082. set associatedVariableName(value: string);
  12083. /** Gets or sets the type of animation applied to the input */
  12084. get animationType(): AnimatedInputBlockTypes;
  12085. set animationType(value: AnimatedInputBlockTypes);
  12086. /**
  12087. * Gets a boolean indicating that this connection point not defined yet
  12088. */
  12089. get isUndefined(): boolean;
  12090. /**
  12091. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12092. * In this case the connection point name must be the name of the uniform to use.
  12093. * Can only be set on inputs
  12094. */
  12095. get isUniform(): boolean;
  12096. set isUniform(value: boolean);
  12097. /**
  12098. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12099. * In this case the connection point name must be the name of the attribute to use
  12100. * Can only be set on inputs
  12101. */
  12102. get isAttribute(): boolean;
  12103. set isAttribute(value: boolean);
  12104. /**
  12105. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12106. * Can only be set on exit points
  12107. */
  12108. get isVarying(): boolean;
  12109. set isVarying(value: boolean);
  12110. /**
  12111. * Gets a boolean indicating that the current connection point is a system value
  12112. */
  12113. get isSystemValue(): boolean;
  12114. /**
  12115. * Gets or sets the current well known value or null if not defined as a system value
  12116. */
  12117. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12118. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12119. /**
  12120. * Gets the current class name
  12121. * @returns the class name
  12122. */
  12123. getClassName(): string;
  12124. /**
  12125. * Animate the input if animationType !== None
  12126. * @param scene defines the rendering scene
  12127. */
  12128. animate(scene: Scene): void;
  12129. private _emitDefine;
  12130. initialize(state: NodeMaterialBuildState): void;
  12131. /**
  12132. * Set the input block to its default value (based on its type)
  12133. */
  12134. setDefaultValue(): void;
  12135. private _emitConstant;
  12136. /** @hidden */
  12137. get _noContextSwitch(): boolean;
  12138. private _emit;
  12139. /** @hidden */
  12140. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12141. /** @hidden */
  12142. _transmit(effect: Effect, scene: Scene): void;
  12143. protected _buildBlock(state: NodeMaterialBuildState): void;
  12144. protected _dumpPropertiesCode(): string;
  12145. dispose(): void;
  12146. serialize(): any;
  12147. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12148. }
  12149. }
  12150. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  12151. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  12152. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12153. import { Nullable } from "babylonjs/types";
  12154. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  12155. import { Observable } from "babylonjs/Misc/observable";
  12156. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12157. /**
  12158. * Enum used to define the compatibility state between two connection points
  12159. */
  12160. export enum NodeMaterialConnectionPointCompatibilityStates {
  12161. /** Points are compatibles */
  12162. Compatible = 0,
  12163. /** Points are incompatible because of their types */
  12164. TypeIncompatible = 1,
  12165. /** Points are incompatible because of their targets (vertex vs fragment) */
  12166. TargetIncompatible = 2
  12167. }
  12168. /**
  12169. * Defines the direction of a connection point
  12170. */
  12171. export enum NodeMaterialConnectionPointDirection {
  12172. /** Input */
  12173. Input = 0,
  12174. /** Output */
  12175. Output = 1
  12176. }
  12177. /**
  12178. * Defines a connection point for a block
  12179. */
  12180. export class NodeMaterialConnectionPoint {
  12181. /**
  12182. * Checks if two types are equivalent
  12183. * @param type1 type 1 to check
  12184. * @param type2 type 2 to check
  12185. * @returns true if both types are equivalent, else false
  12186. */
  12187. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12188. /** @hidden */
  12189. _ownerBlock: NodeMaterialBlock;
  12190. /** @hidden */
  12191. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12192. private _endpoints;
  12193. private _associatedVariableName;
  12194. private _direction;
  12195. /** @hidden */
  12196. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12197. /** @hidden */
  12198. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12199. /** @hidden */
  12200. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12201. private _type;
  12202. /** @hidden */
  12203. _enforceAssociatedVariableName: boolean;
  12204. /** Gets the direction of the point */
  12205. get direction(): NodeMaterialConnectionPointDirection;
  12206. /** Indicates that this connection point needs dual validation before being connected to another point */
  12207. needDualDirectionValidation: boolean;
  12208. /**
  12209. * Gets or sets the additional types supported by this connection point
  12210. */
  12211. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12212. /**
  12213. * Gets or sets the additional types excluded by this connection point
  12214. */
  12215. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12216. /**
  12217. * Observable triggered when this point is connected
  12218. */
  12219. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12220. /**
  12221. * Gets or sets the associated variable name in the shader
  12222. */
  12223. get associatedVariableName(): string;
  12224. set associatedVariableName(value: string);
  12225. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12226. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12227. /**
  12228. * Gets or sets the connection point type (default is float)
  12229. */
  12230. get type(): NodeMaterialBlockConnectionPointTypes;
  12231. set type(value: NodeMaterialBlockConnectionPointTypes);
  12232. /**
  12233. * Gets or sets the connection point name
  12234. */
  12235. name: string;
  12236. /**
  12237. * Gets or sets the connection point name
  12238. */
  12239. displayName: string;
  12240. /**
  12241. * Gets or sets a boolean indicating that this connection point can be omitted
  12242. */
  12243. isOptional: boolean;
  12244. /**
  12245. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12246. */
  12247. isExposedOnFrame: boolean;
  12248. /**
  12249. * Gets or sets number indicating the position that the port is exposed to on a frame
  12250. */
  12251. exposedPortPosition: number;
  12252. /**
  12253. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12254. */
  12255. define: string;
  12256. /** @hidden */
  12257. _prioritizeVertex: boolean;
  12258. private _target;
  12259. /** Gets or sets the target of that connection point */
  12260. get target(): NodeMaterialBlockTargets;
  12261. set target(value: NodeMaterialBlockTargets);
  12262. /**
  12263. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12264. */
  12265. get isConnected(): boolean;
  12266. /**
  12267. * Gets a boolean indicating that the current point is connected to an input block
  12268. */
  12269. get isConnectedToInputBlock(): boolean;
  12270. /**
  12271. * Gets a the connected input block (if any)
  12272. */
  12273. get connectInputBlock(): Nullable<InputBlock>;
  12274. /** Get the other side of the connection (if any) */
  12275. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12276. /** Get the block that owns this connection point */
  12277. get ownerBlock(): NodeMaterialBlock;
  12278. /** Get the block connected on the other side of this connection (if any) */
  12279. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12280. /** Get the block connected on the endpoints of this connection (if any) */
  12281. get connectedBlocks(): Array<NodeMaterialBlock>;
  12282. /** Gets the list of connected endpoints */
  12283. get endpoints(): NodeMaterialConnectionPoint[];
  12284. /** Gets a boolean indicating if that output point is connected to at least one input */
  12285. get hasEndpoints(): boolean;
  12286. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12287. get isConnectedInVertexShader(): boolean;
  12288. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12289. get isConnectedInFragmentShader(): boolean;
  12290. /**
  12291. * Creates a block suitable to be used as an input for this input point.
  12292. * If null is returned, a block based on the point type will be created.
  12293. * @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
  12294. */
  12295. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12296. /**
  12297. * Creates a new connection point
  12298. * @param name defines the connection point name
  12299. * @param ownerBlock defines the block hosting this connection point
  12300. * @param direction defines the direction of the connection point
  12301. */
  12302. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12303. /**
  12304. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12305. * @returns the class name
  12306. */
  12307. getClassName(): string;
  12308. /**
  12309. * Gets a boolean indicating if the current point can be connected to another point
  12310. * @param connectionPoint defines the other connection point
  12311. * @returns a boolean
  12312. */
  12313. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12314. /**
  12315. * Gets a number indicating if the current point can be connected to another point
  12316. * @param connectionPoint defines the other connection point
  12317. * @returns a number defining the compatibility state
  12318. */
  12319. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12320. /**
  12321. * Connect this point to another connection point
  12322. * @param connectionPoint defines the other connection point
  12323. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12324. * @returns the current connection point
  12325. */
  12326. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12327. /**
  12328. * Disconnect this point from one of his endpoint
  12329. * @param endpoint defines the other connection point
  12330. * @returns the current connection point
  12331. */
  12332. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12333. /**
  12334. * Serializes this point in a JSON representation
  12335. * @param isInput defines if the connection point is an input (default is true)
  12336. * @returns the serialized point object
  12337. */
  12338. serialize(isInput?: boolean): any;
  12339. /**
  12340. * Release resources
  12341. */
  12342. dispose(): void;
  12343. }
  12344. }
  12345. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  12346. /**
  12347. * Enum used to define the material modes
  12348. */
  12349. export enum NodeMaterialModes {
  12350. /** Regular material */
  12351. Material = 0,
  12352. /** For post process */
  12353. PostProcess = 1,
  12354. /** For particle system */
  12355. Particle = 2,
  12356. /** For procedural texture */
  12357. ProceduralTexture = 3
  12358. }
  12359. }
  12360. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  12361. /** @hidden */
  12362. export var helperFunctions: {
  12363. name: string;
  12364. shader: string;
  12365. };
  12366. }
  12367. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  12368. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12369. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12370. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12371. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12373. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12374. import { Effect } from "babylonjs/Materials/effect";
  12375. import { Mesh } from "babylonjs/Meshes/mesh";
  12376. import { Nullable } from "babylonjs/types";
  12377. import { Texture } from "babylonjs/Materials/Textures/texture";
  12378. import { Scene } from "babylonjs/scene";
  12379. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12380. /**
  12381. * Block used to read a texture from a sampler
  12382. */
  12383. export class TextureBlock extends NodeMaterialBlock {
  12384. private _defineName;
  12385. private _linearDefineName;
  12386. private _gammaDefineName;
  12387. private _tempTextureRead;
  12388. private _samplerName;
  12389. private _transformedUVName;
  12390. private _textureTransformName;
  12391. private _textureInfoName;
  12392. private _mainUVName;
  12393. private _mainUVDefineName;
  12394. private _fragmentOnly;
  12395. /**
  12396. * Gets or sets the texture associated with the node
  12397. */
  12398. texture: Nullable<Texture>;
  12399. /**
  12400. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12401. */
  12402. convertToGammaSpace: boolean;
  12403. /**
  12404. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12405. */
  12406. convertToLinearSpace: boolean;
  12407. /**
  12408. * Create a new TextureBlock
  12409. * @param name defines the block name
  12410. */
  12411. constructor(name: string, fragmentOnly?: boolean);
  12412. /**
  12413. * Gets the current class name
  12414. * @returns the class name
  12415. */
  12416. getClassName(): string;
  12417. /**
  12418. * Gets the uv input component
  12419. */
  12420. get uv(): NodeMaterialConnectionPoint;
  12421. /**
  12422. * Gets the rgba output component
  12423. */
  12424. get rgba(): NodeMaterialConnectionPoint;
  12425. /**
  12426. * Gets the rgb output component
  12427. */
  12428. get rgb(): NodeMaterialConnectionPoint;
  12429. /**
  12430. * Gets the r output component
  12431. */
  12432. get r(): NodeMaterialConnectionPoint;
  12433. /**
  12434. * Gets the g output component
  12435. */
  12436. get g(): NodeMaterialConnectionPoint;
  12437. /**
  12438. * Gets the b output component
  12439. */
  12440. get b(): NodeMaterialConnectionPoint;
  12441. /**
  12442. * Gets the a output component
  12443. */
  12444. get a(): NodeMaterialConnectionPoint;
  12445. get target(): NodeMaterialBlockTargets;
  12446. autoConfigure(material: NodeMaterial): void;
  12447. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12448. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12449. isReady(): boolean;
  12450. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12451. private get _isMixed();
  12452. private _injectVertexCode;
  12453. private _writeTextureRead;
  12454. private _writeOutput;
  12455. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12456. protected _dumpPropertiesCode(): string;
  12457. serialize(): any;
  12458. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12459. }
  12460. }
  12461. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  12462. /** @hidden */
  12463. export var reflectionFunction: {
  12464. name: string;
  12465. shader: string;
  12466. };
  12467. }
  12468. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  12469. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12470. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12471. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12472. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12474. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12475. import { Effect } from "babylonjs/Materials/effect";
  12476. import { Mesh } from "babylonjs/Meshes/mesh";
  12477. import { Nullable } from "babylonjs/types";
  12478. import { Scene } from "babylonjs/scene";
  12479. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  12480. /**
  12481. * Base block used to read a reflection texture from a sampler
  12482. */
  12483. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12484. /** @hidden */
  12485. _define3DName: string;
  12486. /** @hidden */
  12487. _defineCubicName: string;
  12488. /** @hidden */
  12489. _defineExplicitName: string;
  12490. /** @hidden */
  12491. _defineProjectionName: string;
  12492. /** @hidden */
  12493. _defineLocalCubicName: string;
  12494. /** @hidden */
  12495. _defineSphericalName: string;
  12496. /** @hidden */
  12497. _definePlanarName: string;
  12498. /** @hidden */
  12499. _defineEquirectangularName: string;
  12500. /** @hidden */
  12501. _defineMirroredEquirectangularFixedName: string;
  12502. /** @hidden */
  12503. _defineEquirectangularFixedName: string;
  12504. /** @hidden */
  12505. _defineSkyboxName: string;
  12506. /** @hidden */
  12507. _defineOppositeZ: string;
  12508. /** @hidden */
  12509. _cubeSamplerName: string;
  12510. /** @hidden */
  12511. _2DSamplerName: string;
  12512. protected _positionUVWName: string;
  12513. protected _directionWName: string;
  12514. protected _reflectionVectorName: string;
  12515. /** @hidden */
  12516. _reflectionCoordsName: string;
  12517. /** @hidden */
  12518. _reflectionMatrixName: string;
  12519. protected _reflectionColorName: string;
  12520. /**
  12521. * Gets or sets the texture associated with the node
  12522. */
  12523. texture: Nullable<BaseTexture>;
  12524. /**
  12525. * Create a new ReflectionTextureBaseBlock
  12526. * @param name defines the block name
  12527. */
  12528. constructor(name: string);
  12529. /**
  12530. * Gets the current class name
  12531. * @returns the class name
  12532. */
  12533. getClassName(): string;
  12534. /**
  12535. * Gets the world position input component
  12536. */
  12537. abstract get position(): NodeMaterialConnectionPoint;
  12538. /**
  12539. * Gets the world position input component
  12540. */
  12541. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12542. /**
  12543. * Gets the world normal input component
  12544. */
  12545. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12546. /**
  12547. * Gets the world input component
  12548. */
  12549. abstract get world(): NodeMaterialConnectionPoint;
  12550. /**
  12551. * Gets the camera (or eye) position component
  12552. */
  12553. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12554. /**
  12555. * Gets the view input component
  12556. */
  12557. abstract get view(): NodeMaterialConnectionPoint;
  12558. protected _getTexture(): Nullable<BaseTexture>;
  12559. autoConfigure(material: NodeMaterial): void;
  12560. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12561. isReady(): boolean;
  12562. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12563. /**
  12564. * Gets the code to inject in the vertex shader
  12565. * @param state current state of the node material building
  12566. * @returns the shader code
  12567. */
  12568. handleVertexSide(state: NodeMaterialBuildState): string;
  12569. /**
  12570. * Handles the inits for the fragment code path
  12571. * @param state node material build state
  12572. */
  12573. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12574. /**
  12575. * Generates the reflection coords code for the fragment code path
  12576. * @param worldNormalVarName name of the world normal variable
  12577. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12578. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12579. * @returns the shader code
  12580. */
  12581. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  12582. /**
  12583. * Generates the reflection color code for the fragment code path
  12584. * @param lodVarName name of the lod variable
  12585. * @param swizzleLookupTexture swizzle to use for the final color variable
  12586. * @returns the shader code
  12587. */
  12588. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  12589. /**
  12590. * Generates the code corresponding to the connected output points
  12591. * @param state node material build state
  12592. * @param varName name of the variable to output
  12593. * @returns the shader code
  12594. */
  12595. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  12596. protected _buildBlock(state: NodeMaterialBuildState): this;
  12597. protected _dumpPropertiesCode(): string;
  12598. serialize(): any;
  12599. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12600. }
  12601. }
  12602. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  12603. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12604. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12605. import { Nullable } from "babylonjs/types";
  12606. /**
  12607. * Defines a connection point to be used for points with a custom object type
  12608. */
  12609. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  12610. private _blockType;
  12611. private _blockName;
  12612. private _nameForCheking?;
  12613. /**
  12614. * Creates a new connection point
  12615. * @param name defines the connection point name
  12616. * @param ownerBlock defines the block hosting this connection point
  12617. * @param direction defines the direction of the connection point
  12618. */
  12619. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  12620. /**
  12621. * Gets a number indicating if the current point can be connected to another point
  12622. * @param connectionPoint defines the other connection point
  12623. * @returns a number defining the compatibility state
  12624. */
  12625. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12626. /**
  12627. * Creates a block suitable to be used as an input for this input point.
  12628. * If null is returned, a block based on the point type will be created.
  12629. * @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
  12630. */
  12631. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12632. }
  12633. }
  12634. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  12635. /**
  12636. * Enum defining the type of properties that can be edited in the property pages in the NME
  12637. */
  12638. export enum PropertyTypeForEdition {
  12639. /** property is a boolean */
  12640. Boolean = 0,
  12641. /** property is a float */
  12642. Float = 1,
  12643. /** property is a Vector2 */
  12644. Vector2 = 2,
  12645. /** property is a list of values */
  12646. List = 3
  12647. }
  12648. /**
  12649. * Interface that defines an option in a variable of type list
  12650. */
  12651. export interface IEditablePropertyListOption {
  12652. /** label of the option */
  12653. "label": string;
  12654. /** value of the option */
  12655. "value": number;
  12656. }
  12657. /**
  12658. * Interface that defines the options available for an editable property
  12659. */
  12660. export interface IEditablePropertyOption {
  12661. /** min value */
  12662. "min"?: number;
  12663. /** max value */
  12664. "max"?: number;
  12665. /** notifiers: indicates which actions to take when the property is changed */
  12666. "notifiers"?: {
  12667. /** the material should be rebuilt */
  12668. "rebuild"?: boolean;
  12669. /** the preview should be updated */
  12670. "update"?: boolean;
  12671. };
  12672. /** list of the options for a variable of type list */
  12673. "options"?: IEditablePropertyListOption[];
  12674. }
  12675. /**
  12676. * Interface that describes an editable property
  12677. */
  12678. export interface IPropertyDescriptionForEdition {
  12679. /** name of the property */
  12680. "propertyName": string;
  12681. /** display name of the property */
  12682. "displayName": string;
  12683. /** type of the property */
  12684. "type": PropertyTypeForEdition;
  12685. /** group of the property - all properties with the same group value will be displayed in a specific section */
  12686. "groupName": string;
  12687. /** options for the property */
  12688. "options": IEditablePropertyOption;
  12689. }
  12690. /**
  12691. * Decorator that flags a property in a node material block as being editable
  12692. */
  12693. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  12694. }
  12695. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  12696. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12697. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12698. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12700. import { Nullable } from "babylonjs/types";
  12701. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12702. import { Mesh } from "babylonjs/Meshes/mesh";
  12703. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12704. import { Effect } from "babylonjs/Materials/effect";
  12705. import { Scene } from "babylonjs/scene";
  12706. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12707. /**
  12708. * Block used to implement the refraction part of the sub surface module of the PBR material
  12709. */
  12710. export class RefractionBlock extends NodeMaterialBlock {
  12711. /** @hidden */
  12712. _define3DName: string;
  12713. /** @hidden */
  12714. _refractionMatrixName: string;
  12715. /** @hidden */
  12716. _defineLODRefractionAlpha: string;
  12717. /** @hidden */
  12718. _defineLinearSpecularRefraction: string;
  12719. /** @hidden */
  12720. _defineOppositeZ: string;
  12721. /** @hidden */
  12722. _cubeSamplerName: string;
  12723. /** @hidden */
  12724. _2DSamplerName: string;
  12725. /** @hidden */
  12726. _vRefractionMicrosurfaceInfosName: string;
  12727. /** @hidden */
  12728. _vRefractionInfosName: string;
  12729. private _scene;
  12730. /**
  12731. * The properties below are set by the main PBR block prior to calling methods of this class.
  12732. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  12733. * It's less burden on the user side in the editor part.
  12734. */
  12735. /** @hidden */
  12736. viewConnectionPoint: NodeMaterialConnectionPoint;
  12737. /** @hidden */
  12738. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  12739. /**
  12740. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  12741. * Materials half opaque for instance using refraction could benefit from this control.
  12742. */
  12743. linkRefractionWithTransparency: boolean;
  12744. /**
  12745. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  12746. */
  12747. invertRefractionY: boolean;
  12748. /**
  12749. * Gets or sets the texture associated with the node
  12750. */
  12751. texture: Nullable<BaseTexture>;
  12752. /**
  12753. * Create a new RefractionBlock
  12754. * @param name defines the block name
  12755. */
  12756. constructor(name: string);
  12757. /**
  12758. * Gets the current class name
  12759. * @returns the class name
  12760. */
  12761. getClassName(): string;
  12762. /**
  12763. * Gets the intensity input component
  12764. */
  12765. get intensity(): NodeMaterialConnectionPoint;
  12766. /**
  12767. * Gets the tint at distance input component
  12768. */
  12769. get tintAtDistance(): NodeMaterialConnectionPoint;
  12770. /**
  12771. * Gets the view input component
  12772. */
  12773. get view(): NodeMaterialConnectionPoint;
  12774. /**
  12775. * Gets the refraction object output component
  12776. */
  12777. get refraction(): NodeMaterialConnectionPoint;
  12778. /**
  12779. * Returns true if the block has a texture
  12780. */
  12781. get hasTexture(): boolean;
  12782. protected _getTexture(): Nullable<BaseTexture>;
  12783. autoConfigure(material: NodeMaterial): void;
  12784. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12785. isReady(): boolean;
  12786. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  12787. /**
  12788. * Gets the main code of the block (fragment side)
  12789. * @param state current state of the node material building
  12790. * @returns the shader code
  12791. */
  12792. getCode(state: NodeMaterialBuildState): string;
  12793. protected _buildBlock(state: NodeMaterialBuildState): this;
  12794. protected _dumpPropertiesCode(): string;
  12795. serialize(): any;
  12796. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12797. }
  12798. }
  12799. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  12800. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12801. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12802. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12803. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12805. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12806. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12807. import { Nullable } from "babylonjs/types";
  12808. import { Scene } from "babylonjs/scene";
  12809. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  12810. /**
  12811. * Base block used as input for post process
  12812. */
  12813. export class CurrentScreenBlock extends NodeMaterialBlock {
  12814. private _samplerName;
  12815. private _linearDefineName;
  12816. private _gammaDefineName;
  12817. private _mainUVName;
  12818. private _tempTextureRead;
  12819. /**
  12820. * Gets or sets the texture associated with the node
  12821. */
  12822. texture: Nullable<BaseTexture>;
  12823. /**
  12824. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12825. */
  12826. convertToGammaSpace: boolean;
  12827. /**
  12828. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12829. */
  12830. convertToLinearSpace: boolean;
  12831. /**
  12832. * Create a new CurrentScreenBlock
  12833. * @param name defines the block name
  12834. */
  12835. constructor(name: string);
  12836. /**
  12837. * Gets the current class name
  12838. * @returns the class name
  12839. */
  12840. getClassName(): string;
  12841. /**
  12842. * Gets the uv input component
  12843. */
  12844. get uv(): NodeMaterialConnectionPoint;
  12845. /**
  12846. * Gets the rgba output component
  12847. */
  12848. get rgba(): NodeMaterialConnectionPoint;
  12849. /**
  12850. * Gets the rgb output component
  12851. */
  12852. get rgb(): NodeMaterialConnectionPoint;
  12853. /**
  12854. * Gets the r output component
  12855. */
  12856. get r(): NodeMaterialConnectionPoint;
  12857. /**
  12858. * Gets the g output component
  12859. */
  12860. get g(): NodeMaterialConnectionPoint;
  12861. /**
  12862. * Gets the b output component
  12863. */
  12864. get b(): NodeMaterialConnectionPoint;
  12865. /**
  12866. * Gets the a output component
  12867. */
  12868. get a(): NodeMaterialConnectionPoint;
  12869. /**
  12870. * Initialize the block and prepare the context for build
  12871. * @param state defines the state that will be used for the build
  12872. */
  12873. initialize(state: NodeMaterialBuildState): void;
  12874. get target(): NodeMaterialBlockTargets;
  12875. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12876. isReady(): boolean;
  12877. private _injectVertexCode;
  12878. private _writeTextureRead;
  12879. private _writeOutput;
  12880. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12881. serialize(): any;
  12882. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12883. }
  12884. }
  12885. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  12886. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12887. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12888. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12890. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12891. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12892. import { Nullable } from "babylonjs/types";
  12893. import { Scene } from "babylonjs/scene";
  12894. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  12895. /**
  12896. * Base block used for the particle texture
  12897. */
  12898. export class ParticleTextureBlock extends NodeMaterialBlock {
  12899. private _samplerName;
  12900. private _linearDefineName;
  12901. private _gammaDefineName;
  12902. private _tempTextureRead;
  12903. /**
  12904. * Gets or sets the texture associated with the node
  12905. */
  12906. texture: Nullable<BaseTexture>;
  12907. /**
  12908. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12909. */
  12910. convertToGammaSpace: boolean;
  12911. /**
  12912. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12913. */
  12914. convertToLinearSpace: boolean;
  12915. /**
  12916. * Create a new ParticleTextureBlock
  12917. * @param name defines the block name
  12918. */
  12919. constructor(name: string);
  12920. /**
  12921. * Gets the current class name
  12922. * @returns the class name
  12923. */
  12924. getClassName(): string;
  12925. /**
  12926. * Gets the uv input component
  12927. */
  12928. get uv(): NodeMaterialConnectionPoint;
  12929. /**
  12930. * Gets the rgba output component
  12931. */
  12932. get rgba(): NodeMaterialConnectionPoint;
  12933. /**
  12934. * Gets the rgb output component
  12935. */
  12936. get rgb(): NodeMaterialConnectionPoint;
  12937. /**
  12938. * Gets the r output component
  12939. */
  12940. get r(): NodeMaterialConnectionPoint;
  12941. /**
  12942. * Gets the g output component
  12943. */
  12944. get g(): NodeMaterialConnectionPoint;
  12945. /**
  12946. * Gets the b output component
  12947. */
  12948. get b(): NodeMaterialConnectionPoint;
  12949. /**
  12950. * Gets the a output component
  12951. */
  12952. get a(): NodeMaterialConnectionPoint;
  12953. /**
  12954. * Initialize the block and prepare the context for build
  12955. * @param state defines the state that will be used for the build
  12956. */
  12957. initialize(state: NodeMaterialBuildState): void;
  12958. autoConfigure(material: NodeMaterial): void;
  12959. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12960. isReady(): boolean;
  12961. private _writeOutput;
  12962. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12963. serialize(): any;
  12964. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12965. }
  12966. }
  12967. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  12968. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12969. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12970. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  12971. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  12972. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  12973. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  12974. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  12975. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  12976. import { Scene } from "babylonjs/scene";
  12977. /**
  12978. * Class used to store shared data between 2 NodeMaterialBuildState
  12979. */
  12980. export class NodeMaterialBuildStateSharedData {
  12981. /**
  12982. * Gets the list of emitted varyings
  12983. */
  12984. temps: string[];
  12985. /**
  12986. * Gets the list of emitted varyings
  12987. */
  12988. varyings: string[];
  12989. /**
  12990. * Gets the varying declaration string
  12991. */
  12992. varyingDeclaration: string;
  12993. /**
  12994. * Input blocks
  12995. */
  12996. inputBlocks: InputBlock[];
  12997. /**
  12998. * Input blocks
  12999. */
  13000. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13001. /**
  13002. * Bindable blocks (Blocks that need to set data to the effect)
  13003. */
  13004. bindableBlocks: NodeMaterialBlock[];
  13005. /**
  13006. * List of blocks that can provide a compilation fallback
  13007. */
  13008. blocksWithFallbacks: NodeMaterialBlock[];
  13009. /**
  13010. * List of blocks that can provide a define update
  13011. */
  13012. blocksWithDefines: NodeMaterialBlock[];
  13013. /**
  13014. * List of blocks that can provide a repeatable content
  13015. */
  13016. repeatableContentBlocks: NodeMaterialBlock[];
  13017. /**
  13018. * List of blocks that can provide a dynamic list of uniforms
  13019. */
  13020. dynamicUniformBlocks: NodeMaterialBlock[];
  13021. /**
  13022. * List of blocks that can block the isReady function for the material
  13023. */
  13024. blockingBlocks: NodeMaterialBlock[];
  13025. /**
  13026. * Gets the list of animated inputs
  13027. */
  13028. animatedInputs: InputBlock[];
  13029. /**
  13030. * Build Id used to avoid multiple recompilations
  13031. */
  13032. buildId: number;
  13033. /** List of emitted variables */
  13034. variableNames: {
  13035. [key: string]: number;
  13036. };
  13037. /** List of emitted defines */
  13038. defineNames: {
  13039. [key: string]: number;
  13040. };
  13041. /** Should emit comments? */
  13042. emitComments: boolean;
  13043. /** Emit build activity */
  13044. verbose: boolean;
  13045. /** Gets or sets the hosting scene */
  13046. scene: Scene;
  13047. /**
  13048. * Gets the compilation hints emitted at compilation time
  13049. */
  13050. hints: {
  13051. needWorldViewMatrix: boolean;
  13052. needWorldViewProjectionMatrix: boolean;
  13053. needAlphaBlending: boolean;
  13054. needAlphaTesting: boolean;
  13055. };
  13056. /**
  13057. * List of compilation checks
  13058. */
  13059. checks: {
  13060. emitVertex: boolean;
  13061. emitFragment: boolean;
  13062. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13063. };
  13064. /**
  13065. * Is vertex program allowed to be empty?
  13066. */
  13067. allowEmptyVertexProgram: boolean;
  13068. /** Creates a new shared data */
  13069. constructor();
  13070. /**
  13071. * Emits console errors and exceptions if there is a failing check
  13072. */
  13073. emitErrors(): void;
  13074. }
  13075. }
  13076. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  13077. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  13078. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13079. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  13080. /**
  13081. * Class used to store node based material build state
  13082. */
  13083. export class NodeMaterialBuildState {
  13084. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13085. supportUniformBuffers: boolean;
  13086. /**
  13087. * Gets the list of emitted attributes
  13088. */
  13089. attributes: string[];
  13090. /**
  13091. * Gets the list of emitted uniforms
  13092. */
  13093. uniforms: string[];
  13094. /**
  13095. * Gets the list of emitted constants
  13096. */
  13097. constants: string[];
  13098. /**
  13099. * Gets the list of emitted samplers
  13100. */
  13101. samplers: string[];
  13102. /**
  13103. * Gets the list of emitted functions
  13104. */
  13105. functions: {
  13106. [key: string]: string;
  13107. };
  13108. /**
  13109. * Gets the list of emitted extensions
  13110. */
  13111. extensions: {
  13112. [key: string]: string;
  13113. };
  13114. /**
  13115. * Gets the target of the compilation state
  13116. */
  13117. target: NodeMaterialBlockTargets;
  13118. /**
  13119. * Gets the list of emitted counters
  13120. */
  13121. counters: {
  13122. [key: string]: number;
  13123. };
  13124. /**
  13125. * Shared data between multiple NodeMaterialBuildState instances
  13126. */
  13127. sharedData: NodeMaterialBuildStateSharedData;
  13128. /** @hidden */
  13129. _vertexState: NodeMaterialBuildState;
  13130. /** @hidden */
  13131. _attributeDeclaration: string;
  13132. /** @hidden */
  13133. _uniformDeclaration: string;
  13134. /** @hidden */
  13135. _constantDeclaration: string;
  13136. /** @hidden */
  13137. _samplerDeclaration: string;
  13138. /** @hidden */
  13139. _varyingTransfer: string;
  13140. /** @hidden */
  13141. _injectAtEnd: string;
  13142. private _repeatableContentAnchorIndex;
  13143. /** @hidden */
  13144. _builtCompilationString: string;
  13145. /**
  13146. * Gets the emitted compilation strings
  13147. */
  13148. compilationString: string;
  13149. /**
  13150. * Finalize the compilation strings
  13151. * @param state defines the current compilation state
  13152. */
  13153. finalize(state: NodeMaterialBuildState): void;
  13154. /** @hidden */
  13155. get _repeatableContentAnchor(): string;
  13156. /** @hidden */
  13157. _getFreeVariableName(prefix: string): string;
  13158. /** @hidden */
  13159. _getFreeDefineName(prefix: string): string;
  13160. /** @hidden */
  13161. _excludeVariableName(name: string): void;
  13162. /** @hidden */
  13163. _emit2DSampler(name: string): void;
  13164. /** @hidden */
  13165. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13166. /** @hidden */
  13167. _emitExtension(name: string, extension: string, define?: string): void;
  13168. /** @hidden */
  13169. _emitFunction(name: string, code: string, comments: string): void;
  13170. /** @hidden */
  13171. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13172. replaceStrings?: {
  13173. search: RegExp;
  13174. replace: string;
  13175. }[];
  13176. repeatKey?: string;
  13177. }): string;
  13178. /** @hidden */
  13179. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13180. repeatKey?: string;
  13181. removeAttributes?: boolean;
  13182. removeUniforms?: boolean;
  13183. removeVaryings?: boolean;
  13184. removeIfDef?: boolean;
  13185. replaceStrings?: {
  13186. search: RegExp;
  13187. replace: string;
  13188. }[];
  13189. }, storeKey?: string): void;
  13190. /** @hidden */
  13191. _registerTempVariable(name: string): boolean;
  13192. /** @hidden */
  13193. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13194. /** @hidden */
  13195. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13196. /** @hidden */
  13197. _emitFloat(value: number): string;
  13198. }
  13199. }
  13200. declare module "babylonjs/Misc/uniqueIdGenerator" {
  13201. /**
  13202. * Helper class used to generate session unique ID
  13203. */
  13204. export class UniqueIdGenerator {
  13205. private static _UniqueIdCounter;
  13206. /**
  13207. * Gets an unique (relatively to the current scene) Id
  13208. */
  13209. static get UniqueId(): number;
  13210. }
  13211. }
  13212. declare module "babylonjs/Materials/effectFallbacks" {
  13213. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  13214. import { Effect } from "babylonjs/Materials/effect";
  13215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13216. /**
  13217. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13218. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13219. */
  13220. export class EffectFallbacks implements IEffectFallbacks {
  13221. private _defines;
  13222. private _currentRank;
  13223. private _maxRank;
  13224. private _mesh;
  13225. /**
  13226. * Removes the fallback from the bound mesh.
  13227. */
  13228. unBindMesh(): void;
  13229. /**
  13230. * Adds a fallback on the specified property.
  13231. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13232. * @param define The name of the define in the shader
  13233. */
  13234. addFallback(rank: number, define: string): void;
  13235. /**
  13236. * Sets the mesh to use CPU skinning when needing to fallback.
  13237. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13238. * @param mesh The mesh to use the fallbacks.
  13239. */
  13240. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13241. /**
  13242. * Checks to see if more fallbacks are still availible.
  13243. */
  13244. get hasMoreFallbacks(): boolean;
  13245. /**
  13246. * Removes the defines that should be removed when falling back.
  13247. * @param currentDefines defines the current define statements for the shader.
  13248. * @param effect defines the current effect we try to compile
  13249. * @returns The resulting defines with defines of the current rank removed.
  13250. */
  13251. reduce(currentDefines: string, effect: Effect): string;
  13252. }
  13253. }
  13254. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  13255. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  13256. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13257. import { Nullable } from "babylonjs/types";
  13258. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13259. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13260. import { Effect } from "babylonjs/Materials/effect";
  13261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13262. import { Mesh } from "babylonjs/Meshes/mesh";
  13263. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13264. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13265. import { Scene } from "babylonjs/scene";
  13266. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  13267. /**
  13268. * Defines a block that can be used inside a node based material
  13269. */
  13270. export class NodeMaterialBlock {
  13271. private _buildId;
  13272. private _buildTarget;
  13273. private _target;
  13274. private _isFinalMerger;
  13275. private _isInput;
  13276. private _name;
  13277. protected _isUnique: boolean;
  13278. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13279. inputsAreExclusive: boolean;
  13280. /** @hidden */
  13281. _codeVariableName: string;
  13282. /** @hidden */
  13283. _inputs: NodeMaterialConnectionPoint[];
  13284. /** @hidden */
  13285. _outputs: NodeMaterialConnectionPoint[];
  13286. /** @hidden */
  13287. _preparationId: number;
  13288. /**
  13289. * Gets the name of the block
  13290. */
  13291. get name(): string;
  13292. /**
  13293. * Sets the name of the block. Will check if the name is valid.
  13294. */
  13295. set name(newName: string);
  13296. /**
  13297. * Gets or sets the unique id of the node
  13298. */
  13299. uniqueId: number;
  13300. /**
  13301. * Gets or sets the comments associated with this block
  13302. */
  13303. comments: string;
  13304. /**
  13305. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13306. */
  13307. get isUnique(): boolean;
  13308. /**
  13309. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13310. */
  13311. get isFinalMerger(): boolean;
  13312. /**
  13313. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13314. */
  13315. get isInput(): boolean;
  13316. /**
  13317. * Gets or sets the build Id
  13318. */
  13319. get buildId(): number;
  13320. set buildId(value: number);
  13321. /**
  13322. * Gets or sets the target of the block
  13323. */
  13324. get target(): NodeMaterialBlockTargets;
  13325. set target(value: NodeMaterialBlockTargets);
  13326. /**
  13327. * Gets the list of input points
  13328. */
  13329. get inputs(): NodeMaterialConnectionPoint[];
  13330. /** Gets the list of output points */
  13331. get outputs(): NodeMaterialConnectionPoint[];
  13332. /**
  13333. * Find an input by its name
  13334. * @param name defines the name of the input to look for
  13335. * @returns the input or null if not found
  13336. */
  13337. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13338. /**
  13339. * Find an output by its name
  13340. * @param name defines the name of the outputto look for
  13341. * @returns the output or null if not found
  13342. */
  13343. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13344. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13345. visibleInInspector: boolean;
  13346. /**
  13347. * Creates a new NodeMaterialBlock
  13348. * @param name defines the block name
  13349. * @param target defines the target of that block (Vertex by default)
  13350. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13351. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13352. */
  13353. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13354. /**
  13355. * Initialize the block and prepare the context for build
  13356. * @param state defines the state that will be used for the build
  13357. */
  13358. initialize(state: NodeMaterialBuildState): void;
  13359. /**
  13360. * Bind data to effect. Will only be called for blocks with isBindable === true
  13361. * @param effect defines the effect to bind data to
  13362. * @param nodeMaterial defines the hosting NodeMaterial
  13363. * @param mesh defines the mesh that will be rendered
  13364. * @param subMesh defines the submesh that will be rendered
  13365. */
  13366. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13367. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13368. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13369. protected _writeFloat(value: number): string;
  13370. /**
  13371. * Gets the current class name e.g. "NodeMaterialBlock"
  13372. * @returns the class name
  13373. */
  13374. getClassName(): string;
  13375. /**
  13376. * Register a new input. Must be called inside a block constructor
  13377. * @param name defines the connection point name
  13378. * @param type defines the connection point type
  13379. * @param isOptional defines a boolean indicating that this input can be omitted
  13380. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13381. * @param point an already created connection point. If not provided, create a new one
  13382. * @returns the current block
  13383. */
  13384. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13385. /**
  13386. * Register a new output. Must be called inside a block constructor
  13387. * @param name defines the connection point name
  13388. * @param type defines the connection point type
  13389. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13390. * @param point an already created connection point. If not provided, create a new one
  13391. * @returns the current block
  13392. */
  13393. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13394. /**
  13395. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13396. * @param forOutput defines an optional connection point to check compatibility with
  13397. * @returns the first available input or null
  13398. */
  13399. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13400. /**
  13401. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13402. * @param forBlock defines an optional block to check compatibility with
  13403. * @returns the first available input or null
  13404. */
  13405. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13406. /**
  13407. * Gets the sibling of the given output
  13408. * @param current defines the current output
  13409. * @returns the next output in the list or null
  13410. */
  13411. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13412. /**
  13413. * Connect current block with another block
  13414. * @param other defines the block to connect with
  13415. * @param options define the various options to help pick the right connections
  13416. * @returns the current block
  13417. */
  13418. connectTo(other: NodeMaterialBlock, options?: {
  13419. input?: string;
  13420. output?: string;
  13421. outputSwizzle?: string;
  13422. }): this | undefined;
  13423. protected _buildBlock(state: NodeMaterialBuildState): void;
  13424. /**
  13425. * Add uniforms, samplers and uniform buffers at compilation time
  13426. * @param state defines the state to update
  13427. * @param nodeMaterial defines the node material requesting the update
  13428. * @param defines defines the material defines to update
  13429. * @param uniformBuffers defines the list of uniform buffer names
  13430. */
  13431. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13432. /**
  13433. * Add potential fallbacks if shader compilation fails
  13434. * @param mesh defines the mesh to be rendered
  13435. * @param fallbacks defines the current prioritized list of fallbacks
  13436. */
  13437. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13438. /**
  13439. * Initialize defines for shader compilation
  13440. * @param mesh defines the mesh to be rendered
  13441. * @param nodeMaterial defines the node material requesting the update
  13442. * @param defines defines the material defines to update
  13443. * @param useInstances specifies that instances should be used
  13444. */
  13445. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13446. /**
  13447. * Update defines for shader compilation
  13448. * @param mesh defines the mesh to be rendered
  13449. * @param nodeMaterial defines the node material requesting the update
  13450. * @param defines defines the material defines to update
  13451. * @param useInstances specifies that instances should be used
  13452. * @param subMesh defines which submesh to render
  13453. */
  13454. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13455. /**
  13456. * Lets the block try to connect some inputs automatically
  13457. * @param material defines the hosting NodeMaterial
  13458. */
  13459. autoConfigure(material: NodeMaterial): void;
  13460. /**
  13461. * Function called when a block is declared as repeatable content generator
  13462. * @param vertexShaderState defines the current compilation state for the vertex shader
  13463. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13464. * @param mesh defines the mesh to be rendered
  13465. * @param defines defines the material defines to update
  13466. */
  13467. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13468. /**
  13469. * Checks if the block is ready
  13470. * @param mesh defines the mesh to be rendered
  13471. * @param nodeMaterial defines the node material requesting the update
  13472. * @param defines defines the material defines to update
  13473. * @param useInstances specifies that instances should be used
  13474. * @returns true if the block is ready
  13475. */
  13476. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13477. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13478. private _processBuild;
  13479. /**
  13480. * Validates the new name for the block node.
  13481. * @param newName the new name to be given to the node.
  13482. * @returns false if the name is a reserve word, else true.
  13483. */
  13484. validateBlockName(newName: string): boolean;
  13485. /**
  13486. * Compile the current node and generate the shader code
  13487. * @param state defines the current compilation state (uniforms, samplers, current string)
  13488. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13489. * @returns true if already built
  13490. */
  13491. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13492. protected _inputRename(name: string): string;
  13493. protected _outputRename(name: string): string;
  13494. protected _dumpPropertiesCode(): string;
  13495. /** @hidden */
  13496. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13497. /** @hidden */
  13498. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13499. /**
  13500. * Clone the current block to a new identical block
  13501. * @param scene defines the hosting scene
  13502. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13503. * @returns a copy of the current block
  13504. */
  13505. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13506. /**
  13507. * Serializes this block in a JSON representation
  13508. * @returns the serialized block object
  13509. */
  13510. serialize(): any;
  13511. /** @hidden */
  13512. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13513. private _deserializePortDisplayNamesAndExposedOnFrame;
  13514. /**
  13515. * Release resources
  13516. */
  13517. dispose(): void;
  13518. }
  13519. }
  13520. declare module "babylonjs/Materials/pushMaterial" {
  13521. import { Nullable } from "babylonjs/types";
  13522. import { Scene } from "babylonjs/scene";
  13523. import { Matrix } from "babylonjs/Maths/math.vector";
  13524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13525. import { Mesh } from "babylonjs/Meshes/mesh";
  13526. import { Material } from "babylonjs/Materials/material";
  13527. import { Effect } from "babylonjs/Materials/effect";
  13528. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13529. /**
  13530. * Base class of materials working in push mode in babylon JS
  13531. * @hidden
  13532. */
  13533. export class PushMaterial extends Material {
  13534. protected _activeEffect: Effect;
  13535. protected _normalMatrix: Matrix;
  13536. constructor(name: string, scene: Scene);
  13537. getEffect(): Effect;
  13538. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13539. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13540. /**
  13541. * Binds the given world matrix to the active effect
  13542. *
  13543. * @param world the matrix to bind
  13544. */
  13545. bindOnlyWorldMatrix(world: Matrix): void;
  13546. /**
  13547. * Binds the given normal matrix to the active effect
  13548. *
  13549. * @param normalMatrix the matrix to bind
  13550. */
  13551. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13552. bind(world: Matrix, mesh?: Mesh): void;
  13553. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13554. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13555. }
  13556. }
  13557. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  13558. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13559. /**
  13560. * Root class for all node material optimizers
  13561. */
  13562. export class NodeMaterialOptimizer {
  13563. /**
  13564. * Function used to optimize a NodeMaterial graph
  13565. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13566. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13567. */
  13568. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13569. }
  13570. }
  13571. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  13572. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13573. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13574. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13575. import { Scene } from "babylonjs/scene";
  13576. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13577. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13578. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13579. /**
  13580. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13581. */
  13582. export class TransformBlock extends NodeMaterialBlock {
  13583. /**
  13584. * Defines the value to use to complement W value to transform it to a Vector4
  13585. */
  13586. complementW: number;
  13587. /**
  13588. * Defines the value to use to complement z value to transform it to a Vector4
  13589. */
  13590. complementZ: number;
  13591. /**
  13592. * Creates a new TransformBlock
  13593. * @param name defines the block name
  13594. */
  13595. constructor(name: string);
  13596. /**
  13597. * Gets the current class name
  13598. * @returns the class name
  13599. */
  13600. getClassName(): string;
  13601. /**
  13602. * Gets the vector input
  13603. */
  13604. get vector(): NodeMaterialConnectionPoint;
  13605. /**
  13606. * Gets the output component
  13607. */
  13608. get output(): NodeMaterialConnectionPoint;
  13609. /**
  13610. * Gets the xyz output component
  13611. */
  13612. get xyz(): NodeMaterialConnectionPoint;
  13613. /**
  13614. * Gets the matrix transform input
  13615. */
  13616. get transform(): NodeMaterialConnectionPoint;
  13617. protected _buildBlock(state: NodeMaterialBuildState): this;
  13618. /**
  13619. * Update defines for shader compilation
  13620. * @param mesh defines the mesh to be rendered
  13621. * @param nodeMaterial defines the node material requesting the update
  13622. * @param defines defines the material defines to update
  13623. * @param useInstances specifies that instances should be used
  13624. * @param subMesh defines which submesh to render
  13625. */
  13626. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13627. serialize(): any;
  13628. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13629. protected _dumpPropertiesCode(): string;
  13630. }
  13631. }
  13632. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  13633. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13634. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13635. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13636. /**
  13637. * Block used to output the vertex position
  13638. */
  13639. export class VertexOutputBlock extends NodeMaterialBlock {
  13640. /**
  13641. * Creates a new VertexOutputBlock
  13642. * @param name defines the block name
  13643. */
  13644. constructor(name: string);
  13645. /**
  13646. * Gets the current class name
  13647. * @returns the class name
  13648. */
  13649. getClassName(): string;
  13650. /**
  13651. * Gets the vector input component
  13652. */
  13653. get vector(): NodeMaterialConnectionPoint;
  13654. protected _buildBlock(state: NodeMaterialBuildState): this;
  13655. }
  13656. }
  13657. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  13658. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13659. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13660. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13661. /**
  13662. * Block used to output the final color
  13663. */
  13664. export class FragmentOutputBlock extends NodeMaterialBlock {
  13665. /**
  13666. * Create a new FragmentOutputBlock
  13667. * @param name defines the block name
  13668. */
  13669. constructor(name: string);
  13670. /**
  13671. * Gets the current class name
  13672. * @returns the class name
  13673. */
  13674. getClassName(): string;
  13675. /**
  13676. * Gets the rgba input component
  13677. */
  13678. get rgba(): NodeMaterialConnectionPoint;
  13679. /**
  13680. * Gets the rgb input component
  13681. */
  13682. get rgb(): NodeMaterialConnectionPoint;
  13683. /**
  13684. * Gets the a input component
  13685. */
  13686. get a(): NodeMaterialConnectionPoint;
  13687. protected _buildBlock(state: NodeMaterialBuildState): this;
  13688. }
  13689. }
  13690. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  13691. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13692. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13693. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13694. /**
  13695. * Block used for the particle ramp gradient section
  13696. */
  13697. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  13698. /**
  13699. * Create a new ParticleRampGradientBlock
  13700. * @param name defines the block name
  13701. */
  13702. constructor(name: string);
  13703. /**
  13704. * Gets the current class name
  13705. * @returns the class name
  13706. */
  13707. getClassName(): string;
  13708. /**
  13709. * Gets the color input component
  13710. */
  13711. get color(): NodeMaterialConnectionPoint;
  13712. /**
  13713. * Gets the rampColor output component
  13714. */
  13715. get rampColor(): NodeMaterialConnectionPoint;
  13716. /**
  13717. * Initialize the block and prepare the context for build
  13718. * @param state defines the state that will be used for the build
  13719. */
  13720. initialize(state: NodeMaterialBuildState): void;
  13721. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13722. }
  13723. }
  13724. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  13725. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13726. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13727. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13728. /**
  13729. * Block used for the particle blend multiply section
  13730. */
  13731. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  13732. /**
  13733. * Create a new ParticleBlendMultiplyBlock
  13734. * @param name defines the block name
  13735. */
  13736. constructor(name: string);
  13737. /**
  13738. * Gets the current class name
  13739. * @returns the class name
  13740. */
  13741. getClassName(): string;
  13742. /**
  13743. * Gets the color input component
  13744. */
  13745. get color(): NodeMaterialConnectionPoint;
  13746. /**
  13747. * Gets the alphaTexture input component
  13748. */
  13749. get alphaTexture(): NodeMaterialConnectionPoint;
  13750. /**
  13751. * Gets the alphaColor input component
  13752. */
  13753. get alphaColor(): NodeMaterialConnectionPoint;
  13754. /**
  13755. * Gets the blendColor output component
  13756. */
  13757. get blendColor(): NodeMaterialConnectionPoint;
  13758. /**
  13759. * Initialize the block and prepare the context for build
  13760. * @param state defines the state that will be used for the build
  13761. */
  13762. initialize(state: NodeMaterialBuildState): void;
  13763. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13764. }
  13765. }
  13766. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  13767. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13768. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13769. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13770. /**
  13771. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  13772. */
  13773. export class VectorMergerBlock extends NodeMaterialBlock {
  13774. /**
  13775. * Create a new VectorMergerBlock
  13776. * @param name defines the block name
  13777. */
  13778. constructor(name: string);
  13779. /**
  13780. * Gets the current class name
  13781. * @returns the class name
  13782. */
  13783. getClassName(): string;
  13784. /**
  13785. * Gets the xyz component (input)
  13786. */
  13787. get xyzIn(): NodeMaterialConnectionPoint;
  13788. /**
  13789. * Gets the xy component (input)
  13790. */
  13791. get xyIn(): NodeMaterialConnectionPoint;
  13792. /**
  13793. * Gets the x component (input)
  13794. */
  13795. get x(): NodeMaterialConnectionPoint;
  13796. /**
  13797. * Gets the y component (input)
  13798. */
  13799. get y(): NodeMaterialConnectionPoint;
  13800. /**
  13801. * Gets the z component (input)
  13802. */
  13803. get z(): NodeMaterialConnectionPoint;
  13804. /**
  13805. * Gets the w component (input)
  13806. */
  13807. get w(): NodeMaterialConnectionPoint;
  13808. /**
  13809. * Gets the xyzw component (output)
  13810. */
  13811. get xyzw(): NodeMaterialConnectionPoint;
  13812. /**
  13813. * Gets the xyz component (output)
  13814. */
  13815. get xyzOut(): NodeMaterialConnectionPoint;
  13816. /**
  13817. * Gets the xy component (output)
  13818. */
  13819. get xyOut(): NodeMaterialConnectionPoint;
  13820. /**
  13821. * Gets the xy component (output)
  13822. * @deprecated Please use xyOut instead.
  13823. */
  13824. get xy(): NodeMaterialConnectionPoint;
  13825. /**
  13826. * Gets the xyz component (output)
  13827. * @deprecated Please use xyzOut instead.
  13828. */
  13829. get xyz(): NodeMaterialConnectionPoint;
  13830. protected _buildBlock(state: NodeMaterialBuildState): this;
  13831. }
  13832. }
  13833. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  13834. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13835. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13836. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13837. import { Vector2 } from "babylonjs/Maths/math.vector";
  13838. import { Scene } from "babylonjs/scene";
  13839. /**
  13840. * Block used to remap a float from a range to a new one
  13841. */
  13842. export class RemapBlock extends NodeMaterialBlock {
  13843. /**
  13844. * Gets or sets the source range
  13845. */
  13846. sourceRange: Vector2;
  13847. /**
  13848. * Gets or sets the target range
  13849. */
  13850. targetRange: Vector2;
  13851. /**
  13852. * Creates a new RemapBlock
  13853. * @param name defines the block name
  13854. */
  13855. constructor(name: string);
  13856. /**
  13857. * Gets the current class name
  13858. * @returns the class name
  13859. */
  13860. getClassName(): string;
  13861. /**
  13862. * Gets the input component
  13863. */
  13864. get input(): NodeMaterialConnectionPoint;
  13865. /**
  13866. * Gets the source min input component
  13867. */
  13868. get sourceMin(): NodeMaterialConnectionPoint;
  13869. /**
  13870. * Gets the source max input component
  13871. */
  13872. get sourceMax(): NodeMaterialConnectionPoint;
  13873. /**
  13874. * Gets the target min input component
  13875. */
  13876. get targetMin(): NodeMaterialConnectionPoint;
  13877. /**
  13878. * Gets the target max input component
  13879. */
  13880. get targetMax(): NodeMaterialConnectionPoint;
  13881. /**
  13882. * Gets the output component
  13883. */
  13884. get output(): NodeMaterialConnectionPoint;
  13885. protected _buildBlock(state: NodeMaterialBuildState): this;
  13886. protected _dumpPropertiesCode(): string;
  13887. serialize(): any;
  13888. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13889. }
  13890. }
  13891. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  13892. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13893. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13894. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13895. /**
  13896. * Block used to multiply 2 values
  13897. */
  13898. export class MultiplyBlock extends NodeMaterialBlock {
  13899. /**
  13900. * Creates a new MultiplyBlock
  13901. * @param name defines the block name
  13902. */
  13903. constructor(name: string);
  13904. /**
  13905. * Gets the current class name
  13906. * @returns the class name
  13907. */
  13908. getClassName(): string;
  13909. /**
  13910. * Gets the left operand input component
  13911. */
  13912. get left(): NodeMaterialConnectionPoint;
  13913. /**
  13914. * Gets the right operand input component
  13915. */
  13916. get right(): NodeMaterialConnectionPoint;
  13917. /**
  13918. * Gets the output component
  13919. */
  13920. get output(): NodeMaterialConnectionPoint;
  13921. protected _buildBlock(state: NodeMaterialBuildState): this;
  13922. }
  13923. }
  13924. declare module "babylonjs/Misc/gradients" {
  13925. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13926. /** Interface used by value gradients (color, factor, ...) */
  13927. export interface IValueGradient {
  13928. /**
  13929. * Gets or sets the gradient value (between 0 and 1)
  13930. */
  13931. gradient: number;
  13932. }
  13933. /** Class used to store color4 gradient */
  13934. export class ColorGradient implements IValueGradient {
  13935. /**
  13936. * Gets or sets the gradient value (between 0 and 1)
  13937. */
  13938. gradient: number;
  13939. /**
  13940. * Gets or sets first associated color
  13941. */
  13942. color1: Color4;
  13943. /**
  13944. * Gets or sets second associated color
  13945. */
  13946. color2?: Color4 | undefined;
  13947. /**
  13948. * Creates a new color4 gradient
  13949. * @param gradient gets or sets the gradient value (between 0 and 1)
  13950. * @param color1 gets or sets first associated color
  13951. * @param color2 gets or sets first second color
  13952. */
  13953. constructor(
  13954. /**
  13955. * Gets or sets the gradient value (between 0 and 1)
  13956. */
  13957. gradient: number,
  13958. /**
  13959. * Gets or sets first associated color
  13960. */
  13961. color1: Color4,
  13962. /**
  13963. * Gets or sets second associated color
  13964. */
  13965. color2?: Color4 | undefined);
  13966. /**
  13967. * Will get a color picked randomly between color1 and color2.
  13968. * If color2 is undefined then color1 will be used
  13969. * @param result defines the target Color4 to store the result in
  13970. */
  13971. getColorToRef(result: Color4): void;
  13972. }
  13973. /** Class used to store color 3 gradient */
  13974. export class Color3Gradient implements IValueGradient {
  13975. /**
  13976. * Gets or sets the gradient value (between 0 and 1)
  13977. */
  13978. gradient: number;
  13979. /**
  13980. * Gets or sets the associated color
  13981. */
  13982. color: Color3;
  13983. /**
  13984. * Creates a new color3 gradient
  13985. * @param gradient gets or sets the gradient value (between 0 and 1)
  13986. * @param color gets or sets associated color
  13987. */
  13988. constructor(
  13989. /**
  13990. * Gets or sets the gradient value (between 0 and 1)
  13991. */
  13992. gradient: number,
  13993. /**
  13994. * Gets or sets the associated color
  13995. */
  13996. color: Color3);
  13997. }
  13998. /** Class used to store factor gradient */
  13999. export class FactorGradient implements IValueGradient {
  14000. /**
  14001. * Gets or sets the gradient value (between 0 and 1)
  14002. */
  14003. gradient: number;
  14004. /**
  14005. * Gets or sets first associated factor
  14006. */
  14007. factor1: number;
  14008. /**
  14009. * Gets or sets second associated factor
  14010. */
  14011. factor2?: number | undefined;
  14012. /**
  14013. * Creates a new factor gradient
  14014. * @param gradient gets or sets the gradient value (between 0 and 1)
  14015. * @param factor1 gets or sets first associated factor
  14016. * @param factor2 gets or sets second associated factor
  14017. */
  14018. constructor(
  14019. /**
  14020. * Gets or sets the gradient value (between 0 and 1)
  14021. */
  14022. gradient: number,
  14023. /**
  14024. * Gets or sets first associated factor
  14025. */
  14026. factor1: number,
  14027. /**
  14028. * Gets or sets second associated factor
  14029. */
  14030. factor2?: number | undefined);
  14031. /**
  14032. * Will get a number picked randomly between factor1 and factor2.
  14033. * If factor2 is undefined then factor1 will be used
  14034. * @returns the picked number
  14035. */
  14036. getFactor(): number;
  14037. }
  14038. /**
  14039. * Helper used to simplify some generic gradient tasks
  14040. */
  14041. export class GradientHelper {
  14042. /**
  14043. * Gets the current gradient from an array of IValueGradient
  14044. * @param ratio defines the current ratio to get
  14045. * @param gradients defines the array of IValueGradient
  14046. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14047. */
  14048. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14049. }
  14050. }
  14051. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  14052. import { Nullable } from "babylonjs/types";
  14053. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14054. import { Scene } from "babylonjs/scene";
  14055. module "babylonjs/Engines/thinEngine" {
  14056. interface ThinEngine {
  14057. /**
  14058. * Creates a raw texture
  14059. * @param data defines the data to store in the texture
  14060. * @param width defines the width of the texture
  14061. * @param height defines the height of the texture
  14062. * @param format defines the format of the data
  14063. * @param generateMipMaps defines if the engine should generate the mip levels
  14064. * @param invertY defines if data must be stored with Y axis inverted
  14065. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14066. * @param compression defines the compression used (null by default)
  14067. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14068. * @returns the raw texture inside an InternalTexture
  14069. */
  14070. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14071. /**
  14072. * Update a raw texture
  14073. * @param texture defines the texture to update
  14074. * @param data defines the data to store in the texture
  14075. * @param format defines the format of the data
  14076. * @param invertY defines if data must be stored with Y axis inverted
  14077. */
  14078. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14079. /**
  14080. * Update a raw texture
  14081. * @param texture defines the texture to update
  14082. * @param data defines the data to store in the texture
  14083. * @param format defines the format of the data
  14084. * @param invertY defines if data must be stored with Y axis inverted
  14085. * @param compression defines the compression used (null by default)
  14086. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14087. */
  14088. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14089. /**
  14090. * Creates a new raw cube texture
  14091. * @param data defines the array of data to use to create each face
  14092. * @param size defines the size of the textures
  14093. * @param format defines the format of the data
  14094. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14095. * @param generateMipMaps defines if the engine should generate the mip levels
  14096. * @param invertY defines if data must be stored with Y axis inverted
  14097. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14098. * @param compression defines the compression used (null by default)
  14099. * @returns the cube texture as an InternalTexture
  14100. */
  14101. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14102. /**
  14103. * Update a raw cube texture
  14104. * @param texture defines the texture to udpdate
  14105. * @param data defines the data to store
  14106. * @param format defines the data format
  14107. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14108. * @param invertY defines if data must be stored with Y axis inverted
  14109. */
  14110. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14111. /**
  14112. * Update a raw cube texture
  14113. * @param texture defines the texture to udpdate
  14114. * @param data defines the data to store
  14115. * @param format defines the data format
  14116. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14117. * @param invertY defines if data must be stored with Y axis inverted
  14118. * @param compression defines the compression used (null by default)
  14119. */
  14120. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14121. /**
  14122. * Update a raw cube texture
  14123. * @param texture defines the texture to udpdate
  14124. * @param data defines the data to store
  14125. * @param format defines the data format
  14126. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14127. * @param invertY defines if data must be stored with Y axis inverted
  14128. * @param compression defines the compression used (null by default)
  14129. * @param level defines which level of the texture to update
  14130. */
  14131. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14132. /**
  14133. * Creates a new raw cube texture from a specified url
  14134. * @param url defines the url where the data is located
  14135. * @param scene defines the current scene
  14136. * @param size defines the size of the textures
  14137. * @param format defines the format of the data
  14138. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14139. * @param noMipmap defines if the engine should avoid generating the mip levels
  14140. * @param callback defines a callback used to extract texture data from loaded data
  14141. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14142. * @param onLoad defines a callback called when texture is loaded
  14143. * @param onError defines a callback called if there is an error
  14144. * @returns the cube texture as an InternalTexture
  14145. */
  14146. 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;
  14147. /**
  14148. * Creates a new raw cube texture from a specified url
  14149. * @param url defines the url where the data is located
  14150. * @param scene defines the current scene
  14151. * @param size defines the size of the textures
  14152. * @param format defines the format of the data
  14153. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14154. * @param noMipmap defines if the engine should avoid generating the mip levels
  14155. * @param callback defines a callback used to extract texture data from loaded data
  14156. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14157. * @param onLoad defines a callback called when texture is loaded
  14158. * @param onError defines a callback called if there is an error
  14159. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14160. * @param invertY defines if data must be stored with Y axis inverted
  14161. * @returns the cube texture as an InternalTexture
  14162. */
  14163. 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;
  14164. /**
  14165. * Creates a new raw 3D texture
  14166. * @param data defines the data used to create the texture
  14167. * @param width defines the width of the texture
  14168. * @param height defines the height of the texture
  14169. * @param depth defines the depth of the texture
  14170. * @param format defines the format of the texture
  14171. * @param generateMipMaps defines if the engine must generate mip levels
  14172. * @param invertY defines if data must be stored with Y axis inverted
  14173. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14174. * @param compression defines the compressed used (can be null)
  14175. * @param textureType defines the compressed used (can be null)
  14176. * @returns a new raw 3D texture (stored in an InternalTexture)
  14177. */
  14178. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14179. /**
  14180. * Update a raw 3D texture
  14181. * @param texture defines the texture to update
  14182. * @param data defines the data to store
  14183. * @param format defines the data format
  14184. * @param invertY defines if data must be stored with Y axis inverted
  14185. */
  14186. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14187. /**
  14188. * Update a raw 3D texture
  14189. * @param texture defines the texture to update
  14190. * @param data defines the data to store
  14191. * @param format defines the data format
  14192. * @param invertY defines if data must be stored with Y axis inverted
  14193. * @param compression defines the used compression (can be null)
  14194. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14195. */
  14196. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14197. /**
  14198. * Creates a new raw 2D array texture
  14199. * @param data defines the data used to create the texture
  14200. * @param width defines the width of the texture
  14201. * @param height defines the height of the texture
  14202. * @param depth defines the number of layers of the texture
  14203. * @param format defines the format of the texture
  14204. * @param generateMipMaps defines if the engine must generate mip levels
  14205. * @param invertY defines if data must be stored with Y axis inverted
  14206. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14207. * @param compression defines the compressed used (can be null)
  14208. * @param textureType defines the compressed used (can be null)
  14209. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14210. */
  14211. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14212. /**
  14213. * Update a raw 2D array texture
  14214. * @param texture defines the texture to update
  14215. * @param data defines the data to store
  14216. * @param format defines the data format
  14217. * @param invertY defines if data must be stored with Y axis inverted
  14218. */
  14219. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14220. /**
  14221. * Update a raw 2D array texture
  14222. * @param texture defines the texture to update
  14223. * @param data defines the data to store
  14224. * @param format defines the data format
  14225. * @param invertY defines if data must be stored with Y axis inverted
  14226. * @param compression defines the used compression (can be null)
  14227. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14228. */
  14229. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14230. }
  14231. }
  14232. }
  14233. declare module "babylonjs/Materials/Textures/rawTexture" {
  14234. import { Texture } from "babylonjs/Materials/Textures/texture";
  14235. import "babylonjs/Engines/Extensions/engine.rawTexture";
  14236. import { Nullable } from "babylonjs/types";
  14237. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  14238. import { Scene } from "babylonjs/scene";
  14239. /**
  14240. * Raw texture can help creating a texture directly from an array of data.
  14241. * This can be super useful if you either get the data from an uncompressed source or
  14242. * if you wish to create your texture pixel by pixel.
  14243. */
  14244. export class RawTexture extends Texture {
  14245. /**
  14246. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14247. */
  14248. format: number;
  14249. /**
  14250. * Instantiates a new RawTexture.
  14251. * Raw texture can help creating a texture directly from an array of data.
  14252. * This can be super useful if you either get the data from an uncompressed source or
  14253. * if you wish to create your texture pixel by pixel.
  14254. * @param data define the array of data to use to create the texture
  14255. * @param width define the width of the texture
  14256. * @param height define the height of the texture
  14257. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14258. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14259. * @param generateMipMaps define whether mip maps should be generated or not
  14260. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14261. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14262. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14263. */
  14264. constructor(data: ArrayBufferView, width: number, height: number,
  14265. /**
  14266. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14267. */
  14268. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14269. /**
  14270. * Updates the texture underlying data.
  14271. * @param data Define the new data of the texture
  14272. */
  14273. update(data: ArrayBufferView): void;
  14274. /**
  14275. * Creates a luminance texture from some data.
  14276. * @param data Define the texture data
  14277. * @param width Define the width of the texture
  14278. * @param height Define the height of the texture
  14279. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14280. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14281. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14282. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14283. * @returns the luminance texture
  14284. */
  14285. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14286. /**
  14287. * Creates a luminance alpha texture from some data.
  14288. * @param data Define the texture data
  14289. * @param width Define the width of the texture
  14290. * @param height Define the height of the texture
  14291. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14292. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14293. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14294. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14295. * @returns the luminance alpha texture
  14296. */
  14297. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14298. /**
  14299. * Creates an alpha texture from some data.
  14300. * @param data Define the texture data
  14301. * @param width Define the width of the texture
  14302. * @param height Define the height of the texture
  14303. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14304. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14305. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14306. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14307. * @returns the alpha texture
  14308. */
  14309. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14310. /**
  14311. * Creates a RGB texture from some data.
  14312. * @param data Define the texture data
  14313. * @param width Define the width of the texture
  14314. * @param height Define the height of the texture
  14315. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14316. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14317. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14318. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14319. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14320. * @returns the RGB alpha texture
  14321. */
  14322. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14323. /**
  14324. * Creates a RGBA texture from some data.
  14325. * @param data Define the texture data
  14326. * @param width Define the width of the texture
  14327. * @param height Define the height of the texture
  14328. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14329. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14330. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14331. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14332. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14333. * @returns the RGBA texture
  14334. */
  14335. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14336. /**
  14337. * Creates a R texture from some data.
  14338. * @param data Define the texture data
  14339. * @param width Define the width of the texture
  14340. * @param height Define the height of the texture
  14341. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14342. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14343. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14344. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14345. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14346. * @returns the R texture
  14347. */
  14348. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14349. }
  14350. }
  14351. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  14352. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  14353. import { IndicesArray, DataArray } from "babylonjs/types";
  14354. module "babylonjs/Engines/thinEngine" {
  14355. interface ThinEngine {
  14356. /**
  14357. * Update a dynamic index buffer
  14358. * @param indexBuffer defines the target index buffer
  14359. * @param indices defines the data to update
  14360. * @param offset defines the offset in the target index buffer where update should start
  14361. */
  14362. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14363. /**
  14364. * Updates a dynamic vertex buffer.
  14365. * @param vertexBuffer the vertex buffer to update
  14366. * @param data the data used to update the vertex buffer
  14367. * @param byteOffset the byte offset of the data
  14368. * @param byteLength the byte length of the data
  14369. */
  14370. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14371. }
  14372. }
  14373. }
  14374. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14375. import { Scene } from "babylonjs/scene";
  14376. import { ISceneComponent } from "babylonjs/sceneComponent";
  14377. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14378. module "babylonjs/abstractScene" {
  14379. interface AbstractScene {
  14380. /**
  14381. * The list of procedural textures added to the scene
  14382. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14383. */
  14384. proceduralTextures: Array<ProceduralTexture>;
  14385. }
  14386. }
  14387. /**
  14388. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14389. * in a given scene.
  14390. */
  14391. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14392. /**
  14393. * The component name helpfull to identify the component in the list of scene components.
  14394. */
  14395. readonly name: string;
  14396. /**
  14397. * The scene the component belongs to.
  14398. */
  14399. scene: Scene;
  14400. /**
  14401. * Creates a new instance of the component for the given scene
  14402. * @param scene Defines the scene to register the component in
  14403. */
  14404. constructor(scene: Scene);
  14405. /**
  14406. * Registers the component in a given scene
  14407. */
  14408. register(): void;
  14409. /**
  14410. * Rebuilds the elements related to this component in case of
  14411. * context lost for instance.
  14412. */
  14413. rebuild(): void;
  14414. /**
  14415. * Disposes the component and the associated ressources.
  14416. */
  14417. dispose(): void;
  14418. private _beforeClear;
  14419. }
  14420. }
  14421. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  14422. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14423. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14424. module "babylonjs/Engines/thinEngine" {
  14425. interface ThinEngine {
  14426. /**
  14427. * Creates a new render target cube texture
  14428. * @param size defines the size of the texture
  14429. * @param options defines the options used to create the texture
  14430. * @returns a new render target cube texture stored in an InternalTexture
  14431. */
  14432. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14433. }
  14434. }
  14435. }
  14436. declare module "babylonjs/Shaders/procedural.vertex" {
  14437. /** @hidden */
  14438. export var proceduralVertexShader: {
  14439. name: string;
  14440. shader: string;
  14441. };
  14442. }
  14443. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14444. import { Observable } from "babylonjs/Misc/observable";
  14445. import { Nullable } from "babylonjs/types";
  14446. import { Scene } from "babylonjs/scene";
  14447. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  14448. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  14449. import { Effect } from "babylonjs/Materials/effect";
  14450. import { Texture } from "babylonjs/Materials/Textures/texture";
  14451. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14452. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  14453. import "babylonjs/Shaders/procedural.vertex";
  14454. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  14455. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  14456. /**
  14457. * 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.
  14458. * This is the base class of any Procedural texture and contains most of the shareable code.
  14459. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14460. */
  14461. export class ProceduralTexture extends Texture {
  14462. /**
  14463. * Define if the texture is enabled or not (disabled texture will not render)
  14464. */
  14465. isEnabled: boolean;
  14466. /**
  14467. * Define if the texture must be cleared before rendering (default is true)
  14468. */
  14469. autoClear: boolean;
  14470. /**
  14471. * Callback called when the texture is generated
  14472. */
  14473. onGenerated: () => void;
  14474. /**
  14475. * Event raised when the texture is generated
  14476. */
  14477. onGeneratedObservable: Observable<ProceduralTexture>;
  14478. /**
  14479. * Event raised before the texture is generated
  14480. */
  14481. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14482. /**
  14483. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14484. */
  14485. nodeMaterialSource: Nullable<NodeMaterial>;
  14486. /** @hidden */
  14487. _generateMipMaps: boolean;
  14488. /** @hidden **/
  14489. _effect: Effect;
  14490. /** @hidden */
  14491. _textures: {
  14492. [key: string]: Texture;
  14493. };
  14494. /** @hidden */
  14495. protected _fallbackTexture: Nullable<Texture>;
  14496. private _size;
  14497. private _currentRefreshId;
  14498. private _frameId;
  14499. private _refreshRate;
  14500. private _vertexBuffers;
  14501. private _indexBuffer;
  14502. private _uniforms;
  14503. private _samplers;
  14504. private _fragment;
  14505. private _floats;
  14506. private _ints;
  14507. private _floatsArrays;
  14508. private _colors3;
  14509. private _colors4;
  14510. private _vectors2;
  14511. private _vectors3;
  14512. private _matrices;
  14513. private _fallbackTextureUsed;
  14514. private _fullEngine;
  14515. private _cachedDefines;
  14516. private _contentUpdateId;
  14517. private _contentData;
  14518. /**
  14519. * Instantiates a new procedural texture.
  14520. * 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.
  14521. * This is the base class of any Procedural texture and contains most of the shareable code.
  14522. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14523. * @param name Define the name of the texture
  14524. * @param size Define the size of the texture to create
  14525. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14526. * @param scene Define the scene the texture belongs to
  14527. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14528. * @param generateMipMaps Define if the texture should creates mip maps or not
  14529. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14530. * @param textureType The FBO internal texture type
  14531. */
  14532. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14533. /**
  14534. * The effect that is created when initializing the post process.
  14535. * @returns The created effect corresponding the the postprocess.
  14536. */
  14537. getEffect(): Effect;
  14538. /**
  14539. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14540. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14541. */
  14542. getContent(): Nullable<ArrayBufferView>;
  14543. private _createIndexBuffer;
  14544. /** @hidden */
  14545. _rebuild(): void;
  14546. /**
  14547. * Resets the texture in order to recreate its associated resources.
  14548. * This can be called in case of context loss
  14549. */
  14550. reset(): void;
  14551. protected _getDefines(): string;
  14552. /**
  14553. * Is the texture ready to be used ? (rendered at least once)
  14554. * @returns true if ready, otherwise, false.
  14555. */
  14556. isReady(): boolean;
  14557. /**
  14558. * Resets the refresh counter of the texture and start bak from scratch.
  14559. * Could be useful to regenerate the texture if it is setup to render only once.
  14560. */
  14561. resetRefreshCounter(): void;
  14562. /**
  14563. * Set the fragment shader to use in order to render the texture.
  14564. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14565. */
  14566. setFragment(fragment: any): void;
  14567. /**
  14568. * Define the refresh rate of the texture or the rendering frequency.
  14569. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14570. */
  14571. get refreshRate(): number;
  14572. set refreshRate(value: number);
  14573. /** @hidden */
  14574. _shouldRender(): boolean;
  14575. /**
  14576. * Get the size the texture is rendering at.
  14577. * @returns the size (on cube texture it is always squared)
  14578. */
  14579. getRenderSize(): RenderTargetTextureSize;
  14580. /**
  14581. * Resize the texture to new value.
  14582. * @param size Define the new size the texture should have
  14583. * @param generateMipMaps Define whether the new texture should create mip maps
  14584. */
  14585. resize(size: number, generateMipMaps: boolean): void;
  14586. private _checkUniform;
  14587. /**
  14588. * Set a texture in the shader program used to render.
  14589. * @param name Define the name of the uniform samplers as defined in the shader
  14590. * @param texture Define the texture to bind to this sampler
  14591. * @return the texture itself allowing "fluent" like uniform updates
  14592. */
  14593. setTexture(name: string, texture: Texture): ProceduralTexture;
  14594. /**
  14595. * Set a float in the shader.
  14596. * @param name Define the name of the uniform as defined in the shader
  14597. * @param value Define the value to give to the uniform
  14598. * @return the texture itself allowing "fluent" like uniform updates
  14599. */
  14600. setFloat(name: string, value: number): ProceduralTexture;
  14601. /**
  14602. * Set a int in the shader.
  14603. * @param name Define the name of the uniform as defined in the shader
  14604. * @param value Define the value to give to the uniform
  14605. * @return the texture itself allowing "fluent" like uniform updates
  14606. */
  14607. setInt(name: string, value: number): ProceduralTexture;
  14608. /**
  14609. * Set an array of floats in the shader.
  14610. * @param name Define the name of the uniform as defined in the shader
  14611. * @param value Define the value to give to the uniform
  14612. * @return the texture itself allowing "fluent" like uniform updates
  14613. */
  14614. setFloats(name: string, value: number[]): ProceduralTexture;
  14615. /**
  14616. * Set a vec3 in the shader from a Color3.
  14617. * @param name Define the name of the uniform as defined in the shader
  14618. * @param value Define the value to give to the uniform
  14619. * @return the texture itself allowing "fluent" like uniform updates
  14620. */
  14621. setColor3(name: string, value: Color3): ProceduralTexture;
  14622. /**
  14623. * Set a vec4 in the shader from a Color4.
  14624. * @param name Define the name of the uniform as defined in the shader
  14625. * @param value Define the value to give to the uniform
  14626. * @return the texture itself allowing "fluent" like uniform updates
  14627. */
  14628. setColor4(name: string, value: Color4): ProceduralTexture;
  14629. /**
  14630. * Set a vec2 in the shader from a Vector2.
  14631. * @param name Define the name of the uniform as defined in the shader
  14632. * @param value Define the value to give to the uniform
  14633. * @return the texture itself allowing "fluent" like uniform updates
  14634. */
  14635. setVector2(name: string, value: Vector2): ProceduralTexture;
  14636. /**
  14637. * Set a vec3 in the shader from a Vector3.
  14638. * @param name Define the name of the uniform as defined in the shader
  14639. * @param value Define the value to give to the uniform
  14640. * @return the texture itself allowing "fluent" like uniform updates
  14641. */
  14642. setVector3(name: string, value: Vector3): ProceduralTexture;
  14643. /**
  14644. * Set a mat4 in the shader from a MAtrix.
  14645. * @param name Define the name of the uniform as defined in the shader
  14646. * @param value Define the value to give to the uniform
  14647. * @return the texture itself allowing "fluent" like uniform updates
  14648. */
  14649. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14650. /**
  14651. * Render the texture to its associated render target.
  14652. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14653. */
  14654. render(useCameraPostProcess?: boolean): void;
  14655. /**
  14656. * Clone the texture.
  14657. * @returns the cloned texture
  14658. */
  14659. clone(): ProceduralTexture;
  14660. /**
  14661. * Dispose the texture and release its asoociated resources.
  14662. */
  14663. dispose(): void;
  14664. }
  14665. }
  14666. declare module "babylonjs/Particles/baseParticleSystem" {
  14667. import { Nullable } from "babylonjs/types";
  14668. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14669. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14670. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14671. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  14672. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14673. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14674. import { Color4 } from "babylonjs/Maths/math.color";
  14675. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  14676. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  14677. import { Animation } from "babylonjs/Animations/animation";
  14678. import { Scene } from "babylonjs/scene";
  14679. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14680. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14681. /**
  14682. * This represents the base class for particle system in Babylon.
  14683. * 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.
  14684. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14685. * @example https://doc.babylonjs.com/babylon101/particles
  14686. */
  14687. export class BaseParticleSystem {
  14688. /**
  14689. * Source color is added to the destination color without alpha affecting the result
  14690. */
  14691. static BLENDMODE_ONEONE: number;
  14692. /**
  14693. * Blend current color and particle color using particle’s alpha
  14694. */
  14695. static BLENDMODE_STANDARD: number;
  14696. /**
  14697. * Add current color and particle color multiplied by particle’s alpha
  14698. */
  14699. static BLENDMODE_ADD: number;
  14700. /**
  14701. * Multiply current color with particle color
  14702. */
  14703. static BLENDMODE_MULTIPLY: number;
  14704. /**
  14705. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14706. */
  14707. static BLENDMODE_MULTIPLYADD: number;
  14708. /**
  14709. * List of animations used by the particle system.
  14710. */
  14711. animations: Animation[];
  14712. /**
  14713. * Gets or sets the unique id of the particle system
  14714. */
  14715. uniqueId: number;
  14716. /**
  14717. * The id of the Particle system.
  14718. */
  14719. id: string;
  14720. /**
  14721. * The friendly name of the Particle system.
  14722. */
  14723. name: string;
  14724. /**
  14725. * Snippet ID if the particle system was created from the snippet server
  14726. */
  14727. snippetId: string;
  14728. /**
  14729. * The rendering group used by the Particle system to chose when to render.
  14730. */
  14731. renderingGroupId: number;
  14732. /**
  14733. * The emitter represents the Mesh or position we are attaching the particle system to.
  14734. */
  14735. emitter: Nullable<AbstractMesh | Vector3>;
  14736. /**
  14737. * The maximum number of particles to emit per frame
  14738. */
  14739. emitRate: number;
  14740. /**
  14741. * If you want to launch only a few particles at once, that can be done, as well.
  14742. */
  14743. manualEmitCount: number;
  14744. /**
  14745. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14746. */
  14747. updateSpeed: number;
  14748. /**
  14749. * The amount of time the particle system is running (depends of the overall update speed).
  14750. */
  14751. targetStopDuration: number;
  14752. /**
  14753. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14754. */
  14755. disposeOnStop: boolean;
  14756. /**
  14757. * Minimum power of emitting particles.
  14758. */
  14759. minEmitPower: number;
  14760. /**
  14761. * Maximum power of emitting particles.
  14762. */
  14763. maxEmitPower: number;
  14764. /**
  14765. * Minimum life time of emitting particles.
  14766. */
  14767. minLifeTime: number;
  14768. /**
  14769. * Maximum life time of emitting particles.
  14770. */
  14771. maxLifeTime: number;
  14772. /**
  14773. * Minimum Size of emitting particles.
  14774. */
  14775. minSize: number;
  14776. /**
  14777. * Maximum Size of emitting particles.
  14778. */
  14779. maxSize: number;
  14780. /**
  14781. * Minimum scale of emitting particles on X axis.
  14782. */
  14783. minScaleX: number;
  14784. /**
  14785. * Maximum scale of emitting particles on X axis.
  14786. */
  14787. maxScaleX: number;
  14788. /**
  14789. * Minimum scale of emitting particles on Y axis.
  14790. */
  14791. minScaleY: number;
  14792. /**
  14793. * Maximum scale of emitting particles on Y axis.
  14794. */
  14795. maxScaleY: number;
  14796. /**
  14797. * Gets or sets the minimal initial rotation in radians.
  14798. */
  14799. minInitialRotation: number;
  14800. /**
  14801. * Gets or sets the maximal initial rotation in radians.
  14802. */
  14803. maxInitialRotation: number;
  14804. /**
  14805. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14806. */
  14807. minAngularSpeed: number;
  14808. /**
  14809. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14810. */
  14811. maxAngularSpeed: number;
  14812. /**
  14813. * The texture used to render each particle. (this can be a spritesheet)
  14814. */
  14815. particleTexture: Nullable<BaseTexture>;
  14816. /**
  14817. * The layer mask we are rendering the particles through.
  14818. */
  14819. layerMask: number;
  14820. /**
  14821. * This can help using your own shader to render the particle system.
  14822. * The according effect will be created
  14823. */
  14824. customShader: any;
  14825. /**
  14826. * By default particle system starts as soon as they are created. This prevents the
  14827. * automatic start to happen and let you decide when to start emitting particles.
  14828. */
  14829. preventAutoStart: boolean;
  14830. private _noiseTexture;
  14831. /**
  14832. * Gets or sets a texture used to add random noise to particle positions
  14833. */
  14834. get noiseTexture(): Nullable<ProceduralTexture>;
  14835. set noiseTexture(value: Nullable<ProceduralTexture>);
  14836. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14837. noiseStrength: Vector3;
  14838. /**
  14839. * Callback triggered when the particle animation is ending.
  14840. */
  14841. onAnimationEnd: Nullable<() => void>;
  14842. /**
  14843. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14844. */
  14845. blendMode: number;
  14846. /**
  14847. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14848. * to override the particles.
  14849. */
  14850. forceDepthWrite: boolean;
  14851. /** 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 */
  14852. preWarmCycles: number;
  14853. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14854. preWarmStepOffset: number;
  14855. /**
  14856. * 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)
  14857. */
  14858. spriteCellChangeSpeed: number;
  14859. /**
  14860. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14861. */
  14862. startSpriteCellID: number;
  14863. /**
  14864. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14865. */
  14866. endSpriteCellID: number;
  14867. /**
  14868. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14869. */
  14870. spriteCellWidth: number;
  14871. /**
  14872. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14873. */
  14874. spriteCellHeight: number;
  14875. /**
  14876. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14877. */
  14878. spriteRandomStartCell: boolean;
  14879. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14880. translationPivot: Vector2;
  14881. /** @hidden */
  14882. protected _isAnimationSheetEnabled: boolean;
  14883. /**
  14884. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14885. */
  14886. beginAnimationOnStart: boolean;
  14887. /**
  14888. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14889. */
  14890. beginAnimationFrom: number;
  14891. /**
  14892. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14893. */
  14894. beginAnimationTo: number;
  14895. /**
  14896. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14897. */
  14898. beginAnimationLoop: boolean;
  14899. /**
  14900. * Gets or sets a world offset applied to all particles
  14901. */
  14902. worldOffset: Vector3;
  14903. /**
  14904. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14905. */
  14906. get isAnimationSheetEnabled(): boolean;
  14907. set isAnimationSheetEnabled(value: boolean);
  14908. /**
  14909. * Get hosting scene
  14910. * @returns the scene
  14911. */
  14912. getScene(): Nullable<Scene>;
  14913. /**
  14914. * You can use gravity if you want to give an orientation to your particles.
  14915. */
  14916. gravity: Vector3;
  14917. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14918. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14919. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14920. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14921. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14922. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14923. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14924. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14925. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14926. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14927. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14928. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14929. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14930. /**
  14931. * Defines the delay in milliseconds before starting the system (0 by default)
  14932. */
  14933. startDelay: number;
  14934. /**
  14935. * Gets the current list of drag gradients.
  14936. * You must use addDragGradient and removeDragGradient to udpate this list
  14937. * @returns the list of drag gradients
  14938. */
  14939. getDragGradients(): Nullable<Array<FactorGradient>>;
  14940. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14941. limitVelocityDamping: number;
  14942. /**
  14943. * Gets the current list of limit velocity gradients.
  14944. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14945. * @returns the list of limit velocity gradients
  14946. */
  14947. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14948. /**
  14949. * Gets the current list of color gradients.
  14950. * You must use addColorGradient and removeColorGradient to udpate this list
  14951. * @returns the list of color gradients
  14952. */
  14953. getColorGradients(): Nullable<Array<ColorGradient>>;
  14954. /**
  14955. * Gets the current list of size gradients.
  14956. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14957. * @returns the list of size gradients
  14958. */
  14959. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14960. /**
  14961. * Gets the current list of color remap gradients.
  14962. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14963. * @returns the list of color remap gradients
  14964. */
  14965. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14966. /**
  14967. * Gets the current list of alpha remap gradients.
  14968. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14969. * @returns the list of alpha remap gradients
  14970. */
  14971. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14972. /**
  14973. * Gets the current list of life time gradients.
  14974. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14975. * @returns the list of life time gradients
  14976. */
  14977. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14978. /**
  14979. * Gets the current list of angular speed gradients.
  14980. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14981. * @returns the list of angular speed gradients
  14982. */
  14983. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14984. /**
  14985. * Gets the current list of velocity gradients.
  14986. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14987. * @returns the list of velocity gradients
  14988. */
  14989. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14990. /**
  14991. * Gets the current list of start size gradients.
  14992. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14993. * @returns the list of start size gradients
  14994. */
  14995. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14996. /**
  14997. * Gets the current list of emit rate gradients.
  14998. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14999. * @returns the list of emit rate gradients
  15000. */
  15001. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15002. /**
  15003. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15004. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15005. */
  15006. get direction1(): Vector3;
  15007. set direction1(value: Vector3);
  15008. /**
  15009. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15010. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15011. */
  15012. get direction2(): Vector3;
  15013. set direction2(value: Vector3);
  15014. /**
  15015. * 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.
  15016. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15017. */
  15018. get minEmitBox(): Vector3;
  15019. set minEmitBox(value: Vector3);
  15020. /**
  15021. * 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.
  15022. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15023. */
  15024. get maxEmitBox(): Vector3;
  15025. set maxEmitBox(value: Vector3);
  15026. /**
  15027. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15028. */
  15029. color1: Color4;
  15030. /**
  15031. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15032. */
  15033. color2: Color4;
  15034. /**
  15035. * Color the particle will have at the end of its lifetime
  15036. */
  15037. colorDead: Color4;
  15038. /**
  15039. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15040. */
  15041. textureMask: Color4;
  15042. /**
  15043. * The particle emitter type defines the emitter used by the particle system.
  15044. * It can be for example box, sphere, or cone...
  15045. */
  15046. particleEmitterType: IParticleEmitterType;
  15047. /** @hidden */
  15048. _isSubEmitter: boolean;
  15049. /**
  15050. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15051. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15052. */
  15053. billboardMode: number;
  15054. protected _isBillboardBased: boolean;
  15055. /**
  15056. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15057. */
  15058. get isBillboardBased(): boolean;
  15059. set isBillboardBased(value: boolean);
  15060. /**
  15061. * The scene the particle system belongs to.
  15062. */
  15063. protected _scene: Nullable<Scene>;
  15064. /**
  15065. * The engine the particle system belongs to.
  15066. */
  15067. protected _engine: ThinEngine;
  15068. /**
  15069. * Local cache of defines for image processing.
  15070. */
  15071. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15072. /**
  15073. * Default configuration related to image processing available in the standard Material.
  15074. */
  15075. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15076. /**
  15077. * Gets the image processing configuration used either in this material.
  15078. */
  15079. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15080. /**
  15081. * Sets the Default image processing configuration used either in the this material.
  15082. *
  15083. * If sets to null, the scene one is in use.
  15084. */
  15085. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15086. /**
  15087. * Attaches a new image processing configuration to the Standard Material.
  15088. * @param configuration
  15089. */
  15090. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15091. /** @hidden */
  15092. protected _reset(): void;
  15093. /** @hidden */
  15094. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15095. /**
  15096. * Instantiates a particle system.
  15097. * 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.
  15098. * @param name The name of the particle system
  15099. */
  15100. constructor(name: string);
  15101. /**
  15102. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15103. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15104. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15105. * @returns the emitter
  15106. */
  15107. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15108. /**
  15109. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15110. * @param radius The radius of the hemisphere to emit from
  15111. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15112. * @returns the emitter
  15113. */
  15114. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15115. /**
  15116. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15117. * @param radius The radius of the sphere to emit from
  15118. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15119. * @returns the emitter
  15120. */
  15121. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15122. /**
  15123. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15124. * @param radius The radius of the sphere to emit from
  15125. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15126. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15127. * @returns the emitter
  15128. */
  15129. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15130. /**
  15131. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15132. * @param radius The radius of the emission cylinder
  15133. * @param height The height of the emission cylinder
  15134. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15135. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15136. * @returns the emitter
  15137. */
  15138. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15139. /**
  15140. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15141. * @param radius The radius of the cylinder to emit from
  15142. * @param height The height of the emission cylinder
  15143. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15144. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15145. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15146. * @returns the emitter
  15147. */
  15148. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15149. /**
  15150. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15151. * @param radius The radius of the cone to emit from
  15152. * @param angle The base angle of the cone
  15153. * @returns the emitter
  15154. */
  15155. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15156. /**
  15157. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15158. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15159. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15160. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15161. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15162. * @returns the emitter
  15163. */
  15164. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15165. }
  15166. }
  15167. declare module "babylonjs/Particles/subEmitter" {
  15168. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15169. import { Scene } from "babylonjs/scene";
  15170. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15171. /**
  15172. * Type of sub emitter
  15173. */
  15174. export enum SubEmitterType {
  15175. /**
  15176. * Attached to the particle over it's lifetime
  15177. */
  15178. ATTACHED = 0,
  15179. /**
  15180. * Created when the particle dies
  15181. */
  15182. END = 1
  15183. }
  15184. /**
  15185. * Sub emitter class used to emit particles from an existing particle
  15186. */
  15187. export class SubEmitter {
  15188. /**
  15189. * the particle system to be used by the sub emitter
  15190. */
  15191. particleSystem: ParticleSystem;
  15192. /**
  15193. * Type of the submitter (Default: END)
  15194. */
  15195. type: SubEmitterType;
  15196. /**
  15197. * 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)
  15198. * Note: This only is supported when using an emitter of type Mesh
  15199. */
  15200. inheritDirection: boolean;
  15201. /**
  15202. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15203. */
  15204. inheritedVelocityAmount: number;
  15205. /**
  15206. * Creates a sub emitter
  15207. * @param particleSystem the particle system to be used by the sub emitter
  15208. */
  15209. constructor(
  15210. /**
  15211. * the particle system to be used by the sub emitter
  15212. */
  15213. particleSystem: ParticleSystem);
  15214. /**
  15215. * Clones the sub emitter
  15216. * @returns the cloned sub emitter
  15217. */
  15218. clone(): SubEmitter;
  15219. /**
  15220. * Serialize current object to a JSON object
  15221. * @returns the serialized object
  15222. */
  15223. serialize(): any;
  15224. /** @hidden */
  15225. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15226. /**
  15227. * Creates a new SubEmitter from a serialized JSON version
  15228. * @param serializationObject defines the JSON object to read from
  15229. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15230. * @param rootUrl defines the rootUrl for data loading
  15231. * @returns a new SubEmitter
  15232. */
  15233. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15234. /** Release associated resources */
  15235. dispose(): void;
  15236. }
  15237. }
  15238. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15239. /** @hidden */
  15240. export var clipPlaneFragmentDeclaration: {
  15241. name: string;
  15242. shader: string;
  15243. };
  15244. }
  15245. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15246. /** @hidden */
  15247. export var imageProcessingDeclaration: {
  15248. name: string;
  15249. shader: string;
  15250. };
  15251. }
  15252. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15253. /** @hidden */
  15254. export var imageProcessingFunctions: {
  15255. name: string;
  15256. shader: string;
  15257. };
  15258. }
  15259. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15260. /** @hidden */
  15261. export var clipPlaneFragment: {
  15262. name: string;
  15263. shader: string;
  15264. };
  15265. }
  15266. declare module "babylonjs/Shaders/particles.fragment" {
  15267. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15268. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15269. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15270. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15271. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15272. /** @hidden */
  15273. export var particlesPixelShader: {
  15274. name: string;
  15275. shader: string;
  15276. };
  15277. }
  15278. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15279. /** @hidden */
  15280. export var clipPlaneVertexDeclaration: {
  15281. name: string;
  15282. shader: string;
  15283. };
  15284. }
  15285. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15286. /** @hidden */
  15287. export var clipPlaneVertex: {
  15288. name: string;
  15289. shader: string;
  15290. };
  15291. }
  15292. declare module "babylonjs/Shaders/particles.vertex" {
  15293. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15294. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15295. /** @hidden */
  15296. export var particlesVertexShader: {
  15297. name: string;
  15298. shader: string;
  15299. };
  15300. }
  15301. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  15302. import { Nullable } from "babylonjs/types";
  15303. import { Plane } from "babylonjs/Maths/math";
  15304. /**
  15305. * Interface used to define entities containing multiple clip planes
  15306. */
  15307. export interface IClipPlanesHolder {
  15308. /**
  15309. * Gets or sets the active clipplane 1
  15310. */
  15311. clipPlane: Nullable<Plane>;
  15312. /**
  15313. * Gets or sets the active clipplane 2
  15314. */
  15315. clipPlane2: Nullable<Plane>;
  15316. /**
  15317. * Gets or sets the active clipplane 3
  15318. */
  15319. clipPlane3: Nullable<Plane>;
  15320. /**
  15321. * Gets or sets the active clipplane 4
  15322. */
  15323. clipPlane4: Nullable<Plane>;
  15324. /**
  15325. * Gets or sets the active clipplane 5
  15326. */
  15327. clipPlane5: Nullable<Plane>;
  15328. /**
  15329. * Gets or sets the active clipplane 6
  15330. */
  15331. clipPlane6: Nullable<Plane>;
  15332. }
  15333. }
  15334. declare module "babylonjs/Materials/thinMaterialHelper" {
  15335. import { Effect } from "babylonjs/Materials/effect";
  15336. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  15337. /**
  15338. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  15339. *
  15340. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  15341. *
  15342. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  15343. */
  15344. export class ThinMaterialHelper {
  15345. /**
  15346. * Binds the clip plane information from the holder to the effect.
  15347. * @param effect The effect we are binding the data to
  15348. * @param holder The entity containing the clip plane information
  15349. */
  15350. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  15351. }
  15352. }
  15353. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  15354. module "babylonjs/Engines/thinEngine" {
  15355. interface ThinEngine {
  15356. /**
  15357. * Sets alpha constants used by some alpha blending modes
  15358. * @param r defines the red component
  15359. * @param g defines the green component
  15360. * @param b defines the blue component
  15361. * @param a defines the alpha component
  15362. */
  15363. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  15364. /**
  15365. * Sets the current alpha mode
  15366. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  15367. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  15368. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15369. */
  15370. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  15371. /**
  15372. * Gets the current alpha mode
  15373. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15374. * @returns the current alpha mode
  15375. */
  15376. getAlphaMode(): number;
  15377. /**
  15378. * Sets the current alpha equation
  15379. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15380. */
  15381. setAlphaEquation(equation: number): void;
  15382. /**
  15383. * Gets the current alpha equation.
  15384. * @returns the current alpha equation
  15385. */
  15386. getAlphaEquation(): number;
  15387. }
  15388. }
  15389. }
  15390. declare module "babylonjs/Particles/particleSystem" {
  15391. import { Nullable } from "babylonjs/types";
  15392. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  15393. import { Observable } from "babylonjs/Misc/observable";
  15394. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15395. import { Effect } from "babylonjs/Materials/effect";
  15396. import { IDisposable } from "babylonjs/scene";
  15397. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15398. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15399. import { Particle } from "babylonjs/Particles/particle";
  15400. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15401. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15402. import "babylonjs/Shaders/particles.fragment";
  15403. import "babylonjs/Shaders/particles.vertex";
  15404. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  15405. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15406. import "babylonjs/Engines/Extensions/engine.alpha";
  15407. import { Scene } from "babylonjs/scene";
  15408. /**
  15409. * This represents a particle system in Babylon.
  15410. * 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.
  15411. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15412. * @example https://doc.babylonjs.com/babylon101/particles
  15413. */
  15414. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15415. /**
  15416. * Billboard mode will only apply to Y axis
  15417. */
  15418. static readonly BILLBOARDMODE_Y: number;
  15419. /**
  15420. * Billboard mode will apply to all axes
  15421. */
  15422. static readonly BILLBOARDMODE_ALL: number;
  15423. /**
  15424. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15425. */
  15426. static readonly BILLBOARDMODE_STRETCHED: number;
  15427. /**
  15428. * This function can be defined to provide custom update for active particles.
  15429. * This function will be called instead of regular update (age, position, color, etc.).
  15430. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15431. */
  15432. updateFunction: (particles: Particle[]) => void;
  15433. private _emitterWorldMatrix;
  15434. /**
  15435. * This function can be defined to specify initial direction for every new particle.
  15436. * It by default use the emitterType defined function
  15437. */
  15438. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15439. /**
  15440. * This function can be defined to specify initial position for every new particle.
  15441. * It by default use the emitterType defined function
  15442. */
  15443. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15444. /**
  15445. * @hidden
  15446. */
  15447. _inheritedVelocityOffset: Vector3;
  15448. /**
  15449. * An event triggered when the system is disposed
  15450. */
  15451. onDisposeObservable: Observable<IParticleSystem>;
  15452. /**
  15453. * An event triggered when the system is stopped
  15454. */
  15455. onStoppedObservable: Observable<IParticleSystem>;
  15456. private _onDisposeObserver;
  15457. /**
  15458. * Sets a callback that will be triggered when the system is disposed
  15459. */
  15460. set onDispose(callback: () => void);
  15461. private _particles;
  15462. private _epsilon;
  15463. private _capacity;
  15464. private _stockParticles;
  15465. private _newPartsExcess;
  15466. private _vertexData;
  15467. private _vertexBuffer;
  15468. private _vertexBuffers;
  15469. private _spriteBuffer;
  15470. private _indexBuffer;
  15471. private _effect;
  15472. private _customEffect;
  15473. private _cachedDefines;
  15474. private _scaledColorStep;
  15475. private _colorDiff;
  15476. private _scaledDirection;
  15477. private _scaledGravity;
  15478. private _currentRenderId;
  15479. private _alive;
  15480. private _useInstancing;
  15481. private _vertexArrayObject;
  15482. private _started;
  15483. private _stopped;
  15484. private _actualFrame;
  15485. private _scaledUpdateSpeed;
  15486. private _vertexBufferSize;
  15487. /** @hidden */
  15488. _currentEmitRateGradient: Nullable<FactorGradient>;
  15489. /** @hidden */
  15490. _currentEmitRate1: number;
  15491. /** @hidden */
  15492. _currentEmitRate2: number;
  15493. /** @hidden */
  15494. _currentStartSizeGradient: Nullable<FactorGradient>;
  15495. /** @hidden */
  15496. _currentStartSize1: number;
  15497. /** @hidden */
  15498. _currentStartSize2: number;
  15499. private readonly _rawTextureWidth;
  15500. private _rampGradientsTexture;
  15501. private _useRampGradients;
  15502. /** Gets or sets a matrix to use to compute projection */
  15503. defaultProjectionMatrix: Matrix;
  15504. /** Gets or sets a matrix to use to compute view */
  15505. defaultViewMatrix: Matrix;
  15506. /** Gets or sets a boolean indicating that ramp gradients must be used
  15507. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15508. */
  15509. get useRampGradients(): boolean;
  15510. set useRampGradients(value: boolean);
  15511. /**
  15512. * 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.
  15513. * 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: [])
  15514. */
  15515. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15516. private _subEmitters;
  15517. /**
  15518. * @hidden
  15519. * If the particle systems emitter should be disposed when the particle system is disposed
  15520. */
  15521. _disposeEmitterOnDispose: boolean;
  15522. /**
  15523. * The current active Sub-systems, this property is used by the root particle system only.
  15524. */
  15525. activeSubSystems: Array<ParticleSystem>;
  15526. /**
  15527. * Specifies if the particles are updated in emitter local space or world space
  15528. */
  15529. isLocal: boolean;
  15530. private _rootParticleSystem;
  15531. /**
  15532. * Gets the current list of active particles
  15533. */
  15534. get particles(): Particle[];
  15535. /**
  15536. * Gets the number of particles active at the same time.
  15537. * @returns The number of active particles.
  15538. */
  15539. getActiveCount(): number;
  15540. /**
  15541. * Returns the string "ParticleSystem"
  15542. * @returns a string containing the class name
  15543. */
  15544. getClassName(): string;
  15545. /**
  15546. * Gets a boolean indicating that the system is stopping
  15547. * @returns true if the system is currently stopping
  15548. */
  15549. isStopping(): boolean;
  15550. /**
  15551. * Gets the custom effect used to render the particles
  15552. * @param blendMode Blend mode for which the effect should be retrieved
  15553. * @returns The effect
  15554. */
  15555. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15556. /**
  15557. * Sets the custom effect used to render the particles
  15558. * @param effect The effect to set
  15559. * @param blendMode Blend mode for which the effect should be set
  15560. */
  15561. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15562. /** @hidden */
  15563. private _onBeforeDrawParticlesObservable;
  15564. /**
  15565. * Observable that will be called just before the particles are drawn
  15566. */
  15567. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15568. /**
  15569. * Gets the name of the particle vertex shader
  15570. */
  15571. get vertexShaderName(): string;
  15572. /**
  15573. * Instantiates a particle system.
  15574. * 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.
  15575. * @param name The name of the particle system
  15576. * @param capacity The max number of particles alive at the same time
  15577. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15578. * @param customEffect a custom effect used to change the way particles are rendered by default
  15579. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15580. * @param epsilon Offset used to render the particles
  15581. */
  15582. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15583. private _addFactorGradient;
  15584. private _removeFactorGradient;
  15585. /**
  15586. * Adds a new life time gradient
  15587. * @param gradient defines the gradient to use (between 0 and 1)
  15588. * @param factor defines the life time factor to affect to the specified gradient
  15589. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15590. * @returns the current particle system
  15591. */
  15592. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15593. /**
  15594. * Remove a specific life time gradient
  15595. * @param gradient defines the gradient to remove
  15596. * @returns the current particle system
  15597. */
  15598. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15599. /**
  15600. * Adds a new size gradient
  15601. * @param gradient defines the gradient to use (between 0 and 1)
  15602. * @param factor defines the size factor to affect to the specified gradient
  15603. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15604. * @returns the current particle system
  15605. */
  15606. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15607. /**
  15608. * Remove a specific size gradient
  15609. * @param gradient defines the gradient to remove
  15610. * @returns the current particle system
  15611. */
  15612. removeSizeGradient(gradient: number): IParticleSystem;
  15613. /**
  15614. * Adds a new color remap gradient
  15615. * @param gradient defines the gradient to use (between 0 and 1)
  15616. * @param min defines the color remap minimal range
  15617. * @param max defines the color remap maximal range
  15618. * @returns the current particle system
  15619. */
  15620. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15621. /**
  15622. * Remove a specific color remap gradient
  15623. * @param gradient defines the gradient to remove
  15624. * @returns the current particle system
  15625. */
  15626. removeColorRemapGradient(gradient: number): IParticleSystem;
  15627. /**
  15628. * Adds a new alpha remap gradient
  15629. * @param gradient defines the gradient to use (between 0 and 1)
  15630. * @param min defines the alpha remap minimal range
  15631. * @param max defines the alpha remap maximal range
  15632. * @returns the current particle system
  15633. */
  15634. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15635. /**
  15636. * Remove a specific alpha remap gradient
  15637. * @param gradient defines the gradient to remove
  15638. * @returns the current particle system
  15639. */
  15640. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15641. /**
  15642. * Adds a new angular speed gradient
  15643. * @param gradient defines the gradient to use (between 0 and 1)
  15644. * @param factor defines the angular speed to affect to the specified gradient
  15645. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15646. * @returns the current particle system
  15647. */
  15648. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15649. /**
  15650. * Remove a specific angular speed gradient
  15651. * @param gradient defines the gradient to remove
  15652. * @returns the current particle system
  15653. */
  15654. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15655. /**
  15656. * Adds a new velocity gradient
  15657. * @param gradient defines the gradient to use (between 0 and 1)
  15658. * @param factor defines the velocity to affect to the specified gradient
  15659. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15660. * @returns the current particle system
  15661. */
  15662. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15663. /**
  15664. * Remove a specific velocity gradient
  15665. * @param gradient defines the gradient to remove
  15666. * @returns the current particle system
  15667. */
  15668. removeVelocityGradient(gradient: number): IParticleSystem;
  15669. /**
  15670. * Adds a new limit velocity gradient
  15671. * @param gradient defines the gradient to use (between 0 and 1)
  15672. * @param factor defines the limit velocity value to affect to the specified gradient
  15673. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15674. * @returns the current particle system
  15675. */
  15676. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15677. /**
  15678. * Remove a specific limit velocity gradient
  15679. * @param gradient defines the gradient to remove
  15680. * @returns the current particle system
  15681. */
  15682. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15683. /**
  15684. * Adds a new drag gradient
  15685. * @param gradient defines the gradient to use (between 0 and 1)
  15686. * @param factor defines the drag value to affect to the specified gradient
  15687. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15688. * @returns the current particle system
  15689. */
  15690. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15691. /**
  15692. * Remove a specific drag gradient
  15693. * @param gradient defines the gradient to remove
  15694. * @returns the current particle system
  15695. */
  15696. removeDragGradient(gradient: number): IParticleSystem;
  15697. /**
  15698. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15699. * @param gradient defines the gradient to use (between 0 and 1)
  15700. * @param factor defines the emit rate value to affect to the specified gradient
  15701. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15702. * @returns the current particle system
  15703. */
  15704. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15705. /**
  15706. * Remove a specific emit rate gradient
  15707. * @param gradient defines the gradient to remove
  15708. * @returns the current particle system
  15709. */
  15710. removeEmitRateGradient(gradient: number): IParticleSystem;
  15711. /**
  15712. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15713. * @param gradient defines the gradient to use (between 0 and 1)
  15714. * @param factor defines the start size value to affect to the specified gradient
  15715. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15716. * @returns the current particle system
  15717. */
  15718. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15719. /**
  15720. * Remove a specific start size gradient
  15721. * @param gradient defines the gradient to remove
  15722. * @returns the current particle system
  15723. */
  15724. removeStartSizeGradient(gradient: number): IParticleSystem;
  15725. private _createRampGradientTexture;
  15726. /**
  15727. * Gets the current list of ramp gradients.
  15728. * You must use addRampGradient and removeRampGradient to udpate this list
  15729. * @returns the list of ramp gradients
  15730. */
  15731. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15732. /** Force the system to rebuild all gradients that need to be resync */
  15733. forceRefreshGradients(): void;
  15734. private _syncRampGradientTexture;
  15735. /**
  15736. * Adds a new ramp gradient used to remap particle colors
  15737. * @param gradient defines the gradient to use (between 0 and 1)
  15738. * @param color defines the color to affect to the specified gradient
  15739. * @returns the current particle system
  15740. */
  15741. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15742. /**
  15743. * Remove a specific ramp gradient
  15744. * @param gradient defines the gradient to remove
  15745. * @returns the current particle system
  15746. */
  15747. removeRampGradient(gradient: number): ParticleSystem;
  15748. /**
  15749. * Adds a new color gradient
  15750. * @param gradient defines the gradient to use (between 0 and 1)
  15751. * @param color1 defines the color to affect to the specified gradient
  15752. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15753. * @returns this particle system
  15754. */
  15755. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15756. /**
  15757. * Remove a specific color gradient
  15758. * @param gradient defines the gradient to remove
  15759. * @returns this particle system
  15760. */
  15761. removeColorGradient(gradient: number): IParticleSystem;
  15762. private _fetchR;
  15763. protected _reset(): void;
  15764. private _resetEffect;
  15765. private _createVertexBuffers;
  15766. private _createIndexBuffer;
  15767. /**
  15768. * Gets the maximum number of particles active at the same time.
  15769. * @returns The max number of active particles.
  15770. */
  15771. getCapacity(): number;
  15772. /**
  15773. * Gets whether there are still active particles in the system.
  15774. * @returns True if it is alive, otherwise false.
  15775. */
  15776. isAlive(): boolean;
  15777. /**
  15778. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15779. * @returns True if it has been started, otherwise false.
  15780. */
  15781. isStarted(): boolean;
  15782. private _prepareSubEmitterInternalArray;
  15783. /**
  15784. * Starts the particle system and begins to emit
  15785. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15786. */
  15787. start(delay?: number): void;
  15788. /**
  15789. * Stops the particle system.
  15790. * @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.
  15791. */
  15792. stop(stopSubEmitters?: boolean): void;
  15793. /**
  15794. * Remove all active particles
  15795. */
  15796. reset(): void;
  15797. /**
  15798. * @hidden (for internal use only)
  15799. */
  15800. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15801. /**
  15802. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15803. * Its lifetime will start back at 0.
  15804. */
  15805. recycleParticle: (particle: Particle) => void;
  15806. private _stopSubEmitters;
  15807. private _createParticle;
  15808. private _removeFromRoot;
  15809. private _emitFromParticle;
  15810. private _update;
  15811. /** @hidden */
  15812. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15813. /** @hidden */
  15814. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15815. /**
  15816. * Fill the defines array according to the current settings of the particle system
  15817. * @param defines Array to be updated
  15818. * @param blendMode blend mode to take into account when updating the array
  15819. */
  15820. fillDefines(defines: Array<string>, blendMode: number): void;
  15821. /**
  15822. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  15823. * @param uniforms Uniforms array to fill
  15824. * @param attributes Attributes array to fill
  15825. * @param samplers Samplers array to fill
  15826. */
  15827. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  15828. /** @hidden */
  15829. private _getEffect;
  15830. /**
  15831. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15832. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15833. */
  15834. animate(preWarmOnly?: boolean): void;
  15835. private _appendParticleVertices;
  15836. /**
  15837. * Rebuilds the particle system.
  15838. */
  15839. rebuild(): void;
  15840. /**
  15841. * Is this system ready to be used/rendered
  15842. * @return true if the system is ready
  15843. */
  15844. isReady(): boolean;
  15845. private _render;
  15846. /**
  15847. * Renders the particle system in its current state.
  15848. * @returns the current number of particles
  15849. */
  15850. render(): number;
  15851. /**
  15852. * Disposes the particle system and free the associated resources
  15853. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15854. */
  15855. dispose(disposeTexture?: boolean): void;
  15856. /**
  15857. * Clones the particle system.
  15858. * @param name The name of the cloned object
  15859. * @param newEmitter The new emitter to use
  15860. * @returns the cloned particle system
  15861. */
  15862. clone(name: string, newEmitter: any): ParticleSystem;
  15863. /**
  15864. * Serializes the particle system to a JSON object
  15865. * @param serializeTexture defines if the texture must be serialized as well
  15866. * @returns the JSON object
  15867. */
  15868. serialize(serializeTexture?: boolean): any;
  15869. /** @hidden */
  15870. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  15871. /** @hidden */
  15872. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  15873. /**
  15874. * Parses a JSON object to create a particle system.
  15875. * @param parsedParticleSystem The JSON object to parse
  15876. * @param sceneOrEngine The scene or the engine to create the particle system in
  15877. * @param rootUrl The root url to use to load external dependencies like texture
  15878. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15879. * @returns the Parsed particle system
  15880. */
  15881. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15882. }
  15883. }
  15884. declare module "babylonjs/Particles/particle" {
  15885. import { Nullable } from "babylonjs/types";
  15886. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  15887. import { Color4 } from "babylonjs/Maths/math.color";
  15888. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15889. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15890. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  15891. /**
  15892. * A particle represents one of the element emitted by a particle system.
  15893. * This is mainly define by its coordinates, direction, velocity and age.
  15894. */
  15895. export class Particle {
  15896. /**
  15897. * The particle system the particle belongs to.
  15898. */
  15899. particleSystem: ParticleSystem;
  15900. private static _Count;
  15901. /**
  15902. * Unique ID of the particle
  15903. */
  15904. id: number;
  15905. /**
  15906. * The world position of the particle in the scene.
  15907. */
  15908. position: Vector3;
  15909. /**
  15910. * The world direction of the particle in the scene.
  15911. */
  15912. direction: Vector3;
  15913. /**
  15914. * The color of the particle.
  15915. */
  15916. color: Color4;
  15917. /**
  15918. * The color change of the particle per step.
  15919. */
  15920. colorStep: Color4;
  15921. /**
  15922. * Defines how long will the life of the particle be.
  15923. */
  15924. lifeTime: number;
  15925. /**
  15926. * The current age of the particle.
  15927. */
  15928. age: number;
  15929. /**
  15930. * The current size of the particle.
  15931. */
  15932. size: number;
  15933. /**
  15934. * The current scale of the particle.
  15935. */
  15936. scale: Vector2;
  15937. /**
  15938. * The current angle of the particle.
  15939. */
  15940. angle: number;
  15941. /**
  15942. * Defines how fast is the angle changing.
  15943. */
  15944. angularSpeed: number;
  15945. /**
  15946. * Defines the cell index used by the particle to be rendered from a sprite.
  15947. */
  15948. cellIndex: number;
  15949. /**
  15950. * The information required to support color remapping
  15951. */
  15952. remapData: Vector4;
  15953. /** @hidden */
  15954. _randomCellOffset?: number;
  15955. /** @hidden */
  15956. _initialDirection: Nullable<Vector3>;
  15957. /** @hidden */
  15958. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15959. /** @hidden */
  15960. _initialStartSpriteCellID: number;
  15961. /** @hidden */
  15962. _initialEndSpriteCellID: number;
  15963. /** @hidden */
  15964. _currentColorGradient: Nullable<ColorGradient>;
  15965. /** @hidden */
  15966. _currentColor1: Color4;
  15967. /** @hidden */
  15968. _currentColor2: Color4;
  15969. /** @hidden */
  15970. _currentSizeGradient: Nullable<FactorGradient>;
  15971. /** @hidden */
  15972. _currentSize1: number;
  15973. /** @hidden */
  15974. _currentSize2: number;
  15975. /** @hidden */
  15976. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15977. /** @hidden */
  15978. _currentAngularSpeed1: number;
  15979. /** @hidden */
  15980. _currentAngularSpeed2: number;
  15981. /** @hidden */
  15982. _currentVelocityGradient: Nullable<FactorGradient>;
  15983. /** @hidden */
  15984. _currentVelocity1: number;
  15985. /** @hidden */
  15986. _currentVelocity2: number;
  15987. /** @hidden */
  15988. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15989. /** @hidden */
  15990. _currentLimitVelocity1: number;
  15991. /** @hidden */
  15992. _currentLimitVelocity2: number;
  15993. /** @hidden */
  15994. _currentDragGradient: Nullable<FactorGradient>;
  15995. /** @hidden */
  15996. _currentDrag1: number;
  15997. /** @hidden */
  15998. _currentDrag2: number;
  15999. /** @hidden */
  16000. _randomNoiseCoordinates1: Vector3;
  16001. /** @hidden */
  16002. _randomNoiseCoordinates2: Vector3;
  16003. /** @hidden */
  16004. _localPosition?: Vector3;
  16005. /**
  16006. * Creates a new instance Particle
  16007. * @param particleSystem the particle system the particle belongs to
  16008. */
  16009. constructor(
  16010. /**
  16011. * The particle system the particle belongs to.
  16012. */
  16013. particleSystem: ParticleSystem);
  16014. private updateCellInfoFromSystem;
  16015. /**
  16016. * Defines how the sprite cell index is updated for the particle
  16017. */
  16018. updateCellIndex(): void;
  16019. /** @hidden */
  16020. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16021. /** @hidden */
  16022. _inheritParticleInfoToSubEmitters(): void;
  16023. /** @hidden */
  16024. _reset(): void;
  16025. /**
  16026. * Copy the properties of particle to another one.
  16027. * @param other the particle to copy the information to.
  16028. */
  16029. copyTo(other: Particle): void;
  16030. }
  16031. }
  16032. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  16033. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16034. import { Effect } from "babylonjs/Materials/effect";
  16035. import { Particle } from "babylonjs/Particles/particle";
  16036. import { Nullable } from "babylonjs/types";
  16037. import { Scene } from "babylonjs/scene";
  16038. /**
  16039. * Particle emitter represents a volume emitting particles.
  16040. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16041. */
  16042. export interface IParticleEmitterType {
  16043. /**
  16044. * Called by the particle System when the direction is computed for the created particle.
  16045. * @param worldMatrix is the world matrix of the particle system
  16046. * @param directionToUpdate is the direction vector to update with the result
  16047. * @param particle is the particle we are computed the direction for
  16048. * @param isLocal defines if the direction should be set in local space
  16049. */
  16050. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16051. /**
  16052. * Called by the particle System when the position is computed for the created particle.
  16053. * @param worldMatrix is the world matrix of the particle system
  16054. * @param positionToUpdate is the position vector to update with the result
  16055. * @param particle is the particle we are computed the position for
  16056. * @param isLocal defines if the position should be set in local space
  16057. */
  16058. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16059. /**
  16060. * Clones the current emitter and returns a copy of it
  16061. * @returns the new emitter
  16062. */
  16063. clone(): IParticleEmitterType;
  16064. /**
  16065. * Called by the GPUParticleSystem to setup the update shader
  16066. * @param effect defines the update shader
  16067. */
  16068. applyToShader(effect: Effect): void;
  16069. /**
  16070. * Returns a string to use to update the GPU particles update shader
  16071. * @returns the effect defines string
  16072. */
  16073. getEffectDefines(): string;
  16074. /**
  16075. * Returns a string representing the class name
  16076. * @returns a string containing the class name
  16077. */
  16078. getClassName(): string;
  16079. /**
  16080. * Serializes the particle system to a JSON object.
  16081. * @returns the JSON object
  16082. */
  16083. serialize(): any;
  16084. /**
  16085. * Parse properties from a JSON object
  16086. * @param serializationObject defines the JSON object
  16087. * @param scene defines the hosting scene
  16088. */
  16089. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16090. }
  16091. }
  16092. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  16093. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16094. import { Effect } from "babylonjs/Materials/effect";
  16095. import { Particle } from "babylonjs/Particles/particle";
  16096. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16097. /**
  16098. * Particle emitter emitting particles from the inside of a box.
  16099. * It emits the particles randomly between 2 given directions.
  16100. */
  16101. export class BoxParticleEmitter implements IParticleEmitterType {
  16102. /**
  16103. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16104. */
  16105. direction1: Vector3;
  16106. /**
  16107. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16108. */
  16109. direction2: Vector3;
  16110. /**
  16111. * 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.
  16112. */
  16113. minEmitBox: Vector3;
  16114. /**
  16115. * 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.
  16116. */
  16117. maxEmitBox: Vector3;
  16118. /**
  16119. * Creates a new instance BoxParticleEmitter
  16120. */
  16121. constructor();
  16122. /**
  16123. * Called by the particle System when the direction is computed for the created particle.
  16124. * @param worldMatrix is the world matrix of the particle system
  16125. * @param directionToUpdate is the direction vector to update with the result
  16126. * @param particle is the particle we are computed the direction for
  16127. * @param isLocal defines if the direction should be set in local space
  16128. */
  16129. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16130. /**
  16131. * Called by the particle System when the position is computed for the created particle.
  16132. * @param worldMatrix is the world matrix of the particle system
  16133. * @param positionToUpdate is the position vector to update with the result
  16134. * @param particle is the particle we are computed the position for
  16135. * @param isLocal defines if the position should be set in local space
  16136. */
  16137. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16138. /**
  16139. * Clones the current emitter and returns a copy of it
  16140. * @returns the new emitter
  16141. */
  16142. clone(): BoxParticleEmitter;
  16143. /**
  16144. * Called by the GPUParticleSystem to setup the update shader
  16145. * @param effect defines the update shader
  16146. */
  16147. applyToShader(effect: Effect): void;
  16148. /**
  16149. * Returns a string to use to update the GPU particles update shader
  16150. * @returns a string containng the defines string
  16151. */
  16152. getEffectDefines(): string;
  16153. /**
  16154. * Returns the string "BoxParticleEmitter"
  16155. * @returns a string containing the class name
  16156. */
  16157. getClassName(): string;
  16158. /**
  16159. * Serializes the particle system to a JSON object.
  16160. * @returns the JSON object
  16161. */
  16162. serialize(): any;
  16163. /**
  16164. * Parse properties from a JSON object
  16165. * @param serializationObject defines the JSON object
  16166. */
  16167. parse(serializationObject: any): void;
  16168. }
  16169. }
  16170. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  16171. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16172. import { Effect } from "babylonjs/Materials/effect";
  16173. import { Particle } from "babylonjs/Particles/particle";
  16174. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16175. /**
  16176. * Particle emitter emitting particles from the inside of a cone.
  16177. * It emits the particles alongside the cone volume from the base to the particle.
  16178. * The emission direction might be randomized.
  16179. */
  16180. export class ConeParticleEmitter implements IParticleEmitterType {
  16181. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16182. directionRandomizer: number;
  16183. private _radius;
  16184. private _angle;
  16185. private _height;
  16186. /**
  16187. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16188. */
  16189. radiusRange: number;
  16190. /**
  16191. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16192. */
  16193. heightRange: number;
  16194. /**
  16195. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16196. */
  16197. emitFromSpawnPointOnly: boolean;
  16198. /**
  16199. * Gets or sets the radius of the emission cone
  16200. */
  16201. get radius(): number;
  16202. set radius(value: number);
  16203. /**
  16204. * Gets or sets the angle of the emission cone
  16205. */
  16206. get angle(): number;
  16207. set angle(value: number);
  16208. private _buildHeight;
  16209. /**
  16210. * Creates a new instance ConeParticleEmitter
  16211. * @param radius the radius of the emission cone (1 by default)
  16212. * @param angle the cone base angle (PI by default)
  16213. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16214. */
  16215. constructor(radius?: number, angle?: number,
  16216. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16217. directionRandomizer?: number);
  16218. /**
  16219. * Called by the particle System when the direction is computed for the created particle.
  16220. * @param worldMatrix is the world matrix of the particle system
  16221. * @param directionToUpdate is the direction vector to update with the result
  16222. * @param particle is the particle we are computed the direction for
  16223. * @param isLocal defines if the direction should be set in local space
  16224. */
  16225. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16226. /**
  16227. * Called by the particle System when the position is computed for the created particle.
  16228. * @param worldMatrix is the world matrix of the particle system
  16229. * @param positionToUpdate is the position vector to update with the result
  16230. * @param particle is the particle we are computed the position for
  16231. * @param isLocal defines if the position should be set in local space
  16232. */
  16233. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16234. /**
  16235. * Clones the current emitter and returns a copy of it
  16236. * @returns the new emitter
  16237. */
  16238. clone(): ConeParticleEmitter;
  16239. /**
  16240. * Called by the GPUParticleSystem to setup the update shader
  16241. * @param effect defines the update shader
  16242. */
  16243. applyToShader(effect: Effect): void;
  16244. /**
  16245. * Returns a string to use to update the GPU particles update shader
  16246. * @returns a string containng the defines string
  16247. */
  16248. getEffectDefines(): string;
  16249. /**
  16250. * Returns the string "ConeParticleEmitter"
  16251. * @returns a string containing the class name
  16252. */
  16253. getClassName(): string;
  16254. /**
  16255. * Serializes the particle system to a JSON object.
  16256. * @returns the JSON object
  16257. */
  16258. serialize(): any;
  16259. /**
  16260. * Parse properties from a JSON object
  16261. * @param serializationObject defines the JSON object
  16262. */
  16263. parse(serializationObject: any): void;
  16264. }
  16265. }
  16266. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16267. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16268. import { Effect } from "babylonjs/Materials/effect";
  16269. import { Particle } from "babylonjs/Particles/particle";
  16270. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16271. /**
  16272. * Particle emitter emitting particles from the inside of a cylinder.
  16273. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16274. */
  16275. export class CylinderParticleEmitter implements IParticleEmitterType {
  16276. /**
  16277. * The radius of the emission cylinder.
  16278. */
  16279. radius: number;
  16280. /**
  16281. * The height of the emission cylinder.
  16282. */
  16283. height: number;
  16284. /**
  16285. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16286. */
  16287. radiusRange: number;
  16288. /**
  16289. * How much to randomize the particle direction [0-1].
  16290. */
  16291. directionRandomizer: number;
  16292. /**
  16293. * Creates a new instance CylinderParticleEmitter
  16294. * @param radius the radius of the emission cylinder (1 by default)
  16295. * @param height the height of the emission cylinder (1 by default)
  16296. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16297. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16298. */
  16299. constructor(
  16300. /**
  16301. * The radius of the emission cylinder.
  16302. */
  16303. radius?: number,
  16304. /**
  16305. * The height of the emission cylinder.
  16306. */
  16307. height?: number,
  16308. /**
  16309. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16310. */
  16311. radiusRange?: number,
  16312. /**
  16313. * How much to randomize the particle direction [0-1].
  16314. */
  16315. directionRandomizer?: number);
  16316. /**
  16317. * Called by the particle System when the direction is computed for the created particle.
  16318. * @param worldMatrix is the world matrix of the particle system
  16319. * @param directionToUpdate is the direction vector to update with the result
  16320. * @param particle is the particle we are computed the direction for
  16321. * @param isLocal defines if the direction should be set in local space
  16322. */
  16323. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16324. /**
  16325. * Called by the particle System when the position is computed for the created particle.
  16326. * @param worldMatrix is the world matrix of the particle system
  16327. * @param positionToUpdate is the position vector to update with the result
  16328. * @param particle is the particle we are computed the position for
  16329. * @param isLocal defines if the position should be set in local space
  16330. */
  16331. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16332. /**
  16333. * Clones the current emitter and returns a copy of it
  16334. * @returns the new emitter
  16335. */
  16336. clone(): CylinderParticleEmitter;
  16337. /**
  16338. * Called by the GPUParticleSystem to setup the update shader
  16339. * @param effect defines the update shader
  16340. */
  16341. applyToShader(effect: Effect): void;
  16342. /**
  16343. * Returns a string to use to update the GPU particles update shader
  16344. * @returns a string containng the defines string
  16345. */
  16346. getEffectDefines(): string;
  16347. /**
  16348. * Returns the string "CylinderParticleEmitter"
  16349. * @returns a string containing the class name
  16350. */
  16351. getClassName(): string;
  16352. /**
  16353. * Serializes the particle system to a JSON object.
  16354. * @returns the JSON object
  16355. */
  16356. serialize(): any;
  16357. /**
  16358. * Parse properties from a JSON object
  16359. * @param serializationObject defines the JSON object
  16360. */
  16361. parse(serializationObject: any): void;
  16362. }
  16363. /**
  16364. * Particle emitter emitting particles from the inside of a cylinder.
  16365. * It emits the particles randomly between two vectors.
  16366. */
  16367. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16368. /**
  16369. * The min limit of the emission direction.
  16370. */
  16371. direction1: Vector3;
  16372. /**
  16373. * The max limit of the emission direction.
  16374. */
  16375. direction2: Vector3;
  16376. /**
  16377. * Creates a new instance CylinderDirectedParticleEmitter
  16378. * @param radius the radius of the emission cylinder (1 by default)
  16379. * @param height the height of the emission cylinder (1 by default)
  16380. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16381. * @param direction1 the min limit of the emission direction (up vector by default)
  16382. * @param direction2 the max limit of the emission direction (up vector by default)
  16383. */
  16384. constructor(radius?: number, height?: number, radiusRange?: number,
  16385. /**
  16386. * The min limit of the emission direction.
  16387. */
  16388. direction1?: Vector3,
  16389. /**
  16390. * The max limit of the emission direction.
  16391. */
  16392. direction2?: Vector3);
  16393. /**
  16394. * Called by the particle System when the direction is computed for the created particle.
  16395. * @param worldMatrix is the world matrix of the particle system
  16396. * @param directionToUpdate is the direction vector to update with the result
  16397. * @param particle is the particle we are computed the direction for
  16398. */
  16399. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16400. /**
  16401. * Clones the current emitter and returns a copy of it
  16402. * @returns the new emitter
  16403. */
  16404. clone(): CylinderDirectedParticleEmitter;
  16405. /**
  16406. * Called by the GPUParticleSystem to setup the update shader
  16407. * @param effect defines the update shader
  16408. */
  16409. applyToShader(effect: Effect): void;
  16410. /**
  16411. * Returns a string to use to update the GPU particles update shader
  16412. * @returns a string containng the defines string
  16413. */
  16414. getEffectDefines(): string;
  16415. /**
  16416. * Returns the string "CylinderDirectedParticleEmitter"
  16417. * @returns a string containing the class name
  16418. */
  16419. getClassName(): string;
  16420. /**
  16421. * Serializes the particle system to a JSON object.
  16422. * @returns the JSON object
  16423. */
  16424. serialize(): any;
  16425. /**
  16426. * Parse properties from a JSON object
  16427. * @param serializationObject defines the JSON object
  16428. */
  16429. parse(serializationObject: any): void;
  16430. }
  16431. }
  16432. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16433. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16434. import { Effect } from "babylonjs/Materials/effect";
  16435. import { Particle } from "babylonjs/Particles/particle";
  16436. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16437. /**
  16438. * Particle emitter emitting particles from the inside of a hemisphere.
  16439. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16440. */
  16441. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16442. /**
  16443. * The radius of the emission hemisphere.
  16444. */
  16445. radius: number;
  16446. /**
  16447. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16448. */
  16449. radiusRange: number;
  16450. /**
  16451. * How much to randomize the particle direction [0-1].
  16452. */
  16453. directionRandomizer: number;
  16454. /**
  16455. * Creates a new instance HemisphericParticleEmitter
  16456. * @param radius the radius of the emission hemisphere (1 by default)
  16457. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16458. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16459. */
  16460. constructor(
  16461. /**
  16462. * The radius of the emission hemisphere.
  16463. */
  16464. radius?: number,
  16465. /**
  16466. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16467. */
  16468. radiusRange?: number,
  16469. /**
  16470. * How much to randomize the particle direction [0-1].
  16471. */
  16472. directionRandomizer?: number);
  16473. /**
  16474. * Called by the particle System when the direction is computed for the created particle.
  16475. * @param worldMatrix is the world matrix of the particle system
  16476. * @param directionToUpdate is the direction vector to update with the result
  16477. * @param particle is the particle we are computed the direction for
  16478. * @param isLocal defines if the direction should be set in local space
  16479. */
  16480. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16481. /**
  16482. * Called by the particle System when the position is computed for the created particle.
  16483. * @param worldMatrix is the world matrix of the particle system
  16484. * @param positionToUpdate is the position vector to update with the result
  16485. * @param particle is the particle we are computed the position for
  16486. * @param isLocal defines if the position should be set in local space
  16487. */
  16488. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16489. /**
  16490. * Clones the current emitter and returns a copy of it
  16491. * @returns the new emitter
  16492. */
  16493. clone(): HemisphericParticleEmitter;
  16494. /**
  16495. * Called by the GPUParticleSystem to setup the update shader
  16496. * @param effect defines the update shader
  16497. */
  16498. applyToShader(effect: Effect): void;
  16499. /**
  16500. * Returns a string to use to update the GPU particles update shader
  16501. * @returns a string containng the defines string
  16502. */
  16503. getEffectDefines(): string;
  16504. /**
  16505. * Returns the string "HemisphericParticleEmitter"
  16506. * @returns a string containing the class name
  16507. */
  16508. getClassName(): string;
  16509. /**
  16510. * Serializes the particle system to a JSON object.
  16511. * @returns the JSON object
  16512. */
  16513. serialize(): any;
  16514. /**
  16515. * Parse properties from a JSON object
  16516. * @param serializationObject defines the JSON object
  16517. */
  16518. parse(serializationObject: any): void;
  16519. }
  16520. }
  16521. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16522. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16523. import { Effect } from "babylonjs/Materials/effect";
  16524. import { Particle } from "babylonjs/Particles/particle";
  16525. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16526. /**
  16527. * Particle emitter emitting particles from a point.
  16528. * It emits the particles randomly between 2 given directions.
  16529. */
  16530. export class PointParticleEmitter implements IParticleEmitterType {
  16531. /**
  16532. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16533. */
  16534. direction1: Vector3;
  16535. /**
  16536. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16537. */
  16538. direction2: Vector3;
  16539. /**
  16540. * Creates a new instance PointParticleEmitter
  16541. */
  16542. constructor();
  16543. /**
  16544. * Called by the particle System when the direction is computed for the created particle.
  16545. * @param worldMatrix is the world matrix of the particle system
  16546. * @param directionToUpdate is the direction vector to update with the result
  16547. * @param particle is the particle we are computed the direction for
  16548. * @param isLocal defines if the direction should be set in local space
  16549. */
  16550. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16551. /**
  16552. * Called by the particle System when the position is computed for the created particle.
  16553. * @param worldMatrix is the world matrix of the particle system
  16554. * @param positionToUpdate is the position vector to update with the result
  16555. * @param particle is the particle we are computed the position for
  16556. * @param isLocal defines if the position should be set in local space
  16557. */
  16558. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16559. /**
  16560. * Clones the current emitter and returns a copy of it
  16561. * @returns the new emitter
  16562. */
  16563. clone(): PointParticleEmitter;
  16564. /**
  16565. * Called by the GPUParticleSystem to setup the update shader
  16566. * @param effect defines the update shader
  16567. */
  16568. applyToShader(effect: Effect): void;
  16569. /**
  16570. * Returns a string to use to update the GPU particles update shader
  16571. * @returns a string containng the defines string
  16572. */
  16573. getEffectDefines(): string;
  16574. /**
  16575. * Returns the string "PointParticleEmitter"
  16576. * @returns a string containing the class name
  16577. */
  16578. getClassName(): string;
  16579. /**
  16580. * Serializes the particle system to a JSON object.
  16581. * @returns the JSON object
  16582. */
  16583. serialize(): any;
  16584. /**
  16585. * Parse properties from a JSON object
  16586. * @param serializationObject defines the JSON object
  16587. */
  16588. parse(serializationObject: any): void;
  16589. }
  16590. }
  16591. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16592. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16593. import { Effect } from "babylonjs/Materials/effect";
  16594. import { Particle } from "babylonjs/Particles/particle";
  16595. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16596. /**
  16597. * Particle emitter emitting particles from the inside of a sphere.
  16598. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16599. */
  16600. export class SphereParticleEmitter implements IParticleEmitterType {
  16601. /**
  16602. * The radius of the emission sphere.
  16603. */
  16604. radius: number;
  16605. /**
  16606. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16607. */
  16608. radiusRange: number;
  16609. /**
  16610. * How much to randomize the particle direction [0-1].
  16611. */
  16612. directionRandomizer: number;
  16613. /**
  16614. * Creates a new instance SphereParticleEmitter
  16615. * @param radius the radius of the emission sphere (1 by default)
  16616. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16617. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16618. */
  16619. constructor(
  16620. /**
  16621. * The radius of the emission sphere.
  16622. */
  16623. radius?: number,
  16624. /**
  16625. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16626. */
  16627. radiusRange?: number,
  16628. /**
  16629. * How much to randomize the particle direction [0-1].
  16630. */
  16631. directionRandomizer?: number);
  16632. /**
  16633. * Called by the particle System when the direction is computed for the created particle.
  16634. * @param worldMatrix is the world matrix of the particle system
  16635. * @param directionToUpdate is the direction vector to update with the result
  16636. * @param particle is the particle we are computed the direction for
  16637. * @param isLocal defines if the direction should be set in local space
  16638. */
  16639. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16640. /**
  16641. * Called by the particle System when the position is computed for the created particle.
  16642. * @param worldMatrix is the world matrix of the particle system
  16643. * @param positionToUpdate is the position vector to update with the result
  16644. * @param particle is the particle we are computed the position for
  16645. * @param isLocal defines if the position should be set in local space
  16646. */
  16647. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16648. /**
  16649. * Clones the current emitter and returns a copy of it
  16650. * @returns the new emitter
  16651. */
  16652. clone(): SphereParticleEmitter;
  16653. /**
  16654. * Called by the GPUParticleSystem to setup the update shader
  16655. * @param effect defines the update shader
  16656. */
  16657. applyToShader(effect: Effect): void;
  16658. /**
  16659. * Returns a string to use to update the GPU particles update shader
  16660. * @returns a string containng the defines string
  16661. */
  16662. getEffectDefines(): string;
  16663. /**
  16664. * Returns the string "SphereParticleEmitter"
  16665. * @returns a string containing the class name
  16666. */
  16667. getClassName(): string;
  16668. /**
  16669. * Serializes the particle system to a JSON object.
  16670. * @returns the JSON object
  16671. */
  16672. serialize(): any;
  16673. /**
  16674. * Parse properties from a JSON object
  16675. * @param serializationObject defines the JSON object
  16676. */
  16677. parse(serializationObject: any): void;
  16678. }
  16679. /**
  16680. * Particle emitter emitting particles from the inside of a sphere.
  16681. * It emits the particles randomly between two vectors.
  16682. */
  16683. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16684. /**
  16685. * The min limit of the emission direction.
  16686. */
  16687. direction1: Vector3;
  16688. /**
  16689. * The max limit of the emission direction.
  16690. */
  16691. direction2: Vector3;
  16692. /**
  16693. * Creates a new instance SphereDirectedParticleEmitter
  16694. * @param radius the radius of the emission sphere (1 by default)
  16695. * @param direction1 the min limit of the emission direction (up vector by default)
  16696. * @param direction2 the max limit of the emission direction (up vector by default)
  16697. */
  16698. constructor(radius?: number,
  16699. /**
  16700. * The min limit of the emission direction.
  16701. */
  16702. direction1?: Vector3,
  16703. /**
  16704. * The max limit of the emission direction.
  16705. */
  16706. direction2?: Vector3);
  16707. /**
  16708. * Called by the particle System when the direction is computed for the created particle.
  16709. * @param worldMatrix is the world matrix of the particle system
  16710. * @param directionToUpdate is the direction vector to update with the result
  16711. * @param particle is the particle we are computed the direction for
  16712. */
  16713. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16714. /**
  16715. * Clones the current emitter and returns a copy of it
  16716. * @returns the new emitter
  16717. */
  16718. clone(): SphereDirectedParticleEmitter;
  16719. /**
  16720. * Called by the GPUParticleSystem to setup the update shader
  16721. * @param effect defines the update shader
  16722. */
  16723. applyToShader(effect: Effect): void;
  16724. /**
  16725. * Returns a string to use to update the GPU particles update shader
  16726. * @returns a string containng the defines string
  16727. */
  16728. getEffectDefines(): string;
  16729. /**
  16730. * Returns the string "SphereDirectedParticleEmitter"
  16731. * @returns a string containing the class name
  16732. */
  16733. getClassName(): string;
  16734. /**
  16735. * Serializes the particle system to a JSON object.
  16736. * @returns the JSON object
  16737. */
  16738. serialize(): any;
  16739. /**
  16740. * Parse properties from a JSON object
  16741. * @param serializationObject defines the JSON object
  16742. */
  16743. parse(serializationObject: any): void;
  16744. }
  16745. }
  16746. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  16747. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16748. import { Effect } from "babylonjs/Materials/effect";
  16749. import { Particle } from "babylonjs/Particles/particle";
  16750. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16751. import { Nullable } from "babylonjs/types";
  16752. /**
  16753. * Particle emitter emitting particles from a custom list of positions.
  16754. */
  16755. export class CustomParticleEmitter implements IParticleEmitterType {
  16756. /**
  16757. * Gets or sets the position generator that will create the inital position of each particle.
  16758. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16759. */
  16760. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16761. /**
  16762. * Gets or sets the destination generator that will create the final destination of each particle.
  16763. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16764. */
  16765. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16766. /**
  16767. * Creates a new instance CustomParticleEmitter
  16768. */
  16769. constructor();
  16770. /**
  16771. * Called by the particle System when the direction is computed for the created particle.
  16772. * @param worldMatrix is the world matrix of the particle system
  16773. * @param directionToUpdate is the direction vector to update with the result
  16774. * @param particle is the particle we are computed the direction for
  16775. * @param isLocal defines if the direction should be set in local space
  16776. */
  16777. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16778. /**
  16779. * Called by the particle System when the position is computed for the created particle.
  16780. * @param worldMatrix is the world matrix of the particle system
  16781. * @param positionToUpdate is the position vector to update with the result
  16782. * @param particle is the particle we are computed the position for
  16783. * @param isLocal defines if the position should be set in local space
  16784. */
  16785. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16786. /**
  16787. * Clones the current emitter and returns a copy of it
  16788. * @returns the new emitter
  16789. */
  16790. clone(): CustomParticleEmitter;
  16791. /**
  16792. * Called by the GPUParticleSystem to setup the update shader
  16793. * @param effect defines the update shader
  16794. */
  16795. applyToShader(effect: Effect): void;
  16796. /**
  16797. * Returns a string to use to update the GPU particles update shader
  16798. * @returns a string containng the defines string
  16799. */
  16800. getEffectDefines(): string;
  16801. /**
  16802. * Returns the string "PointParticleEmitter"
  16803. * @returns a string containing the class name
  16804. */
  16805. getClassName(): string;
  16806. /**
  16807. * Serializes the particle system to a JSON object.
  16808. * @returns the JSON object
  16809. */
  16810. serialize(): any;
  16811. /**
  16812. * Parse properties from a JSON object
  16813. * @param serializationObject defines the JSON object
  16814. */
  16815. parse(serializationObject: any): void;
  16816. }
  16817. }
  16818. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  16819. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16820. import { Effect } from "babylonjs/Materials/effect";
  16821. import { Particle } from "babylonjs/Particles/particle";
  16822. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16823. import { Nullable } from "babylonjs/types";
  16824. import { Scene } from "babylonjs/scene";
  16825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16826. /**
  16827. * Particle emitter emitting particles from the inside of a box.
  16828. * It emits the particles randomly between 2 given directions.
  16829. */
  16830. export class MeshParticleEmitter implements IParticleEmitterType {
  16831. private _indices;
  16832. private _positions;
  16833. private _normals;
  16834. private _storedNormal;
  16835. private _mesh;
  16836. /**
  16837. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16838. */
  16839. direction1: Vector3;
  16840. /**
  16841. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16842. */
  16843. direction2: Vector3;
  16844. /**
  16845. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  16846. */
  16847. useMeshNormalsForDirection: boolean;
  16848. /** Defines the mesh to use as source */
  16849. get mesh(): Nullable<AbstractMesh>;
  16850. set mesh(value: Nullable<AbstractMesh>);
  16851. /**
  16852. * Creates a new instance MeshParticleEmitter
  16853. * @param mesh defines the mesh to use as source
  16854. */
  16855. constructor(mesh?: Nullable<AbstractMesh>);
  16856. /**
  16857. * Called by the particle System when the direction is computed for the created particle.
  16858. * @param worldMatrix is the world matrix of the particle system
  16859. * @param directionToUpdate is the direction vector to update with the result
  16860. * @param particle is the particle we are computed the direction for
  16861. * @param isLocal defines if the direction should be set in local space
  16862. */
  16863. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16864. /**
  16865. * Called by the particle System when the position is computed for the created particle.
  16866. * @param worldMatrix is the world matrix of the particle system
  16867. * @param positionToUpdate is the position vector to update with the result
  16868. * @param particle is the particle we are computed the position for
  16869. * @param isLocal defines if the position should be set in local space
  16870. */
  16871. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16872. /**
  16873. * Clones the current emitter and returns a copy of it
  16874. * @returns the new emitter
  16875. */
  16876. clone(): MeshParticleEmitter;
  16877. /**
  16878. * Called by the GPUParticleSystem to setup the update shader
  16879. * @param effect defines the update shader
  16880. */
  16881. applyToShader(effect: Effect): void;
  16882. /**
  16883. * Returns a string to use to update the GPU particles update shader
  16884. * @returns a string containng the defines string
  16885. */
  16886. getEffectDefines(): string;
  16887. /**
  16888. * Returns the string "BoxParticleEmitter"
  16889. * @returns a string containing the class name
  16890. */
  16891. getClassName(): string;
  16892. /**
  16893. * Serializes the particle system to a JSON object.
  16894. * @returns the JSON object
  16895. */
  16896. serialize(): any;
  16897. /**
  16898. * Parse properties from a JSON object
  16899. * @param serializationObject defines the JSON object
  16900. * @param scene defines the hosting scene
  16901. */
  16902. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16903. }
  16904. }
  16905. declare module "babylonjs/Particles/EmitterTypes/index" {
  16906. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16907. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16908. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16909. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16910. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16911. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16912. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16913. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  16914. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  16915. }
  16916. declare module "babylonjs/Particles/IParticleSystem" {
  16917. import { Nullable } from "babylonjs/types";
  16918. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16919. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16920. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16921. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16922. import { Scene } from "babylonjs/scene";
  16923. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  16924. import { Effect } from "babylonjs/Materials/effect";
  16925. import { Observable } from "babylonjs/Misc/observable";
  16926. import { Animation } from "babylonjs/Animations/animation";
  16927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16928. /**
  16929. * Interface representing a particle system in Babylon.js.
  16930. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16931. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16932. */
  16933. export interface IParticleSystem {
  16934. /**
  16935. * List of animations used by the particle system.
  16936. */
  16937. animations: Animation[];
  16938. /**
  16939. * The id of the Particle system.
  16940. */
  16941. id: string;
  16942. /**
  16943. * The name of the Particle system.
  16944. */
  16945. name: string;
  16946. /**
  16947. * The emitter represents the Mesh or position we are attaching the particle system to.
  16948. */
  16949. emitter: Nullable<AbstractMesh | Vector3>;
  16950. /**
  16951. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16952. */
  16953. isBillboardBased: boolean;
  16954. /**
  16955. * The rendering group used by the Particle system to chose when to render.
  16956. */
  16957. renderingGroupId: number;
  16958. /**
  16959. * The layer mask we are rendering the particles through.
  16960. */
  16961. layerMask: number;
  16962. /**
  16963. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16964. */
  16965. updateSpeed: number;
  16966. /**
  16967. * The amount of time the particle system is running (depends of the overall update speed).
  16968. */
  16969. targetStopDuration: number;
  16970. /**
  16971. * The texture used to render each particle. (this can be a spritesheet)
  16972. */
  16973. particleTexture: Nullable<BaseTexture>;
  16974. /**
  16975. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16976. */
  16977. blendMode: number;
  16978. /**
  16979. * Minimum life time of emitting particles.
  16980. */
  16981. minLifeTime: number;
  16982. /**
  16983. * Maximum life time of emitting particles.
  16984. */
  16985. maxLifeTime: number;
  16986. /**
  16987. * Minimum Size of emitting particles.
  16988. */
  16989. minSize: number;
  16990. /**
  16991. * Maximum Size of emitting particles.
  16992. */
  16993. maxSize: number;
  16994. /**
  16995. * Minimum scale of emitting particles on X axis.
  16996. */
  16997. minScaleX: number;
  16998. /**
  16999. * Maximum scale of emitting particles on X axis.
  17000. */
  17001. maxScaleX: number;
  17002. /**
  17003. * Minimum scale of emitting particles on Y axis.
  17004. */
  17005. minScaleY: number;
  17006. /**
  17007. * Maximum scale of emitting particles on Y axis.
  17008. */
  17009. maxScaleY: number;
  17010. /**
  17011. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17012. */
  17013. color1: Color4;
  17014. /**
  17015. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17016. */
  17017. color2: Color4;
  17018. /**
  17019. * Color the particle will have at the end of its lifetime.
  17020. */
  17021. colorDead: Color4;
  17022. /**
  17023. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17024. */
  17025. emitRate: number;
  17026. /**
  17027. * You can use gravity if you want to give an orientation to your particles.
  17028. */
  17029. gravity: Vector3;
  17030. /**
  17031. * Minimum power of emitting particles.
  17032. */
  17033. minEmitPower: number;
  17034. /**
  17035. * Maximum power of emitting particles.
  17036. */
  17037. maxEmitPower: number;
  17038. /**
  17039. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17040. */
  17041. minAngularSpeed: number;
  17042. /**
  17043. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17044. */
  17045. maxAngularSpeed: number;
  17046. /**
  17047. * Gets or sets the minimal initial rotation in radians.
  17048. */
  17049. minInitialRotation: number;
  17050. /**
  17051. * Gets or sets the maximal initial rotation in radians.
  17052. */
  17053. maxInitialRotation: number;
  17054. /**
  17055. * The particle emitter type defines the emitter used by the particle system.
  17056. * It can be for example box, sphere, or cone...
  17057. */
  17058. particleEmitterType: Nullable<IParticleEmitterType>;
  17059. /**
  17060. * Defines the delay in milliseconds before starting the system (0 by default)
  17061. */
  17062. startDelay: number;
  17063. /**
  17064. * 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
  17065. */
  17066. preWarmCycles: number;
  17067. /**
  17068. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17069. */
  17070. preWarmStepOffset: number;
  17071. /**
  17072. * 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)
  17073. */
  17074. spriteCellChangeSpeed: number;
  17075. /**
  17076. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17077. */
  17078. startSpriteCellID: number;
  17079. /**
  17080. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17081. */
  17082. endSpriteCellID: number;
  17083. /**
  17084. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17085. */
  17086. spriteCellWidth: number;
  17087. /**
  17088. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17089. */
  17090. spriteCellHeight: number;
  17091. /**
  17092. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17093. */
  17094. spriteRandomStartCell: boolean;
  17095. /**
  17096. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17097. */
  17098. isAnimationSheetEnabled: boolean;
  17099. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17100. translationPivot: Vector2;
  17101. /**
  17102. * Gets or sets a texture used to add random noise to particle positions
  17103. */
  17104. noiseTexture: Nullable<BaseTexture>;
  17105. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17106. noiseStrength: Vector3;
  17107. /**
  17108. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17109. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17110. */
  17111. billboardMode: number;
  17112. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17113. limitVelocityDamping: number;
  17114. /**
  17115. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17116. */
  17117. beginAnimationOnStart: boolean;
  17118. /**
  17119. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17120. */
  17121. beginAnimationFrom: number;
  17122. /**
  17123. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17124. */
  17125. beginAnimationTo: number;
  17126. /**
  17127. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17128. */
  17129. beginAnimationLoop: boolean;
  17130. /**
  17131. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17132. */
  17133. disposeOnStop: boolean;
  17134. /**
  17135. * Specifies if the particles are updated in emitter local space or world space
  17136. */
  17137. isLocal: boolean;
  17138. /** Snippet ID if the particle system was created from the snippet server */
  17139. snippetId: string;
  17140. /** Gets or sets a matrix to use to compute projection */
  17141. defaultProjectionMatrix: Matrix;
  17142. /**
  17143. * Gets the maximum number of particles active at the same time.
  17144. * @returns The max number of active particles.
  17145. */
  17146. getCapacity(): number;
  17147. /**
  17148. * Gets the number of particles active at the same time.
  17149. * @returns The number of active particles.
  17150. */
  17151. getActiveCount(): number;
  17152. /**
  17153. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17154. * @returns True if it has been started, otherwise false.
  17155. */
  17156. isStarted(): boolean;
  17157. /**
  17158. * Animates the particle system for this frame.
  17159. */
  17160. animate(): void;
  17161. /**
  17162. * Renders the particle system in its current state.
  17163. * @returns the current number of particles
  17164. */
  17165. render(): number;
  17166. /**
  17167. * Dispose the particle system and frees its associated resources.
  17168. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17169. */
  17170. dispose(disposeTexture?: boolean): void;
  17171. /**
  17172. * An event triggered when the system is disposed
  17173. */
  17174. onDisposeObservable: Observable<IParticleSystem>;
  17175. /**
  17176. * An event triggered when the system is stopped
  17177. */
  17178. onStoppedObservable: Observable<IParticleSystem>;
  17179. /**
  17180. * Clones the particle system.
  17181. * @param name The name of the cloned object
  17182. * @param newEmitter The new emitter to use
  17183. * @returns the cloned particle system
  17184. */
  17185. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17186. /**
  17187. * Serializes the particle system to a JSON object
  17188. * @param serializeTexture defines if the texture must be serialized as well
  17189. * @returns the JSON object
  17190. */
  17191. serialize(serializeTexture: boolean): any;
  17192. /**
  17193. * Rebuild the particle system
  17194. */
  17195. rebuild(): void;
  17196. /** Force the system to rebuild all gradients that need to be resync */
  17197. forceRefreshGradients(): void;
  17198. /**
  17199. * Starts the particle system and begins to emit
  17200. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17201. */
  17202. start(delay?: number): void;
  17203. /**
  17204. * Stops the particle system.
  17205. */
  17206. stop(): void;
  17207. /**
  17208. * Remove all active particles
  17209. */
  17210. reset(): void;
  17211. /**
  17212. * Gets a boolean indicating that the system is stopping
  17213. * @returns true if the system is currently stopping
  17214. */
  17215. isStopping(): boolean;
  17216. /**
  17217. * Is this system ready to be used/rendered
  17218. * @return true if the system is ready
  17219. */
  17220. isReady(): boolean;
  17221. /**
  17222. * Returns the string "ParticleSystem"
  17223. * @returns a string containing the class name
  17224. */
  17225. getClassName(): string;
  17226. /**
  17227. * Gets the custom effect used to render the particles
  17228. * @param blendMode Blend mode for which the effect should be retrieved
  17229. * @returns The effect
  17230. */
  17231. getCustomEffect(blendMode: number): Nullable<Effect>;
  17232. /**
  17233. * Sets the custom effect used to render the particles
  17234. * @param effect The effect to set
  17235. * @param blendMode Blend mode for which the effect should be set
  17236. */
  17237. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17238. /**
  17239. * Fill the defines array according to the current settings of the particle system
  17240. * @param defines Array to be updated
  17241. * @param blendMode blend mode to take into account when updating the array
  17242. */
  17243. fillDefines(defines: Array<string>, blendMode: number): void;
  17244. /**
  17245. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17246. * @param uniforms Uniforms array to fill
  17247. * @param attributes Attributes array to fill
  17248. * @param samplers Samplers array to fill
  17249. */
  17250. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17251. /**
  17252. * Observable that will be called just before the particles are drawn
  17253. */
  17254. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17255. /**
  17256. * Gets the name of the particle vertex shader
  17257. */
  17258. vertexShaderName: string;
  17259. /**
  17260. * Adds a new color gradient
  17261. * @param gradient defines the gradient to use (between 0 and 1)
  17262. * @param color1 defines the color to affect to the specified gradient
  17263. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17264. * @returns the current particle system
  17265. */
  17266. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17267. /**
  17268. * Remove a specific color gradient
  17269. * @param gradient defines the gradient to remove
  17270. * @returns the current particle system
  17271. */
  17272. removeColorGradient(gradient: number): IParticleSystem;
  17273. /**
  17274. * Adds a new size gradient
  17275. * @param gradient defines the gradient to use (between 0 and 1)
  17276. * @param factor defines the size factor to affect to the specified gradient
  17277. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17278. * @returns the current particle system
  17279. */
  17280. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17281. /**
  17282. * Remove a specific size gradient
  17283. * @param gradient defines the gradient to remove
  17284. * @returns the current particle system
  17285. */
  17286. removeSizeGradient(gradient: number): IParticleSystem;
  17287. /**
  17288. * Gets the current list of color gradients.
  17289. * You must use addColorGradient and removeColorGradient to udpate this list
  17290. * @returns the list of color gradients
  17291. */
  17292. getColorGradients(): Nullable<Array<ColorGradient>>;
  17293. /**
  17294. * Gets the current list of size gradients.
  17295. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17296. * @returns the list of size gradients
  17297. */
  17298. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17299. /**
  17300. * Gets the current list of angular speed gradients.
  17301. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17302. * @returns the list of angular speed gradients
  17303. */
  17304. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17305. /**
  17306. * Adds a new angular speed gradient
  17307. * @param gradient defines the gradient to use (between 0 and 1)
  17308. * @param factor defines the angular speed to affect to the specified gradient
  17309. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17310. * @returns the current particle system
  17311. */
  17312. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17313. /**
  17314. * Remove a specific angular speed gradient
  17315. * @param gradient defines the gradient to remove
  17316. * @returns the current particle system
  17317. */
  17318. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17319. /**
  17320. * Gets the current list of velocity gradients.
  17321. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17322. * @returns the list of velocity gradients
  17323. */
  17324. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17325. /**
  17326. * Adds a new velocity gradient
  17327. * @param gradient defines the gradient to use (between 0 and 1)
  17328. * @param factor defines the velocity to affect to the specified gradient
  17329. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17330. * @returns the current particle system
  17331. */
  17332. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17333. /**
  17334. * Remove a specific velocity gradient
  17335. * @param gradient defines the gradient to remove
  17336. * @returns the current particle system
  17337. */
  17338. removeVelocityGradient(gradient: number): IParticleSystem;
  17339. /**
  17340. * Gets the current list of limit velocity gradients.
  17341. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17342. * @returns the list of limit velocity gradients
  17343. */
  17344. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17345. /**
  17346. * Adds a new limit velocity gradient
  17347. * @param gradient defines the gradient to use (between 0 and 1)
  17348. * @param factor defines the limit velocity to affect to the specified gradient
  17349. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17350. * @returns the current particle system
  17351. */
  17352. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17353. /**
  17354. * Remove a specific limit velocity gradient
  17355. * @param gradient defines the gradient to remove
  17356. * @returns the current particle system
  17357. */
  17358. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17359. /**
  17360. * Adds a new drag gradient
  17361. * @param gradient defines the gradient to use (between 0 and 1)
  17362. * @param factor defines the drag to affect to the specified gradient
  17363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17364. * @returns the current particle system
  17365. */
  17366. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17367. /**
  17368. * Remove a specific drag gradient
  17369. * @param gradient defines the gradient to remove
  17370. * @returns the current particle system
  17371. */
  17372. removeDragGradient(gradient: number): IParticleSystem;
  17373. /**
  17374. * Gets the current list of drag gradients.
  17375. * You must use addDragGradient and removeDragGradient to udpate this list
  17376. * @returns the list of drag gradients
  17377. */
  17378. getDragGradients(): Nullable<Array<FactorGradient>>;
  17379. /**
  17380. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17381. * @param gradient defines the gradient to use (between 0 and 1)
  17382. * @param factor defines the emit rate to affect to the specified gradient
  17383. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17384. * @returns the current particle system
  17385. */
  17386. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17387. /**
  17388. * Remove a specific emit rate gradient
  17389. * @param gradient defines the gradient to remove
  17390. * @returns the current particle system
  17391. */
  17392. removeEmitRateGradient(gradient: number): IParticleSystem;
  17393. /**
  17394. * Gets the current list of emit rate gradients.
  17395. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17396. * @returns the list of emit rate gradients
  17397. */
  17398. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17399. /**
  17400. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17401. * @param gradient defines the gradient to use (between 0 and 1)
  17402. * @param factor defines the start size to affect to the specified gradient
  17403. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17404. * @returns the current particle system
  17405. */
  17406. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17407. /**
  17408. * Remove a specific start size gradient
  17409. * @param gradient defines the gradient to remove
  17410. * @returns the current particle system
  17411. */
  17412. removeStartSizeGradient(gradient: number): IParticleSystem;
  17413. /**
  17414. * Gets the current list of start size gradients.
  17415. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17416. * @returns the list of start size gradients
  17417. */
  17418. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17419. /**
  17420. * Adds a new life time gradient
  17421. * @param gradient defines the gradient to use (between 0 and 1)
  17422. * @param factor defines the life time factor to affect to the specified gradient
  17423. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17424. * @returns the current particle system
  17425. */
  17426. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17427. /**
  17428. * Remove a specific life time gradient
  17429. * @param gradient defines the gradient to remove
  17430. * @returns the current particle system
  17431. */
  17432. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17433. /**
  17434. * Gets the current list of life time gradients.
  17435. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17436. * @returns the list of life time gradients
  17437. */
  17438. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17439. /**
  17440. * Gets the current list of color gradients.
  17441. * You must use addColorGradient and removeColorGradient to udpate this list
  17442. * @returns the list of color gradients
  17443. */
  17444. getColorGradients(): Nullable<Array<ColorGradient>>;
  17445. /**
  17446. * Adds a new ramp gradient used to remap particle colors
  17447. * @param gradient defines the gradient to use (between 0 and 1)
  17448. * @param color defines the color to affect to the specified gradient
  17449. * @returns the current particle system
  17450. */
  17451. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17452. /**
  17453. * Gets the current list of ramp gradients.
  17454. * You must use addRampGradient and removeRampGradient to udpate this list
  17455. * @returns the list of ramp gradients
  17456. */
  17457. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17458. /** Gets or sets a boolean indicating that ramp gradients must be used
  17459. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17460. */
  17461. useRampGradients: boolean;
  17462. /**
  17463. * Adds a new color remap gradient
  17464. * @param gradient defines the gradient to use (between 0 and 1)
  17465. * @param min defines the color remap minimal range
  17466. * @param max defines the color remap maximal range
  17467. * @returns the current particle system
  17468. */
  17469. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17470. /**
  17471. * Gets the current list of color remap gradients.
  17472. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17473. * @returns the list of color remap gradients
  17474. */
  17475. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17476. /**
  17477. * Adds a new alpha remap gradient
  17478. * @param gradient defines the gradient to use (between 0 and 1)
  17479. * @param min defines the alpha remap minimal range
  17480. * @param max defines the alpha remap maximal range
  17481. * @returns the current particle system
  17482. */
  17483. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17484. /**
  17485. * Gets the current list of alpha remap gradients.
  17486. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17487. * @returns the list of alpha remap gradients
  17488. */
  17489. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17490. /**
  17491. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17492. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17493. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17494. * @returns the emitter
  17495. */
  17496. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17497. /**
  17498. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17499. * @param radius The radius of the hemisphere to emit from
  17500. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17501. * @returns the emitter
  17502. */
  17503. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17504. /**
  17505. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17506. * @param radius The radius of the sphere to emit from
  17507. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17508. * @returns the emitter
  17509. */
  17510. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17511. /**
  17512. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17513. * @param radius The radius of the sphere to emit from
  17514. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17515. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17516. * @returns the emitter
  17517. */
  17518. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17519. /**
  17520. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17521. * @param radius The radius of the emission cylinder
  17522. * @param height The height of the emission cylinder
  17523. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17524. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17525. * @returns the emitter
  17526. */
  17527. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17528. /**
  17529. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17530. * @param radius The radius of the cylinder to emit from
  17531. * @param height The height of the emission cylinder
  17532. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17533. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17534. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17535. * @returns the emitter
  17536. */
  17537. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17538. /**
  17539. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17540. * @param radius The radius of the cone to emit from
  17541. * @param angle The base angle of the cone
  17542. * @returns the emitter
  17543. */
  17544. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17545. /**
  17546. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17547. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17548. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17549. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17550. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17551. * @returns the emitter
  17552. */
  17553. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17554. /**
  17555. * Get hosting scene
  17556. * @returns the scene
  17557. */
  17558. getScene(): Nullable<Scene>;
  17559. }
  17560. }
  17561. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  17562. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  17563. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  17564. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  17565. /**
  17566. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17567. */
  17568. export class ColorSplitterBlock extends NodeMaterialBlock {
  17569. /**
  17570. * Create a new ColorSplitterBlock
  17571. * @param name defines the block name
  17572. */
  17573. constructor(name: string);
  17574. /**
  17575. * Gets the current class name
  17576. * @returns the class name
  17577. */
  17578. getClassName(): string;
  17579. /**
  17580. * Gets the rgba component (input)
  17581. */
  17582. get rgba(): NodeMaterialConnectionPoint;
  17583. /**
  17584. * Gets the rgb component (input)
  17585. */
  17586. get rgbIn(): NodeMaterialConnectionPoint;
  17587. /**
  17588. * Gets the rgb component (output)
  17589. */
  17590. get rgbOut(): NodeMaterialConnectionPoint;
  17591. /**
  17592. * Gets the r component (output)
  17593. */
  17594. get r(): NodeMaterialConnectionPoint;
  17595. /**
  17596. * Gets the g component (output)
  17597. */
  17598. get g(): NodeMaterialConnectionPoint;
  17599. /**
  17600. * Gets the b component (output)
  17601. */
  17602. get b(): NodeMaterialConnectionPoint;
  17603. /**
  17604. * Gets the a component (output)
  17605. */
  17606. get a(): NodeMaterialConnectionPoint;
  17607. protected _inputRename(name: string): string;
  17608. protected _outputRename(name: string): string;
  17609. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17610. }
  17611. }
  17612. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  17613. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  17614. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  17615. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  17616. import { Scene } from "babylonjs/scene";
  17617. /**
  17618. * Operations supported by the Trigonometry block
  17619. */
  17620. export enum TrigonometryBlockOperations {
  17621. /** Cos */
  17622. Cos = 0,
  17623. /** Sin */
  17624. Sin = 1,
  17625. /** Abs */
  17626. Abs = 2,
  17627. /** Exp */
  17628. Exp = 3,
  17629. /** Exp2 */
  17630. Exp2 = 4,
  17631. /** Round */
  17632. Round = 5,
  17633. /** Floor */
  17634. Floor = 6,
  17635. /** Ceiling */
  17636. Ceiling = 7,
  17637. /** Square root */
  17638. Sqrt = 8,
  17639. /** Log */
  17640. Log = 9,
  17641. /** Tangent */
  17642. Tan = 10,
  17643. /** Arc tangent */
  17644. ArcTan = 11,
  17645. /** Arc cosinus */
  17646. ArcCos = 12,
  17647. /** Arc sinus */
  17648. ArcSin = 13,
  17649. /** Fraction */
  17650. Fract = 14,
  17651. /** Sign */
  17652. Sign = 15,
  17653. /** To radians (from degrees) */
  17654. Radians = 16,
  17655. /** To degrees (from radians) */
  17656. Degrees = 17
  17657. }
  17658. /**
  17659. * Block used to apply trigonometry operation to floats
  17660. */
  17661. export class TrigonometryBlock extends NodeMaterialBlock {
  17662. /**
  17663. * Gets or sets the operation applied by the block
  17664. */
  17665. operation: TrigonometryBlockOperations;
  17666. /**
  17667. * Creates a new TrigonometryBlock
  17668. * @param name defines the block name
  17669. */
  17670. constructor(name: string);
  17671. /**
  17672. * Gets the current class name
  17673. * @returns the class name
  17674. */
  17675. getClassName(): string;
  17676. /**
  17677. * Gets the input component
  17678. */
  17679. get input(): NodeMaterialConnectionPoint;
  17680. /**
  17681. * Gets the output component
  17682. */
  17683. get output(): NodeMaterialConnectionPoint;
  17684. protected _buildBlock(state: NodeMaterialBuildState): this;
  17685. serialize(): any;
  17686. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17687. protected _dumpPropertiesCode(): string;
  17688. }
  17689. }
  17690. declare module "babylonjs/Materials/Node/nodeMaterial" {
  17691. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  17692. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  17693. import { Scene } from "babylonjs/scene";
  17694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17695. import { Matrix } from "babylonjs/Maths/math.vector";
  17696. import { Mesh } from "babylonjs/Meshes/mesh";
  17697. import { Engine } from "babylonjs/Engines/engine";
  17698. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17699. import { Observable } from "babylonjs/Misc/observable";
  17700. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17701. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17702. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  17703. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17704. import { Nullable } from "babylonjs/types";
  17705. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  17706. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  17707. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  17708. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  17709. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  17710. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  17711. import { Effect } from "babylonjs/Materials/effect";
  17712. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  17713. import { Camera } from "babylonjs/Cameras/camera";
  17714. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  17715. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17716. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17717. /**
  17718. * Interface used to configure the node material editor
  17719. */
  17720. export interface INodeMaterialEditorOptions {
  17721. /** Define the URl to load node editor script */
  17722. editorURL?: string;
  17723. }
  17724. /** @hidden */
  17725. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17726. NORMAL: boolean;
  17727. TANGENT: boolean;
  17728. UV1: boolean;
  17729. /** BONES */
  17730. NUM_BONE_INFLUENCERS: number;
  17731. BonesPerMesh: number;
  17732. BONETEXTURE: boolean;
  17733. /** MORPH TARGETS */
  17734. MORPHTARGETS: boolean;
  17735. MORPHTARGETS_NORMAL: boolean;
  17736. MORPHTARGETS_TANGENT: boolean;
  17737. MORPHTARGETS_UV: boolean;
  17738. NUM_MORPH_INFLUENCERS: number;
  17739. /** IMAGE PROCESSING */
  17740. IMAGEPROCESSING: boolean;
  17741. VIGNETTE: boolean;
  17742. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17743. VIGNETTEBLENDMODEOPAQUE: boolean;
  17744. TONEMAPPING: boolean;
  17745. TONEMAPPING_ACES: boolean;
  17746. CONTRAST: boolean;
  17747. EXPOSURE: boolean;
  17748. COLORCURVES: boolean;
  17749. COLORGRADING: boolean;
  17750. COLORGRADING3D: boolean;
  17751. SAMPLER3DGREENDEPTH: boolean;
  17752. SAMPLER3DBGRMAP: boolean;
  17753. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17754. /** MISC. */
  17755. BUMPDIRECTUV: number;
  17756. constructor();
  17757. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17758. }
  17759. /**
  17760. * Class used to configure NodeMaterial
  17761. */
  17762. export interface INodeMaterialOptions {
  17763. /**
  17764. * Defines if blocks should emit comments
  17765. */
  17766. emitComments: boolean;
  17767. }
  17768. /**
  17769. * Class used to create a node based material built by assembling shader blocks
  17770. */
  17771. export class NodeMaterial extends PushMaterial {
  17772. private static _BuildIdGenerator;
  17773. private _options;
  17774. private _vertexCompilationState;
  17775. private _fragmentCompilationState;
  17776. private _sharedData;
  17777. private _buildId;
  17778. private _buildWasSuccessful;
  17779. private _cachedWorldViewMatrix;
  17780. private _cachedWorldViewProjectionMatrix;
  17781. private _optimizers;
  17782. private _animationFrame;
  17783. /** Define the Url to load node editor script */
  17784. static EditorURL: string;
  17785. /** Define the Url to load snippets */
  17786. static SnippetUrl: string;
  17787. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17788. static IgnoreTexturesAtLoadTime: boolean;
  17789. private BJSNODEMATERIALEDITOR;
  17790. /** Get the inspector from bundle or global */
  17791. private _getGlobalNodeMaterialEditor;
  17792. /**
  17793. * Snippet ID if the material was created from the snippet server
  17794. */
  17795. snippetId: string;
  17796. /**
  17797. * Gets or sets data used by visual editor
  17798. * @see https://nme.babylonjs.com
  17799. */
  17800. editorData: any;
  17801. /**
  17802. * 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)
  17803. */
  17804. ignoreAlpha: boolean;
  17805. /**
  17806. * Defines the maximum number of lights that can be used in the material
  17807. */
  17808. maxSimultaneousLights: number;
  17809. /**
  17810. * Observable raised when the material is built
  17811. */
  17812. onBuildObservable: Observable<NodeMaterial>;
  17813. /**
  17814. * Gets or sets the root nodes of the material vertex shader
  17815. */
  17816. _vertexOutputNodes: NodeMaterialBlock[];
  17817. /**
  17818. * Gets or sets the root nodes of the material fragment (pixel) shader
  17819. */
  17820. _fragmentOutputNodes: NodeMaterialBlock[];
  17821. /** Gets or sets options to control the node material overall behavior */
  17822. get options(): INodeMaterialOptions;
  17823. set options(options: INodeMaterialOptions);
  17824. /**
  17825. * Default configuration related to image processing available in the standard Material.
  17826. */
  17827. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17828. /**
  17829. * Gets the image processing configuration used either in this material.
  17830. */
  17831. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17832. /**
  17833. * Sets the Default image processing configuration used either in the this material.
  17834. *
  17835. * If sets to null, the scene one is in use.
  17836. */
  17837. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17838. /**
  17839. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17840. */
  17841. attachedBlocks: NodeMaterialBlock[];
  17842. /**
  17843. * Specifies the mode of the node material
  17844. * @hidden
  17845. */
  17846. _mode: NodeMaterialModes;
  17847. /**
  17848. * Gets the mode property
  17849. */
  17850. get mode(): NodeMaterialModes;
  17851. /**
  17852. * A free comment about the material
  17853. */
  17854. comment: string;
  17855. /**
  17856. * Create a new node based material
  17857. * @param name defines the material name
  17858. * @param scene defines the hosting scene
  17859. * @param options defines creation option
  17860. */
  17861. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  17862. /**
  17863. * Gets the current class name of the material e.g. "NodeMaterial"
  17864. * @returns the class name
  17865. */
  17866. getClassName(): string;
  17867. /**
  17868. * Keep track of the image processing observer to allow dispose and replace.
  17869. */
  17870. private _imageProcessingObserver;
  17871. /**
  17872. * Attaches a new image processing configuration to the Standard Material.
  17873. * @param configuration
  17874. */
  17875. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17876. /**
  17877. * Get a block by its name
  17878. * @param name defines the name of the block to retrieve
  17879. * @returns the required block or null if not found
  17880. */
  17881. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  17882. /**
  17883. * Get a block by its name
  17884. * @param predicate defines the predicate used to find the good candidate
  17885. * @returns the required block or null if not found
  17886. */
  17887. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  17888. /**
  17889. * Get an input block by its name
  17890. * @param predicate defines the predicate used to find the good candidate
  17891. * @returns the required input block or null if not found
  17892. */
  17893. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  17894. /**
  17895. * Gets the list of input blocks attached to this material
  17896. * @returns an array of InputBlocks
  17897. */
  17898. getInputBlocks(): InputBlock[];
  17899. /**
  17900. * Adds a new optimizer to the list of optimizers
  17901. * @param optimizer defines the optimizers to add
  17902. * @returns the current material
  17903. */
  17904. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17905. /**
  17906. * Remove an optimizer from the list of optimizers
  17907. * @param optimizer defines the optimizers to remove
  17908. * @returns the current material
  17909. */
  17910. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17911. /**
  17912. * Add a new block to the list of output nodes
  17913. * @param node defines the node to add
  17914. * @returns the current material
  17915. */
  17916. addOutputNode(node: NodeMaterialBlock): this;
  17917. /**
  17918. * Remove a block from the list of root nodes
  17919. * @param node defines the node to remove
  17920. * @returns the current material
  17921. */
  17922. removeOutputNode(node: NodeMaterialBlock): this;
  17923. private _addVertexOutputNode;
  17924. private _removeVertexOutputNode;
  17925. private _addFragmentOutputNode;
  17926. private _removeFragmentOutputNode;
  17927. /**
  17928. * Specifies if the material will require alpha blending
  17929. * @returns a boolean specifying if alpha blending is needed
  17930. */
  17931. needAlphaBlending(): boolean;
  17932. /**
  17933. * Specifies if this material should be rendered in alpha test mode
  17934. * @returns a boolean specifying if an alpha test is needed.
  17935. */
  17936. needAlphaTesting(): boolean;
  17937. private _initializeBlock;
  17938. private _resetDualBlocks;
  17939. /**
  17940. * Remove a block from the current node material
  17941. * @param block defines the block to remove
  17942. */
  17943. removeBlock(block: NodeMaterialBlock): void;
  17944. /**
  17945. * Build the material and generates the inner effect
  17946. * @param verbose defines if the build should log activity
  17947. */
  17948. build(verbose?: boolean): void;
  17949. /**
  17950. * Runs an otpimization phase to try to improve the shader code
  17951. */
  17952. optimize(): void;
  17953. private _prepareDefinesForAttributes;
  17954. /**
  17955. * Create a post process from the material
  17956. * @param camera The camera to apply the render pass to.
  17957. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  17958. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  17959. * @param engine The engine which the post process will be applied. (default: current engine)
  17960. * @param reusable If the post process can be reused on the same frame. (default: false)
  17961. * @param textureType Type of textures used when performing the post process. (default: 0)
  17962. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  17963. * @returns the post process created
  17964. */
  17965. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  17966. /**
  17967. * Create the post process effect from the material
  17968. * @param postProcess The post process to create the effect for
  17969. */
  17970. createEffectForPostProcess(postProcess: PostProcess): void;
  17971. private _createEffectForPostProcess;
  17972. /**
  17973. * Create a new procedural texture based on this node material
  17974. * @param size defines the size of the texture
  17975. * @param scene defines the hosting scene
  17976. * @returns the new procedural texture attached to this node material
  17977. */
  17978. createProceduralTexture(size: number | {
  17979. width: number;
  17980. height: number;
  17981. layers?: number;
  17982. }, scene: Scene): Nullable<ProceduralTexture>;
  17983. private _createEffectForParticles;
  17984. private _checkInternals;
  17985. /**
  17986. * Create the effect to be used as the custom effect for a particle system
  17987. * @param particleSystem Particle system to create the effect for
  17988. * @param onCompiled defines a function to call when the effect creation is successful
  17989. * @param onError defines a function to call when the effect creation has failed
  17990. */
  17991. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  17992. private _processDefines;
  17993. /**
  17994. * Get if the submesh is ready to be used and all its information available.
  17995. * Child classes can use it to update shaders
  17996. * @param mesh defines the mesh to check
  17997. * @param subMesh defines which submesh to check
  17998. * @param useInstances specifies that instances should be used
  17999. * @returns a boolean indicating that the submesh is ready or not
  18000. */
  18001. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18002. /**
  18003. * Get a string representing the shaders built by the current node graph
  18004. */
  18005. get compiledShaders(): string;
  18006. /**
  18007. * Binds the world matrix to the material
  18008. * @param world defines the world transformation matrix
  18009. */
  18010. bindOnlyWorldMatrix(world: Matrix): void;
  18011. /**
  18012. * Binds the submesh to this material by preparing the effect and shader to draw
  18013. * @param world defines the world transformation matrix
  18014. * @param mesh defines the mesh containing the submesh
  18015. * @param subMesh defines the submesh to bind the material to
  18016. */
  18017. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18018. /**
  18019. * Gets the active textures from the material
  18020. * @returns an array of textures
  18021. */
  18022. getActiveTextures(): BaseTexture[];
  18023. /**
  18024. * Gets the list of texture blocks
  18025. * @returns an array of texture blocks
  18026. */
  18027. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18028. /**
  18029. * Specifies if the material uses a texture
  18030. * @param texture defines the texture to check against the material
  18031. * @returns a boolean specifying if the material uses the texture
  18032. */
  18033. hasTexture(texture: BaseTexture): boolean;
  18034. /**
  18035. * Disposes the material
  18036. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18037. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18038. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18039. */
  18040. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18041. /** Creates the node editor window. */
  18042. private _createNodeEditor;
  18043. /**
  18044. * Launch the node material editor
  18045. * @param config Define the configuration of the editor
  18046. * @return a promise fulfilled when the node editor is visible
  18047. */
  18048. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18049. /**
  18050. * Clear the current material
  18051. */
  18052. clear(): void;
  18053. /**
  18054. * Clear the current material and set it to a default state
  18055. */
  18056. setToDefault(): void;
  18057. /**
  18058. * Clear the current material and set it to a default state for post process
  18059. */
  18060. setToDefaultPostProcess(): void;
  18061. /**
  18062. * Clear the current material and set it to a default state for procedural texture
  18063. */
  18064. setToDefaultProceduralTexture(): void;
  18065. /**
  18066. * Clear the current material and set it to a default state for particle
  18067. */
  18068. setToDefaultParticle(): void;
  18069. /**
  18070. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18071. * @param url defines the url to load from
  18072. * @returns a promise that will fullfil when the material is fully loaded
  18073. */
  18074. loadAsync(url: string): Promise<void>;
  18075. private _gatherBlocks;
  18076. /**
  18077. * Generate a string containing the code declaration required to create an equivalent of this material
  18078. * @returns a string
  18079. */
  18080. generateCode(): string;
  18081. /**
  18082. * Serializes this material in a JSON representation
  18083. * @returns the serialized material object
  18084. */
  18085. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18086. private _restoreConnections;
  18087. /**
  18088. * Clear the current graph and load a new one from a serialization object
  18089. * @param source defines the JSON representation of the material
  18090. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18091. * @param merge defines whether or not the source must be merged or replace the current content
  18092. */
  18093. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18094. /**
  18095. * Makes a duplicate of the current material.
  18096. * @param name - name to use for the new material.
  18097. */
  18098. clone(name: string): NodeMaterial;
  18099. /**
  18100. * Creates a node material from parsed material data
  18101. * @param source defines the JSON representation of the material
  18102. * @param scene defines the hosting scene
  18103. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18104. * @returns a new node material
  18105. */
  18106. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18107. /**
  18108. * Creates a node material from a snippet saved in a remote file
  18109. * @param name defines the name of the material to create
  18110. * @param url defines the url to load from
  18111. * @param scene defines the hosting scene
  18112. * @returns a promise that will resolve to the new node material
  18113. */
  18114. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18115. /**
  18116. * Creates a node material from a snippet saved by the node material editor
  18117. * @param snippetId defines the snippet to load
  18118. * @param scene defines the hosting scene
  18119. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18120. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18121. * @returns a promise that will resolve to the new node material
  18122. */
  18123. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18124. /**
  18125. * Creates a new node material set to default basic configuration
  18126. * @param name defines the name of the material
  18127. * @param scene defines the hosting scene
  18128. * @returns a new NodeMaterial
  18129. */
  18130. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18131. }
  18132. }
  18133. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  18134. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18135. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  18136. import { Nullable } from "babylonjs/types";
  18137. module "babylonjs/Engines/thinEngine" {
  18138. interface ThinEngine {
  18139. /**
  18140. * Unbind a list of render target textures from the webGL context
  18141. * This is used only when drawBuffer extension or webGL2 are active
  18142. * @param textures defines the render target textures to unbind
  18143. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18144. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18145. */
  18146. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18147. /**
  18148. * Create a multi render target texture
  18149. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18150. * @param size defines the size of the texture
  18151. * @param options defines the creation options
  18152. * @returns the cube texture as an InternalTexture
  18153. */
  18154. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  18155. /**
  18156. * Update the sample count for a given multiple render target texture
  18157. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18158. * @param textures defines the textures to update
  18159. * @param samples defines the sample count to set
  18160. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18161. */
  18162. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  18163. /**
  18164. * Select a subsets of attachments to draw to.
  18165. * @param attachments gl attachments
  18166. */
  18167. bindAttachments(attachments: number[]): void;
  18168. /**
  18169. * Creates a layout object to draw/clear on specific textures in a MRT
  18170. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18171. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18172. */
  18173. buildTextureLayout(textureStatus: boolean[]): number[];
  18174. /**
  18175. * Restores the webgl state to only draw on the main color attachment
  18176. */
  18177. restoreSingleAttachment(): void;
  18178. }
  18179. }
  18180. }
  18181. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  18182. import { Scene } from "babylonjs/scene";
  18183. import { Engine } from "babylonjs/Engines/engine";
  18184. import { Texture } from "babylonjs/Materials/Textures/texture";
  18185. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18186. import "babylonjs/Engines/Extensions/engine.multiRender";
  18187. /**
  18188. * Creation options of the multi render target texture.
  18189. */
  18190. export interface IMultiRenderTargetOptions {
  18191. /**
  18192. * Define if the texture needs to create mip maps after render.
  18193. */
  18194. generateMipMaps?: boolean;
  18195. /**
  18196. * Define the types of all the draw buffers we want to create
  18197. */
  18198. types?: number[];
  18199. /**
  18200. * Define the sampling modes of all the draw buffers we want to create
  18201. */
  18202. samplingModes?: number[];
  18203. /**
  18204. * Define if a depth buffer is required
  18205. */
  18206. generateDepthBuffer?: boolean;
  18207. /**
  18208. * Define if a stencil buffer is required
  18209. */
  18210. generateStencilBuffer?: boolean;
  18211. /**
  18212. * Define if a depth texture is required instead of a depth buffer
  18213. */
  18214. generateDepthTexture?: boolean;
  18215. /**
  18216. * Define the number of desired draw buffers
  18217. */
  18218. textureCount?: number;
  18219. /**
  18220. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18221. */
  18222. doNotChangeAspectRatio?: boolean;
  18223. /**
  18224. * Define the default type of the buffers we are creating
  18225. */
  18226. defaultType?: number;
  18227. }
  18228. /**
  18229. * A multi render target, like a render target provides the ability to render to a texture.
  18230. * Unlike the render target, it can render to several draw buffers in one draw.
  18231. * This is specially interesting in deferred rendering or for any effects requiring more than
  18232. * just one color from a single pass.
  18233. */
  18234. export class MultiRenderTarget extends RenderTargetTexture {
  18235. private _internalTextures;
  18236. private _textures;
  18237. private _multiRenderTargetOptions;
  18238. private _count;
  18239. /**
  18240. * Get if draw buffers are currently supported by the used hardware and browser.
  18241. */
  18242. get isSupported(): boolean;
  18243. /**
  18244. * Get the list of textures generated by the multi render target.
  18245. */
  18246. get textures(): Texture[];
  18247. /**
  18248. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18249. */
  18250. get count(): number;
  18251. /**
  18252. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18253. */
  18254. get depthTexture(): Texture;
  18255. /**
  18256. * Set the wrapping mode on U of all the textures we are rendering to.
  18257. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18258. */
  18259. set wrapU(wrap: number);
  18260. /**
  18261. * Set the wrapping mode on V of all the textures we are rendering to.
  18262. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18263. */
  18264. set wrapV(wrap: number);
  18265. /**
  18266. * Instantiate a new multi render target texture.
  18267. * A multi render target, like a render target provides the ability to render to a texture.
  18268. * Unlike the render target, it can render to several draw buffers in one draw.
  18269. * This is specially interesting in deferred rendering or for any effects requiring more than
  18270. * just one color from a single pass.
  18271. * @param name Define the name of the texture
  18272. * @param size Define the size of the buffers to render to
  18273. * @param count Define the number of target we are rendering into
  18274. * @param scene Define the scene the texture belongs to
  18275. * @param options Define the options used to create the multi render target
  18276. */
  18277. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18278. private _initTypes;
  18279. /** @hidden */
  18280. _rebuild(forceFullRebuild?: boolean): void;
  18281. private _createInternalTextures;
  18282. private _createTextures;
  18283. /**
  18284. * Replaces a texture within the MRT.
  18285. * @param texture The new texture to insert in the MRT
  18286. * @param index The index of the texture to replace
  18287. */
  18288. replaceTexture(texture: Texture, index: number): void;
  18289. /**
  18290. * Define the number of samples used if MSAA is enabled.
  18291. */
  18292. get samples(): number;
  18293. set samples(value: number);
  18294. /**
  18295. * Resize all the textures in the multi render target.
  18296. * Be careful as it will recreate all the data in the new texture.
  18297. * @param size Define the new size
  18298. */
  18299. resize(size: any): void;
  18300. /**
  18301. * Changes the number of render targets in this MRT
  18302. * Be careful as it will recreate all the data in the new texture.
  18303. * @param count new texture count
  18304. * @param options Specifies texture types and sampling modes for new textures
  18305. */
  18306. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18307. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18308. /**
  18309. * Dispose the render targets and their associated resources
  18310. */
  18311. dispose(): void;
  18312. /**
  18313. * Release all the underlying texture used as draw buffers.
  18314. */
  18315. releaseInternalTextures(): void;
  18316. }
  18317. }
  18318. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  18319. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  18320. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  18321. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  18322. /** @hidden */
  18323. export var imageProcessingPixelShader: {
  18324. name: string;
  18325. shader: string;
  18326. };
  18327. }
  18328. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  18329. import { Nullable } from "babylonjs/types";
  18330. import { Color4 } from "babylonjs/Maths/math.color";
  18331. import { Camera } from "babylonjs/Cameras/camera";
  18332. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18333. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  18334. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  18335. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18336. import { Engine } from "babylonjs/Engines/engine";
  18337. import "babylonjs/Shaders/imageProcessing.fragment";
  18338. import "babylonjs/Shaders/postprocess.vertex";
  18339. /**
  18340. * ImageProcessingPostProcess
  18341. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18342. */
  18343. export class ImageProcessingPostProcess extends PostProcess {
  18344. /**
  18345. * Default configuration related to image processing available in the PBR Material.
  18346. */
  18347. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18348. /**
  18349. * Gets the image processing configuration used either in this material.
  18350. */
  18351. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18352. /**
  18353. * Sets the Default image processing configuration used either in the this material.
  18354. *
  18355. * If sets to null, the scene one is in use.
  18356. */
  18357. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18358. /**
  18359. * Keep track of the image processing observer to allow dispose and replace.
  18360. */
  18361. private _imageProcessingObserver;
  18362. /**
  18363. * Attaches a new image processing configuration to the PBR Material.
  18364. * @param configuration
  18365. */
  18366. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18367. /**
  18368. * If the post process is supported.
  18369. */
  18370. get isSupported(): boolean;
  18371. /**
  18372. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18373. */
  18374. get colorCurves(): Nullable<ColorCurves>;
  18375. /**
  18376. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18377. */
  18378. set colorCurves(value: Nullable<ColorCurves>);
  18379. /**
  18380. * Gets wether the color curves effect is enabled.
  18381. */
  18382. get colorCurvesEnabled(): boolean;
  18383. /**
  18384. * Sets wether the color curves effect is enabled.
  18385. */
  18386. set colorCurvesEnabled(value: boolean);
  18387. /**
  18388. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18389. */
  18390. get colorGradingTexture(): Nullable<BaseTexture>;
  18391. /**
  18392. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18393. */
  18394. set colorGradingTexture(value: Nullable<BaseTexture>);
  18395. /**
  18396. * Gets wether the color grading effect is enabled.
  18397. */
  18398. get colorGradingEnabled(): boolean;
  18399. /**
  18400. * Gets wether the color grading effect is enabled.
  18401. */
  18402. set colorGradingEnabled(value: boolean);
  18403. /**
  18404. * Gets exposure used in the effect.
  18405. */
  18406. get exposure(): number;
  18407. /**
  18408. * Sets exposure used in the effect.
  18409. */
  18410. set exposure(value: number);
  18411. /**
  18412. * Gets wether tonemapping is enabled or not.
  18413. */
  18414. get toneMappingEnabled(): boolean;
  18415. /**
  18416. * Sets wether tonemapping is enabled or not
  18417. */
  18418. set toneMappingEnabled(value: boolean);
  18419. /**
  18420. * Gets the type of tone mapping effect.
  18421. */
  18422. get toneMappingType(): number;
  18423. /**
  18424. * Sets the type of tone mapping effect.
  18425. */
  18426. set toneMappingType(value: number);
  18427. /**
  18428. * Gets contrast used in the effect.
  18429. */
  18430. get contrast(): number;
  18431. /**
  18432. * Sets contrast used in the effect.
  18433. */
  18434. set contrast(value: number);
  18435. /**
  18436. * Gets Vignette stretch size.
  18437. */
  18438. get vignetteStretch(): number;
  18439. /**
  18440. * Sets Vignette stretch size.
  18441. */
  18442. set vignetteStretch(value: number);
  18443. /**
  18444. * Gets Vignette centre X Offset.
  18445. */
  18446. get vignetteCentreX(): number;
  18447. /**
  18448. * Sets Vignette centre X Offset.
  18449. */
  18450. set vignetteCentreX(value: number);
  18451. /**
  18452. * Gets Vignette centre Y Offset.
  18453. */
  18454. get vignetteCentreY(): number;
  18455. /**
  18456. * Sets Vignette centre Y Offset.
  18457. */
  18458. set vignetteCentreY(value: number);
  18459. /**
  18460. * Gets Vignette weight or intensity of the vignette effect.
  18461. */
  18462. get vignetteWeight(): number;
  18463. /**
  18464. * Sets Vignette weight or intensity of the vignette effect.
  18465. */
  18466. set vignetteWeight(value: number);
  18467. /**
  18468. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18469. * if vignetteEnabled is set to true.
  18470. */
  18471. get vignetteColor(): Color4;
  18472. /**
  18473. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18474. * if vignetteEnabled is set to true.
  18475. */
  18476. set vignetteColor(value: Color4);
  18477. /**
  18478. * Gets Camera field of view used by the Vignette effect.
  18479. */
  18480. get vignetteCameraFov(): number;
  18481. /**
  18482. * Sets Camera field of view used by the Vignette effect.
  18483. */
  18484. set vignetteCameraFov(value: number);
  18485. /**
  18486. * Gets the vignette blend mode allowing different kind of effect.
  18487. */
  18488. get vignetteBlendMode(): number;
  18489. /**
  18490. * Sets the vignette blend mode allowing different kind of effect.
  18491. */
  18492. set vignetteBlendMode(value: number);
  18493. /**
  18494. * Gets wether the vignette effect is enabled.
  18495. */
  18496. get vignetteEnabled(): boolean;
  18497. /**
  18498. * Sets wether the vignette effect is enabled.
  18499. */
  18500. set vignetteEnabled(value: boolean);
  18501. private _fromLinearSpace;
  18502. /**
  18503. * Gets wether the input of the processing is in Gamma or Linear Space.
  18504. */
  18505. get fromLinearSpace(): boolean;
  18506. /**
  18507. * Sets wether the input of the processing is in Gamma or Linear Space.
  18508. */
  18509. set fromLinearSpace(value: boolean);
  18510. /**
  18511. * Defines cache preventing GC.
  18512. */
  18513. private _defines;
  18514. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  18515. /**
  18516. * "ImageProcessingPostProcess"
  18517. * @returns "ImageProcessingPostProcess"
  18518. */
  18519. getClassName(): string;
  18520. /**
  18521. * @hidden
  18522. */
  18523. _updateParameters(): void;
  18524. dispose(camera?: Camera): void;
  18525. }
  18526. }
  18527. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  18528. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18529. /**
  18530. * Interface for defining prepass effects in the prepass post-process pipeline
  18531. */
  18532. export interface PrePassEffectConfiguration {
  18533. /**
  18534. * Name of the effect
  18535. */
  18536. name: string;
  18537. /**
  18538. * Post process to attach for this effect
  18539. */
  18540. postProcess?: PostProcess;
  18541. /**
  18542. * Textures required in the MRT
  18543. */
  18544. texturesRequired: number[];
  18545. /**
  18546. * Is the effect enabled
  18547. */
  18548. enabled: boolean;
  18549. /**
  18550. * Disposes the effect configuration
  18551. */
  18552. dispose?: () => void;
  18553. /**
  18554. * Creates the associated post process
  18555. */
  18556. createPostProcess?: () => PostProcess;
  18557. }
  18558. }
  18559. declare module "babylonjs/Materials/fresnelParameters" {
  18560. import { DeepImmutable } from "babylonjs/types";
  18561. import { Color3 } from "babylonjs/Maths/math.color";
  18562. /**
  18563. * Options to be used when creating a FresnelParameters.
  18564. */
  18565. export type IFresnelParametersCreationOptions = {
  18566. /**
  18567. * Define the color used on edges (grazing angle)
  18568. */
  18569. leftColor?: Color3;
  18570. /**
  18571. * Define the color used on center
  18572. */
  18573. rightColor?: Color3;
  18574. /**
  18575. * Define bias applied to computed fresnel term
  18576. */
  18577. bias?: number;
  18578. /**
  18579. * Defined the power exponent applied to fresnel term
  18580. */
  18581. power?: number;
  18582. /**
  18583. * Define if the fresnel effect is enable or not.
  18584. */
  18585. isEnabled?: boolean;
  18586. };
  18587. /**
  18588. * Serialized format for FresnelParameters.
  18589. */
  18590. export type IFresnelParametersSerialized = {
  18591. /**
  18592. * Define the color used on edges (grazing angle) [as an array]
  18593. */
  18594. leftColor: number[];
  18595. /**
  18596. * Define the color used on center [as an array]
  18597. */
  18598. rightColor: number[];
  18599. /**
  18600. * Define bias applied to computed fresnel term
  18601. */
  18602. bias: number;
  18603. /**
  18604. * Defined the power exponent applied to fresnel term
  18605. */
  18606. power?: number;
  18607. /**
  18608. * Define if the fresnel effect is enable or not.
  18609. */
  18610. isEnabled: boolean;
  18611. };
  18612. /**
  18613. * This represents all the required information to add a fresnel effect on a material:
  18614. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18615. */
  18616. export class FresnelParameters {
  18617. private _isEnabled;
  18618. /**
  18619. * Define if the fresnel effect is enable or not.
  18620. */
  18621. get isEnabled(): boolean;
  18622. set isEnabled(value: boolean);
  18623. /**
  18624. * Define the color used on edges (grazing angle)
  18625. */
  18626. leftColor: Color3;
  18627. /**
  18628. * Define the color used on center
  18629. */
  18630. rightColor: Color3;
  18631. /**
  18632. * Define bias applied to computed fresnel term
  18633. */
  18634. bias: number;
  18635. /**
  18636. * Defined the power exponent applied to fresnel term
  18637. */
  18638. power: number;
  18639. /**
  18640. * Creates a new FresnelParameters object.
  18641. *
  18642. * @param options provide your own settings to optionally to override defaults
  18643. */
  18644. constructor(options?: IFresnelParametersCreationOptions);
  18645. /**
  18646. * Clones the current fresnel and its valuues
  18647. * @returns a clone fresnel configuration
  18648. */
  18649. clone(): FresnelParameters;
  18650. /**
  18651. * Determines equality between FresnelParameters objects
  18652. * @param otherFresnelParameters defines the second operand
  18653. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18654. */
  18655. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18656. /**
  18657. * Serializes the current fresnel parameters to a JSON representation.
  18658. * @return the JSON serialization
  18659. */
  18660. serialize(): IFresnelParametersSerialized;
  18661. /**
  18662. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18663. * @param parsedFresnelParameters Define the JSON representation
  18664. * @returns the parsed parameters
  18665. */
  18666. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18667. }
  18668. }
  18669. declare module "babylonjs/Materials/materialFlags" {
  18670. /**
  18671. * This groups all the flags used to control the materials channel.
  18672. */
  18673. export class MaterialFlags {
  18674. private static _DiffuseTextureEnabled;
  18675. /**
  18676. * Are diffuse textures enabled in the application.
  18677. */
  18678. static get DiffuseTextureEnabled(): boolean;
  18679. static set DiffuseTextureEnabled(value: boolean);
  18680. private static _DetailTextureEnabled;
  18681. /**
  18682. * Are detail textures enabled in the application.
  18683. */
  18684. static get DetailTextureEnabled(): boolean;
  18685. static set DetailTextureEnabled(value: boolean);
  18686. private static _AmbientTextureEnabled;
  18687. /**
  18688. * Are ambient textures enabled in the application.
  18689. */
  18690. static get AmbientTextureEnabled(): boolean;
  18691. static set AmbientTextureEnabled(value: boolean);
  18692. private static _OpacityTextureEnabled;
  18693. /**
  18694. * Are opacity textures enabled in the application.
  18695. */
  18696. static get OpacityTextureEnabled(): boolean;
  18697. static set OpacityTextureEnabled(value: boolean);
  18698. private static _ReflectionTextureEnabled;
  18699. /**
  18700. * Are reflection textures enabled in the application.
  18701. */
  18702. static get ReflectionTextureEnabled(): boolean;
  18703. static set ReflectionTextureEnabled(value: boolean);
  18704. private static _EmissiveTextureEnabled;
  18705. /**
  18706. * Are emissive textures enabled in the application.
  18707. */
  18708. static get EmissiveTextureEnabled(): boolean;
  18709. static set EmissiveTextureEnabled(value: boolean);
  18710. private static _SpecularTextureEnabled;
  18711. /**
  18712. * Are specular textures enabled in the application.
  18713. */
  18714. static get SpecularTextureEnabled(): boolean;
  18715. static set SpecularTextureEnabled(value: boolean);
  18716. private static _BumpTextureEnabled;
  18717. /**
  18718. * Are bump textures enabled in the application.
  18719. */
  18720. static get BumpTextureEnabled(): boolean;
  18721. static set BumpTextureEnabled(value: boolean);
  18722. private static _LightmapTextureEnabled;
  18723. /**
  18724. * Are lightmap textures enabled in the application.
  18725. */
  18726. static get LightmapTextureEnabled(): boolean;
  18727. static set LightmapTextureEnabled(value: boolean);
  18728. private static _RefractionTextureEnabled;
  18729. /**
  18730. * Are refraction textures enabled in the application.
  18731. */
  18732. static get RefractionTextureEnabled(): boolean;
  18733. static set RefractionTextureEnabled(value: boolean);
  18734. private static _ColorGradingTextureEnabled;
  18735. /**
  18736. * Are color grading textures enabled in the application.
  18737. */
  18738. static get ColorGradingTextureEnabled(): boolean;
  18739. static set ColorGradingTextureEnabled(value: boolean);
  18740. private static _FresnelEnabled;
  18741. /**
  18742. * Are fresnels enabled in the application.
  18743. */
  18744. static get FresnelEnabled(): boolean;
  18745. static set FresnelEnabled(value: boolean);
  18746. private static _ClearCoatTextureEnabled;
  18747. /**
  18748. * Are clear coat textures enabled in the application.
  18749. */
  18750. static get ClearCoatTextureEnabled(): boolean;
  18751. static set ClearCoatTextureEnabled(value: boolean);
  18752. private static _ClearCoatBumpTextureEnabled;
  18753. /**
  18754. * Are clear coat bump textures enabled in the application.
  18755. */
  18756. static get ClearCoatBumpTextureEnabled(): boolean;
  18757. static set ClearCoatBumpTextureEnabled(value: boolean);
  18758. private static _ClearCoatTintTextureEnabled;
  18759. /**
  18760. * Are clear coat tint textures enabled in the application.
  18761. */
  18762. static get ClearCoatTintTextureEnabled(): boolean;
  18763. static set ClearCoatTintTextureEnabled(value: boolean);
  18764. private static _SheenTextureEnabled;
  18765. /**
  18766. * Are sheen textures enabled in the application.
  18767. */
  18768. static get SheenTextureEnabled(): boolean;
  18769. static set SheenTextureEnabled(value: boolean);
  18770. private static _AnisotropicTextureEnabled;
  18771. /**
  18772. * Are anisotropic textures enabled in the application.
  18773. */
  18774. static get AnisotropicTextureEnabled(): boolean;
  18775. static set AnisotropicTextureEnabled(value: boolean);
  18776. private static _ThicknessTextureEnabled;
  18777. /**
  18778. * Are thickness textures enabled in the application.
  18779. */
  18780. static get ThicknessTextureEnabled(): boolean;
  18781. static set ThicknessTextureEnabled(value: boolean);
  18782. }
  18783. }
  18784. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  18785. /** @hidden */
  18786. export var defaultFragmentDeclaration: {
  18787. name: string;
  18788. shader: string;
  18789. };
  18790. }
  18791. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  18792. /** @hidden */
  18793. export var defaultUboDeclaration: {
  18794. name: string;
  18795. shader: string;
  18796. };
  18797. }
  18798. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  18799. /** @hidden */
  18800. export var prePassDeclaration: {
  18801. name: string;
  18802. shader: string;
  18803. };
  18804. }
  18805. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  18806. /** @hidden */
  18807. export var lightFragmentDeclaration: {
  18808. name: string;
  18809. shader: string;
  18810. };
  18811. }
  18812. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  18813. /** @hidden */
  18814. export var lightUboDeclaration: {
  18815. name: string;
  18816. shader: string;
  18817. };
  18818. }
  18819. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  18820. /** @hidden */
  18821. export var lightsFragmentFunctions: {
  18822. name: string;
  18823. shader: string;
  18824. };
  18825. }
  18826. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  18827. /** @hidden */
  18828. export var shadowsFragmentFunctions: {
  18829. name: string;
  18830. shader: string;
  18831. };
  18832. }
  18833. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  18834. /** @hidden */
  18835. export var fresnelFunction: {
  18836. name: string;
  18837. shader: string;
  18838. };
  18839. }
  18840. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  18841. /** @hidden */
  18842. export var bumpFragmentMainFunctions: {
  18843. name: string;
  18844. shader: string;
  18845. };
  18846. }
  18847. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  18848. /** @hidden */
  18849. export var bumpFragmentFunctions: {
  18850. name: string;
  18851. shader: string;
  18852. };
  18853. }
  18854. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  18855. /** @hidden */
  18856. export var logDepthDeclaration: {
  18857. name: string;
  18858. shader: string;
  18859. };
  18860. }
  18861. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  18862. /** @hidden */
  18863. export var fogFragmentDeclaration: {
  18864. name: string;
  18865. shader: string;
  18866. };
  18867. }
  18868. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  18869. /** @hidden */
  18870. export var bumpFragment: {
  18871. name: string;
  18872. shader: string;
  18873. };
  18874. }
  18875. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  18876. /** @hidden */
  18877. export var depthPrePass: {
  18878. name: string;
  18879. shader: string;
  18880. };
  18881. }
  18882. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  18883. /** @hidden */
  18884. export var lightFragment: {
  18885. name: string;
  18886. shader: string;
  18887. };
  18888. }
  18889. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  18890. /** @hidden */
  18891. export var logDepthFragment: {
  18892. name: string;
  18893. shader: string;
  18894. };
  18895. }
  18896. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  18897. /** @hidden */
  18898. export var fogFragment: {
  18899. name: string;
  18900. shader: string;
  18901. };
  18902. }
  18903. declare module "babylonjs/Shaders/default.fragment" {
  18904. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  18905. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  18906. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  18907. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  18908. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  18909. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  18910. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  18911. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  18912. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  18913. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  18914. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  18915. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  18916. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  18917. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  18918. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  18919. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  18920. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  18921. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  18922. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  18923. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  18924. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  18925. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  18926. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  18927. /** @hidden */
  18928. export var defaultPixelShader: {
  18929. name: string;
  18930. shader: string;
  18931. };
  18932. }
  18933. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  18934. /** @hidden */
  18935. export var defaultVertexDeclaration: {
  18936. name: string;
  18937. shader: string;
  18938. };
  18939. }
  18940. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  18941. /** @hidden */
  18942. export var bonesDeclaration: {
  18943. name: string;
  18944. shader: string;
  18945. };
  18946. }
  18947. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  18948. /** @hidden */
  18949. export var instancesDeclaration: {
  18950. name: string;
  18951. shader: string;
  18952. };
  18953. }
  18954. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  18955. /** @hidden */
  18956. export var prePassVertexDeclaration: {
  18957. name: string;
  18958. shader: string;
  18959. };
  18960. }
  18961. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  18962. /** @hidden */
  18963. export var bumpVertexDeclaration: {
  18964. name: string;
  18965. shader: string;
  18966. };
  18967. }
  18968. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  18969. /** @hidden */
  18970. export var fogVertexDeclaration: {
  18971. name: string;
  18972. shader: string;
  18973. };
  18974. }
  18975. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  18976. /** @hidden */
  18977. export var morphTargetsVertexGlobalDeclaration: {
  18978. name: string;
  18979. shader: string;
  18980. };
  18981. }
  18982. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  18983. /** @hidden */
  18984. export var morphTargetsVertexDeclaration: {
  18985. name: string;
  18986. shader: string;
  18987. };
  18988. }
  18989. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  18990. /** @hidden */
  18991. export var morphTargetsVertex: {
  18992. name: string;
  18993. shader: string;
  18994. };
  18995. }
  18996. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  18997. /** @hidden */
  18998. export var instancesVertex: {
  18999. name: string;
  19000. shader: string;
  19001. };
  19002. }
  19003. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  19004. /** @hidden */
  19005. export var bonesVertex: {
  19006. name: string;
  19007. shader: string;
  19008. };
  19009. }
  19010. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  19011. /** @hidden */
  19012. export var prePassVertex: {
  19013. name: string;
  19014. shader: string;
  19015. };
  19016. }
  19017. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  19018. /** @hidden */
  19019. export var bumpVertex: {
  19020. name: string;
  19021. shader: string;
  19022. };
  19023. }
  19024. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  19025. /** @hidden */
  19026. export var fogVertex: {
  19027. name: string;
  19028. shader: string;
  19029. };
  19030. }
  19031. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  19032. /** @hidden */
  19033. export var shadowsVertex: {
  19034. name: string;
  19035. shader: string;
  19036. };
  19037. }
  19038. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  19039. /** @hidden */
  19040. export var pointCloudVertex: {
  19041. name: string;
  19042. shader: string;
  19043. };
  19044. }
  19045. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  19046. /** @hidden */
  19047. export var logDepthVertex: {
  19048. name: string;
  19049. shader: string;
  19050. };
  19051. }
  19052. declare module "babylonjs/Shaders/default.vertex" {
  19053. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  19054. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  19055. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19056. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19057. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19058. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  19059. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  19060. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19061. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  19062. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  19063. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  19064. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  19065. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  19066. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  19067. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  19068. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19069. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19070. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  19071. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  19072. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19073. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  19074. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  19075. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  19076. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  19077. /** @hidden */
  19078. export var defaultVertexShader: {
  19079. name: string;
  19080. shader: string;
  19081. };
  19082. }
  19083. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  19084. import { Nullable } from "babylonjs/types";
  19085. import { Scene } from "babylonjs/scene";
  19086. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19087. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19088. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19089. /**
  19090. * @hidden
  19091. */
  19092. export interface IMaterialDetailMapDefines {
  19093. DETAIL: boolean;
  19094. DETAILDIRECTUV: number;
  19095. DETAIL_NORMALBLENDMETHOD: number;
  19096. /** @hidden */
  19097. _areTexturesDirty: boolean;
  19098. }
  19099. /**
  19100. * Define the code related to the detail map parameters of a material
  19101. *
  19102. * Inspired from:
  19103. * 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
  19104. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19105. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19106. */
  19107. export class DetailMapConfiguration {
  19108. private _texture;
  19109. /**
  19110. * The detail texture of the material.
  19111. */
  19112. texture: Nullable<BaseTexture>;
  19113. /**
  19114. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19115. * Bigger values mean stronger blending
  19116. */
  19117. diffuseBlendLevel: number;
  19118. /**
  19119. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19120. * Bigger values mean stronger blending. Only used with PBR materials
  19121. */
  19122. roughnessBlendLevel: number;
  19123. /**
  19124. * Defines how strong the bump effect from the detail map is
  19125. * Bigger values mean stronger effect
  19126. */
  19127. bumpLevel: number;
  19128. private _normalBlendMethod;
  19129. /**
  19130. * The method used to blend the bump and detail normals together
  19131. */
  19132. normalBlendMethod: number;
  19133. private _isEnabled;
  19134. /**
  19135. * Enable or disable the detail map on this material
  19136. */
  19137. isEnabled: boolean;
  19138. /** @hidden */
  19139. private _internalMarkAllSubMeshesAsTexturesDirty;
  19140. /** @hidden */
  19141. _markAllSubMeshesAsTexturesDirty(): void;
  19142. /**
  19143. * Instantiate a new detail map
  19144. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19145. */
  19146. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19147. /**
  19148. * Gets whether the submesh is ready to be used or not.
  19149. * @param defines the list of "defines" to update.
  19150. * @param scene defines the scene the material belongs to.
  19151. * @returns - boolean indicating that the submesh is ready or not.
  19152. */
  19153. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19154. /**
  19155. * Update the defines for detail map usage
  19156. * @param defines the list of "defines" to update.
  19157. * @param scene defines the scene the material belongs to.
  19158. */
  19159. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19160. /**
  19161. * Binds the material data.
  19162. * @param uniformBuffer defines the Uniform buffer to fill in.
  19163. * @param scene defines the scene the material belongs to.
  19164. * @param isFrozen defines whether the material is frozen or not.
  19165. */
  19166. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19167. /**
  19168. * Checks to see if a texture is used in the material.
  19169. * @param texture - Base texture to use.
  19170. * @returns - Boolean specifying if a texture is used in the material.
  19171. */
  19172. hasTexture(texture: BaseTexture): boolean;
  19173. /**
  19174. * Returns an array of the actively used textures.
  19175. * @param activeTextures Array of BaseTextures
  19176. */
  19177. getActiveTextures(activeTextures: BaseTexture[]): void;
  19178. /**
  19179. * Returns the animatable textures.
  19180. * @param animatables Array of animatable textures.
  19181. */
  19182. getAnimatables(animatables: IAnimatable[]): void;
  19183. /**
  19184. * Disposes the resources of the material.
  19185. * @param forceDisposeTextures - Forces the disposal of all textures.
  19186. */
  19187. dispose(forceDisposeTextures?: boolean): void;
  19188. /**
  19189. * Get the current class name useful for serialization or dynamic coding.
  19190. * @returns "DetailMap"
  19191. */
  19192. getClassName(): string;
  19193. /**
  19194. * Add the required uniforms to the current list.
  19195. * @param uniforms defines the current uniform list.
  19196. */
  19197. static AddUniforms(uniforms: string[]): void;
  19198. /**
  19199. * Add the required samplers to the current list.
  19200. * @param samplers defines the current sampler list.
  19201. */
  19202. static AddSamplers(samplers: string[]): void;
  19203. /**
  19204. * Add the required uniforms to the current buffer.
  19205. * @param uniformBuffer defines the current uniform buffer.
  19206. */
  19207. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19208. /**
  19209. * Makes a duplicate of the current instance into another one.
  19210. * @param detailMap define the instance where to copy the info
  19211. */
  19212. copyTo(detailMap: DetailMapConfiguration): void;
  19213. /**
  19214. * Serializes this detail map instance
  19215. * @returns - An object with the serialized instance.
  19216. */
  19217. serialize(): any;
  19218. /**
  19219. * Parses a detail map setting from a serialized object.
  19220. * @param source - Serialized object.
  19221. * @param scene Defines the scene we are parsing for
  19222. * @param rootUrl Defines the rootUrl to load from
  19223. */
  19224. parse(source: any, scene: Scene, rootUrl: string): void;
  19225. }
  19226. }
  19227. declare module "babylonjs/Materials/standardMaterial" {
  19228. import { SmartArray } from "babylonjs/Misc/smartArray";
  19229. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19230. import { Nullable } from "babylonjs/types";
  19231. import { Scene } from "babylonjs/scene";
  19232. import { Matrix } from "babylonjs/Maths/math.vector";
  19233. import { Color3 } from "babylonjs/Maths/math.color";
  19234. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19236. import { Mesh } from "babylonjs/Meshes/mesh";
  19237. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  19238. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19239. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  19240. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  19241. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  19242. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  19243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19244. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19245. import "babylonjs/Shaders/default.fragment";
  19246. import "babylonjs/Shaders/default.vertex";
  19247. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  19248. /** @hidden */
  19249. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19250. MAINUV1: boolean;
  19251. MAINUV2: boolean;
  19252. DIFFUSE: boolean;
  19253. DIFFUSEDIRECTUV: number;
  19254. DETAIL: boolean;
  19255. DETAILDIRECTUV: number;
  19256. DETAIL_NORMALBLENDMETHOD: number;
  19257. AMBIENT: boolean;
  19258. AMBIENTDIRECTUV: number;
  19259. OPACITY: boolean;
  19260. OPACITYDIRECTUV: number;
  19261. OPACITYRGB: boolean;
  19262. REFLECTION: boolean;
  19263. EMISSIVE: boolean;
  19264. EMISSIVEDIRECTUV: number;
  19265. SPECULAR: boolean;
  19266. SPECULARDIRECTUV: number;
  19267. BUMP: boolean;
  19268. BUMPDIRECTUV: number;
  19269. PARALLAX: boolean;
  19270. PARALLAXOCCLUSION: boolean;
  19271. SPECULAROVERALPHA: boolean;
  19272. CLIPPLANE: boolean;
  19273. CLIPPLANE2: boolean;
  19274. CLIPPLANE3: boolean;
  19275. CLIPPLANE4: boolean;
  19276. CLIPPLANE5: boolean;
  19277. CLIPPLANE6: boolean;
  19278. ALPHATEST: boolean;
  19279. DEPTHPREPASS: boolean;
  19280. ALPHAFROMDIFFUSE: boolean;
  19281. POINTSIZE: boolean;
  19282. FOG: boolean;
  19283. SPECULARTERM: boolean;
  19284. DIFFUSEFRESNEL: boolean;
  19285. OPACITYFRESNEL: boolean;
  19286. REFLECTIONFRESNEL: boolean;
  19287. REFRACTIONFRESNEL: boolean;
  19288. EMISSIVEFRESNEL: boolean;
  19289. FRESNEL: boolean;
  19290. NORMAL: boolean;
  19291. UV1: boolean;
  19292. UV2: boolean;
  19293. VERTEXCOLOR: boolean;
  19294. VERTEXALPHA: boolean;
  19295. NUM_BONE_INFLUENCERS: number;
  19296. BonesPerMesh: number;
  19297. BONETEXTURE: boolean;
  19298. BONES_VELOCITY_ENABLED: boolean;
  19299. INSTANCES: boolean;
  19300. THIN_INSTANCES: boolean;
  19301. GLOSSINESS: boolean;
  19302. ROUGHNESS: boolean;
  19303. EMISSIVEASILLUMINATION: boolean;
  19304. LINKEMISSIVEWITHDIFFUSE: boolean;
  19305. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19306. LIGHTMAP: boolean;
  19307. LIGHTMAPDIRECTUV: number;
  19308. OBJECTSPACE_NORMALMAP: boolean;
  19309. USELIGHTMAPASSHADOWMAP: boolean;
  19310. REFLECTIONMAP_3D: boolean;
  19311. REFLECTIONMAP_SPHERICAL: boolean;
  19312. REFLECTIONMAP_PLANAR: boolean;
  19313. REFLECTIONMAP_CUBIC: boolean;
  19314. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19315. REFLECTIONMAP_PROJECTION: boolean;
  19316. REFLECTIONMAP_SKYBOX: boolean;
  19317. REFLECTIONMAP_EXPLICIT: boolean;
  19318. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19319. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19320. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19321. INVERTCUBICMAP: boolean;
  19322. LOGARITHMICDEPTH: boolean;
  19323. REFRACTION: boolean;
  19324. REFRACTIONMAP_3D: boolean;
  19325. REFLECTIONOVERALPHA: boolean;
  19326. TWOSIDEDLIGHTING: boolean;
  19327. SHADOWFLOAT: boolean;
  19328. MORPHTARGETS: boolean;
  19329. MORPHTARGETS_NORMAL: boolean;
  19330. MORPHTARGETS_TANGENT: boolean;
  19331. MORPHTARGETS_UV: boolean;
  19332. NUM_MORPH_INFLUENCERS: number;
  19333. NONUNIFORMSCALING: boolean;
  19334. PREMULTIPLYALPHA: boolean;
  19335. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19336. ALPHABLEND: boolean;
  19337. PREPASS: boolean;
  19338. PREPASS_IRRADIANCE: boolean;
  19339. PREPASS_IRRADIANCE_INDEX: number;
  19340. PREPASS_ALBEDO: boolean;
  19341. PREPASS_ALBEDO_INDEX: number;
  19342. PREPASS_DEPTHNORMAL: boolean;
  19343. PREPASS_DEPTHNORMAL_INDEX: number;
  19344. PREPASS_POSITION: boolean;
  19345. PREPASS_POSITION_INDEX: number;
  19346. PREPASS_VELOCITY: boolean;
  19347. PREPASS_VELOCITY_INDEX: number;
  19348. PREPASS_REFLECTIVITY: boolean;
  19349. PREPASS_REFLECTIVITY_INDEX: number;
  19350. SCENE_MRT_COUNT: number;
  19351. RGBDLIGHTMAP: boolean;
  19352. RGBDREFLECTION: boolean;
  19353. RGBDREFRACTION: boolean;
  19354. IMAGEPROCESSING: boolean;
  19355. VIGNETTE: boolean;
  19356. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19357. VIGNETTEBLENDMODEOPAQUE: boolean;
  19358. TONEMAPPING: boolean;
  19359. TONEMAPPING_ACES: boolean;
  19360. CONTRAST: boolean;
  19361. COLORCURVES: boolean;
  19362. COLORGRADING: boolean;
  19363. COLORGRADING3D: boolean;
  19364. SAMPLER3DGREENDEPTH: boolean;
  19365. SAMPLER3DBGRMAP: boolean;
  19366. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19367. MULTIVIEW: boolean;
  19368. /**
  19369. * If the reflection texture on this material is in linear color space
  19370. * @hidden
  19371. */
  19372. IS_REFLECTION_LINEAR: boolean;
  19373. /**
  19374. * If the refraction texture on this material is in linear color space
  19375. * @hidden
  19376. */
  19377. IS_REFRACTION_LINEAR: boolean;
  19378. EXPOSURE: boolean;
  19379. constructor();
  19380. setReflectionMode(modeToEnable: string): void;
  19381. }
  19382. /**
  19383. * This is the default material used in Babylon. It is the best trade off between quality
  19384. * and performances.
  19385. * @see https://doc.babylonjs.com/babylon101/materials
  19386. */
  19387. export class StandardMaterial extends PushMaterial {
  19388. private _diffuseTexture;
  19389. /**
  19390. * The basic texture of the material as viewed under a light.
  19391. */
  19392. diffuseTexture: Nullable<BaseTexture>;
  19393. private _ambientTexture;
  19394. /**
  19395. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19396. */
  19397. ambientTexture: Nullable<BaseTexture>;
  19398. private _opacityTexture;
  19399. /**
  19400. * Define the transparency of the material from a texture.
  19401. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19402. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19403. */
  19404. opacityTexture: Nullable<BaseTexture>;
  19405. private _reflectionTexture;
  19406. /**
  19407. * Define the texture used to display the reflection.
  19408. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19409. */
  19410. reflectionTexture: Nullable<BaseTexture>;
  19411. private _emissiveTexture;
  19412. /**
  19413. * Define texture of the material as if self lit.
  19414. * This will be mixed in the final result even in the absence of light.
  19415. */
  19416. emissiveTexture: Nullable<BaseTexture>;
  19417. private _specularTexture;
  19418. /**
  19419. * Define how the color and intensity of the highlight given by the light in the material.
  19420. */
  19421. specularTexture: Nullable<BaseTexture>;
  19422. private _bumpTexture;
  19423. /**
  19424. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19425. * 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.
  19426. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  19427. */
  19428. bumpTexture: Nullable<BaseTexture>;
  19429. private _lightmapTexture;
  19430. /**
  19431. * Complex lighting can be computationally expensive to compute at runtime.
  19432. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19433. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  19434. */
  19435. lightmapTexture: Nullable<BaseTexture>;
  19436. private _refractionTexture;
  19437. /**
  19438. * Define the texture used to display the refraction.
  19439. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19440. */
  19441. refractionTexture: Nullable<BaseTexture>;
  19442. /**
  19443. * The color of the material lit by the environmental background lighting.
  19444. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19445. */
  19446. ambientColor: Color3;
  19447. /**
  19448. * The basic color of the material as viewed under a light.
  19449. */
  19450. diffuseColor: Color3;
  19451. /**
  19452. * Define how the color and intensity of the highlight given by the light in the material.
  19453. */
  19454. specularColor: Color3;
  19455. /**
  19456. * Define the color of the material as if self lit.
  19457. * This will be mixed in the final result even in the absence of light.
  19458. */
  19459. emissiveColor: Color3;
  19460. /**
  19461. * Defines how sharp are the highlights in the material.
  19462. * The bigger the value the sharper giving a more glossy feeling to the result.
  19463. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19464. */
  19465. specularPower: number;
  19466. private _useAlphaFromDiffuseTexture;
  19467. /**
  19468. * Does the transparency come from the diffuse texture alpha channel.
  19469. */
  19470. useAlphaFromDiffuseTexture: boolean;
  19471. private _useEmissiveAsIllumination;
  19472. /**
  19473. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19474. */
  19475. useEmissiveAsIllumination: boolean;
  19476. private _linkEmissiveWithDiffuse;
  19477. /**
  19478. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19479. * the emissive level when the final color is close to one.
  19480. */
  19481. linkEmissiveWithDiffuse: boolean;
  19482. private _useSpecularOverAlpha;
  19483. /**
  19484. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19485. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19486. */
  19487. useSpecularOverAlpha: boolean;
  19488. private _useReflectionOverAlpha;
  19489. /**
  19490. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19491. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19492. */
  19493. useReflectionOverAlpha: boolean;
  19494. private _disableLighting;
  19495. /**
  19496. * Does lights from the scene impacts this material.
  19497. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19498. */
  19499. disableLighting: boolean;
  19500. private _useObjectSpaceNormalMap;
  19501. /**
  19502. * Allows using an object space normal map (instead of tangent space).
  19503. */
  19504. useObjectSpaceNormalMap: boolean;
  19505. private _useParallax;
  19506. /**
  19507. * Is parallax enabled or not.
  19508. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19509. */
  19510. useParallax: boolean;
  19511. private _useParallaxOcclusion;
  19512. /**
  19513. * Is parallax occlusion enabled or not.
  19514. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19515. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19516. */
  19517. useParallaxOcclusion: boolean;
  19518. /**
  19519. * 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.
  19520. */
  19521. parallaxScaleBias: number;
  19522. private _roughness;
  19523. /**
  19524. * Helps to define how blurry the reflections should appears in the material.
  19525. */
  19526. roughness: number;
  19527. /**
  19528. * In case of refraction, define the value of the index of refraction.
  19529. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19530. */
  19531. indexOfRefraction: number;
  19532. /**
  19533. * Invert the refraction texture alongside the y axis.
  19534. * It can be useful with procedural textures or probe for instance.
  19535. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19536. */
  19537. invertRefractionY: boolean;
  19538. /**
  19539. * Defines the alpha limits in alpha test mode.
  19540. */
  19541. alphaCutOff: number;
  19542. private _useLightmapAsShadowmap;
  19543. /**
  19544. * In case of light mapping, define whether the map contains light or shadow informations.
  19545. */
  19546. useLightmapAsShadowmap: boolean;
  19547. private _diffuseFresnelParameters;
  19548. /**
  19549. * Define the diffuse fresnel parameters of the material.
  19550. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19551. */
  19552. diffuseFresnelParameters: FresnelParameters;
  19553. private _opacityFresnelParameters;
  19554. /**
  19555. * Define the opacity fresnel parameters of the material.
  19556. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19557. */
  19558. opacityFresnelParameters: FresnelParameters;
  19559. private _reflectionFresnelParameters;
  19560. /**
  19561. * Define the reflection fresnel parameters of the material.
  19562. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19563. */
  19564. reflectionFresnelParameters: FresnelParameters;
  19565. private _refractionFresnelParameters;
  19566. /**
  19567. * Define the refraction fresnel parameters of the material.
  19568. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19569. */
  19570. refractionFresnelParameters: FresnelParameters;
  19571. private _emissiveFresnelParameters;
  19572. /**
  19573. * Define the emissive fresnel parameters of the material.
  19574. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19575. */
  19576. emissiveFresnelParameters: FresnelParameters;
  19577. private _useReflectionFresnelFromSpecular;
  19578. /**
  19579. * If true automatically deducts the fresnels values from the material specularity.
  19580. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19581. */
  19582. useReflectionFresnelFromSpecular: boolean;
  19583. private _useGlossinessFromSpecularMapAlpha;
  19584. /**
  19585. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19586. */
  19587. useGlossinessFromSpecularMapAlpha: boolean;
  19588. private _maxSimultaneousLights;
  19589. /**
  19590. * Defines the maximum number of lights that can be used in the material
  19591. */
  19592. maxSimultaneousLights: number;
  19593. private _invertNormalMapX;
  19594. /**
  19595. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19596. */
  19597. invertNormalMapX: boolean;
  19598. private _invertNormalMapY;
  19599. /**
  19600. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19601. */
  19602. invertNormalMapY: boolean;
  19603. private _twoSidedLighting;
  19604. /**
  19605. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19606. */
  19607. twoSidedLighting: boolean;
  19608. /**
  19609. * Default configuration related to image processing available in the standard Material.
  19610. */
  19611. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19612. /**
  19613. * Gets the image processing configuration used either in this material.
  19614. */
  19615. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19616. /**
  19617. * Sets the Default image processing configuration used either in the this material.
  19618. *
  19619. * If sets to null, the scene one is in use.
  19620. */
  19621. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19622. /**
  19623. * Keep track of the image processing observer to allow dispose and replace.
  19624. */
  19625. private _imageProcessingObserver;
  19626. /**
  19627. * Attaches a new image processing configuration to the Standard Material.
  19628. * @param configuration
  19629. */
  19630. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19631. /**
  19632. * Defines additionnal PrePass parameters for the material.
  19633. */
  19634. readonly prePassConfiguration: PrePassConfiguration;
  19635. /**
  19636. * Gets wether the color curves effect is enabled.
  19637. */
  19638. get cameraColorCurvesEnabled(): boolean;
  19639. /**
  19640. * Sets wether the color curves effect is enabled.
  19641. */
  19642. set cameraColorCurvesEnabled(value: boolean);
  19643. /**
  19644. * Gets wether the color grading effect is enabled.
  19645. */
  19646. get cameraColorGradingEnabled(): boolean;
  19647. /**
  19648. * Gets wether the color grading effect is enabled.
  19649. */
  19650. set cameraColorGradingEnabled(value: boolean);
  19651. /**
  19652. * Gets wether tonemapping is enabled or not.
  19653. */
  19654. get cameraToneMappingEnabled(): boolean;
  19655. /**
  19656. * Sets wether tonemapping is enabled or not
  19657. */
  19658. set cameraToneMappingEnabled(value: boolean);
  19659. /**
  19660. * The camera exposure used on this material.
  19661. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19662. * This corresponds to a photographic exposure.
  19663. */
  19664. get cameraExposure(): number;
  19665. /**
  19666. * The camera exposure used on this material.
  19667. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19668. * This corresponds to a photographic exposure.
  19669. */
  19670. set cameraExposure(value: number);
  19671. /**
  19672. * Gets The camera contrast used on this material.
  19673. */
  19674. get cameraContrast(): number;
  19675. /**
  19676. * Sets The camera contrast used on this material.
  19677. */
  19678. set cameraContrast(value: number);
  19679. /**
  19680. * Gets the Color Grading 2D Lookup Texture.
  19681. */
  19682. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19683. /**
  19684. * Sets the Color Grading 2D Lookup Texture.
  19685. */
  19686. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19687. /**
  19688. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19689. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19690. * 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;
  19691. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19692. */
  19693. get cameraColorCurves(): Nullable<ColorCurves>;
  19694. /**
  19695. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19696. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19697. * 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;
  19698. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19699. */
  19700. set cameraColorCurves(value: Nullable<ColorCurves>);
  19701. /**
  19702. * Can this material render to several textures at once
  19703. */
  19704. get canRenderToMRT(): boolean;
  19705. /**
  19706. * Defines the detail map parameters for the material.
  19707. */
  19708. readonly detailMap: DetailMapConfiguration;
  19709. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19710. protected _worldViewProjectionMatrix: Matrix;
  19711. protected _globalAmbientColor: Color3;
  19712. protected _useLogarithmicDepth: boolean;
  19713. protected _rebuildInParallel: boolean;
  19714. /**
  19715. * Instantiates a new standard material.
  19716. * This is the default material used in Babylon. It is the best trade off between quality
  19717. * and performances.
  19718. * @see https://doc.babylonjs.com/babylon101/materials
  19719. * @param name Define the name of the material in the scene
  19720. * @param scene Define the scene the material belong to
  19721. */
  19722. constructor(name: string, scene: Scene);
  19723. /**
  19724. * Gets a boolean indicating that current material needs to register RTT
  19725. */
  19726. get hasRenderTargetTextures(): boolean;
  19727. /**
  19728. * Gets the current class name of the material e.g. "StandardMaterial"
  19729. * Mainly use in serialization.
  19730. * @returns the class name
  19731. */
  19732. getClassName(): string;
  19733. /**
  19734. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19735. * You can try switching to logarithmic depth.
  19736. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19737. */
  19738. get useLogarithmicDepth(): boolean;
  19739. set useLogarithmicDepth(value: boolean);
  19740. /**
  19741. * Specifies if the material will require alpha blending
  19742. * @returns a boolean specifying if alpha blending is needed
  19743. */
  19744. needAlphaBlending(): boolean;
  19745. /**
  19746. * Specifies if this material should be rendered in alpha test mode
  19747. * @returns a boolean specifying if an alpha test is needed.
  19748. */
  19749. needAlphaTesting(): boolean;
  19750. /**
  19751. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19752. */
  19753. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19754. /**
  19755. * Specifies whether or not there is a usable alpha channel for transparency.
  19756. */
  19757. protected _hasAlphaChannel(): boolean;
  19758. /**
  19759. * Get the texture used for alpha test purpose.
  19760. * @returns the diffuse texture in case of the standard material.
  19761. */
  19762. getAlphaTestTexture(): Nullable<BaseTexture>;
  19763. /**
  19764. * Get if the submesh is ready to be used and all its information available.
  19765. * Child classes can use it to update shaders
  19766. * @param mesh defines the mesh to check
  19767. * @param subMesh defines which submesh to check
  19768. * @param useInstances specifies that instances should be used
  19769. * @returns a boolean indicating that the submesh is ready or not
  19770. */
  19771. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19772. /**
  19773. * Builds the material UBO layouts.
  19774. * Used internally during the effect preparation.
  19775. */
  19776. buildUniformLayout(): void;
  19777. /**
  19778. * Unbinds the material from the mesh
  19779. */
  19780. unbind(): void;
  19781. /**
  19782. * Binds the submesh to this material by preparing the effect and shader to draw
  19783. * @param world defines the world transformation matrix
  19784. * @param mesh defines the mesh containing the submesh
  19785. * @param subMesh defines the submesh to bind the material to
  19786. */
  19787. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19788. /**
  19789. * Get the list of animatables in the material.
  19790. * @returns the list of animatables object used in the material
  19791. */
  19792. getAnimatables(): IAnimatable[];
  19793. /**
  19794. * Gets the active textures from the material
  19795. * @returns an array of textures
  19796. */
  19797. getActiveTextures(): BaseTexture[];
  19798. /**
  19799. * Specifies if the material uses a texture
  19800. * @param texture defines the texture to check against the material
  19801. * @returns a boolean specifying if the material uses the texture
  19802. */
  19803. hasTexture(texture: BaseTexture): boolean;
  19804. /**
  19805. * Disposes the material
  19806. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19807. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19808. */
  19809. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19810. /**
  19811. * Makes a duplicate of the material, and gives it a new name
  19812. * @param name defines the new name for the duplicated material
  19813. * @returns the cloned material
  19814. */
  19815. clone(name: string): StandardMaterial;
  19816. /**
  19817. * Serializes this material in a JSON representation
  19818. * @returns the serialized material object
  19819. */
  19820. serialize(): any;
  19821. /**
  19822. * Creates a standard material from parsed material data
  19823. * @param source defines the JSON representation of the material
  19824. * @param scene defines the hosting scene
  19825. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19826. * @returns a new standard material
  19827. */
  19828. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19829. /**
  19830. * Are diffuse textures enabled in the application.
  19831. */
  19832. static get DiffuseTextureEnabled(): boolean;
  19833. static set DiffuseTextureEnabled(value: boolean);
  19834. /**
  19835. * Are detail textures enabled in the application.
  19836. */
  19837. static get DetailTextureEnabled(): boolean;
  19838. static set DetailTextureEnabled(value: boolean);
  19839. /**
  19840. * Are ambient textures enabled in the application.
  19841. */
  19842. static get AmbientTextureEnabled(): boolean;
  19843. static set AmbientTextureEnabled(value: boolean);
  19844. /**
  19845. * Are opacity textures enabled in the application.
  19846. */
  19847. static get OpacityTextureEnabled(): boolean;
  19848. static set OpacityTextureEnabled(value: boolean);
  19849. /**
  19850. * Are reflection textures enabled in the application.
  19851. */
  19852. static get ReflectionTextureEnabled(): boolean;
  19853. static set ReflectionTextureEnabled(value: boolean);
  19854. /**
  19855. * Are emissive textures enabled in the application.
  19856. */
  19857. static get EmissiveTextureEnabled(): boolean;
  19858. static set EmissiveTextureEnabled(value: boolean);
  19859. /**
  19860. * Are specular textures enabled in the application.
  19861. */
  19862. static get SpecularTextureEnabled(): boolean;
  19863. static set SpecularTextureEnabled(value: boolean);
  19864. /**
  19865. * Are bump textures enabled in the application.
  19866. */
  19867. static get BumpTextureEnabled(): boolean;
  19868. static set BumpTextureEnabled(value: boolean);
  19869. /**
  19870. * Are lightmap textures enabled in the application.
  19871. */
  19872. static get LightmapTextureEnabled(): boolean;
  19873. static set LightmapTextureEnabled(value: boolean);
  19874. /**
  19875. * Are refraction textures enabled in the application.
  19876. */
  19877. static get RefractionTextureEnabled(): boolean;
  19878. static set RefractionTextureEnabled(value: boolean);
  19879. /**
  19880. * Are color grading textures enabled in the application.
  19881. */
  19882. static get ColorGradingTextureEnabled(): boolean;
  19883. static set ColorGradingTextureEnabled(value: boolean);
  19884. /**
  19885. * Are fresnels enabled in the application.
  19886. */
  19887. static get FresnelEnabled(): boolean;
  19888. static set FresnelEnabled(value: boolean);
  19889. }
  19890. }
  19891. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  19892. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19893. /** @hidden */
  19894. export var rgbdDecodePixelShader: {
  19895. name: string;
  19896. shader: string;
  19897. };
  19898. }
  19899. declare module "babylonjs/Misc/rgbdTextureTools" {
  19900. import "babylonjs/Shaders/rgbdDecode.fragment";
  19901. import "babylonjs/Engines/Extensions/engine.renderTarget";
  19902. import { Texture } from "babylonjs/Materials/Textures/texture";
  19903. /**
  19904. * Class used to host RGBD texture specific utilities
  19905. */
  19906. export class RGBDTextureTools {
  19907. /**
  19908. * Expand the RGBD Texture from RGBD to Half Float if possible.
  19909. * @param texture the texture to expand.
  19910. */
  19911. static ExpandRGBDTexture(texture: Texture): void;
  19912. }
  19913. }
  19914. declare module "babylonjs/Misc/brdfTextureTools" {
  19915. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19916. import { Scene } from "babylonjs/scene";
  19917. /**
  19918. * Class used to host texture specific utilities
  19919. */
  19920. export class BRDFTextureTools {
  19921. /**
  19922. * Prevents texture cache collision
  19923. */
  19924. private static _instanceNumber;
  19925. /**
  19926. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  19927. * @param scene defines the hosting scene
  19928. * @returns the environment BRDF texture
  19929. */
  19930. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  19931. private static _environmentBRDFBase64Texture;
  19932. }
  19933. }
  19934. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  19935. import { Nullable } from "babylonjs/types";
  19936. import { Color3 } from "babylonjs/Maths/math.color";
  19937. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19938. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19939. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19940. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  19941. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19942. import { Engine } from "babylonjs/Engines/engine";
  19943. import { Scene } from "babylonjs/scene";
  19944. /**
  19945. * @hidden
  19946. */
  19947. export interface IMaterialClearCoatDefines {
  19948. CLEARCOAT: boolean;
  19949. CLEARCOAT_DEFAULTIOR: boolean;
  19950. CLEARCOAT_TEXTURE: boolean;
  19951. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  19952. CLEARCOAT_TEXTUREDIRECTUV: number;
  19953. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  19954. CLEARCOAT_BUMP: boolean;
  19955. CLEARCOAT_BUMPDIRECTUV: number;
  19956. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19957. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19958. CLEARCOAT_REMAP_F0: boolean;
  19959. CLEARCOAT_TINT: boolean;
  19960. CLEARCOAT_TINT_TEXTURE: boolean;
  19961. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  19962. /** @hidden */
  19963. _areTexturesDirty: boolean;
  19964. }
  19965. /**
  19966. * Define the code related to the clear coat parameters of the pbr material.
  19967. */
  19968. export class PBRClearCoatConfiguration {
  19969. /**
  19970. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19971. * The default fits with a polyurethane material.
  19972. * @hidden
  19973. */
  19974. static readonly _DefaultIndexOfRefraction: number;
  19975. private _isEnabled;
  19976. /**
  19977. * Defines if the clear coat is enabled in the material.
  19978. */
  19979. isEnabled: boolean;
  19980. /**
  19981. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  19982. */
  19983. intensity: number;
  19984. /**
  19985. * Defines the clear coat layer roughness.
  19986. */
  19987. roughness: number;
  19988. private _indexOfRefraction;
  19989. /**
  19990. * Defines the index of refraction of the clear coat.
  19991. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19992. * The default fits with a polyurethane material.
  19993. * Changing the default value is more performance intensive.
  19994. */
  19995. indexOfRefraction: number;
  19996. private _texture;
  19997. /**
  19998. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  19999. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20000. * if textureRoughness is not empty, else no texture roughness is used
  20001. */
  20002. texture: Nullable<BaseTexture>;
  20003. private _useRoughnessFromMainTexture;
  20004. /**
  20005. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20006. * If false, the green channel from textureRoughness is used for roughness
  20007. */
  20008. useRoughnessFromMainTexture: boolean;
  20009. private _textureRoughness;
  20010. /**
  20011. * Stores the clear coat roughness in a texture (green channel)
  20012. * Not used if useRoughnessFromMainTexture is true
  20013. */
  20014. textureRoughness: Nullable<BaseTexture>;
  20015. private _remapF0OnInterfaceChange;
  20016. /**
  20017. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20018. */
  20019. remapF0OnInterfaceChange: boolean;
  20020. private _bumpTexture;
  20021. /**
  20022. * Define the clear coat specific bump texture.
  20023. */
  20024. bumpTexture: Nullable<BaseTexture>;
  20025. private _isTintEnabled;
  20026. /**
  20027. * Defines if the clear coat tint is enabled in the material.
  20028. */
  20029. isTintEnabled: boolean;
  20030. /**
  20031. * Defines the clear coat tint of the material.
  20032. * This is only use if tint is enabled
  20033. */
  20034. tintColor: Color3;
  20035. /**
  20036. * Defines the distance at which the tint color should be found in the
  20037. * clear coat media.
  20038. * This is only use if tint is enabled
  20039. */
  20040. tintColorAtDistance: number;
  20041. /**
  20042. * Defines the clear coat layer thickness.
  20043. * This is only use if tint is enabled
  20044. */
  20045. tintThickness: number;
  20046. private _tintTexture;
  20047. /**
  20048. * Stores the clear tint values in a texture.
  20049. * rgb is tint
  20050. * a is a thickness factor
  20051. */
  20052. tintTexture: Nullable<BaseTexture>;
  20053. /** @hidden */
  20054. private _internalMarkAllSubMeshesAsTexturesDirty;
  20055. /** @hidden */
  20056. _markAllSubMeshesAsTexturesDirty(): void;
  20057. /**
  20058. * Instantiate a new istance of clear coat configuration.
  20059. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20060. */
  20061. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20062. /**
  20063. * Gets wehter the submesh is ready to be used or not.
  20064. * @param defines the list of "defines" to update.
  20065. * @param scene defines the scene the material belongs to.
  20066. * @param engine defines the engine the material belongs to.
  20067. * @param disableBumpMap defines wether the material disables bump or not.
  20068. * @returns - boolean indicating that the submesh is ready or not.
  20069. */
  20070. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20071. /**
  20072. * Checks to see if a texture is used in the material.
  20073. * @param defines the list of "defines" to update.
  20074. * @param scene defines the scene to the material belongs to.
  20075. */
  20076. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20077. /**
  20078. * Binds the material data.
  20079. * @param uniformBuffer defines the Uniform buffer to fill in.
  20080. * @param scene defines the scene the material belongs to.
  20081. * @param engine defines the engine the material belongs to.
  20082. * @param disableBumpMap defines wether the material disables bump or not.
  20083. * @param isFrozen defines wether the material is frozen or not.
  20084. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20085. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20086. * @param subMesh the submesh to bind data for
  20087. */
  20088. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20089. /**
  20090. * Checks to see if a texture is used in the material.
  20091. * @param texture - Base texture to use.
  20092. * @returns - Boolean specifying if a texture is used in the material.
  20093. */
  20094. hasTexture(texture: BaseTexture): boolean;
  20095. /**
  20096. * Returns an array of the actively used textures.
  20097. * @param activeTextures Array of BaseTextures
  20098. */
  20099. getActiveTextures(activeTextures: BaseTexture[]): void;
  20100. /**
  20101. * Returns the animatable textures.
  20102. * @param animatables Array of animatable textures.
  20103. */
  20104. getAnimatables(animatables: IAnimatable[]): void;
  20105. /**
  20106. * Disposes the resources of the material.
  20107. * @param forceDisposeTextures - Forces the disposal of all textures.
  20108. */
  20109. dispose(forceDisposeTextures?: boolean): void;
  20110. /**
  20111. * Get the current class name of the texture useful for serialization or dynamic coding.
  20112. * @returns "PBRClearCoatConfiguration"
  20113. */
  20114. getClassName(): string;
  20115. /**
  20116. * Add fallbacks to the effect fallbacks list.
  20117. * @param defines defines the Base texture to use.
  20118. * @param fallbacks defines the current fallback list.
  20119. * @param currentRank defines the current fallback rank.
  20120. * @returns the new fallback rank.
  20121. */
  20122. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20123. /**
  20124. * Add the required uniforms to the current list.
  20125. * @param uniforms defines the current uniform list.
  20126. */
  20127. static AddUniforms(uniforms: string[]): void;
  20128. /**
  20129. * Add the required samplers to the current list.
  20130. * @param samplers defines the current sampler list.
  20131. */
  20132. static AddSamplers(samplers: string[]): void;
  20133. /**
  20134. * Add the required uniforms to the current buffer.
  20135. * @param uniformBuffer defines the current uniform buffer.
  20136. */
  20137. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20138. /**
  20139. * Makes a duplicate of the current configuration into another one.
  20140. * @param clearCoatConfiguration define the config where to copy the info
  20141. */
  20142. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20143. /**
  20144. * Serializes this clear coat configuration.
  20145. * @returns - An object with the serialized config.
  20146. */
  20147. serialize(): any;
  20148. /**
  20149. * Parses a anisotropy Configuration from a serialized object.
  20150. * @param source - Serialized object.
  20151. * @param scene Defines the scene we are parsing for
  20152. * @param rootUrl Defines the rootUrl to load from
  20153. */
  20154. parse(source: any, scene: Scene, rootUrl: string): void;
  20155. }
  20156. }
  20157. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  20158. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20160. import { Vector2 } from "babylonjs/Maths/math.vector";
  20161. import { Scene } from "babylonjs/scene";
  20162. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20163. import { Nullable } from "babylonjs/types";
  20164. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20165. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20166. /**
  20167. * @hidden
  20168. */
  20169. export interface IMaterialAnisotropicDefines {
  20170. ANISOTROPIC: boolean;
  20171. ANISOTROPIC_TEXTURE: boolean;
  20172. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20173. MAINUV1: boolean;
  20174. _areTexturesDirty: boolean;
  20175. _needUVs: boolean;
  20176. }
  20177. /**
  20178. * Define the code related to the anisotropic parameters of the pbr material.
  20179. */
  20180. export class PBRAnisotropicConfiguration {
  20181. private _isEnabled;
  20182. /**
  20183. * Defines if the anisotropy is enabled in the material.
  20184. */
  20185. isEnabled: boolean;
  20186. /**
  20187. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20188. */
  20189. intensity: number;
  20190. /**
  20191. * Defines if the effect is along the tangents, bitangents or in between.
  20192. * By default, the effect is "strectching" the highlights along the tangents.
  20193. */
  20194. direction: Vector2;
  20195. private _texture;
  20196. /**
  20197. * Stores the anisotropy values in a texture.
  20198. * rg is direction (like normal from -1 to 1)
  20199. * b is a intensity
  20200. */
  20201. texture: Nullable<BaseTexture>;
  20202. /** @hidden */
  20203. private _internalMarkAllSubMeshesAsTexturesDirty;
  20204. /** @hidden */
  20205. _markAllSubMeshesAsTexturesDirty(): void;
  20206. /**
  20207. * Instantiate a new istance of anisotropy configuration.
  20208. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20209. */
  20210. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20211. /**
  20212. * Specifies that the submesh is ready to be used.
  20213. * @param defines the list of "defines" to update.
  20214. * @param scene defines the scene the material belongs to.
  20215. * @returns - boolean indicating that the submesh is ready or not.
  20216. */
  20217. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20218. /**
  20219. * Checks to see if a texture is used in the material.
  20220. * @param defines the list of "defines" to update.
  20221. * @param mesh the mesh we are preparing the defines for.
  20222. * @param scene defines the scene the material belongs to.
  20223. */
  20224. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20225. /**
  20226. * Binds the material data.
  20227. * @param uniformBuffer defines the Uniform buffer to fill in.
  20228. * @param scene defines the scene the material belongs to.
  20229. * @param isFrozen defines wether the material is frozen or not.
  20230. */
  20231. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20232. /**
  20233. * Checks to see if a texture is used in the material.
  20234. * @param texture - Base texture to use.
  20235. * @returns - Boolean specifying if a texture is used in the material.
  20236. */
  20237. hasTexture(texture: BaseTexture): boolean;
  20238. /**
  20239. * Returns an array of the actively used textures.
  20240. * @param activeTextures Array of BaseTextures
  20241. */
  20242. getActiveTextures(activeTextures: BaseTexture[]): void;
  20243. /**
  20244. * Returns the animatable textures.
  20245. * @param animatables Array of animatable textures.
  20246. */
  20247. getAnimatables(animatables: IAnimatable[]): void;
  20248. /**
  20249. * Disposes the resources of the material.
  20250. * @param forceDisposeTextures - Forces the disposal of all textures.
  20251. */
  20252. dispose(forceDisposeTextures?: boolean): void;
  20253. /**
  20254. * Get the current class name of the texture useful for serialization or dynamic coding.
  20255. * @returns "PBRAnisotropicConfiguration"
  20256. */
  20257. getClassName(): string;
  20258. /**
  20259. * Add fallbacks to the effect fallbacks list.
  20260. * @param defines defines the Base texture to use.
  20261. * @param fallbacks defines the current fallback list.
  20262. * @param currentRank defines the current fallback rank.
  20263. * @returns the new fallback rank.
  20264. */
  20265. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20266. /**
  20267. * Add the required uniforms to the current list.
  20268. * @param uniforms defines the current uniform list.
  20269. */
  20270. static AddUniforms(uniforms: string[]): void;
  20271. /**
  20272. * Add the required uniforms to the current buffer.
  20273. * @param uniformBuffer defines the current uniform buffer.
  20274. */
  20275. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20276. /**
  20277. * Add the required samplers to the current list.
  20278. * @param samplers defines the current sampler list.
  20279. */
  20280. static AddSamplers(samplers: string[]): void;
  20281. /**
  20282. * Makes a duplicate of the current configuration into another one.
  20283. * @param anisotropicConfiguration define the config where to copy the info
  20284. */
  20285. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  20286. /**
  20287. * Serializes this anisotropy configuration.
  20288. * @returns - An object with the serialized config.
  20289. */
  20290. serialize(): any;
  20291. /**
  20292. * Parses a anisotropy Configuration from a serialized object.
  20293. * @param source - Serialized object.
  20294. * @param scene Defines the scene we are parsing for
  20295. * @param rootUrl Defines the rootUrl to load from
  20296. */
  20297. parse(source: any, scene: Scene, rootUrl: string): void;
  20298. }
  20299. }
  20300. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  20301. import { Scene } from "babylonjs/scene";
  20302. /**
  20303. * @hidden
  20304. */
  20305. export interface IMaterialBRDFDefines {
  20306. BRDF_V_HEIGHT_CORRELATED: boolean;
  20307. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20308. SPHERICAL_HARMONICS: boolean;
  20309. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20310. /** @hidden */
  20311. _areMiscDirty: boolean;
  20312. }
  20313. /**
  20314. * Define the code related to the BRDF parameters of the pbr material.
  20315. */
  20316. export class PBRBRDFConfiguration {
  20317. /**
  20318. * Default value used for the energy conservation.
  20319. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20320. */
  20321. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  20322. /**
  20323. * Default value used for the Smith Visibility Height Correlated mode.
  20324. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20325. */
  20326. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  20327. /**
  20328. * Default value used for the IBL diffuse part.
  20329. * This can help switching back to the polynomials mode globally which is a tiny bit
  20330. * less GPU intensive at the drawback of a lower quality.
  20331. */
  20332. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  20333. /**
  20334. * Default value used for activating energy conservation for the specular workflow.
  20335. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20336. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20337. */
  20338. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  20339. private _useEnergyConservation;
  20340. /**
  20341. * Defines if the material uses energy conservation.
  20342. */
  20343. useEnergyConservation: boolean;
  20344. private _useSmithVisibilityHeightCorrelated;
  20345. /**
  20346. * LEGACY Mode set to false
  20347. * Defines if the material uses height smith correlated visibility term.
  20348. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  20349. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  20350. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  20351. * Not relying on height correlated will also disable energy conservation.
  20352. */
  20353. useSmithVisibilityHeightCorrelated: boolean;
  20354. private _useSphericalHarmonics;
  20355. /**
  20356. * LEGACY Mode set to false
  20357. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  20358. * diffuse part of the IBL.
  20359. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  20360. * to the ground truth.
  20361. */
  20362. useSphericalHarmonics: boolean;
  20363. private _useSpecularGlossinessInputEnergyConservation;
  20364. /**
  20365. * Defines if the material uses energy conservation, when the specular workflow is active.
  20366. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20367. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20368. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  20369. */
  20370. useSpecularGlossinessInputEnergyConservation: boolean;
  20371. /** @hidden */
  20372. private _internalMarkAllSubMeshesAsMiscDirty;
  20373. /** @hidden */
  20374. _markAllSubMeshesAsMiscDirty(): void;
  20375. /**
  20376. * Instantiate a new istance of clear coat configuration.
  20377. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  20378. */
  20379. constructor(markAllSubMeshesAsMiscDirty: () => void);
  20380. /**
  20381. * Checks to see if a texture is used in the material.
  20382. * @param defines the list of "defines" to update.
  20383. */
  20384. prepareDefines(defines: IMaterialBRDFDefines): void;
  20385. /**
  20386. * Get the current class name of the texture useful for serialization or dynamic coding.
  20387. * @returns "PBRClearCoatConfiguration"
  20388. */
  20389. getClassName(): string;
  20390. /**
  20391. * Makes a duplicate of the current configuration into another one.
  20392. * @param brdfConfiguration define the config where to copy the info
  20393. */
  20394. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  20395. /**
  20396. * Serializes this BRDF configuration.
  20397. * @returns - An object with the serialized config.
  20398. */
  20399. serialize(): any;
  20400. /**
  20401. * Parses a anisotropy Configuration from a serialized object.
  20402. * @param source - Serialized object.
  20403. * @param scene Defines the scene we are parsing for
  20404. * @param rootUrl Defines the rootUrl to load from
  20405. */
  20406. parse(source: any, scene: Scene, rootUrl: string): void;
  20407. }
  20408. }
  20409. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  20410. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20411. import { Color3 } from "babylonjs/Maths/math.color";
  20412. import { Scene } from "babylonjs/scene";
  20413. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20414. import { Nullable } from "babylonjs/types";
  20415. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20416. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20417. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20418. /**
  20419. * @hidden
  20420. */
  20421. export interface IMaterialSheenDefines {
  20422. SHEEN: boolean;
  20423. SHEEN_TEXTURE: boolean;
  20424. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20425. SHEEN_TEXTUREDIRECTUV: number;
  20426. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20427. SHEEN_LINKWITHALBEDO: boolean;
  20428. SHEEN_ROUGHNESS: boolean;
  20429. SHEEN_ALBEDOSCALING: boolean;
  20430. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20431. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20432. /** @hidden */
  20433. _areTexturesDirty: boolean;
  20434. }
  20435. /**
  20436. * Define the code related to the Sheen parameters of the pbr material.
  20437. */
  20438. export class PBRSheenConfiguration {
  20439. private _isEnabled;
  20440. /**
  20441. * Defines if the material uses sheen.
  20442. */
  20443. isEnabled: boolean;
  20444. private _linkSheenWithAlbedo;
  20445. /**
  20446. * Defines if the sheen is linked to the sheen color.
  20447. */
  20448. linkSheenWithAlbedo: boolean;
  20449. /**
  20450. * Defines the sheen intensity.
  20451. */
  20452. intensity: number;
  20453. /**
  20454. * Defines the sheen color.
  20455. */
  20456. color: Color3;
  20457. private _texture;
  20458. /**
  20459. * Stores the sheen tint values in a texture.
  20460. * rgb is tint
  20461. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  20462. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  20463. */
  20464. texture: Nullable<BaseTexture>;
  20465. private _useRoughnessFromMainTexture;
  20466. /**
  20467. * Indicates that the alpha channel of the texture property will be used for roughness.
  20468. * Has no effect if the roughness (and texture!) property is not defined
  20469. */
  20470. useRoughnessFromMainTexture: boolean;
  20471. private _roughness;
  20472. /**
  20473. * Defines the sheen roughness.
  20474. * It is not taken into account if linkSheenWithAlbedo is true.
  20475. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  20476. */
  20477. roughness: Nullable<number>;
  20478. private _textureRoughness;
  20479. /**
  20480. * Stores the sheen roughness in a texture.
  20481. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  20482. */
  20483. textureRoughness: Nullable<BaseTexture>;
  20484. private _albedoScaling;
  20485. /**
  20486. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  20487. * It allows the strength of the sheen effect to not depend on the base color of the material,
  20488. * making it easier to setup and tweak the effect
  20489. */
  20490. albedoScaling: boolean;
  20491. /** @hidden */
  20492. private _internalMarkAllSubMeshesAsTexturesDirty;
  20493. /** @hidden */
  20494. _markAllSubMeshesAsTexturesDirty(): void;
  20495. /**
  20496. * Instantiate a new istance of clear coat configuration.
  20497. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20498. */
  20499. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20500. /**
  20501. * Specifies that the submesh is ready to be used.
  20502. * @param defines the list of "defines" to update.
  20503. * @param scene defines the scene the material belongs to.
  20504. * @returns - boolean indicating that the submesh is ready or not.
  20505. */
  20506. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  20507. /**
  20508. * Checks to see if a texture is used in the material.
  20509. * @param defines the list of "defines" to update.
  20510. * @param scene defines the scene the material belongs to.
  20511. */
  20512. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  20513. /**
  20514. * Binds the material data.
  20515. * @param uniformBuffer defines the Uniform buffer to fill in.
  20516. * @param scene defines the scene the material belongs to.
  20517. * @param isFrozen defines wether the material is frozen or not.
  20518. * @param subMesh the submesh to bind data for
  20519. */
  20520. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  20521. /**
  20522. * Checks to see if a texture is used in the material.
  20523. * @param texture - Base texture to use.
  20524. * @returns - Boolean specifying if a texture is used in the material.
  20525. */
  20526. hasTexture(texture: BaseTexture): boolean;
  20527. /**
  20528. * Returns an array of the actively used textures.
  20529. * @param activeTextures Array of BaseTextures
  20530. */
  20531. getActiveTextures(activeTextures: BaseTexture[]): void;
  20532. /**
  20533. * Returns the animatable textures.
  20534. * @param animatables Array of animatable textures.
  20535. */
  20536. getAnimatables(animatables: IAnimatable[]): void;
  20537. /**
  20538. * Disposes the resources of the material.
  20539. * @param forceDisposeTextures - Forces the disposal of all textures.
  20540. */
  20541. dispose(forceDisposeTextures?: boolean): void;
  20542. /**
  20543. * Get the current class name of the texture useful for serialization or dynamic coding.
  20544. * @returns "PBRSheenConfiguration"
  20545. */
  20546. getClassName(): string;
  20547. /**
  20548. * Add fallbacks to the effect fallbacks list.
  20549. * @param defines defines the Base texture to use.
  20550. * @param fallbacks defines the current fallback list.
  20551. * @param currentRank defines the current fallback rank.
  20552. * @returns the new fallback rank.
  20553. */
  20554. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20555. /**
  20556. * Add the required uniforms to the current list.
  20557. * @param uniforms defines the current uniform list.
  20558. */
  20559. static AddUniforms(uniforms: string[]): void;
  20560. /**
  20561. * Add the required uniforms to the current buffer.
  20562. * @param uniformBuffer defines the current uniform buffer.
  20563. */
  20564. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20565. /**
  20566. * Add the required samplers to the current list.
  20567. * @param samplers defines the current sampler list.
  20568. */
  20569. static AddSamplers(samplers: string[]): void;
  20570. /**
  20571. * Makes a duplicate of the current configuration into another one.
  20572. * @param sheenConfiguration define the config where to copy the info
  20573. */
  20574. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  20575. /**
  20576. * Serializes this BRDF configuration.
  20577. * @returns - An object with the serialized config.
  20578. */
  20579. serialize(): any;
  20580. /**
  20581. * Parses a anisotropy Configuration from a serialized object.
  20582. * @param source - Serialized object.
  20583. * @param scene Defines the scene we are parsing for
  20584. * @param rootUrl Defines the rootUrl to load from
  20585. */
  20586. parse(source: any, scene: Scene, rootUrl: string): void;
  20587. }
  20588. }
  20589. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  20590. import { Nullable } from "babylonjs/types";
  20591. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20592. import { Color3 } from "babylonjs/Maths/math.color";
  20593. import { SmartArray } from "babylonjs/Misc/smartArray";
  20594. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20595. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20596. import { Effect } from "babylonjs/Materials/effect";
  20597. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20598. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20599. import { Engine } from "babylonjs/Engines/engine";
  20600. import { Scene } from "babylonjs/scene";
  20601. /**
  20602. * @hidden
  20603. */
  20604. export interface IMaterialSubSurfaceDefines {
  20605. SUBSURFACE: boolean;
  20606. SS_REFRACTION: boolean;
  20607. SS_TRANSLUCENCY: boolean;
  20608. SS_SCATTERING: boolean;
  20609. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20610. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20611. SS_REFRACTIONMAP_3D: boolean;
  20612. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20613. SS_LODINREFRACTIONALPHA: boolean;
  20614. SS_GAMMAREFRACTION: boolean;
  20615. SS_RGBDREFRACTION: boolean;
  20616. SS_LINEARSPECULARREFRACTION: boolean;
  20617. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20618. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20619. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20620. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20621. /** @hidden */
  20622. _areTexturesDirty: boolean;
  20623. }
  20624. /**
  20625. * Define the code related to the sub surface parameters of the pbr material.
  20626. */
  20627. export class PBRSubSurfaceConfiguration {
  20628. private _isRefractionEnabled;
  20629. /**
  20630. * Defines if the refraction is enabled in the material.
  20631. */
  20632. isRefractionEnabled: boolean;
  20633. private _isTranslucencyEnabled;
  20634. /**
  20635. * Defines if the translucency is enabled in the material.
  20636. */
  20637. isTranslucencyEnabled: boolean;
  20638. private _isScatteringEnabled;
  20639. /**
  20640. * Defines if the sub surface scattering is enabled in the material.
  20641. */
  20642. isScatteringEnabled: boolean;
  20643. private _scatteringDiffusionProfileIndex;
  20644. /**
  20645. * Diffusion profile for subsurface scattering.
  20646. * Useful for better scattering in the skins or foliages.
  20647. */
  20648. get scatteringDiffusionProfile(): Nullable<Color3>;
  20649. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20650. /**
  20651. * Defines the refraction intensity of the material.
  20652. * The refraction when enabled replaces the Diffuse part of the material.
  20653. * The intensity helps transitionning between diffuse and refraction.
  20654. */
  20655. refractionIntensity: number;
  20656. /**
  20657. * Defines the translucency intensity of the material.
  20658. * When translucency has been enabled, this defines how much of the "translucency"
  20659. * is addded to the diffuse part of the material.
  20660. */
  20661. translucencyIntensity: number;
  20662. /**
  20663. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20664. */
  20665. useAlbedoToTintRefraction: boolean;
  20666. private _thicknessTexture;
  20667. /**
  20668. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20669. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20670. * 0 would mean minimumThickness
  20671. * 1 would mean maximumThickness
  20672. * The other channels might be use as a mask to vary the different effects intensity.
  20673. */
  20674. thicknessTexture: Nullable<BaseTexture>;
  20675. private _refractionTexture;
  20676. /**
  20677. * Defines the texture to use for refraction.
  20678. */
  20679. refractionTexture: Nullable<BaseTexture>;
  20680. private _indexOfRefraction;
  20681. /**
  20682. * Index of refraction of the material base layer.
  20683. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20684. *
  20685. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20686. *
  20687. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20688. */
  20689. indexOfRefraction: number;
  20690. private _volumeIndexOfRefraction;
  20691. /**
  20692. * Index of refraction of the material's volume.
  20693. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20694. *
  20695. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20696. * the volume will use the same IOR as the surface.
  20697. */
  20698. get volumeIndexOfRefraction(): number;
  20699. set volumeIndexOfRefraction(value: number);
  20700. private _invertRefractionY;
  20701. /**
  20702. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20703. */
  20704. invertRefractionY: boolean;
  20705. private _linkRefractionWithTransparency;
  20706. /**
  20707. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20708. * Materials half opaque for instance using refraction could benefit from this control.
  20709. */
  20710. linkRefractionWithTransparency: boolean;
  20711. /**
  20712. * Defines the minimum thickness stored in the thickness map.
  20713. * If no thickness map is defined, this value will be used to simulate thickness.
  20714. */
  20715. minimumThickness: number;
  20716. /**
  20717. * Defines the maximum thickness stored in the thickness map.
  20718. */
  20719. maximumThickness: number;
  20720. /**
  20721. * Defines the volume tint of the material.
  20722. * This is used for both translucency and scattering.
  20723. */
  20724. tintColor: Color3;
  20725. /**
  20726. * Defines the distance at which the tint color should be found in the media.
  20727. * This is used for refraction only.
  20728. */
  20729. tintColorAtDistance: number;
  20730. /**
  20731. * Defines how far each channel transmit through the media.
  20732. * It is defined as a color to simplify it selection.
  20733. */
  20734. diffusionDistance: Color3;
  20735. private _useMaskFromThicknessTexture;
  20736. /**
  20737. * Stores the intensity of the different subsurface effects in the thickness texture.
  20738. * * the green channel is the translucency intensity.
  20739. * * the blue channel is the scattering intensity.
  20740. * * the alpha channel is the refraction intensity.
  20741. */
  20742. useMaskFromThicknessTexture: boolean;
  20743. private _scene;
  20744. private _useMaskFromThicknessTextureGltf;
  20745. /**
  20746. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20747. * matches the channel-packing that is used by glTF.
  20748. * * the red channel is the transmission/translucency intensity.
  20749. * * the green channel is the thickness.
  20750. */
  20751. useMaskFromThicknessTextureGltf: boolean;
  20752. /** @hidden */
  20753. private _internalMarkAllSubMeshesAsTexturesDirty;
  20754. private _internalMarkScenePrePassDirty;
  20755. /** @hidden */
  20756. _markAllSubMeshesAsTexturesDirty(): void;
  20757. /** @hidden */
  20758. _markScenePrePassDirty(): void;
  20759. /**
  20760. * Instantiate a new istance of sub surface configuration.
  20761. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20762. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  20763. * @param scene The scene
  20764. */
  20765. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  20766. /**
  20767. * Gets wehter the submesh is ready to be used or not.
  20768. * @param defines the list of "defines" to update.
  20769. * @param scene defines the scene the material belongs to.
  20770. * @returns - boolean indicating that the submesh is ready or not.
  20771. */
  20772. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  20773. /**
  20774. * Checks to see if a texture is used in the material.
  20775. * @param defines the list of "defines" to update.
  20776. * @param scene defines the scene to the material belongs to.
  20777. */
  20778. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  20779. /**
  20780. * Binds the material data.
  20781. * @param uniformBuffer defines the Uniform buffer to fill in.
  20782. * @param scene defines the scene the material belongs to.
  20783. * @param engine defines the engine the material belongs to.
  20784. * @param isFrozen defines whether the material is frozen or not.
  20785. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  20786. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  20787. */
  20788. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  20789. /**
  20790. * Unbinds the material from the mesh.
  20791. * @param activeEffect defines the effect that should be unbound from.
  20792. * @returns true if unbound, otherwise false
  20793. */
  20794. unbind(activeEffect: Effect): boolean;
  20795. /**
  20796. * Returns the texture used for refraction or null if none is used.
  20797. * @param scene defines the scene the material belongs to.
  20798. * @returns - Refraction texture if present. If no refraction texture and refraction
  20799. * is linked with transparency, returns environment texture. Otherwise, returns null.
  20800. */
  20801. private _getRefractionTexture;
  20802. /**
  20803. * Returns true if alpha blending should be disabled.
  20804. */
  20805. get disableAlphaBlending(): boolean;
  20806. /**
  20807. * Fills the list of render target textures.
  20808. * @param renderTargets the list of render targets to update
  20809. */
  20810. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  20811. /**
  20812. * Checks to see if a texture is used in the material.
  20813. * @param texture - Base texture to use.
  20814. * @returns - Boolean specifying if a texture is used in the material.
  20815. */
  20816. hasTexture(texture: BaseTexture): boolean;
  20817. /**
  20818. * Gets a boolean indicating that current material needs to register RTT
  20819. * @returns true if this uses a render target otherwise false.
  20820. */
  20821. hasRenderTargetTextures(): boolean;
  20822. /**
  20823. * Returns an array of the actively used textures.
  20824. * @param activeTextures Array of BaseTextures
  20825. */
  20826. getActiveTextures(activeTextures: BaseTexture[]): void;
  20827. /**
  20828. * Returns the animatable textures.
  20829. * @param animatables Array of animatable textures.
  20830. */
  20831. getAnimatables(animatables: IAnimatable[]): void;
  20832. /**
  20833. * Disposes the resources of the material.
  20834. * @param forceDisposeTextures - Forces the disposal of all textures.
  20835. */
  20836. dispose(forceDisposeTextures?: boolean): void;
  20837. /**
  20838. * Get the current class name of the texture useful for serialization or dynamic coding.
  20839. * @returns "PBRSubSurfaceConfiguration"
  20840. */
  20841. getClassName(): string;
  20842. /**
  20843. * Add fallbacks to the effect fallbacks list.
  20844. * @param defines defines the Base texture to use.
  20845. * @param fallbacks defines the current fallback list.
  20846. * @param currentRank defines the current fallback rank.
  20847. * @returns the new fallback rank.
  20848. */
  20849. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20850. /**
  20851. * Add the required uniforms to the current list.
  20852. * @param uniforms defines the current uniform list.
  20853. */
  20854. static AddUniforms(uniforms: string[]): void;
  20855. /**
  20856. * Add the required samplers to the current list.
  20857. * @param samplers defines the current sampler list.
  20858. */
  20859. static AddSamplers(samplers: string[]): void;
  20860. /**
  20861. * Add the required uniforms to the current buffer.
  20862. * @param uniformBuffer defines the current uniform buffer.
  20863. */
  20864. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20865. /**
  20866. * Makes a duplicate of the current configuration into another one.
  20867. * @param configuration define the config where to copy the info
  20868. */
  20869. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  20870. /**
  20871. * Serializes this Sub Surface configuration.
  20872. * @returns - An object with the serialized config.
  20873. */
  20874. serialize(): any;
  20875. /**
  20876. * Parses a anisotropy Configuration from a serialized object.
  20877. * @param source - Serialized object.
  20878. * @param scene Defines the scene we are parsing for
  20879. * @param rootUrl Defines the rootUrl to load from
  20880. */
  20881. parse(source: any, scene: Scene, rootUrl: string): void;
  20882. }
  20883. }
  20884. declare module "babylonjs/Maths/sphericalPolynomial" {
  20885. import { Vector3 } from "babylonjs/Maths/math.vector";
  20886. import { Color3 } from "babylonjs/Maths/math.color";
  20887. /**
  20888. * Class representing spherical harmonics coefficients to the 3rd degree
  20889. */
  20890. export class SphericalHarmonics {
  20891. /**
  20892. * Defines whether or not the harmonics have been prescaled for rendering.
  20893. */
  20894. preScaled: boolean;
  20895. /**
  20896. * The l0,0 coefficients of the spherical harmonics
  20897. */
  20898. l00: Vector3;
  20899. /**
  20900. * The l1,-1 coefficients of the spherical harmonics
  20901. */
  20902. l1_1: Vector3;
  20903. /**
  20904. * The l1,0 coefficients of the spherical harmonics
  20905. */
  20906. l10: Vector3;
  20907. /**
  20908. * The l1,1 coefficients of the spherical harmonics
  20909. */
  20910. l11: Vector3;
  20911. /**
  20912. * The l2,-2 coefficients of the spherical harmonics
  20913. */
  20914. l2_2: Vector3;
  20915. /**
  20916. * The l2,-1 coefficients of the spherical harmonics
  20917. */
  20918. l2_1: Vector3;
  20919. /**
  20920. * The l2,0 coefficients of the spherical harmonics
  20921. */
  20922. l20: Vector3;
  20923. /**
  20924. * The l2,1 coefficients of the spherical harmonics
  20925. */
  20926. l21: Vector3;
  20927. /**
  20928. * The l2,2 coefficients of the spherical harmonics
  20929. */
  20930. l22: Vector3;
  20931. /**
  20932. * Adds a light to the spherical harmonics
  20933. * @param direction the direction of the light
  20934. * @param color the color of the light
  20935. * @param deltaSolidAngle the delta solid angle of the light
  20936. */
  20937. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  20938. /**
  20939. * Scales the spherical harmonics by the given amount
  20940. * @param scale the amount to scale
  20941. */
  20942. scaleInPlace(scale: number): void;
  20943. /**
  20944. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  20945. *
  20946. * ```
  20947. * E_lm = A_l * L_lm
  20948. * ```
  20949. *
  20950. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  20951. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  20952. * the scaling factors are given in equation 9.
  20953. */
  20954. convertIncidentRadianceToIrradiance(): void;
  20955. /**
  20956. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  20957. *
  20958. * ```
  20959. * L = (1/pi) * E * rho
  20960. * ```
  20961. *
  20962. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  20963. */
  20964. convertIrradianceToLambertianRadiance(): void;
  20965. /**
  20966. * Integrates the reconstruction coefficients directly in to the SH preventing further
  20967. * required operations at run time.
  20968. *
  20969. * This is simply done by scaling back the SH with Ylm constants parameter.
  20970. * The trigonometric part being applied by the shader at run time.
  20971. */
  20972. preScaleForRendering(): void;
  20973. /**
  20974. * Constructs a spherical harmonics from an array.
  20975. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  20976. * @returns the spherical harmonics
  20977. */
  20978. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  20979. /**
  20980. * Gets the spherical harmonics from polynomial
  20981. * @param polynomial the spherical polynomial
  20982. * @returns the spherical harmonics
  20983. */
  20984. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  20985. }
  20986. /**
  20987. * Class representing spherical polynomial coefficients to the 3rd degree
  20988. */
  20989. export class SphericalPolynomial {
  20990. private _harmonics;
  20991. /**
  20992. * The spherical harmonics used to create the polynomials.
  20993. */
  20994. get preScaledHarmonics(): SphericalHarmonics;
  20995. /**
  20996. * The x coefficients of the spherical polynomial
  20997. */
  20998. x: Vector3;
  20999. /**
  21000. * The y coefficients of the spherical polynomial
  21001. */
  21002. y: Vector3;
  21003. /**
  21004. * The z coefficients of the spherical polynomial
  21005. */
  21006. z: Vector3;
  21007. /**
  21008. * The xx coefficients of the spherical polynomial
  21009. */
  21010. xx: Vector3;
  21011. /**
  21012. * The yy coefficients of the spherical polynomial
  21013. */
  21014. yy: Vector3;
  21015. /**
  21016. * The zz coefficients of the spherical polynomial
  21017. */
  21018. zz: Vector3;
  21019. /**
  21020. * The xy coefficients of the spherical polynomial
  21021. */
  21022. xy: Vector3;
  21023. /**
  21024. * The yz coefficients of the spherical polynomial
  21025. */
  21026. yz: Vector3;
  21027. /**
  21028. * The zx coefficients of the spherical polynomial
  21029. */
  21030. zx: Vector3;
  21031. /**
  21032. * Adds an ambient color to the spherical polynomial
  21033. * @param color the color to add
  21034. */
  21035. addAmbient(color: Color3): void;
  21036. /**
  21037. * Scales the spherical polynomial by the given amount
  21038. * @param scale the amount to scale
  21039. */
  21040. scaleInPlace(scale: number): void;
  21041. /**
  21042. * Gets the spherical polynomial from harmonics
  21043. * @param harmonics the spherical harmonics
  21044. * @returns the spherical polynomial
  21045. */
  21046. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21047. /**
  21048. * Constructs a spherical polynomial from an array.
  21049. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21050. * @returns the spherical polynomial
  21051. */
  21052. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21053. }
  21054. }
  21055. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  21056. import { Nullable } from "babylonjs/types";
  21057. /**
  21058. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21059. */
  21060. export interface CubeMapInfo {
  21061. /**
  21062. * The pixel array for the front face.
  21063. * This is stored in format, left to right, up to down format.
  21064. */
  21065. front: Nullable<ArrayBufferView>;
  21066. /**
  21067. * The pixel array for the back face.
  21068. * This is stored in format, left to right, up to down format.
  21069. */
  21070. back: Nullable<ArrayBufferView>;
  21071. /**
  21072. * The pixel array for the left face.
  21073. * This is stored in format, left to right, up to down format.
  21074. */
  21075. left: Nullable<ArrayBufferView>;
  21076. /**
  21077. * The pixel array for the right face.
  21078. * This is stored in format, left to right, up to down format.
  21079. */
  21080. right: Nullable<ArrayBufferView>;
  21081. /**
  21082. * The pixel array for the up face.
  21083. * This is stored in format, left to right, up to down format.
  21084. */
  21085. up: Nullable<ArrayBufferView>;
  21086. /**
  21087. * The pixel array for the down face.
  21088. * This is stored in format, left to right, up to down format.
  21089. */
  21090. down: Nullable<ArrayBufferView>;
  21091. /**
  21092. * The size of the cubemap stored.
  21093. *
  21094. * Each faces will be size * size pixels.
  21095. */
  21096. size: number;
  21097. /**
  21098. * The format of the texture.
  21099. *
  21100. * RGBA, RGB.
  21101. */
  21102. format: number;
  21103. /**
  21104. * The type of the texture data.
  21105. *
  21106. * UNSIGNED_INT, FLOAT.
  21107. */
  21108. type: number;
  21109. /**
  21110. * Specifies whether the texture is in gamma space.
  21111. */
  21112. gammaSpace: boolean;
  21113. }
  21114. /**
  21115. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21116. */
  21117. export class PanoramaToCubeMapTools {
  21118. private static FACE_LEFT;
  21119. private static FACE_RIGHT;
  21120. private static FACE_FRONT;
  21121. private static FACE_BACK;
  21122. private static FACE_DOWN;
  21123. private static FACE_UP;
  21124. /**
  21125. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  21126. *
  21127. * @param float32Array The source data.
  21128. * @param inputWidth The width of the input panorama.
  21129. * @param inputHeight The height of the input panorama.
  21130. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21131. * @return The cubemap data
  21132. */
  21133. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21134. private static CreateCubemapTexture;
  21135. private static CalcProjectionSpherical;
  21136. }
  21137. }
  21138. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  21139. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  21140. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21141. import { Nullable } from "babylonjs/types";
  21142. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  21143. /**
  21144. * Helper class dealing with the extraction of spherical polynomial dataArray
  21145. * from a cube map.
  21146. */
  21147. export class CubeMapToSphericalPolynomialTools {
  21148. private static FileFaces;
  21149. /**
  21150. * Converts a texture to the according Spherical Polynomial data.
  21151. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21152. *
  21153. * @param texture The texture to extract the information from.
  21154. * @return The Spherical Polynomial data.
  21155. */
  21156. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  21157. /**
  21158. * Converts a cubemap to the according Spherical Polynomial data.
  21159. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21160. *
  21161. * @param cubeInfo The Cube map to extract the information from.
  21162. * @return The Spherical Polynomial data.
  21163. */
  21164. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21165. }
  21166. }
  21167. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  21168. import { Nullable } from "babylonjs/types";
  21169. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  21170. module "babylonjs/Materials/Textures/baseTexture" {
  21171. interface BaseTexture {
  21172. /**
  21173. * Get the polynomial representation of the texture data.
  21174. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21175. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21176. */
  21177. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21178. }
  21179. }
  21180. }
  21181. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  21182. /** @hidden */
  21183. export var pbrFragmentDeclaration: {
  21184. name: string;
  21185. shader: string;
  21186. };
  21187. }
  21188. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  21189. /** @hidden */
  21190. export var pbrUboDeclaration: {
  21191. name: string;
  21192. shader: string;
  21193. };
  21194. }
  21195. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  21196. /** @hidden */
  21197. export var pbrFragmentExtraDeclaration: {
  21198. name: string;
  21199. shader: string;
  21200. };
  21201. }
  21202. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  21203. /** @hidden */
  21204. export var pbrFragmentSamplersDeclaration: {
  21205. name: string;
  21206. shader: string;
  21207. };
  21208. }
  21209. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  21210. /** @hidden */
  21211. export var subSurfaceScatteringFunctions: {
  21212. name: string;
  21213. shader: string;
  21214. };
  21215. }
  21216. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  21217. /** @hidden */
  21218. export var importanceSampling: {
  21219. name: string;
  21220. shader: string;
  21221. };
  21222. }
  21223. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  21224. /** @hidden */
  21225. export var pbrHelperFunctions: {
  21226. name: string;
  21227. shader: string;
  21228. };
  21229. }
  21230. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  21231. /** @hidden */
  21232. export var harmonicsFunctions: {
  21233. name: string;
  21234. shader: string;
  21235. };
  21236. }
  21237. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  21238. /** @hidden */
  21239. export var pbrDirectLightingSetupFunctions: {
  21240. name: string;
  21241. shader: string;
  21242. };
  21243. }
  21244. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  21245. /** @hidden */
  21246. export var pbrDirectLightingFalloffFunctions: {
  21247. name: string;
  21248. shader: string;
  21249. };
  21250. }
  21251. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  21252. /** @hidden */
  21253. export var pbrBRDFFunctions: {
  21254. name: string;
  21255. shader: string;
  21256. };
  21257. }
  21258. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  21259. /** @hidden */
  21260. export var hdrFilteringFunctions: {
  21261. name: string;
  21262. shader: string;
  21263. };
  21264. }
  21265. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  21266. /** @hidden */
  21267. export var pbrDirectLightingFunctions: {
  21268. name: string;
  21269. shader: string;
  21270. };
  21271. }
  21272. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  21273. /** @hidden */
  21274. export var pbrIBLFunctions: {
  21275. name: string;
  21276. shader: string;
  21277. };
  21278. }
  21279. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  21280. /** @hidden */
  21281. export var pbrBlockAlbedoOpacity: {
  21282. name: string;
  21283. shader: string;
  21284. };
  21285. }
  21286. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  21287. /** @hidden */
  21288. export var pbrBlockReflectivity: {
  21289. name: string;
  21290. shader: string;
  21291. };
  21292. }
  21293. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  21294. /** @hidden */
  21295. export var pbrBlockAmbientOcclusion: {
  21296. name: string;
  21297. shader: string;
  21298. };
  21299. }
  21300. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  21301. /** @hidden */
  21302. export var pbrBlockAlphaFresnel: {
  21303. name: string;
  21304. shader: string;
  21305. };
  21306. }
  21307. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  21308. /** @hidden */
  21309. export var pbrBlockAnisotropic: {
  21310. name: string;
  21311. shader: string;
  21312. };
  21313. }
  21314. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  21315. /** @hidden */
  21316. export var pbrBlockReflection: {
  21317. name: string;
  21318. shader: string;
  21319. };
  21320. }
  21321. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  21322. /** @hidden */
  21323. export var pbrBlockSheen: {
  21324. name: string;
  21325. shader: string;
  21326. };
  21327. }
  21328. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  21329. /** @hidden */
  21330. export var pbrBlockClearcoat: {
  21331. name: string;
  21332. shader: string;
  21333. };
  21334. }
  21335. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  21336. /** @hidden */
  21337. export var pbrBlockSubSurface: {
  21338. name: string;
  21339. shader: string;
  21340. };
  21341. }
  21342. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  21343. /** @hidden */
  21344. export var pbrBlockNormalGeometric: {
  21345. name: string;
  21346. shader: string;
  21347. };
  21348. }
  21349. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  21350. /** @hidden */
  21351. export var pbrBlockNormalFinal: {
  21352. name: string;
  21353. shader: string;
  21354. };
  21355. }
  21356. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  21357. /** @hidden */
  21358. export var pbrBlockLightmapInit: {
  21359. name: string;
  21360. shader: string;
  21361. };
  21362. }
  21363. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  21364. /** @hidden */
  21365. export var pbrBlockGeometryInfo: {
  21366. name: string;
  21367. shader: string;
  21368. };
  21369. }
  21370. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  21371. /** @hidden */
  21372. export var pbrBlockReflectance0: {
  21373. name: string;
  21374. shader: string;
  21375. };
  21376. }
  21377. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  21378. /** @hidden */
  21379. export var pbrBlockReflectance: {
  21380. name: string;
  21381. shader: string;
  21382. };
  21383. }
  21384. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  21385. /** @hidden */
  21386. export var pbrBlockDirectLighting: {
  21387. name: string;
  21388. shader: string;
  21389. };
  21390. }
  21391. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  21392. /** @hidden */
  21393. export var pbrBlockFinalLitComponents: {
  21394. name: string;
  21395. shader: string;
  21396. };
  21397. }
  21398. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  21399. /** @hidden */
  21400. export var pbrBlockFinalUnlitComponents: {
  21401. name: string;
  21402. shader: string;
  21403. };
  21404. }
  21405. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  21406. /** @hidden */
  21407. export var pbrBlockFinalColorComposition: {
  21408. name: string;
  21409. shader: string;
  21410. };
  21411. }
  21412. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  21413. /** @hidden */
  21414. export var pbrBlockImageProcessing: {
  21415. name: string;
  21416. shader: string;
  21417. };
  21418. }
  21419. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  21420. /** @hidden */
  21421. export var pbrDebug: {
  21422. name: string;
  21423. shader: string;
  21424. };
  21425. }
  21426. declare module "babylonjs/Shaders/pbr.fragment" {
  21427. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  21428. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  21429. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  21430. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  21431. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  21432. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  21433. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  21434. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  21435. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  21436. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  21437. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  21438. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21439. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  21440. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  21441. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  21442. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  21443. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  21444. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  21445. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  21446. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  21447. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  21448. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  21449. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  21450. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  21451. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  21452. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  21453. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21454. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  21455. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  21456. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  21457. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  21458. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  21459. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  21460. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  21461. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  21462. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  21463. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  21464. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  21465. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  21466. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  21467. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  21468. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  21469. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  21470. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  21471. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  21472. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  21473. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  21474. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  21475. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  21476. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  21477. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  21478. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  21479. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  21480. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  21481. /** @hidden */
  21482. export var pbrPixelShader: {
  21483. name: string;
  21484. shader: string;
  21485. };
  21486. }
  21487. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  21488. /** @hidden */
  21489. export var pbrVertexDeclaration: {
  21490. name: string;
  21491. shader: string;
  21492. };
  21493. }
  21494. declare module "babylonjs/Shaders/pbr.vertex" {
  21495. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  21496. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  21497. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21498. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  21499. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  21500. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  21501. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  21502. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  21503. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  21504. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  21505. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  21506. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  21507. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  21508. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  21509. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  21510. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  21511. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  21512. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  21513. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  21514. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  21515. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  21516. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  21517. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  21518. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  21519. /** @hidden */
  21520. export var pbrVertexShader: {
  21521. name: string;
  21522. shader: string;
  21523. };
  21524. }
  21525. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  21526. import { Nullable } from "babylonjs/types";
  21527. import { Scene } from "babylonjs/scene";
  21528. import { Matrix } from "babylonjs/Maths/math.vector";
  21529. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21531. import { Mesh } from "babylonjs/Meshes/mesh";
  21532. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  21533. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  21534. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  21535. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  21536. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  21537. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  21538. import { Color3 } from "babylonjs/Maths/math.color";
  21539. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  21540. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  21541. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21542. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  21543. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21544. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21545. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  21546. import "babylonjs/Shaders/pbr.fragment";
  21547. import "babylonjs/Shaders/pbr.vertex";
  21548. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  21549. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  21550. /**
  21551. * Manages the defines for the PBR Material.
  21552. * @hidden
  21553. */
  21554. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  21555. PBR: boolean;
  21556. NUM_SAMPLES: string;
  21557. REALTIME_FILTERING: boolean;
  21558. MAINUV1: boolean;
  21559. MAINUV2: boolean;
  21560. UV1: boolean;
  21561. UV2: boolean;
  21562. ALBEDO: boolean;
  21563. GAMMAALBEDO: boolean;
  21564. ALBEDODIRECTUV: number;
  21565. VERTEXCOLOR: boolean;
  21566. DETAIL: boolean;
  21567. DETAILDIRECTUV: number;
  21568. DETAIL_NORMALBLENDMETHOD: number;
  21569. AMBIENT: boolean;
  21570. AMBIENTDIRECTUV: number;
  21571. AMBIENTINGRAYSCALE: boolean;
  21572. OPACITY: boolean;
  21573. VERTEXALPHA: boolean;
  21574. OPACITYDIRECTUV: number;
  21575. OPACITYRGB: boolean;
  21576. ALPHATEST: boolean;
  21577. DEPTHPREPASS: boolean;
  21578. ALPHABLEND: boolean;
  21579. ALPHAFROMALBEDO: boolean;
  21580. ALPHATESTVALUE: string;
  21581. SPECULAROVERALPHA: boolean;
  21582. RADIANCEOVERALPHA: boolean;
  21583. ALPHAFRESNEL: boolean;
  21584. LINEARALPHAFRESNEL: boolean;
  21585. PREMULTIPLYALPHA: boolean;
  21586. EMISSIVE: boolean;
  21587. EMISSIVEDIRECTUV: number;
  21588. REFLECTIVITY: boolean;
  21589. REFLECTIVITYDIRECTUV: number;
  21590. SPECULARTERM: boolean;
  21591. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  21592. MICROSURFACEAUTOMATIC: boolean;
  21593. LODBASEDMICROSFURACE: boolean;
  21594. MICROSURFACEMAP: boolean;
  21595. MICROSURFACEMAPDIRECTUV: number;
  21596. METALLICWORKFLOW: boolean;
  21597. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  21598. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  21599. METALLNESSSTOREINMETALMAPBLUE: boolean;
  21600. AOSTOREINMETALMAPRED: boolean;
  21601. METALLIC_REFLECTANCE: boolean;
  21602. METALLIC_REFLECTANCEDIRECTUV: number;
  21603. ENVIRONMENTBRDF: boolean;
  21604. ENVIRONMENTBRDF_RGBD: boolean;
  21605. NORMAL: boolean;
  21606. TANGENT: boolean;
  21607. BUMP: boolean;
  21608. BUMPDIRECTUV: number;
  21609. OBJECTSPACE_NORMALMAP: boolean;
  21610. PARALLAX: boolean;
  21611. PARALLAXOCCLUSION: boolean;
  21612. NORMALXYSCALE: boolean;
  21613. LIGHTMAP: boolean;
  21614. LIGHTMAPDIRECTUV: number;
  21615. USELIGHTMAPASSHADOWMAP: boolean;
  21616. GAMMALIGHTMAP: boolean;
  21617. RGBDLIGHTMAP: boolean;
  21618. REFLECTION: boolean;
  21619. REFLECTIONMAP_3D: boolean;
  21620. REFLECTIONMAP_SPHERICAL: boolean;
  21621. REFLECTIONMAP_PLANAR: boolean;
  21622. REFLECTIONMAP_CUBIC: boolean;
  21623. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  21624. REFLECTIONMAP_PROJECTION: boolean;
  21625. REFLECTIONMAP_SKYBOX: boolean;
  21626. REFLECTIONMAP_EXPLICIT: boolean;
  21627. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  21628. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  21629. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  21630. INVERTCUBICMAP: boolean;
  21631. USESPHERICALFROMREFLECTIONMAP: boolean;
  21632. USEIRRADIANCEMAP: boolean;
  21633. SPHERICAL_HARMONICS: boolean;
  21634. USESPHERICALINVERTEX: boolean;
  21635. REFLECTIONMAP_OPPOSITEZ: boolean;
  21636. LODINREFLECTIONALPHA: boolean;
  21637. GAMMAREFLECTION: boolean;
  21638. RGBDREFLECTION: boolean;
  21639. LINEARSPECULARREFLECTION: boolean;
  21640. RADIANCEOCCLUSION: boolean;
  21641. HORIZONOCCLUSION: boolean;
  21642. INSTANCES: boolean;
  21643. THIN_INSTANCES: boolean;
  21644. PREPASS: boolean;
  21645. PREPASS_IRRADIANCE: boolean;
  21646. PREPASS_IRRADIANCE_INDEX: number;
  21647. PREPASS_ALBEDO: boolean;
  21648. PREPASS_ALBEDO_INDEX: number;
  21649. PREPASS_DEPTHNORMAL: boolean;
  21650. PREPASS_DEPTHNORMAL_INDEX: number;
  21651. PREPASS_POSITION: boolean;
  21652. PREPASS_POSITION_INDEX: number;
  21653. PREPASS_VELOCITY: boolean;
  21654. PREPASS_VELOCITY_INDEX: number;
  21655. PREPASS_REFLECTIVITY: boolean;
  21656. PREPASS_REFLECTIVITY_INDEX: number;
  21657. SCENE_MRT_COUNT: number;
  21658. NUM_BONE_INFLUENCERS: number;
  21659. BonesPerMesh: number;
  21660. BONETEXTURE: boolean;
  21661. BONES_VELOCITY_ENABLED: boolean;
  21662. NONUNIFORMSCALING: boolean;
  21663. MORPHTARGETS: boolean;
  21664. MORPHTARGETS_NORMAL: boolean;
  21665. MORPHTARGETS_TANGENT: boolean;
  21666. MORPHTARGETS_UV: boolean;
  21667. NUM_MORPH_INFLUENCERS: number;
  21668. IMAGEPROCESSING: boolean;
  21669. VIGNETTE: boolean;
  21670. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21671. VIGNETTEBLENDMODEOPAQUE: boolean;
  21672. TONEMAPPING: boolean;
  21673. TONEMAPPING_ACES: boolean;
  21674. CONTRAST: boolean;
  21675. COLORCURVES: boolean;
  21676. COLORGRADING: boolean;
  21677. COLORGRADING3D: boolean;
  21678. SAMPLER3DGREENDEPTH: boolean;
  21679. SAMPLER3DBGRMAP: boolean;
  21680. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21681. EXPOSURE: boolean;
  21682. MULTIVIEW: boolean;
  21683. USEPHYSICALLIGHTFALLOFF: boolean;
  21684. USEGLTFLIGHTFALLOFF: boolean;
  21685. TWOSIDEDLIGHTING: boolean;
  21686. SHADOWFLOAT: boolean;
  21687. CLIPPLANE: boolean;
  21688. CLIPPLANE2: boolean;
  21689. CLIPPLANE3: boolean;
  21690. CLIPPLANE4: boolean;
  21691. CLIPPLANE5: boolean;
  21692. CLIPPLANE6: boolean;
  21693. POINTSIZE: boolean;
  21694. FOG: boolean;
  21695. LOGARITHMICDEPTH: boolean;
  21696. FORCENORMALFORWARD: boolean;
  21697. SPECULARAA: boolean;
  21698. CLEARCOAT: boolean;
  21699. CLEARCOAT_DEFAULTIOR: boolean;
  21700. CLEARCOAT_TEXTURE: boolean;
  21701. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  21702. CLEARCOAT_TEXTUREDIRECTUV: number;
  21703. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  21704. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21705. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21706. CLEARCOAT_BUMP: boolean;
  21707. CLEARCOAT_BUMPDIRECTUV: number;
  21708. CLEARCOAT_REMAP_F0: boolean;
  21709. CLEARCOAT_TINT: boolean;
  21710. CLEARCOAT_TINT_TEXTURE: boolean;
  21711. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  21712. ANISOTROPIC: boolean;
  21713. ANISOTROPIC_TEXTURE: boolean;
  21714. ANISOTROPIC_TEXTUREDIRECTUV: number;
  21715. BRDF_V_HEIGHT_CORRELATED: boolean;
  21716. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21717. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21718. SHEEN: boolean;
  21719. SHEEN_TEXTURE: boolean;
  21720. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21721. SHEEN_TEXTUREDIRECTUV: number;
  21722. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21723. SHEEN_LINKWITHALBEDO: boolean;
  21724. SHEEN_ROUGHNESS: boolean;
  21725. SHEEN_ALBEDOSCALING: boolean;
  21726. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21727. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21728. SUBSURFACE: boolean;
  21729. SS_REFRACTION: boolean;
  21730. SS_TRANSLUCENCY: boolean;
  21731. SS_SCATTERING: boolean;
  21732. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21733. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21734. SS_REFRACTIONMAP_3D: boolean;
  21735. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21736. SS_LODINREFRACTIONALPHA: boolean;
  21737. SS_GAMMAREFRACTION: boolean;
  21738. SS_RGBDREFRACTION: boolean;
  21739. SS_LINEARSPECULARREFRACTION: boolean;
  21740. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21741. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21742. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21743. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21744. UNLIT: boolean;
  21745. DEBUGMODE: number;
  21746. /**
  21747. * Initializes the PBR Material defines.
  21748. */
  21749. constructor();
  21750. /**
  21751. * Resets the PBR Material defines.
  21752. */
  21753. reset(): void;
  21754. }
  21755. /**
  21756. * The Physically based material base class of BJS.
  21757. *
  21758. * This offers the main features of a standard PBR material.
  21759. * For more information, please refer to the documentation :
  21760. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21761. */
  21762. export abstract class PBRBaseMaterial extends PushMaterial {
  21763. /**
  21764. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21765. */
  21766. static readonly PBRMATERIAL_OPAQUE: number;
  21767. /**
  21768. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21769. */
  21770. static readonly PBRMATERIAL_ALPHATEST: number;
  21771. /**
  21772. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21773. */
  21774. static readonly PBRMATERIAL_ALPHABLEND: number;
  21775. /**
  21776. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21777. * They are also discarded below the alpha cutoff threshold to improve performances.
  21778. */
  21779. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21780. /**
  21781. * Defines the default value of how much AO map is occluding the analytical lights
  21782. * (point spot...).
  21783. */
  21784. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21785. /**
  21786. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21787. */
  21788. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21789. /**
  21790. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21791. * to enhance interoperability with other engines.
  21792. */
  21793. static readonly LIGHTFALLOFF_GLTF: number;
  21794. /**
  21795. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21796. * to enhance interoperability with other materials.
  21797. */
  21798. static readonly LIGHTFALLOFF_STANDARD: number;
  21799. /**
  21800. * Intensity of the direct lights e.g. the four lights available in your scene.
  21801. * This impacts both the direct diffuse and specular highlights.
  21802. */
  21803. protected _directIntensity: number;
  21804. /**
  21805. * Intensity of the emissive part of the material.
  21806. * This helps controlling the emissive effect without modifying the emissive color.
  21807. */
  21808. protected _emissiveIntensity: number;
  21809. /**
  21810. * Intensity of the environment e.g. how much the environment will light the object
  21811. * either through harmonics for rough material or through the refelction for shiny ones.
  21812. */
  21813. protected _environmentIntensity: number;
  21814. /**
  21815. * This is a special control allowing the reduction of the specular highlights coming from the
  21816. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21817. */
  21818. protected _specularIntensity: number;
  21819. /**
  21820. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21821. */
  21822. private _lightingInfos;
  21823. /**
  21824. * Debug Control allowing disabling the bump map on this material.
  21825. */
  21826. protected _disableBumpMap: boolean;
  21827. /**
  21828. * AKA Diffuse Texture in standard nomenclature.
  21829. */
  21830. protected _albedoTexture: Nullable<BaseTexture>;
  21831. /**
  21832. * AKA Occlusion Texture in other nomenclature.
  21833. */
  21834. protected _ambientTexture: Nullable<BaseTexture>;
  21835. /**
  21836. * AKA Occlusion Texture Intensity in other nomenclature.
  21837. */
  21838. protected _ambientTextureStrength: number;
  21839. /**
  21840. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21841. * 1 means it completely occludes it
  21842. * 0 mean it has no impact
  21843. */
  21844. protected _ambientTextureImpactOnAnalyticalLights: number;
  21845. /**
  21846. * Stores the alpha values in a texture.
  21847. */
  21848. protected _opacityTexture: Nullable<BaseTexture>;
  21849. /**
  21850. * Stores the reflection values in a texture.
  21851. */
  21852. protected _reflectionTexture: Nullable<BaseTexture>;
  21853. /**
  21854. * Stores the emissive values in a texture.
  21855. */
  21856. protected _emissiveTexture: Nullable<BaseTexture>;
  21857. /**
  21858. * AKA Specular texture in other nomenclature.
  21859. */
  21860. protected _reflectivityTexture: Nullable<BaseTexture>;
  21861. /**
  21862. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21863. */
  21864. protected _metallicTexture: Nullable<BaseTexture>;
  21865. /**
  21866. * Specifies the metallic scalar of the metallic/roughness workflow.
  21867. * Can also be used to scale the metalness values of the metallic texture.
  21868. */
  21869. protected _metallic: Nullable<number>;
  21870. /**
  21871. * Specifies the roughness scalar of the metallic/roughness workflow.
  21872. * Can also be used to scale the roughness values of the metallic texture.
  21873. */
  21874. protected _roughness: Nullable<number>;
  21875. /**
  21876. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21877. * By default the indexOfrefraction is used to compute F0;
  21878. *
  21879. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21880. *
  21881. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21882. * F90 = metallicReflectanceColor;
  21883. */
  21884. protected _metallicF0Factor: number;
  21885. /**
  21886. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21887. * By default the F90 is always 1;
  21888. *
  21889. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21890. *
  21891. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21892. * F90 = metallicReflectanceColor;
  21893. */
  21894. protected _metallicReflectanceColor: Color3;
  21895. /**
  21896. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21897. * This is multiply against the scalar values defined in the material.
  21898. */
  21899. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  21900. /**
  21901. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21902. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21903. */
  21904. protected _microSurfaceTexture: Nullable<BaseTexture>;
  21905. /**
  21906. * Stores surface normal data used to displace a mesh in a texture.
  21907. */
  21908. protected _bumpTexture: Nullable<BaseTexture>;
  21909. /**
  21910. * Stores the pre-calculated light information of a mesh in a texture.
  21911. */
  21912. protected _lightmapTexture: Nullable<BaseTexture>;
  21913. /**
  21914. * The color of a material in ambient lighting.
  21915. */
  21916. protected _ambientColor: Color3;
  21917. /**
  21918. * AKA Diffuse Color in other nomenclature.
  21919. */
  21920. protected _albedoColor: Color3;
  21921. /**
  21922. * AKA Specular Color in other nomenclature.
  21923. */
  21924. protected _reflectivityColor: Color3;
  21925. /**
  21926. * The color applied when light is reflected from a material.
  21927. */
  21928. protected _reflectionColor: Color3;
  21929. /**
  21930. * The color applied when light is emitted from a material.
  21931. */
  21932. protected _emissiveColor: Color3;
  21933. /**
  21934. * AKA Glossiness in other nomenclature.
  21935. */
  21936. protected _microSurface: number;
  21937. /**
  21938. * Specifies that the material will use the light map as a show map.
  21939. */
  21940. protected _useLightmapAsShadowmap: boolean;
  21941. /**
  21942. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21943. * makes the reflect vector face the model (under horizon).
  21944. */
  21945. protected _useHorizonOcclusion: boolean;
  21946. /**
  21947. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21948. * too much the area relying on ambient texture to define their ambient occlusion.
  21949. */
  21950. protected _useRadianceOcclusion: boolean;
  21951. /**
  21952. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21953. */
  21954. protected _useAlphaFromAlbedoTexture: boolean;
  21955. /**
  21956. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  21957. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21958. */
  21959. protected _useSpecularOverAlpha: boolean;
  21960. /**
  21961. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21962. */
  21963. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21964. /**
  21965. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21966. */
  21967. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  21968. /**
  21969. * Specifies if the metallic texture contains the roughness information in its green channel.
  21970. */
  21971. protected _useRoughnessFromMetallicTextureGreen: boolean;
  21972. /**
  21973. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21974. */
  21975. protected _useMetallnessFromMetallicTextureBlue: boolean;
  21976. /**
  21977. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21978. */
  21979. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  21980. /**
  21981. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21982. */
  21983. protected _useAmbientInGrayScale: boolean;
  21984. /**
  21985. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21986. * The material will try to infer what glossiness each pixel should be.
  21987. */
  21988. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  21989. /**
  21990. * Defines the falloff type used in this material.
  21991. * It by default is Physical.
  21992. */
  21993. protected _lightFalloff: number;
  21994. /**
  21995. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21996. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21997. */
  21998. protected _useRadianceOverAlpha: boolean;
  21999. /**
  22000. * Allows using an object space normal map (instead of tangent space).
  22001. */
  22002. protected _useObjectSpaceNormalMap: boolean;
  22003. /**
  22004. * Allows using the bump map in parallax mode.
  22005. */
  22006. protected _useParallax: boolean;
  22007. /**
  22008. * Allows using the bump map in parallax occlusion mode.
  22009. */
  22010. protected _useParallaxOcclusion: boolean;
  22011. /**
  22012. * Controls the scale bias of the parallax mode.
  22013. */
  22014. protected _parallaxScaleBias: number;
  22015. /**
  22016. * If sets to true, disables all the lights affecting the material.
  22017. */
  22018. protected _disableLighting: boolean;
  22019. /**
  22020. * Number of Simultaneous lights allowed on the material.
  22021. */
  22022. protected _maxSimultaneousLights: number;
  22023. /**
  22024. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  22025. */
  22026. protected _invertNormalMapX: boolean;
  22027. /**
  22028. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  22029. */
  22030. protected _invertNormalMapY: boolean;
  22031. /**
  22032. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22033. */
  22034. protected _twoSidedLighting: boolean;
  22035. /**
  22036. * Defines the alpha limits in alpha test mode.
  22037. */
  22038. protected _alphaCutOff: number;
  22039. /**
  22040. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22041. */
  22042. protected _forceAlphaTest: boolean;
  22043. /**
  22044. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22045. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22046. */
  22047. protected _useAlphaFresnel: boolean;
  22048. /**
  22049. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22050. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22051. */
  22052. protected _useLinearAlphaFresnel: boolean;
  22053. /**
  22054. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  22055. * from cos thetav and roughness:
  22056. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  22057. */
  22058. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  22059. /**
  22060. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22061. */
  22062. protected _forceIrradianceInFragment: boolean;
  22063. private _realTimeFiltering;
  22064. /**
  22065. * Enables realtime filtering on the texture.
  22066. */
  22067. get realTimeFiltering(): boolean;
  22068. set realTimeFiltering(b: boolean);
  22069. private _realTimeFilteringQuality;
  22070. /**
  22071. * Quality switch for realtime filtering
  22072. */
  22073. get realTimeFilteringQuality(): number;
  22074. set realTimeFilteringQuality(n: number);
  22075. /**
  22076. * Can this material render to several textures at once
  22077. */
  22078. get canRenderToMRT(): boolean;
  22079. /**
  22080. * Force normal to face away from face.
  22081. */
  22082. protected _forceNormalForward: boolean;
  22083. /**
  22084. * Enables specular anti aliasing in the PBR shader.
  22085. * It will both interacts on the Geometry for analytical and IBL lighting.
  22086. * It also prefilter the roughness map based on the bump values.
  22087. */
  22088. protected _enableSpecularAntiAliasing: boolean;
  22089. /**
  22090. * Default configuration related to image processing available in the PBR Material.
  22091. */
  22092. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22093. /**
  22094. * Keep track of the image processing observer to allow dispose and replace.
  22095. */
  22096. private _imageProcessingObserver;
  22097. /**
  22098. * Attaches a new image processing configuration to the PBR Material.
  22099. * @param configuration
  22100. */
  22101. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22102. /**
  22103. * Stores the available render targets.
  22104. */
  22105. private _renderTargets;
  22106. /**
  22107. * Sets the global ambient color for the material used in lighting calculations.
  22108. */
  22109. private _globalAmbientColor;
  22110. /**
  22111. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22112. */
  22113. private _useLogarithmicDepth;
  22114. /**
  22115. * If set to true, no lighting calculations will be applied.
  22116. */
  22117. private _unlit;
  22118. private _debugMode;
  22119. /**
  22120. * @hidden
  22121. * This is reserved for the inspector.
  22122. * Defines the material debug mode.
  22123. * It helps seeing only some components of the material while troubleshooting.
  22124. */
  22125. debugMode: number;
  22126. /**
  22127. * @hidden
  22128. * This is reserved for the inspector.
  22129. * Specify from where on screen the debug mode should start.
  22130. * The value goes from -1 (full screen) to 1 (not visible)
  22131. * It helps with side by side comparison against the final render
  22132. * This defaults to -1
  22133. */
  22134. private debugLimit;
  22135. /**
  22136. * @hidden
  22137. * This is reserved for the inspector.
  22138. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22139. * You can use the factor to better multiply the final value.
  22140. */
  22141. private debugFactor;
  22142. /**
  22143. * Defines the clear coat layer parameters for the material.
  22144. */
  22145. readonly clearCoat: PBRClearCoatConfiguration;
  22146. /**
  22147. * Defines the anisotropic parameters for the material.
  22148. */
  22149. readonly anisotropy: PBRAnisotropicConfiguration;
  22150. /**
  22151. * Defines the BRDF parameters for the material.
  22152. */
  22153. readonly brdf: PBRBRDFConfiguration;
  22154. /**
  22155. * Defines the Sheen parameters for the material.
  22156. */
  22157. readonly sheen: PBRSheenConfiguration;
  22158. /**
  22159. * Defines the SubSurface parameters for the material.
  22160. */
  22161. readonly subSurface: PBRSubSurfaceConfiguration;
  22162. /**
  22163. * Defines additionnal PrePass parameters for the material.
  22164. */
  22165. readonly prePassConfiguration: PrePassConfiguration;
  22166. /**
  22167. * Defines the detail map parameters for the material.
  22168. */
  22169. readonly detailMap: DetailMapConfiguration;
  22170. protected _rebuildInParallel: boolean;
  22171. /**
  22172. * Instantiates a new PBRMaterial instance.
  22173. *
  22174. * @param name The material name
  22175. * @param scene The scene the material will be use in.
  22176. */
  22177. constructor(name: string, scene: Scene);
  22178. /**
  22179. * Gets a boolean indicating that current material needs to register RTT
  22180. */
  22181. get hasRenderTargetTextures(): boolean;
  22182. /**
  22183. * Gets the name of the material class.
  22184. */
  22185. getClassName(): string;
  22186. /**
  22187. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22188. */
  22189. get useLogarithmicDepth(): boolean;
  22190. /**
  22191. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22192. */
  22193. set useLogarithmicDepth(value: boolean);
  22194. /**
  22195. * Returns true if alpha blending should be disabled.
  22196. */
  22197. protected get _disableAlphaBlending(): boolean;
  22198. /**
  22199. * Specifies whether or not this material should be rendered in alpha blend mode.
  22200. */
  22201. needAlphaBlending(): boolean;
  22202. /**
  22203. * Specifies whether or not this material should be rendered in alpha test mode.
  22204. */
  22205. needAlphaTesting(): boolean;
  22206. /**
  22207. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22208. */
  22209. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22210. /**
  22211. * Specifies whether or not there is a usable alpha channel for transparency.
  22212. */
  22213. protected _hasAlphaChannel(): boolean;
  22214. /**
  22215. * Gets the texture used for the alpha test.
  22216. */
  22217. getAlphaTestTexture(): Nullable<BaseTexture>;
  22218. /**
  22219. * Specifies that the submesh is ready to be used.
  22220. * @param mesh - BJS mesh.
  22221. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22222. * @param useInstances - Specifies that instances should be used.
  22223. * @returns - boolean indicating that the submesh is ready or not.
  22224. */
  22225. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22226. /**
  22227. * Specifies if the material uses metallic roughness workflow.
  22228. * @returns boolean specifiying if the material uses metallic roughness workflow.
  22229. */
  22230. isMetallicWorkflow(): boolean;
  22231. private _prepareEffect;
  22232. private _prepareDefines;
  22233. /**
  22234. * Force shader compilation
  22235. */
  22236. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22237. /**
  22238. * Initializes the uniform buffer layout for the shader.
  22239. */
  22240. buildUniformLayout(): void;
  22241. /**
  22242. * Unbinds the material from the mesh
  22243. */
  22244. unbind(): void;
  22245. /**
  22246. * Binds the submesh data.
  22247. * @param world - The world matrix.
  22248. * @param mesh - The BJS mesh.
  22249. * @param subMesh - A submesh of the BJS mesh.
  22250. */
  22251. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22252. /**
  22253. * Returns the animatable textures.
  22254. * @returns - Array of animatable textures.
  22255. */
  22256. getAnimatables(): IAnimatable[];
  22257. /**
  22258. * Returns the texture used for reflections.
  22259. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  22260. */
  22261. private _getReflectionTexture;
  22262. /**
  22263. * Returns an array of the actively used textures.
  22264. * @returns - Array of BaseTextures
  22265. */
  22266. getActiveTextures(): BaseTexture[];
  22267. /**
  22268. * Checks to see if a texture is used in the material.
  22269. * @param texture - Base texture to use.
  22270. * @returns - Boolean specifying if a texture is used in the material.
  22271. */
  22272. hasTexture(texture: BaseTexture): boolean;
  22273. /**
  22274. * Sets the required values to the prepass renderer.
  22275. * @param prePassRenderer defines the prepass renderer to setup
  22276. */
  22277. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22278. /**
  22279. * Disposes the resources of the material.
  22280. * @param forceDisposeEffect - Forces the disposal of effects.
  22281. * @param forceDisposeTextures - Forces the disposal of all textures.
  22282. */
  22283. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22284. }
  22285. }
  22286. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  22287. import { Nullable } from "babylonjs/types";
  22288. import { Scene } from "babylonjs/scene";
  22289. import { Color3 } from "babylonjs/Maths/math.color";
  22290. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  22291. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  22292. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22293. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  22294. /**
  22295. * The Physically based material of BJS.
  22296. *
  22297. * This offers the main features of a standard PBR material.
  22298. * For more information, please refer to the documentation :
  22299. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22300. */
  22301. export class PBRMaterial extends PBRBaseMaterial {
  22302. /**
  22303. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22304. */
  22305. static readonly PBRMATERIAL_OPAQUE: number;
  22306. /**
  22307. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22308. */
  22309. static readonly PBRMATERIAL_ALPHATEST: number;
  22310. /**
  22311. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22312. */
  22313. static readonly PBRMATERIAL_ALPHABLEND: number;
  22314. /**
  22315. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22316. * They are also discarded below the alpha cutoff threshold to improve performances.
  22317. */
  22318. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22319. /**
  22320. * Defines the default value of how much AO map is occluding the analytical lights
  22321. * (point spot...).
  22322. */
  22323. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22324. /**
  22325. * Intensity of the direct lights e.g. the four lights available in your scene.
  22326. * This impacts both the direct diffuse and specular highlights.
  22327. */
  22328. directIntensity: number;
  22329. /**
  22330. * Intensity of the emissive part of the material.
  22331. * This helps controlling the emissive effect without modifying the emissive color.
  22332. */
  22333. emissiveIntensity: number;
  22334. /**
  22335. * Intensity of the environment e.g. how much the environment will light the object
  22336. * either through harmonics for rough material or through the refelction for shiny ones.
  22337. */
  22338. environmentIntensity: number;
  22339. /**
  22340. * This is a special control allowing the reduction of the specular highlights coming from the
  22341. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22342. */
  22343. specularIntensity: number;
  22344. /**
  22345. * Debug Control allowing disabling the bump map on this material.
  22346. */
  22347. disableBumpMap: boolean;
  22348. /**
  22349. * AKA Diffuse Texture in standard nomenclature.
  22350. */
  22351. albedoTexture: BaseTexture;
  22352. /**
  22353. * AKA Occlusion Texture in other nomenclature.
  22354. */
  22355. ambientTexture: BaseTexture;
  22356. /**
  22357. * AKA Occlusion Texture Intensity in other nomenclature.
  22358. */
  22359. ambientTextureStrength: number;
  22360. /**
  22361. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22362. * 1 means it completely occludes it
  22363. * 0 mean it has no impact
  22364. */
  22365. ambientTextureImpactOnAnalyticalLights: number;
  22366. /**
  22367. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  22368. */
  22369. opacityTexture: BaseTexture;
  22370. /**
  22371. * Stores the reflection values in a texture.
  22372. */
  22373. reflectionTexture: Nullable<BaseTexture>;
  22374. /**
  22375. * Stores the emissive values in a texture.
  22376. */
  22377. emissiveTexture: BaseTexture;
  22378. /**
  22379. * AKA Specular texture in other nomenclature.
  22380. */
  22381. reflectivityTexture: BaseTexture;
  22382. /**
  22383. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22384. */
  22385. metallicTexture: BaseTexture;
  22386. /**
  22387. * Specifies the metallic scalar of the metallic/roughness workflow.
  22388. * Can also be used to scale the metalness values of the metallic texture.
  22389. */
  22390. metallic: Nullable<number>;
  22391. /**
  22392. * Specifies the roughness scalar of the metallic/roughness workflow.
  22393. * Can also be used to scale the roughness values of the metallic texture.
  22394. */
  22395. roughness: Nullable<number>;
  22396. /**
  22397. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22398. * By default the indexOfrefraction is used to compute F0;
  22399. *
  22400. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22401. *
  22402. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22403. * F90 = metallicReflectanceColor;
  22404. */
  22405. metallicF0Factor: number;
  22406. /**
  22407. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22408. * By default the F90 is always 1;
  22409. *
  22410. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22411. *
  22412. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22413. * F90 = metallicReflectanceColor;
  22414. */
  22415. metallicReflectanceColor: Color3;
  22416. /**
  22417. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22418. * This is multiply against the scalar values defined in the material.
  22419. */
  22420. metallicReflectanceTexture: Nullable<BaseTexture>;
  22421. /**
  22422. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22423. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22424. */
  22425. microSurfaceTexture: BaseTexture;
  22426. /**
  22427. * Stores surface normal data used to displace a mesh in a texture.
  22428. */
  22429. bumpTexture: BaseTexture;
  22430. /**
  22431. * Stores the pre-calculated light information of a mesh in a texture.
  22432. */
  22433. lightmapTexture: BaseTexture;
  22434. /**
  22435. * Stores the refracted light information in a texture.
  22436. */
  22437. get refractionTexture(): Nullable<BaseTexture>;
  22438. set refractionTexture(value: Nullable<BaseTexture>);
  22439. /**
  22440. * The color of a material in ambient lighting.
  22441. */
  22442. ambientColor: Color3;
  22443. /**
  22444. * AKA Diffuse Color in other nomenclature.
  22445. */
  22446. albedoColor: Color3;
  22447. /**
  22448. * AKA Specular Color in other nomenclature.
  22449. */
  22450. reflectivityColor: Color3;
  22451. /**
  22452. * The color reflected from the material.
  22453. */
  22454. reflectionColor: Color3;
  22455. /**
  22456. * The color emitted from the material.
  22457. */
  22458. emissiveColor: Color3;
  22459. /**
  22460. * AKA Glossiness in other nomenclature.
  22461. */
  22462. microSurface: number;
  22463. /**
  22464. * Index of refraction of the material base layer.
  22465. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  22466. *
  22467. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  22468. *
  22469. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  22470. */
  22471. get indexOfRefraction(): number;
  22472. set indexOfRefraction(value: number);
  22473. /**
  22474. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22475. */
  22476. get invertRefractionY(): boolean;
  22477. set invertRefractionY(value: boolean);
  22478. /**
  22479. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  22480. * Materials half opaque for instance using refraction could benefit from this control.
  22481. */
  22482. get linkRefractionWithTransparency(): boolean;
  22483. set linkRefractionWithTransparency(value: boolean);
  22484. /**
  22485. * If true, the light map contains occlusion information instead of lighting info.
  22486. */
  22487. useLightmapAsShadowmap: boolean;
  22488. /**
  22489. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22490. */
  22491. useAlphaFromAlbedoTexture: boolean;
  22492. /**
  22493. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22494. */
  22495. forceAlphaTest: boolean;
  22496. /**
  22497. * Defines the alpha limits in alpha test mode.
  22498. */
  22499. alphaCutOff: number;
  22500. /**
  22501. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  22502. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  22503. */
  22504. useSpecularOverAlpha: boolean;
  22505. /**
  22506. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22507. */
  22508. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22509. /**
  22510. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22511. */
  22512. useRoughnessFromMetallicTextureAlpha: boolean;
  22513. /**
  22514. * Specifies if the metallic texture contains the roughness information in its green channel.
  22515. */
  22516. useRoughnessFromMetallicTextureGreen: boolean;
  22517. /**
  22518. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22519. */
  22520. useMetallnessFromMetallicTextureBlue: boolean;
  22521. /**
  22522. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22523. */
  22524. useAmbientOcclusionFromMetallicTextureRed: boolean;
  22525. /**
  22526. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22527. */
  22528. useAmbientInGrayScale: boolean;
  22529. /**
  22530. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22531. * The material will try to infer what glossiness each pixel should be.
  22532. */
  22533. useAutoMicroSurfaceFromReflectivityMap: boolean;
  22534. /**
  22535. * BJS is using an harcoded light falloff based on a manually sets up range.
  22536. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22537. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22538. */
  22539. get usePhysicalLightFalloff(): boolean;
  22540. /**
  22541. * BJS is using an harcoded light falloff based on a manually sets up range.
  22542. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22543. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22544. */
  22545. set usePhysicalLightFalloff(value: boolean);
  22546. /**
  22547. * In order to support the falloff compatibility with gltf, a special mode has been added
  22548. * to reproduce the gltf light falloff.
  22549. */
  22550. get useGLTFLightFalloff(): boolean;
  22551. /**
  22552. * In order to support the falloff compatibility with gltf, a special mode has been added
  22553. * to reproduce the gltf light falloff.
  22554. */
  22555. set useGLTFLightFalloff(value: boolean);
  22556. /**
  22557. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  22558. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  22559. */
  22560. useRadianceOverAlpha: boolean;
  22561. /**
  22562. * Allows using an object space normal map (instead of tangent space).
  22563. */
  22564. useObjectSpaceNormalMap: boolean;
  22565. /**
  22566. * Allows using the bump map in parallax mode.
  22567. */
  22568. useParallax: boolean;
  22569. /**
  22570. * Allows using the bump map in parallax occlusion mode.
  22571. */
  22572. useParallaxOcclusion: boolean;
  22573. /**
  22574. * Controls the scale bias of the parallax mode.
  22575. */
  22576. parallaxScaleBias: number;
  22577. /**
  22578. * If sets to true, disables all the lights affecting the material.
  22579. */
  22580. disableLighting: boolean;
  22581. /**
  22582. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22583. */
  22584. forceIrradianceInFragment: boolean;
  22585. /**
  22586. * Number of Simultaneous lights allowed on the material.
  22587. */
  22588. maxSimultaneousLights: number;
  22589. /**
  22590. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  22591. */
  22592. invertNormalMapX: boolean;
  22593. /**
  22594. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  22595. */
  22596. invertNormalMapY: boolean;
  22597. /**
  22598. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22599. */
  22600. twoSidedLighting: boolean;
  22601. /**
  22602. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22603. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22604. */
  22605. useAlphaFresnel: boolean;
  22606. /**
  22607. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22608. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22609. */
  22610. useLinearAlphaFresnel: boolean;
  22611. /**
  22612. * Let user defines the brdf lookup texture used for IBL.
  22613. * A default 8bit version is embedded but you could point at :
  22614. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  22615. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  22616. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  22617. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  22618. */
  22619. environmentBRDFTexture: Nullable<BaseTexture>;
  22620. /**
  22621. * Force normal to face away from face.
  22622. */
  22623. forceNormalForward: boolean;
  22624. /**
  22625. * Enables specular anti aliasing in the PBR shader.
  22626. * It will both interacts on the Geometry for analytical and IBL lighting.
  22627. * It also prefilter the roughness map based on the bump values.
  22628. */
  22629. enableSpecularAntiAliasing: boolean;
  22630. /**
  22631. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22632. * makes the reflect vector face the model (under horizon).
  22633. */
  22634. useHorizonOcclusion: boolean;
  22635. /**
  22636. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22637. * too much the area relying on ambient texture to define their ambient occlusion.
  22638. */
  22639. useRadianceOcclusion: boolean;
  22640. /**
  22641. * If set to true, no lighting calculations will be applied.
  22642. */
  22643. unlit: boolean;
  22644. /**
  22645. * Gets the image processing configuration used either in this material.
  22646. */
  22647. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22648. /**
  22649. * Sets the Default image processing configuration used either in the this material.
  22650. *
  22651. * If sets to null, the scene one is in use.
  22652. */
  22653. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22654. /**
  22655. * Gets wether the color curves effect is enabled.
  22656. */
  22657. get cameraColorCurvesEnabled(): boolean;
  22658. /**
  22659. * Sets wether the color curves effect is enabled.
  22660. */
  22661. set cameraColorCurvesEnabled(value: boolean);
  22662. /**
  22663. * Gets wether the color grading effect is enabled.
  22664. */
  22665. get cameraColorGradingEnabled(): boolean;
  22666. /**
  22667. * Gets wether the color grading effect is enabled.
  22668. */
  22669. set cameraColorGradingEnabled(value: boolean);
  22670. /**
  22671. * Gets wether tonemapping is enabled or not.
  22672. */
  22673. get cameraToneMappingEnabled(): boolean;
  22674. /**
  22675. * Sets wether tonemapping is enabled or not
  22676. */
  22677. set cameraToneMappingEnabled(value: boolean);
  22678. /**
  22679. * The camera exposure used on this material.
  22680. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22681. * This corresponds to a photographic exposure.
  22682. */
  22683. get cameraExposure(): number;
  22684. /**
  22685. * The camera exposure used on this material.
  22686. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22687. * This corresponds to a photographic exposure.
  22688. */
  22689. set cameraExposure(value: number);
  22690. /**
  22691. * Gets The camera contrast used on this material.
  22692. */
  22693. get cameraContrast(): number;
  22694. /**
  22695. * Sets The camera contrast used on this material.
  22696. */
  22697. set cameraContrast(value: number);
  22698. /**
  22699. * Gets the Color Grading 2D Lookup Texture.
  22700. */
  22701. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  22702. /**
  22703. * Sets the Color Grading 2D Lookup Texture.
  22704. */
  22705. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  22706. /**
  22707. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22708. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22709. * 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;
  22710. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22711. */
  22712. get cameraColorCurves(): Nullable<ColorCurves>;
  22713. /**
  22714. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22715. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22716. * 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;
  22717. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22718. */
  22719. set cameraColorCurves(value: Nullable<ColorCurves>);
  22720. /**
  22721. * Instantiates a new PBRMaterial instance.
  22722. *
  22723. * @param name The material name
  22724. * @param scene The scene the material will be use in.
  22725. */
  22726. constructor(name: string, scene: Scene);
  22727. /**
  22728. * Returns the name of this material class.
  22729. */
  22730. getClassName(): string;
  22731. /**
  22732. * Makes a duplicate of the current material.
  22733. * @param name - name to use for the new material.
  22734. */
  22735. clone(name: string): PBRMaterial;
  22736. /**
  22737. * Serializes this PBR Material.
  22738. * @returns - An object with the serialized material.
  22739. */
  22740. serialize(): any;
  22741. /**
  22742. * Parses a PBR Material from a serialized object.
  22743. * @param source - Serialized object.
  22744. * @param scene - BJS scene instance.
  22745. * @param rootUrl - url for the scene object
  22746. * @returns - PBRMaterial
  22747. */
  22748. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  22749. }
  22750. }
  22751. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  22752. /** @hidden */
  22753. export var mrtFragmentDeclaration: {
  22754. name: string;
  22755. shader: string;
  22756. };
  22757. }
  22758. declare module "babylonjs/Shaders/geometry.fragment" {
  22759. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  22760. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  22761. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  22762. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  22763. /** @hidden */
  22764. export var geometryPixelShader: {
  22765. name: string;
  22766. shader: string;
  22767. };
  22768. }
  22769. declare module "babylonjs/Shaders/geometry.vertex" {
  22770. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  22771. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  22772. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  22773. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  22774. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  22775. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  22776. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  22777. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  22778. /** @hidden */
  22779. export var geometryVertexShader: {
  22780. name: string;
  22781. shader: string;
  22782. };
  22783. }
  22784. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  22785. import { Matrix } from "babylonjs/Maths/math.vector";
  22786. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22787. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  22788. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  22789. import { Effect } from "babylonjs/Materials/effect";
  22790. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  22791. import { Scene } from "babylonjs/scene";
  22792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22793. import { Nullable } from "babylonjs/types";
  22794. import "babylonjs/Shaders/geometry.fragment";
  22795. import "babylonjs/Shaders/geometry.vertex";
  22796. /** @hidden */
  22797. interface ISavedTransformationMatrix {
  22798. world: Matrix;
  22799. viewProjection: Matrix;
  22800. }
  22801. /**
  22802. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  22803. */
  22804. export class GeometryBufferRenderer {
  22805. /**
  22806. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  22807. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  22808. */
  22809. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  22810. /**
  22811. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22812. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22813. */
  22814. static readonly POSITION_TEXTURE_TYPE: number;
  22815. /**
  22816. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22817. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22818. */
  22819. static readonly VELOCITY_TEXTURE_TYPE: number;
  22820. /**
  22821. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22822. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22823. */
  22824. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22825. /**
  22826. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22827. * in order to compute objects velocities when enableVelocity is set to "true"
  22828. * @hidden
  22829. */
  22830. _previousTransformationMatrices: {
  22831. [index: number]: ISavedTransformationMatrix;
  22832. };
  22833. /**
  22834. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22835. * in order to compute objects velocities when enableVelocity is set to "true"
  22836. * @hidden
  22837. */
  22838. _previousBonesTransformationMatrices: {
  22839. [index: number]: Float32Array;
  22840. };
  22841. /**
  22842. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22843. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22844. */
  22845. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22846. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22847. renderTransparentMeshes: boolean;
  22848. private _scene;
  22849. private _resizeObserver;
  22850. private _multiRenderTarget;
  22851. private _ratio;
  22852. private _enablePosition;
  22853. private _enableVelocity;
  22854. private _enableReflectivity;
  22855. private _positionIndex;
  22856. private _velocityIndex;
  22857. private _reflectivityIndex;
  22858. private _depthNormalIndex;
  22859. private _linkedWithPrePass;
  22860. private _prePassRenderer;
  22861. private _attachments;
  22862. protected _effect: Effect;
  22863. protected _cachedDefines: string;
  22864. /**
  22865. * @hidden
  22866. * Sets up internal structures to share outputs with PrePassRenderer
  22867. * This method should only be called by the PrePassRenderer itself
  22868. */
  22869. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  22870. /**
  22871. * @hidden
  22872. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  22873. * This method should only be called by the PrePassRenderer itself
  22874. */
  22875. _unlinkPrePassRenderer(): void;
  22876. /**
  22877. * @hidden
  22878. * Resets the geometry buffer layout
  22879. */
  22880. _resetLayout(): void;
  22881. /**
  22882. * @hidden
  22883. * Replaces a texture in the geometry buffer renderer
  22884. * Useful when linking textures of the prepass renderer
  22885. */
  22886. _forceTextureType(geometryBufferType: number, index: number): void;
  22887. /**
  22888. * @hidden
  22889. * Sets texture attachments
  22890. * Useful when linking textures of the prepass renderer
  22891. */
  22892. _setAttachments(attachments: number[]): void;
  22893. /**
  22894. * @hidden
  22895. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  22896. * Useful when linking textures of the prepass renderer
  22897. */
  22898. _linkInternalTexture(internalTexture: InternalTexture): void;
  22899. /**
  22900. * Gets the render list (meshes to be rendered) used in the G buffer.
  22901. */
  22902. get renderList(): Nullable<AbstractMesh[]>;
  22903. /**
  22904. * Set the render list (meshes to be rendered) used in the G buffer.
  22905. */
  22906. set renderList(meshes: Nullable<AbstractMesh[]>);
  22907. /**
  22908. * Gets wether or not G buffer are supported by the running hardware.
  22909. * This requires draw buffer supports
  22910. */
  22911. get isSupported(): boolean;
  22912. /**
  22913. * Returns the index of the given texture type in the G-Buffer textures array
  22914. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  22915. * @returns the index of the given texture type in the G-Buffer textures array
  22916. */
  22917. getTextureIndex(textureType: number): number;
  22918. /**
  22919. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  22920. */
  22921. get enablePosition(): boolean;
  22922. /**
  22923. * Sets whether or not objects positions are enabled for the G buffer.
  22924. */
  22925. set enablePosition(enable: boolean);
  22926. /**
  22927. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  22928. */
  22929. get enableVelocity(): boolean;
  22930. /**
  22931. * Sets wether or not objects velocities are enabled for the G buffer.
  22932. */
  22933. set enableVelocity(enable: boolean);
  22934. /**
  22935. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  22936. */
  22937. get enableReflectivity(): boolean;
  22938. /**
  22939. * Sets wether or not objects roughness are enabled for the G buffer.
  22940. */
  22941. set enableReflectivity(enable: boolean);
  22942. /**
  22943. * Gets the scene associated with the buffer.
  22944. */
  22945. get scene(): Scene;
  22946. /**
  22947. * Gets the ratio used by the buffer during its creation.
  22948. * How big is the buffer related to the main canvas.
  22949. */
  22950. get ratio(): number;
  22951. /** @hidden */
  22952. static _SceneComponentInitialization: (scene: Scene) => void;
  22953. /**
  22954. * Creates a new G Buffer for the scene
  22955. * @param scene The scene the buffer belongs to
  22956. * @param ratio How big is the buffer related to the main canvas.
  22957. */
  22958. constructor(scene: Scene, ratio?: number);
  22959. /**
  22960. * Checks wether everything is ready to render a submesh to the G buffer.
  22961. * @param subMesh the submesh to check readiness for
  22962. * @param useInstances is the mesh drawn using instance or not
  22963. * @returns true if ready otherwise false
  22964. */
  22965. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22966. /**
  22967. * Gets the current underlying G Buffer.
  22968. * @returns the buffer
  22969. */
  22970. getGBuffer(): MultiRenderTarget;
  22971. /**
  22972. * Gets the number of samples used to render the buffer (anti aliasing).
  22973. */
  22974. get samples(): number;
  22975. /**
  22976. * Sets the number of samples used to render the buffer (anti aliasing).
  22977. */
  22978. set samples(value: number);
  22979. /**
  22980. * Disposes the renderer and frees up associated resources.
  22981. */
  22982. dispose(): void;
  22983. private _assignRenderTargetIndices;
  22984. protected _createRenderTargets(): void;
  22985. private _copyBonesTransformationMatrices;
  22986. }
  22987. }
  22988. declare module "babylonjs/Rendering/prePassRenderer" {
  22989. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  22990. import { Scene } from "babylonjs/scene";
  22991. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  22992. import { Effect } from "babylonjs/Materials/effect";
  22993. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  22994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22995. import { Material } from "babylonjs/Materials/material";
  22996. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22997. /**
  22998. * Renders a pre pass of the scene
  22999. * This means every mesh in the scene will be rendered to a render target texture
  23000. * And then this texture will be composited to the rendering canvas with post processes
  23001. * It is necessary for effects like subsurface scattering or deferred shading
  23002. */
  23003. export class PrePassRenderer {
  23004. /** @hidden */
  23005. static _SceneComponentInitialization: (scene: Scene) => void;
  23006. private _textureFormats;
  23007. /**
  23008. * To save performance, we can excluded skinned meshes from the prepass
  23009. */
  23010. excludedSkinnedMesh: AbstractMesh[];
  23011. /**
  23012. * Force material to be excluded from the prepass
  23013. * Can be useful when `useGeometryBufferFallback` is set to `true`
  23014. * and you don't want a material to show in the effect.
  23015. */
  23016. excludedMaterials: Material[];
  23017. private _textureIndices;
  23018. private _scene;
  23019. private _engine;
  23020. private _isDirty;
  23021. /**
  23022. * Number of textures in the multi render target texture where the scene is directly rendered
  23023. */
  23024. mrtCount: number;
  23025. /**
  23026. * The render target where the scene is directly rendered
  23027. */
  23028. prePassRT: MultiRenderTarget;
  23029. private _multiRenderAttachments;
  23030. private _defaultAttachments;
  23031. private _clearAttachments;
  23032. private _postProcesses;
  23033. private readonly _clearColor;
  23034. /**
  23035. * Image processing post process for composition
  23036. */
  23037. imageProcessingPostProcess: ImageProcessingPostProcess;
  23038. /**
  23039. * Configuration for prepass effects
  23040. */
  23041. private _effectConfigurations;
  23042. private _mrtFormats;
  23043. private _mrtLayout;
  23044. private _enabled;
  23045. /**
  23046. * Indicates if the prepass is enabled
  23047. */
  23048. get enabled(): boolean;
  23049. /**
  23050. * How many samples are used for MSAA of the scene render target
  23051. */
  23052. get samples(): number;
  23053. set samples(n: number);
  23054. private _geometryBuffer;
  23055. private _useGeometryBufferFallback;
  23056. /**
  23057. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  23058. */
  23059. get useGeometryBufferFallback(): boolean;
  23060. set useGeometryBufferFallback(value: boolean);
  23061. /**
  23062. * Instanciates a prepass renderer
  23063. * @param scene The scene
  23064. */
  23065. constructor(scene: Scene);
  23066. private _initializeAttachments;
  23067. private _createCompositionEffect;
  23068. /**
  23069. * Indicates if rendering a prepass is supported
  23070. */
  23071. get isSupported(): boolean;
  23072. /**
  23073. * Sets the proper output textures to draw in the engine.
  23074. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  23075. * @param subMesh Submesh on which the effect is applied
  23076. */
  23077. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  23078. /**
  23079. * @hidden
  23080. */
  23081. _beforeCameraDraw(): void;
  23082. /**
  23083. * @hidden
  23084. */
  23085. _afterCameraDraw(): void;
  23086. private _checkRTSize;
  23087. private _bindFrameBuffer;
  23088. /**
  23089. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  23090. */
  23091. clear(): void;
  23092. private _setState;
  23093. private _updateGeometryBufferLayout;
  23094. /**
  23095. * Adds an effect configuration to the prepass.
  23096. * If an effect has already been added, it won't add it twice and will return the configuration
  23097. * already present.
  23098. * @param cfg the effect configuration
  23099. * @return the effect configuration now used by the prepass
  23100. */
  23101. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23102. /**
  23103. * Returns the index of a texture in the multi render target texture array.
  23104. * @param type Texture type
  23105. * @return The index
  23106. */
  23107. getIndex(type: number): number;
  23108. private _enable;
  23109. private _disable;
  23110. private _resetLayout;
  23111. private _resetPostProcessChain;
  23112. private _bindPostProcessChain;
  23113. /**
  23114. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23115. */
  23116. markAsDirty(): void;
  23117. /**
  23118. * Enables a texture on the MultiRenderTarget for prepass
  23119. */
  23120. private _enableTextures;
  23121. private _update;
  23122. private _markAllMaterialsAsPrePassDirty;
  23123. /**
  23124. * Disposes the prepass renderer.
  23125. */
  23126. dispose(): void;
  23127. }
  23128. }
  23129. declare module "babylonjs/PostProcesses/postProcess" {
  23130. import { Nullable } from "babylonjs/types";
  23131. import { SmartArray } from "babylonjs/Misc/smartArray";
  23132. import { Observable } from "babylonjs/Misc/observable";
  23133. import { Vector2 } from "babylonjs/Maths/math.vector";
  23134. import { Camera } from "babylonjs/Cameras/camera";
  23135. import { Effect } from "babylonjs/Materials/effect";
  23136. import "babylonjs/Shaders/postprocess.vertex";
  23137. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23138. import { Engine } from "babylonjs/Engines/engine";
  23139. import { Color4 } from "babylonjs/Maths/math.color";
  23140. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23141. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23142. import { Scene } from "babylonjs/scene";
  23143. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23144. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  23145. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  23146. /**
  23147. * Size options for a post process
  23148. */
  23149. export type PostProcessOptions = {
  23150. width: number;
  23151. height: number;
  23152. };
  23153. /**
  23154. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23155. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23156. */
  23157. export class PostProcess {
  23158. /**
  23159. * Gets or sets the unique id of the post process
  23160. */
  23161. uniqueId: number;
  23162. /** Name of the PostProcess. */
  23163. name: string;
  23164. /**
  23165. * Width of the texture to apply the post process on
  23166. */
  23167. width: number;
  23168. /**
  23169. * Height of the texture to apply the post process on
  23170. */
  23171. height: number;
  23172. /**
  23173. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23174. */
  23175. nodeMaterialSource: Nullable<NodeMaterial>;
  23176. /**
  23177. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23178. * @hidden
  23179. */
  23180. _outputTexture: Nullable<InternalTexture>;
  23181. /**
  23182. * Sampling mode used by the shader
  23183. * See https://doc.babylonjs.com/classes/3.1/texture
  23184. */
  23185. renderTargetSamplingMode: number;
  23186. /**
  23187. * Clear color to use when screen clearing
  23188. */
  23189. clearColor: Color4;
  23190. /**
  23191. * If the buffer needs to be cleared before applying the post process. (default: true)
  23192. * Should be set to false if shader will overwrite all previous pixels.
  23193. */
  23194. autoClear: boolean;
  23195. /**
  23196. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23197. */
  23198. alphaMode: number;
  23199. /**
  23200. * Sets the setAlphaBlendConstants of the babylon engine
  23201. */
  23202. alphaConstants: Color4;
  23203. /**
  23204. * Animations to be used for the post processing
  23205. */
  23206. animations: import("babylonjs/Animations/animation").Animation[];
  23207. /**
  23208. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23209. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23210. */
  23211. enablePixelPerfectMode: boolean;
  23212. /**
  23213. * Force the postprocess to be applied without taking in account viewport
  23214. */
  23215. forceFullscreenViewport: boolean;
  23216. /**
  23217. * List of inspectable custom properties (used by the Inspector)
  23218. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23219. */
  23220. inspectableCustomProperties: IInspectable[];
  23221. /**
  23222. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23223. *
  23224. * | Value | Type | Description |
  23225. * | ----- | ----------------------------------- | ----------- |
  23226. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23227. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23228. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23229. *
  23230. */
  23231. scaleMode: number;
  23232. /**
  23233. * Force textures to be a power of two (default: false)
  23234. */
  23235. alwaysForcePOT: boolean;
  23236. private _samples;
  23237. /**
  23238. * Number of sample textures (default: 1)
  23239. */
  23240. get samples(): number;
  23241. set samples(n: number);
  23242. /**
  23243. * Modify the scale of the post process to be the same as the viewport (default: false)
  23244. */
  23245. adaptScaleToCurrentViewport: boolean;
  23246. private _camera;
  23247. protected _scene: Scene;
  23248. private _engine;
  23249. private _options;
  23250. private _reusable;
  23251. private _textureType;
  23252. private _textureFormat;
  23253. /**
  23254. * Smart array of input and output textures for the post process.
  23255. * @hidden
  23256. */
  23257. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23258. /**
  23259. * The index in _textures that corresponds to the output texture.
  23260. * @hidden
  23261. */
  23262. _currentRenderTextureInd: number;
  23263. private _effect;
  23264. private _samplers;
  23265. private _fragmentUrl;
  23266. private _vertexUrl;
  23267. private _parameters;
  23268. private _scaleRatio;
  23269. protected _indexParameters: any;
  23270. private _shareOutputWithPostProcess;
  23271. private _texelSize;
  23272. private _forcedOutputTexture;
  23273. /**
  23274. * Prepass configuration in case this post process needs a texture from prepass
  23275. * @hidden
  23276. */
  23277. _prePassEffectConfiguration: PrePassEffectConfiguration;
  23278. /**
  23279. * Returns the fragment url or shader name used in the post process.
  23280. * @returns the fragment url or name in the shader store.
  23281. */
  23282. getEffectName(): string;
  23283. /**
  23284. * An event triggered when the postprocess is activated.
  23285. */
  23286. onActivateObservable: Observable<Camera>;
  23287. private _onActivateObserver;
  23288. /**
  23289. * A function that is added to the onActivateObservable
  23290. */
  23291. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23292. /**
  23293. * An event triggered when the postprocess changes its size.
  23294. */
  23295. onSizeChangedObservable: Observable<PostProcess>;
  23296. private _onSizeChangedObserver;
  23297. /**
  23298. * A function that is added to the onSizeChangedObservable
  23299. */
  23300. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23301. /**
  23302. * An event triggered when the postprocess applies its effect.
  23303. */
  23304. onApplyObservable: Observable<Effect>;
  23305. private _onApplyObserver;
  23306. /**
  23307. * A function that is added to the onApplyObservable
  23308. */
  23309. set onApply(callback: (effect: Effect) => void);
  23310. /**
  23311. * An event triggered before rendering the postprocess
  23312. */
  23313. onBeforeRenderObservable: Observable<Effect>;
  23314. private _onBeforeRenderObserver;
  23315. /**
  23316. * A function that is added to the onBeforeRenderObservable
  23317. */
  23318. set onBeforeRender(callback: (effect: Effect) => void);
  23319. /**
  23320. * An event triggered after rendering the postprocess
  23321. */
  23322. onAfterRenderObservable: Observable<Effect>;
  23323. private _onAfterRenderObserver;
  23324. /**
  23325. * A function that is added to the onAfterRenderObservable
  23326. */
  23327. set onAfterRender(callback: (efect: Effect) => void);
  23328. /**
  23329. * 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
  23330. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23331. */
  23332. get inputTexture(): InternalTexture;
  23333. set inputTexture(value: InternalTexture);
  23334. /**
  23335. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23336. * the only way to unset it is to use this function to restore its internal state
  23337. */
  23338. restoreDefaultInputTexture(): void;
  23339. /**
  23340. * Gets the camera which post process is applied to.
  23341. * @returns The camera the post process is applied to.
  23342. */
  23343. getCamera(): Camera;
  23344. /**
  23345. * Gets the texel size of the postprocess.
  23346. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23347. */
  23348. get texelSize(): Vector2;
  23349. /**
  23350. * Creates a new instance PostProcess
  23351. * @param name The name of the PostProcess.
  23352. * @param fragmentUrl The url of the fragment shader to be used.
  23353. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23354. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23355. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23356. * @param camera The camera to apply the render pass to.
  23357. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23358. * @param engine The engine which the post process will be applied. (default: current engine)
  23359. * @param reusable If the post process can be reused on the same frame. (default: false)
  23360. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23361. * @param textureType Type of textures used when performing the post process. (default: 0)
  23362. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23363. * @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
  23364. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23365. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23366. */
  23367. 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);
  23368. /**
  23369. * Gets a string identifying the name of the class
  23370. * @returns "PostProcess" string
  23371. */
  23372. getClassName(): string;
  23373. /**
  23374. * Gets the engine which this post process belongs to.
  23375. * @returns The engine the post process was enabled with.
  23376. */
  23377. getEngine(): Engine;
  23378. /**
  23379. * The effect that is created when initializing the post process.
  23380. * @returns The created effect corresponding the the postprocess.
  23381. */
  23382. getEffect(): Effect;
  23383. /**
  23384. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23385. * @param postProcess The post process to share the output with.
  23386. * @returns This post process.
  23387. */
  23388. shareOutputWith(postProcess: PostProcess): PostProcess;
  23389. /**
  23390. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23391. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23392. */
  23393. useOwnOutput(): void;
  23394. /**
  23395. * Updates the effect with the current post process compile time values and recompiles the shader.
  23396. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23397. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23398. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23399. * @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
  23400. * @param onCompiled Called when the shader has been compiled.
  23401. * @param onError Called if there is an error when compiling a shader.
  23402. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23403. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23404. */
  23405. 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;
  23406. /**
  23407. * The post process is reusable if it can be used multiple times within one frame.
  23408. * @returns If the post process is reusable
  23409. */
  23410. isReusable(): boolean;
  23411. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23412. markTextureDirty(): void;
  23413. /**
  23414. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23415. * 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.
  23416. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23417. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23418. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23419. * @returns The target texture that was bound to be written to.
  23420. */
  23421. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23422. /**
  23423. * If the post process is supported.
  23424. */
  23425. get isSupported(): boolean;
  23426. /**
  23427. * The aspect ratio of the output texture.
  23428. */
  23429. get aspectRatio(): number;
  23430. /**
  23431. * Get a value indicating if the post-process is ready to be used
  23432. * @returns true if the post-process is ready (shader is compiled)
  23433. */
  23434. isReady(): boolean;
  23435. /**
  23436. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23437. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23438. */
  23439. apply(): Nullable<Effect>;
  23440. private _disposeTextures;
  23441. /**
  23442. * Sets the required values to the prepass renderer.
  23443. * @param prePassRenderer defines the prepass renderer to setup.
  23444. * @returns true if the pre pass is needed.
  23445. */
  23446. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23447. /**
  23448. * Disposes the post process.
  23449. * @param camera The camera to dispose the post process on.
  23450. */
  23451. dispose(camera?: Camera): void;
  23452. /**
  23453. * Serializes the particle system to a JSON object
  23454. * @returns the JSON object
  23455. */
  23456. serialize(): any;
  23457. /**
  23458. * Creates a material from parsed material data
  23459. * @param parsedPostProcess defines parsed post process data
  23460. * @param scene defines the hosting scene
  23461. * @param rootUrl defines the root URL to use to load textures
  23462. * @returns a new post process
  23463. */
  23464. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23465. }
  23466. }
  23467. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23468. /** @hidden */
  23469. export var kernelBlurVaryingDeclaration: {
  23470. name: string;
  23471. shader: string;
  23472. };
  23473. }
  23474. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  23475. /** @hidden */
  23476. export var packingFunctions: {
  23477. name: string;
  23478. shader: string;
  23479. };
  23480. }
  23481. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23482. /** @hidden */
  23483. export var kernelBlurFragment: {
  23484. name: string;
  23485. shader: string;
  23486. };
  23487. }
  23488. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23489. /** @hidden */
  23490. export var kernelBlurFragment2: {
  23491. name: string;
  23492. shader: string;
  23493. };
  23494. }
  23495. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23496. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23497. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23498. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23499. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23500. /** @hidden */
  23501. export var kernelBlurPixelShader: {
  23502. name: string;
  23503. shader: string;
  23504. };
  23505. }
  23506. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23507. /** @hidden */
  23508. export var kernelBlurVertex: {
  23509. name: string;
  23510. shader: string;
  23511. };
  23512. }
  23513. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23514. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23515. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23516. /** @hidden */
  23517. export var kernelBlurVertexShader: {
  23518. name: string;
  23519. shader: string;
  23520. };
  23521. }
  23522. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23523. import { Vector2 } from "babylonjs/Maths/math.vector";
  23524. import { Nullable } from "babylonjs/types";
  23525. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23526. import { Camera } from "babylonjs/Cameras/camera";
  23527. import { Effect } from "babylonjs/Materials/effect";
  23528. import { Engine } from "babylonjs/Engines/engine";
  23529. import "babylonjs/Shaders/kernelBlur.fragment";
  23530. import "babylonjs/Shaders/kernelBlur.vertex";
  23531. import { Scene } from "babylonjs/scene";
  23532. /**
  23533. * The Blur Post Process which blurs an image based on a kernel and direction.
  23534. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23535. */
  23536. export class BlurPostProcess extends PostProcess {
  23537. private blockCompilation;
  23538. protected _kernel: number;
  23539. protected _idealKernel: number;
  23540. protected _packedFloat: boolean;
  23541. private _staticDefines;
  23542. /** The direction in which to blur the image. */
  23543. direction: Vector2;
  23544. /**
  23545. * Sets the length in pixels of the blur sample region
  23546. */
  23547. set kernel(v: number);
  23548. /**
  23549. * Gets the length in pixels of the blur sample region
  23550. */
  23551. get kernel(): number;
  23552. /**
  23553. * Sets wether or not the blur needs to unpack/repack floats
  23554. */
  23555. set packedFloat(v: boolean);
  23556. /**
  23557. * Gets wether or not the blur is unpacking/repacking floats
  23558. */
  23559. get packedFloat(): boolean;
  23560. /**
  23561. * Gets a string identifying the name of the class
  23562. * @returns "BlurPostProcess" string
  23563. */
  23564. getClassName(): string;
  23565. /**
  23566. * Creates a new instance BlurPostProcess
  23567. * @param name The name of the effect.
  23568. * @param direction The direction in which to blur the image.
  23569. * @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.
  23570. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23571. * @param camera The camera to apply the render pass to.
  23572. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23573. * @param engine The engine which the post process will be applied. (default: current engine)
  23574. * @param reusable If the post process can be reused on the same frame. (default: false)
  23575. * @param textureType Type of textures used when performing the post process. (default: 0)
  23576. * @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)
  23577. */
  23578. 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);
  23579. /**
  23580. * Updates the effect with the current post process compile time values and recompiles the shader.
  23581. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23582. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23583. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23584. * @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
  23585. * @param onCompiled Called when the shader has been compiled.
  23586. * @param onError Called if there is an error when compiling a shader.
  23587. */
  23588. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23589. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23590. /**
  23591. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23592. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23593. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23594. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23595. * The gaps between physical kernels are compensated for in the weighting of the samples
  23596. * @param idealKernel Ideal blur kernel.
  23597. * @return Nearest best kernel.
  23598. */
  23599. protected _nearestBestKernel(idealKernel: number): number;
  23600. /**
  23601. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23602. * @param x The point on the Gaussian distribution to sample.
  23603. * @return the value of the Gaussian function at x.
  23604. */
  23605. protected _gaussianWeight(x: number): number;
  23606. /**
  23607. * Generates a string that can be used as a floating point number in GLSL.
  23608. * @param x Value to print.
  23609. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23610. * @return GLSL float string.
  23611. */
  23612. protected _glslFloat(x: number, decimalFigures?: number): string;
  23613. /** @hidden */
  23614. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23615. }
  23616. }
  23617. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23618. import { Scene } from "babylonjs/scene";
  23619. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23620. import { Plane } from "babylonjs/Maths/math.plane";
  23621. /**
  23622. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23623. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23624. * You can then easily use it as a reflectionTexture on a flat surface.
  23625. * In case the surface is not a plane, please consider relying on reflection probes.
  23626. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23627. */
  23628. export class MirrorTexture extends RenderTargetTexture {
  23629. private scene;
  23630. /**
  23631. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23632. * 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.
  23633. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23634. */
  23635. mirrorPlane: Plane;
  23636. /**
  23637. * Define the blur ratio used to blur the reflection if needed.
  23638. */
  23639. set blurRatio(value: number);
  23640. get blurRatio(): number;
  23641. /**
  23642. * Define the adaptive blur kernel used to blur the reflection if needed.
  23643. * This will autocompute the closest best match for the `blurKernel`
  23644. */
  23645. set adaptiveBlurKernel(value: number);
  23646. /**
  23647. * Define the blur kernel used to blur the reflection if needed.
  23648. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23649. */
  23650. set blurKernel(value: number);
  23651. /**
  23652. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23653. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23654. */
  23655. set blurKernelX(value: number);
  23656. get blurKernelX(): number;
  23657. /**
  23658. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23659. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23660. */
  23661. set blurKernelY(value: number);
  23662. get blurKernelY(): number;
  23663. private _autoComputeBlurKernel;
  23664. protected _onRatioRescale(): void;
  23665. private _updateGammaSpace;
  23666. private _imageProcessingConfigChangeObserver;
  23667. private _transformMatrix;
  23668. private _mirrorMatrix;
  23669. private _savedViewMatrix;
  23670. private _blurX;
  23671. private _blurY;
  23672. private _adaptiveBlurKernel;
  23673. private _blurKernelX;
  23674. private _blurKernelY;
  23675. private _blurRatio;
  23676. /**
  23677. * Instantiates a Mirror Texture.
  23678. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23679. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23680. * You can then easily use it as a reflectionTexture on a flat surface.
  23681. * In case the surface is not a plane, please consider relying on reflection probes.
  23682. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23683. * @param name
  23684. * @param size
  23685. * @param scene
  23686. * @param generateMipMaps
  23687. * @param type
  23688. * @param samplingMode
  23689. * @param generateDepthBuffer
  23690. */
  23691. constructor(name: string, size: number | {
  23692. width: number;
  23693. height: number;
  23694. } | {
  23695. ratio: number;
  23696. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23697. private _preparePostProcesses;
  23698. /**
  23699. * Clone the mirror texture.
  23700. * @returns the cloned texture
  23701. */
  23702. clone(): MirrorTexture;
  23703. /**
  23704. * Serialize the texture to a JSON representation you could use in Parse later on
  23705. * @returns the serialized JSON representation
  23706. */
  23707. serialize(): any;
  23708. /**
  23709. * Dispose the texture and release its associated resources.
  23710. */
  23711. dispose(): void;
  23712. }
  23713. }
  23714. declare module "babylonjs/Materials/Textures/texture" {
  23715. import { Observable } from "babylonjs/Misc/observable";
  23716. import { Nullable } from "babylonjs/types";
  23717. import { Matrix } from "babylonjs/Maths/math.vector";
  23718. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23719. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23720. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23721. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  23722. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  23723. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23724. import { Scene } from "babylonjs/scene";
  23725. /**
  23726. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23727. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23728. */
  23729. export class Texture extends BaseTexture {
  23730. /**
  23731. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23732. */
  23733. static SerializeBuffers: boolean;
  23734. /**
  23735. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  23736. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  23737. */
  23738. static ForceSerializeBuffers: boolean;
  23739. /** @hidden */
  23740. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23741. /** @hidden */
  23742. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23743. /** @hidden */
  23744. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23745. /** nearest is mag = nearest and min = nearest and mip = linear */
  23746. static readonly NEAREST_SAMPLINGMODE: number;
  23747. /** nearest is mag = nearest and min = nearest and mip = linear */
  23748. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23749. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23750. static readonly BILINEAR_SAMPLINGMODE: number;
  23751. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23752. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23753. /** Trilinear is mag = linear and min = linear and mip = linear */
  23754. static readonly TRILINEAR_SAMPLINGMODE: number;
  23755. /** Trilinear is mag = linear and min = linear and mip = linear */
  23756. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23757. /** mag = nearest and min = nearest and mip = nearest */
  23758. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23759. /** mag = nearest and min = linear and mip = nearest */
  23760. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23761. /** mag = nearest and min = linear and mip = linear */
  23762. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23763. /** mag = nearest and min = linear and mip = none */
  23764. static readonly NEAREST_LINEAR: number;
  23765. /** mag = nearest and min = nearest and mip = none */
  23766. static readonly NEAREST_NEAREST: number;
  23767. /** mag = linear and min = nearest and mip = nearest */
  23768. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23769. /** mag = linear and min = nearest and mip = linear */
  23770. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23771. /** mag = linear and min = linear and mip = none */
  23772. static readonly LINEAR_LINEAR: number;
  23773. /** mag = linear and min = nearest and mip = none */
  23774. static readonly LINEAR_NEAREST: number;
  23775. /** Explicit coordinates mode */
  23776. static readonly EXPLICIT_MODE: number;
  23777. /** Spherical coordinates mode */
  23778. static readonly SPHERICAL_MODE: number;
  23779. /** Planar coordinates mode */
  23780. static readonly PLANAR_MODE: number;
  23781. /** Cubic coordinates mode */
  23782. static readonly CUBIC_MODE: number;
  23783. /** Projection coordinates mode */
  23784. static readonly PROJECTION_MODE: number;
  23785. /** Inverse Cubic coordinates mode */
  23786. static readonly SKYBOX_MODE: number;
  23787. /** Inverse Cubic coordinates mode */
  23788. static readonly INVCUBIC_MODE: number;
  23789. /** Equirectangular coordinates mode */
  23790. static readonly EQUIRECTANGULAR_MODE: number;
  23791. /** Equirectangular Fixed coordinates mode */
  23792. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23793. /** Equirectangular Fixed Mirrored coordinates mode */
  23794. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23795. /** Texture is not repeating outside of 0..1 UVs */
  23796. static readonly CLAMP_ADDRESSMODE: number;
  23797. /** Texture is repeating outside of 0..1 UVs */
  23798. static readonly WRAP_ADDRESSMODE: number;
  23799. /** Texture is repeating and mirrored */
  23800. static readonly MIRROR_ADDRESSMODE: number;
  23801. /**
  23802. * 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
  23803. */
  23804. static UseSerializedUrlIfAny: boolean;
  23805. /**
  23806. * Define the url of the texture.
  23807. */
  23808. url: Nullable<string>;
  23809. /**
  23810. * Define an offset on the texture to offset the u coordinates of the UVs
  23811. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23812. */
  23813. uOffset: number;
  23814. /**
  23815. * Define an offset on the texture to offset the v coordinates of the UVs
  23816. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23817. */
  23818. vOffset: number;
  23819. /**
  23820. * Define an offset on the texture to scale the u coordinates of the UVs
  23821. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23822. */
  23823. uScale: number;
  23824. /**
  23825. * Define an offset on the texture to scale the v coordinates of the UVs
  23826. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23827. */
  23828. vScale: number;
  23829. /**
  23830. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23831. * @see https://doc.babylonjs.com/how_to/more_materials
  23832. */
  23833. uAng: number;
  23834. /**
  23835. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23836. * @see https://doc.babylonjs.com/how_to/more_materials
  23837. */
  23838. vAng: number;
  23839. /**
  23840. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23841. * @see https://doc.babylonjs.com/how_to/more_materials
  23842. */
  23843. wAng: number;
  23844. /**
  23845. * Defines the center of rotation (U)
  23846. */
  23847. uRotationCenter: number;
  23848. /**
  23849. * Defines the center of rotation (V)
  23850. */
  23851. vRotationCenter: number;
  23852. /**
  23853. * Defines the center of rotation (W)
  23854. */
  23855. wRotationCenter: number;
  23856. /**
  23857. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  23858. */
  23859. homogeneousRotationInUVTransform: boolean;
  23860. /**
  23861. * Are mip maps generated for this texture or not.
  23862. */
  23863. get noMipmap(): boolean;
  23864. /**
  23865. * List of inspectable custom properties (used by the Inspector)
  23866. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23867. */
  23868. inspectableCustomProperties: Nullable<IInspectable[]>;
  23869. private _noMipmap;
  23870. /** @hidden */
  23871. _invertY: boolean;
  23872. private _rowGenerationMatrix;
  23873. private _cachedTextureMatrix;
  23874. private _projectionModeMatrix;
  23875. private _t0;
  23876. private _t1;
  23877. private _t2;
  23878. private _cachedUOffset;
  23879. private _cachedVOffset;
  23880. private _cachedUScale;
  23881. private _cachedVScale;
  23882. private _cachedUAng;
  23883. private _cachedVAng;
  23884. private _cachedWAng;
  23885. private _cachedProjectionMatrixId;
  23886. private _cachedURotationCenter;
  23887. private _cachedVRotationCenter;
  23888. private _cachedWRotationCenter;
  23889. private _cachedHomogeneousRotationInUVTransform;
  23890. private _cachedCoordinatesMode;
  23891. /** @hidden */
  23892. protected _initialSamplingMode: number;
  23893. /** @hidden */
  23894. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23895. private _deleteBuffer;
  23896. protected _format: Nullable<number>;
  23897. private _delayedOnLoad;
  23898. private _delayedOnError;
  23899. private _mimeType?;
  23900. private _loaderOptions?;
  23901. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23902. get mimeType(): string | undefined;
  23903. /**
  23904. * Observable triggered once the texture has been loaded.
  23905. */
  23906. onLoadObservable: Observable<Texture>;
  23907. protected _isBlocking: boolean;
  23908. /**
  23909. * Is the texture preventing material to render while loading.
  23910. * If false, a default texture will be used instead of the loading one during the preparation step.
  23911. */
  23912. set isBlocking(value: boolean);
  23913. get isBlocking(): boolean;
  23914. /**
  23915. * Get the current sampling mode associated with the texture.
  23916. */
  23917. get samplingMode(): number;
  23918. /**
  23919. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23920. */
  23921. get invertY(): boolean;
  23922. /**
  23923. * Instantiates a new texture.
  23924. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23925. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23926. * @param url defines the url of the picture to load as a texture
  23927. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23928. * @param noMipmap defines if the texture will require mip maps or not
  23929. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23930. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23931. * @param onLoad defines a callback triggered when the texture has been loaded
  23932. * @param onError defines a callback triggered when an error occurred during the loading session
  23933. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23934. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23935. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23936. * @param mimeType defines an optional mime type information
  23937. * @param loaderOptions options to be passed to the loader
  23938. */
  23939. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string, loaderOptions?: any);
  23940. /**
  23941. * Update the url (and optional buffer) of this texture if url was null during construction.
  23942. * @param url the url of the texture
  23943. * @param buffer the buffer of the texture (defaults to null)
  23944. * @param onLoad callback called when the texture is loaded (defaults to null)
  23945. */
  23946. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23947. /**
  23948. * Finish the loading sequence of a texture flagged as delayed load.
  23949. * @hidden
  23950. */
  23951. delayLoad(): void;
  23952. private _prepareRowForTextureGeneration;
  23953. /**
  23954. * Checks if the texture has the same transform matrix than another texture
  23955. * @param texture texture to check against
  23956. * @returns true if the transforms are the same, else false
  23957. */
  23958. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  23959. /**
  23960. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23961. * @returns the transform matrix of the texture.
  23962. */
  23963. getTextureMatrix(uBase?: number): Matrix;
  23964. /**
  23965. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23966. * @returns The reflection texture transform
  23967. */
  23968. getReflectionTextureMatrix(): Matrix;
  23969. /**
  23970. * Clones the texture.
  23971. * @returns the cloned texture
  23972. */
  23973. clone(): Texture;
  23974. /**
  23975. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23976. * @returns The JSON representation of the texture
  23977. */
  23978. serialize(): any;
  23979. /**
  23980. * Get the current class name of the texture useful for serialization or dynamic coding.
  23981. * @returns "Texture"
  23982. */
  23983. getClassName(): string;
  23984. /**
  23985. * Dispose the texture and release its associated resources.
  23986. */
  23987. dispose(): void;
  23988. /**
  23989. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23990. * @param parsedTexture Define the JSON representation of the texture
  23991. * @param scene Define the scene the parsed texture should be instantiated in
  23992. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23993. * @returns The parsed texture if successful
  23994. */
  23995. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23996. /**
  23997. * Creates a texture from its base 64 representation.
  23998. * @param data Define the base64 payload without the data: prefix
  23999. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24000. * @param scene Define the scene the texture should belong to
  24001. * @param noMipmap Forces the texture to not create mip map information if true
  24002. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24003. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24004. * @param onLoad define a callback triggered when the texture has been loaded
  24005. * @param onError define a callback triggered when an error occurred during the loading session
  24006. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24007. * @returns the created texture
  24008. */
  24009. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24010. /**
  24011. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24012. * @param data Define the base64 payload without the data: prefix
  24013. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24014. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24015. * @param scene Define the scene the texture should belong to
  24016. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24017. * @param noMipmap Forces the texture to not create mip map information if true
  24018. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24019. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24020. * @param onLoad define a callback triggered when the texture has been loaded
  24021. * @param onError define a callback triggered when an error occurred during the loading session
  24022. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24023. * @returns the created texture
  24024. */
  24025. 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;
  24026. }
  24027. }
  24028. declare module "babylonjs/Sprites/thinSprite" {
  24029. import { IVector3Like, IColor4Like } from "babylonjs/Maths/math.like";
  24030. import { Nullable } from "babylonjs/types";
  24031. /**
  24032. * ThinSprite Class used to represent a thin sprite
  24033. * This is the base class for sprites but can also directly be used with ThinEngine
  24034. * @see https://doc.babylonjs.com/babylon101/sprites
  24035. */
  24036. export class ThinSprite {
  24037. /** Gets or sets the cell index in the sprite sheet */
  24038. cellIndex: number;
  24039. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  24040. cellRef: string;
  24041. /** Gets or sets the current world position */
  24042. position: IVector3Like;
  24043. /** Gets or sets the main color */
  24044. color: IColor4Like;
  24045. /** Gets or sets the width */
  24046. width: number;
  24047. /** Gets or sets the height */
  24048. height: number;
  24049. /** Gets or sets rotation angle */
  24050. angle: number;
  24051. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  24052. invertU: boolean;
  24053. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  24054. invertV: boolean;
  24055. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  24056. isVisible: boolean;
  24057. /**
  24058. * Returns a boolean indicating if the animation is started
  24059. */
  24060. get animationStarted(): boolean;
  24061. /** Gets the initial key for the animation (setting it will restart the animation) */
  24062. get fromIndex(): number;
  24063. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24064. get toIndex(): number;
  24065. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24066. get loopAnimation(): boolean;
  24067. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24068. get delay(): number;
  24069. /** @hidden */
  24070. _xOffset: number;
  24071. /** @hidden */
  24072. _yOffset: number;
  24073. /** @hidden */
  24074. _xSize: number;
  24075. /** @hidden */
  24076. _ySize: number;
  24077. private _animationStarted;
  24078. protected _loopAnimation: boolean;
  24079. protected _fromIndex: number;
  24080. protected _toIndex: number;
  24081. protected _delay: number;
  24082. private _direction;
  24083. private _time;
  24084. private _onBaseAnimationEnd;
  24085. /**
  24086. * Creates a new Thin Sprite
  24087. */
  24088. constructor();
  24089. /**
  24090. * Starts an animation
  24091. * @param from defines the initial key
  24092. * @param to defines the end key
  24093. * @param loop defines if the animation must loop
  24094. * @param delay defines the start delay (in ms)
  24095. * @param onAnimationEnd defines a callback for when the animation ends
  24096. */
  24097. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  24098. /** Stops current animation (if any) */
  24099. stopAnimation(): void;
  24100. /** @hidden */
  24101. _animate(deltaTime: number): void;
  24102. }
  24103. }
  24104. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility" {
  24105. /** @hidden */
  24106. export var imageProcessingCompatibility: {
  24107. name: string;
  24108. shader: string;
  24109. };
  24110. }
  24111. declare module "babylonjs/Shaders/sprites.fragment" {
  24112. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  24113. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  24114. import "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility";
  24115. /** @hidden */
  24116. export var spritesPixelShader: {
  24117. name: string;
  24118. shader: string;
  24119. };
  24120. }
  24121. declare module "babylonjs/Shaders/sprites.vertex" {
  24122. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  24123. /** @hidden */
  24124. export var spritesVertexShader: {
  24125. name: string;
  24126. shader: string;
  24127. };
  24128. }
  24129. declare module "babylonjs/Sprites/spriteRenderer" {
  24130. import { Nullable } from "babylonjs/types";
  24131. import { IMatrixLike } from "babylonjs/Maths/math.like";
  24132. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24133. import { ThinSprite } from "babylonjs/Sprites/thinSprite";
  24134. import { ISize } from "babylonjs/Maths/math.size";
  24135. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  24136. import { Scene } from "babylonjs/scene";
  24137. import "babylonjs/Engines/Extensions/engine.alpha";
  24138. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  24139. import "babylonjs/Shaders/sprites.fragment";
  24140. import "babylonjs/Shaders/sprites.vertex";
  24141. /**
  24142. * Class used to render sprites.
  24143. *
  24144. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  24145. */
  24146. export class SpriteRenderer {
  24147. /**
  24148. * Defines the texture of the spritesheet
  24149. */
  24150. texture: Nullable<ThinTexture>;
  24151. /**
  24152. * Defines the default width of a cell in the spritesheet
  24153. */
  24154. cellWidth: number;
  24155. /**
  24156. * Defines the default height of a cell in the spritesheet
  24157. */
  24158. cellHeight: number;
  24159. /**
  24160. * Blend mode use to render the particle, it can be any of
  24161. * the static Constants.ALPHA_x properties provided in this class.
  24162. * Default value is Constants.ALPHA_COMBINE
  24163. */
  24164. blendMode: number;
  24165. /**
  24166. * Gets or sets a boolean indicating if alpha mode is automatically
  24167. * reset.
  24168. */
  24169. autoResetAlpha: boolean;
  24170. /**
  24171. * Disables writing to the depth buffer when rendering the sprites.
  24172. * It can be handy to disable depth writing when using textures without alpha channel
  24173. * and setting some specific blend modes.
  24174. */
  24175. disableDepthWrite: boolean;
  24176. /**
  24177. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24178. */
  24179. fogEnabled: boolean;
  24180. /**
  24181. * Gets the capacity of the manager
  24182. */
  24183. get capacity(): number;
  24184. private readonly _engine;
  24185. private readonly _useVAO;
  24186. private readonly _useInstancing;
  24187. private readonly _scene;
  24188. private readonly _capacity;
  24189. private readonly _epsilon;
  24190. private _vertexBufferSize;
  24191. private _vertexData;
  24192. private _buffer;
  24193. private _vertexBuffers;
  24194. private _spriteBuffer;
  24195. private _indexBuffer;
  24196. private _effectBase;
  24197. private _effectFog;
  24198. private _vertexArrayObject;
  24199. /**
  24200. * Creates a new sprite Renderer
  24201. * @param engine defines the engine the renderer works with
  24202. * @param capacity defines the maximum allowed number of sprites
  24203. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24204. * @param scene defines the hosting scene
  24205. */
  24206. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24207. /**
  24208. * Render all child sprites
  24209. * @param sprites defines the list of sprites to render
  24210. * @param deltaTime defines the time since last frame
  24211. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24212. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24213. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24214. */
  24215. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24216. private _appendSpriteVertex;
  24217. /**
  24218. * Release associated resources
  24219. */
  24220. dispose(): void;
  24221. }
  24222. }
  24223. declare module "babylonjs/Sprites/spriteManager" {
  24224. import { IDisposable, Scene } from "babylonjs/scene";
  24225. import { Nullable } from "babylonjs/types";
  24226. import { Observable } from "babylonjs/Misc/observable";
  24227. import { Sprite } from "babylonjs/Sprites/sprite";
  24228. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24229. import { Camera } from "babylonjs/Cameras/camera";
  24230. import { Texture } from "babylonjs/Materials/Textures/texture";
  24231. import { Ray } from "babylonjs/Culling/ray";
  24232. /**
  24233. * Defines the minimum interface to fullfil in order to be a sprite manager.
  24234. */
  24235. export interface ISpriteManager extends IDisposable {
  24236. /**
  24237. * Gets manager's name
  24238. */
  24239. name: string;
  24240. /**
  24241. * Restricts the camera to viewing objects with the same layerMask.
  24242. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  24243. */
  24244. layerMask: number;
  24245. /**
  24246. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24247. */
  24248. isPickable: boolean;
  24249. /**
  24250. * Gets the hosting scene
  24251. */
  24252. scene: Scene;
  24253. /**
  24254. * Specifies the rendering group id for this mesh (0 by default)
  24255. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24256. */
  24257. renderingGroupId: number;
  24258. /**
  24259. * Defines the list of sprites managed by the manager.
  24260. */
  24261. sprites: Array<Sprite>;
  24262. /**
  24263. * Gets or sets the spritesheet texture
  24264. */
  24265. texture: Texture;
  24266. /** Defines the default width of a cell in the spritesheet */
  24267. cellWidth: number;
  24268. /** Defines the default height of a cell in the spritesheet */
  24269. cellHeight: number;
  24270. /**
  24271. * Tests the intersection of a sprite with a specific ray.
  24272. * @param ray The ray we are sending to test the collision
  24273. * @param camera The camera space we are sending rays in
  24274. * @param predicate A predicate allowing excluding sprites from the list of object to test
  24275. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24276. * @returns picking info or null.
  24277. */
  24278. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24279. /**
  24280. * Intersects the sprites with a ray
  24281. * @param ray defines the ray to intersect with
  24282. * @param camera defines the current active camera
  24283. * @param predicate defines a predicate used to select candidate sprites
  24284. * @returns null if no hit or a PickingInfo array
  24285. */
  24286. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24287. /**
  24288. * Renders the list of sprites on screen.
  24289. */
  24290. render(): void;
  24291. }
  24292. /**
  24293. * Class used to manage multiple sprites on the same spritesheet
  24294. * @see https://doc.babylonjs.com/babylon101/sprites
  24295. */
  24296. export class SpriteManager implements ISpriteManager {
  24297. /** defines the manager's name */
  24298. name: string;
  24299. /** Define the Url to load snippets */
  24300. static SnippetUrl: string;
  24301. /** Snippet ID if the manager was created from the snippet server */
  24302. snippetId: string;
  24303. /** Gets the list of sprites */
  24304. sprites: Sprite[];
  24305. /** Gets or sets the rendering group id (0 by default) */
  24306. renderingGroupId: number;
  24307. /** Gets or sets camera layer mask */
  24308. layerMask: number;
  24309. /** Gets or sets a boolean indicating if the sprites are pickable */
  24310. isPickable: boolean;
  24311. /**
  24312. * An event triggered when the manager is disposed.
  24313. */
  24314. onDisposeObservable: Observable<SpriteManager>;
  24315. /**
  24316. * Callback called when the manager is disposed
  24317. */
  24318. set onDispose(callback: () => void);
  24319. /**
  24320. * Gets or sets the unique id of the sprite
  24321. */
  24322. uniqueId: number;
  24323. /**
  24324. * Gets the array of sprites
  24325. */
  24326. get children(): Sprite[];
  24327. /**
  24328. * Gets the hosting scene
  24329. */
  24330. get scene(): Scene;
  24331. /**
  24332. * Gets the capacity of the manager
  24333. */
  24334. get capacity(): number;
  24335. /**
  24336. * Gets or sets the spritesheet texture
  24337. */
  24338. get texture(): Texture;
  24339. set texture(value: Texture);
  24340. /** Defines the default width of a cell in the spritesheet */
  24341. get cellWidth(): number;
  24342. set cellWidth(value: number);
  24343. /** Defines the default height of a cell in the spritesheet */
  24344. get cellHeight(): number;
  24345. set cellHeight(value: number);
  24346. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  24347. get fogEnabled(): boolean;
  24348. set fogEnabled(value: boolean);
  24349. /**
  24350. * Blend mode use to render the particle, it can be any of
  24351. * the static Constants.ALPHA_x properties provided in this class.
  24352. * Default value is Constants.ALPHA_COMBINE
  24353. */
  24354. get blendMode(): number;
  24355. set blendMode(blendMode: number);
  24356. /** Disables writing to the depth buffer when rendering the sprites.
  24357. * It can be handy to disable depth writing when using textures without alpha channel
  24358. * and setting some specific blend modes.
  24359. */
  24360. disableDepthWrite: boolean;
  24361. private _spriteRenderer;
  24362. /** Associative array from JSON sprite data file */
  24363. private _cellData;
  24364. /** Array of sprite names from JSON sprite data file */
  24365. private _spriteMap;
  24366. /** True when packed cell data from JSON file is ready*/
  24367. private _packedAndReady;
  24368. private _textureContent;
  24369. private _onDisposeObserver;
  24370. private _fromPacked;
  24371. private _scene;
  24372. /**
  24373. * Creates a new sprite manager
  24374. * @param name defines the manager's name
  24375. * @param imgUrl defines the sprite sheet url
  24376. * @param capacity defines the maximum allowed number of sprites
  24377. * @param cellSize defines the size of a sprite cell
  24378. * @param scene defines the hosting scene
  24379. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24380. * @param samplingMode defines the smapling mode to use with spritesheet
  24381. * @param fromPacked set to false; do not alter
  24382. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  24383. */
  24384. constructor(
  24385. /** defines the manager's name */
  24386. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  24387. /**
  24388. * Returns the string "SpriteManager"
  24389. * @returns "SpriteManager"
  24390. */
  24391. getClassName(): string;
  24392. private _makePacked;
  24393. private _checkTextureAlpha;
  24394. /**
  24395. * Intersects the sprites with a ray
  24396. * @param ray defines the ray to intersect with
  24397. * @param camera defines the current active camera
  24398. * @param predicate defines a predicate used to select candidate sprites
  24399. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  24400. * @returns null if no hit or a PickingInfo
  24401. */
  24402. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24403. /**
  24404. * Intersects the sprites with a ray
  24405. * @param ray defines the ray to intersect with
  24406. * @param camera defines the current active camera
  24407. * @param predicate defines a predicate used to select candidate sprites
  24408. * @returns null if no hit or a PickingInfo array
  24409. */
  24410. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24411. /**
  24412. * Render all child sprites
  24413. */
  24414. render(): void;
  24415. private _customUpdate;
  24416. /**
  24417. * Release associated resources
  24418. */
  24419. dispose(): void;
  24420. /**
  24421. * Serializes the sprite manager to a JSON object
  24422. * @param serializeTexture defines if the texture must be serialized as well
  24423. * @returns the JSON object
  24424. */
  24425. serialize(serializeTexture?: boolean): any;
  24426. /**
  24427. * Parses a JSON object to create a new sprite manager.
  24428. * @param parsedManager The JSON object to parse
  24429. * @param scene The scene to create the sprite managerin
  24430. * @param rootUrl The root url to use to load external dependencies like texture
  24431. * @returns the new sprite manager
  24432. */
  24433. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  24434. /**
  24435. * Creates a sprite manager from a snippet saved in a remote file
  24436. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  24437. * @param url defines the url to load from
  24438. * @param scene defines the hosting scene
  24439. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24440. * @returns a promise that will resolve to the new sprite manager
  24441. */
  24442. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24443. /**
  24444. * Creates a sprite manager from a snippet saved by the sprite editor
  24445. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  24446. * @param scene defines the hosting scene
  24447. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24448. * @returns a promise that will resolve to the new sprite manager
  24449. */
  24450. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24451. }
  24452. }
  24453. declare module "babylonjs/Sprites/sprite" {
  24454. import { Vector3 } from "babylonjs/Maths/math.vector";
  24455. import { Nullable } from "babylonjs/types";
  24456. import { ActionManager } from "babylonjs/Actions/actionManager";
  24457. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  24458. import { Color4 } from "babylonjs/Maths/math.color";
  24459. import { Observable } from "babylonjs/Misc/observable";
  24460. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24461. import { ThinSprite } from "babylonjs/Sprites/thinSprite";
  24462. import { Animation } from "babylonjs/Animations/animation";
  24463. /**
  24464. * Class used to represent a sprite
  24465. * @see https://doc.babylonjs.com/babylon101/sprites
  24466. */
  24467. export class Sprite extends ThinSprite implements IAnimatable {
  24468. /** defines the name */
  24469. name: string;
  24470. /** Gets or sets the current world position */
  24471. position: Vector3;
  24472. /** Gets or sets the main color */
  24473. color: Color4;
  24474. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  24475. disposeWhenFinishedAnimating: boolean;
  24476. /** Gets the list of attached animations */
  24477. animations: Nullable<Array<Animation>>;
  24478. /** Gets or sets a boolean indicating if the sprite can be picked */
  24479. isPickable: boolean;
  24480. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  24481. useAlphaForPicking: boolean;
  24482. /**
  24483. * Gets or sets the associated action manager
  24484. */
  24485. actionManager: Nullable<ActionManager>;
  24486. /**
  24487. * An event triggered when the control has been disposed
  24488. */
  24489. onDisposeObservable: Observable<Sprite>;
  24490. private _manager;
  24491. private _onAnimationEnd;
  24492. /**
  24493. * Gets or sets the sprite size
  24494. */
  24495. get size(): number;
  24496. set size(value: number);
  24497. /**
  24498. * Gets or sets the unique id of the sprite
  24499. */
  24500. uniqueId: number;
  24501. /**
  24502. * Gets the manager of this sprite
  24503. */
  24504. get manager(): ISpriteManager;
  24505. /**
  24506. * Creates a new Sprite
  24507. * @param name defines the name
  24508. * @param manager defines the manager
  24509. */
  24510. constructor(
  24511. /** defines the name */
  24512. name: string, manager: ISpriteManager);
  24513. /**
  24514. * Returns the string "Sprite"
  24515. * @returns "Sprite"
  24516. */
  24517. getClassName(): string;
  24518. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  24519. get fromIndex(): number;
  24520. set fromIndex(value: number);
  24521. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24522. get toIndex(): number;
  24523. set toIndex(value: number);
  24524. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24525. get loopAnimation(): boolean;
  24526. set loopAnimation(value: boolean);
  24527. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24528. get delay(): number;
  24529. set delay(value: number);
  24530. /**
  24531. * Starts an animation
  24532. * @param from defines the initial key
  24533. * @param to defines the end key
  24534. * @param loop defines if the animation must loop
  24535. * @param delay defines the start delay (in ms)
  24536. * @param onAnimationEnd defines a callback to call when animation ends
  24537. */
  24538. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  24539. private _endAnimation;
  24540. /** Release associated resources */
  24541. dispose(): void;
  24542. /**
  24543. * Serializes the sprite to a JSON object
  24544. * @returns the JSON object
  24545. */
  24546. serialize(): any;
  24547. /**
  24548. * Parses a JSON object to create a new sprite
  24549. * @param parsedSprite The JSON object to parse
  24550. * @param manager defines the hosting manager
  24551. * @returns the new sprite
  24552. */
  24553. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  24554. }
  24555. }
  24556. declare module "babylonjs/Collisions/pickingInfo" {
  24557. import { Nullable } from "babylonjs/types";
  24558. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  24559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24560. import { Sprite } from "babylonjs/Sprites/sprite";
  24561. import { Ray } from "babylonjs/Culling/ray";
  24562. /**
  24563. * Information about the result of picking within a scene
  24564. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24565. */
  24566. export class PickingInfo {
  24567. /** @hidden */
  24568. _pickingUnavailable: boolean;
  24569. /**
  24570. * If the pick collided with an object
  24571. */
  24572. hit: boolean;
  24573. /**
  24574. * Distance away where the pick collided
  24575. */
  24576. distance: number;
  24577. /**
  24578. * The location of pick collision
  24579. */
  24580. pickedPoint: Nullable<Vector3>;
  24581. /**
  24582. * The mesh corresponding the the pick collision
  24583. */
  24584. pickedMesh: Nullable<AbstractMesh>;
  24585. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  24586. bu: number;
  24587. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  24588. bv: number;
  24589. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24590. faceId: number;
  24591. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24592. subMeshFaceId: number;
  24593. /** Id of the the submesh that was picked */
  24594. subMeshId: number;
  24595. /** If a sprite was picked, this will be the sprite the pick collided with */
  24596. pickedSprite: Nullable<Sprite>;
  24597. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  24598. thinInstanceIndex: number;
  24599. /**
  24600. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24601. */
  24602. originMesh: Nullable<AbstractMesh>;
  24603. /**
  24604. * The ray that was used to perform the picking.
  24605. */
  24606. ray: Nullable<Ray>;
  24607. /**
  24608. * Gets the normal correspodning to the face the pick collided with
  24609. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24610. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24611. * @returns The normal correspodning to the face the pick collided with
  24612. */
  24613. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  24614. /**
  24615. * Gets the texture coordinates of where the pick occured
  24616. * @returns the vector containing the coordnates of the texture
  24617. */
  24618. getTextureCoordinates(): Nullable<Vector2>;
  24619. }
  24620. }
  24621. declare module "babylonjs/Events/pointerEvents" {
  24622. import { Nullable } from "babylonjs/types";
  24623. import { Vector2 } from "babylonjs/Maths/math.vector";
  24624. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24625. import { Ray } from "babylonjs/Culling/ray";
  24626. /**
  24627. * Gather the list of pointer event types as constants.
  24628. */
  24629. export class PointerEventTypes {
  24630. /**
  24631. * 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.
  24632. */
  24633. static readonly POINTERDOWN: number;
  24634. /**
  24635. * The pointerup event is fired when a pointer is no longer active.
  24636. */
  24637. static readonly POINTERUP: number;
  24638. /**
  24639. * The pointermove event is fired when a pointer changes coordinates.
  24640. */
  24641. static readonly POINTERMOVE: number;
  24642. /**
  24643. * The pointerwheel event is fired when a mouse wheel has been rotated.
  24644. */
  24645. static readonly POINTERWHEEL: number;
  24646. /**
  24647. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  24648. */
  24649. static readonly POINTERPICK: number;
  24650. /**
  24651. * The pointertap event is fired when a the object has been touched and released without drag.
  24652. */
  24653. static readonly POINTERTAP: number;
  24654. /**
  24655. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  24656. */
  24657. static readonly POINTERDOUBLETAP: number;
  24658. }
  24659. /**
  24660. * Base class of pointer info types.
  24661. */
  24662. export class PointerInfoBase {
  24663. /**
  24664. * Defines the type of event (PointerEventTypes)
  24665. */
  24666. type: number;
  24667. /**
  24668. * Defines the related dom event
  24669. */
  24670. event: PointerEvent | MouseWheelEvent;
  24671. /**
  24672. * Instantiates the base class of pointers info.
  24673. * @param type Defines the type of event (PointerEventTypes)
  24674. * @param event Defines the related dom event
  24675. */
  24676. constructor(
  24677. /**
  24678. * Defines the type of event (PointerEventTypes)
  24679. */
  24680. type: number,
  24681. /**
  24682. * Defines the related dom event
  24683. */
  24684. event: PointerEvent | MouseWheelEvent);
  24685. }
  24686. /**
  24687. * This class is used to store pointer related info for the onPrePointerObservable event.
  24688. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  24689. */
  24690. export class PointerInfoPre extends PointerInfoBase {
  24691. /**
  24692. * Ray from a pointer if availible (eg. 6dof controller)
  24693. */
  24694. ray: Nullable<Ray>;
  24695. /**
  24696. * Defines the local position of the pointer on the canvas.
  24697. */
  24698. localPosition: Vector2;
  24699. /**
  24700. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  24701. */
  24702. skipOnPointerObservable: boolean;
  24703. /**
  24704. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  24705. * @param type Defines the type of event (PointerEventTypes)
  24706. * @param event Defines the related dom event
  24707. * @param localX Defines the local x coordinates of the pointer when the event occured
  24708. * @param localY Defines the local y coordinates of the pointer when the event occured
  24709. */
  24710. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  24711. }
  24712. /**
  24713. * This type contains all the data related to a pointer event in Babylon.js.
  24714. * 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.
  24715. */
  24716. export class PointerInfo extends PointerInfoBase {
  24717. /**
  24718. * Defines the picking info associated to the info (if any)\
  24719. */
  24720. pickInfo: Nullable<PickingInfo>;
  24721. /**
  24722. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  24723. * @param type Defines the type of event (PointerEventTypes)
  24724. * @param event Defines the related dom event
  24725. * @param pickInfo Defines the picking info associated to the info (if any)\
  24726. */
  24727. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  24728. /**
  24729. * Defines the picking info associated to the info (if any)\
  24730. */
  24731. pickInfo: Nullable<PickingInfo>);
  24732. }
  24733. /**
  24734. * Data relating to a touch event on the screen.
  24735. */
  24736. export interface PointerTouch {
  24737. /**
  24738. * X coordinate of touch.
  24739. */
  24740. x: number;
  24741. /**
  24742. * Y coordinate of touch.
  24743. */
  24744. y: number;
  24745. /**
  24746. * Id of touch. Unique for each finger.
  24747. */
  24748. pointerId: number;
  24749. /**
  24750. * Event type passed from DOM.
  24751. */
  24752. type: any;
  24753. }
  24754. }
  24755. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  24756. import { Observable } from "babylonjs/Misc/observable";
  24757. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  24758. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  24759. /**
  24760. * Manage the mouse inputs to control the movement of a free camera.
  24761. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24762. */
  24763. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  24764. /**
  24765. * Define if touch is enabled in the mouse input
  24766. */
  24767. touchEnabled: boolean;
  24768. /**
  24769. * Defines the camera the input is attached to.
  24770. */
  24771. camera: FreeCamera;
  24772. /**
  24773. * Defines the buttons associated with the input to handle camera move.
  24774. */
  24775. buttons: number[];
  24776. /**
  24777. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  24778. */
  24779. angularSensibility: number;
  24780. private _pointerInput;
  24781. private _onMouseMove;
  24782. private _observer;
  24783. private previousPosition;
  24784. /**
  24785. * Observable for when a pointer move event occurs containing the move offset
  24786. */
  24787. onPointerMovedObservable: Observable<{
  24788. offsetX: number;
  24789. offsetY: number;
  24790. }>;
  24791. /**
  24792. * @hidden
  24793. * If the camera should be rotated automatically based on pointer movement
  24794. */
  24795. _allowCameraRotation: boolean;
  24796. /**
  24797. * Manage the mouse inputs to control the movement of a free camera.
  24798. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24799. * @param touchEnabled Defines if touch is enabled or not
  24800. */
  24801. constructor(
  24802. /**
  24803. * Define if touch is enabled in the mouse input
  24804. */
  24805. touchEnabled?: boolean);
  24806. /**
  24807. * Attach the input controls to a specific dom element to get the input from.
  24808. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24809. */
  24810. attachControl(noPreventDefault?: boolean): void;
  24811. /**
  24812. * Called on JS contextmenu event.
  24813. * Override this method to provide functionality.
  24814. */
  24815. protected onContextMenu(evt: PointerEvent): void;
  24816. /**
  24817. * Detach the current controls from the specified dom element.
  24818. */
  24819. detachControl(): void;
  24820. /**
  24821. * Gets the class name of the current intput.
  24822. * @returns the class name
  24823. */
  24824. getClassName(): string;
  24825. /**
  24826. * Get the friendly name associated with the input class.
  24827. * @returns the input friendly name
  24828. */
  24829. getSimpleName(): string;
  24830. }
  24831. }
  24832. declare module "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput" {
  24833. import { Observable } from "babylonjs/Misc/observable";
  24834. import { Camera } from "babylonjs/Cameras/camera";
  24835. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  24836. /**
  24837. * Base class for mouse wheel input..
  24838. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  24839. * for example usage.
  24840. */
  24841. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  24842. /**
  24843. * Defines the camera the input is attached to.
  24844. */
  24845. abstract camera: Camera;
  24846. /**
  24847. * How fast is the camera moves in relation to X axis mouseWheel events.
  24848. * Use negative value to reverse direction.
  24849. */
  24850. wheelPrecisionX: number;
  24851. /**
  24852. * How fast is the camera moves in relation to Y axis mouseWheel events.
  24853. * Use negative value to reverse direction.
  24854. */
  24855. wheelPrecisionY: number;
  24856. /**
  24857. * How fast is the camera moves in relation to Z axis mouseWheel events.
  24858. * Use negative value to reverse direction.
  24859. */
  24860. wheelPrecisionZ: number;
  24861. /**
  24862. * Observable for when a mouse wheel move event occurs.
  24863. */
  24864. onChangedObservable: Observable<{
  24865. wheelDeltaX: number;
  24866. wheelDeltaY: number;
  24867. wheelDeltaZ: number;
  24868. }>;
  24869. private _wheel;
  24870. private _observer;
  24871. /**
  24872. * Attach the input controls to a specific dom element to get the input from.
  24873. * @param noPreventDefault Defines whether event caught by the controls
  24874. * should call preventdefault().
  24875. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24876. */
  24877. attachControl(noPreventDefault?: boolean): void;
  24878. /**
  24879. * Detach the current controls from the specified dom element.
  24880. */
  24881. detachControl(): void;
  24882. /**
  24883. * Called for each rendered frame.
  24884. */
  24885. checkInputs(): void;
  24886. /**
  24887. * Gets the class name of the current intput.
  24888. * @returns the class name
  24889. */
  24890. getClassName(): string;
  24891. /**
  24892. * Get the friendly name associated with the input class.
  24893. * @returns the input friendly name
  24894. */
  24895. getSimpleName(): string;
  24896. /**
  24897. * Incremental value of multiple mouse wheel movements of the X axis.
  24898. * Should be zero-ed when read.
  24899. */
  24900. protected _wheelDeltaX: number;
  24901. /**
  24902. * Incremental value of multiple mouse wheel movements of the Y axis.
  24903. * Should be zero-ed when read.
  24904. */
  24905. protected _wheelDeltaY: number;
  24906. /**
  24907. * Incremental value of multiple mouse wheel movements of the Z axis.
  24908. * Should be zero-ed when read.
  24909. */
  24910. protected _wheelDeltaZ: number;
  24911. /**
  24912. * Firefox uses a different scheme to report scroll distances to other
  24913. * browsers. Rather than use complicated methods to calculate the exact
  24914. * multiple we need to apply, let's just cheat and use a constant.
  24915. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  24916. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  24917. */
  24918. private readonly _ffMultiplier;
  24919. /**
  24920. * Different event attributes for wheel data fall into a few set ranges.
  24921. * Some relevant but dated date here:
  24922. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  24923. */
  24924. private readonly _normalize;
  24925. }
  24926. }
  24927. declare module "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput" {
  24928. import { Nullable } from "babylonjs/types";
  24929. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  24930. import { BaseCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput";
  24931. import { Coordinate } from "babylonjs/Maths/math.axis";
  24932. /**
  24933. * Manage the mouse wheel inputs to control a free camera.
  24934. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24935. */
  24936. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  24937. /**
  24938. * Defines the camera the input is attached to.
  24939. */
  24940. camera: FreeCamera;
  24941. /**
  24942. * Gets the class name of the current input.
  24943. * @returns the class name
  24944. */
  24945. getClassName(): string;
  24946. /**
  24947. * Set which movement axis (relative to camera's orientation) the mouse
  24948. * wheel's X axis controls.
  24949. * @param axis The axis to be moved. Set null to clear.
  24950. */
  24951. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  24952. /**
  24953. * Get the configured movement axis (relative to camera's orientation) the
  24954. * mouse wheel's X axis controls.
  24955. * @returns The configured axis or null if none.
  24956. */
  24957. get wheelXMoveRelative(): Nullable<Coordinate>;
  24958. /**
  24959. * Set which movement axis (relative to camera's orientation) the mouse
  24960. * wheel's Y axis controls.
  24961. * @param axis The axis to be moved. Set null to clear.
  24962. */
  24963. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  24964. /**
  24965. * Get the configured movement axis (relative to camera's orientation) the
  24966. * mouse wheel's Y axis controls.
  24967. * @returns The configured axis or null if none.
  24968. */
  24969. get wheelYMoveRelative(): Nullable<Coordinate>;
  24970. /**
  24971. * Set which movement axis (relative to camera's orientation) the mouse
  24972. * wheel's Z axis controls.
  24973. * @param axis The axis to be moved. Set null to clear.
  24974. */
  24975. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  24976. /**
  24977. * Get the configured movement axis (relative to camera's orientation) the
  24978. * mouse wheel's Z axis controls.
  24979. * @returns The configured axis or null if none.
  24980. */
  24981. get wheelZMoveRelative(): Nullable<Coordinate>;
  24982. /**
  24983. * Set which rotation axis (relative to camera's orientation) the mouse
  24984. * wheel's X axis controls.
  24985. * @param axis The axis to be moved. Set null to clear.
  24986. */
  24987. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  24988. /**
  24989. * Get the configured rotation axis (relative to camera's orientation) the
  24990. * mouse wheel's X axis controls.
  24991. * @returns The configured axis or null if none.
  24992. */
  24993. get wheelXRotateRelative(): Nullable<Coordinate>;
  24994. /**
  24995. * Set which rotation axis (relative to camera's orientation) the mouse
  24996. * wheel's Y axis controls.
  24997. * @param axis The axis to be moved. Set null to clear.
  24998. */
  24999. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  25000. /**
  25001. * Get the configured rotation axis (relative to camera's orientation) the
  25002. * mouse wheel's Y axis controls.
  25003. * @returns The configured axis or null if none.
  25004. */
  25005. get wheelYRotateRelative(): Nullable<Coordinate>;
  25006. /**
  25007. * Set which rotation axis (relative to camera's orientation) the mouse
  25008. * wheel's Z axis controls.
  25009. * @param axis The axis to be moved. Set null to clear.
  25010. */
  25011. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  25012. /**
  25013. * Get the configured rotation axis (relative to camera's orientation) the
  25014. * mouse wheel's Z axis controls.
  25015. * @returns The configured axis or null if none.
  25016. */
  25017. get wheelZRotateRelative(): Nullable<Coordinate>;
  25018. /**
  25019. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  25020. * controls.
  25021. * @param axis The axis to be moved. Set null to clear.
  25022. */
  25023. set wheelXMoveScene(axis: Nullable<Coordinate>);
  25024. /**
  25025. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25026. * X axis controls.
  25027. * @returns The configured axis or null if none.
  25028. */
  25029. get wheelXMoveScene(): Nullable<Coordinate>;
  25030. /**
  25031. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  25032. * controls.
  25033. * @param axis The axis to be moved. Set null to clear.
  25034. */
  25035. set wheelYMoveScene(axis: Nullable<Coordinate>);
  25036. /**
  25037. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25038. * Y axis controls.
  25039. * @returns The configured axis or null if none.
  25040. */
  25041. get wheelYMoveScene(): Nullable<Coordinate>;
  25042. /**
  25043. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  25044. * controls.
  25045. * @param axis The axis to be moved. Set null to clear.
  25046. */
  25047. set wheelZMoveScene(axis: Nullable<Coordinate>);
  25048. /**
  25049. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25050. * Z axis controls.
  25051. * @returns The configured axis or null if none.
  25052. */
  25053. get wheelZMoveScene(): Nullable<Coordinate>;
  25054. /**
  25055. * Called for each rendered frame.
  25056. */
  25057. checkInputs(): void;
  25058. private _moveRelative;
  25059. private _rotateRelative;
  25060. private _moveScene;
  25061. /**
  25062. * These are set to the desired default behaviour.
  25063. */
  25064. private _wheelXAction;
  25065. private _wheelXActionCoordinate;
  25066. private _wheelYAction;
  25067. private _wheelYActionCoordinate;
  25068. private _wheelZAction;
  25069. private _wheelZActionCoordinate;
  25070. /**
  25071. * Update the camera according to any configured properties for the 3
  25072. * mouse-wheel axis.
  25073. */
  25074. private _updateCamera;
  25075. }
  25076. }
  25077. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  25078. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  25079. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25080. /**
  25081. * Manage the touch inputs to control the movement of a free camera.
  25082. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25083. */
  25084. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  25085. /**
  25086. * Define if mouse events can be treated as touch events
  25087. */
  25088. allowMouse: boolean;
  25089. /**
  25090. * Defines the camera the input is attached to.
  25091. */
  25092. camera: FreeCamera;
  25093. /**
  25094. * Defines the touch sensibility for rotation.
  25095. * The higher the faster.
  25096. */
  25097. touchAngularSensibility: number;
  25098. /**
  25099. * Defines the touch sensibility for move.
  25100. * The higher the faster.
  25101. */
  25102. touchMoveSensibility: number;
  25103. private _offsetX;
  25104. private _offsetY;
  25105. private _pointerPressed;
  25106. private _pointerInput?;
  25107. private _observer;
  25108. private _onLostFocus;
  25109. /**
  25110. * Manage the touch inputs to control the movement of a free camera.
  25111. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25112. * @param allowMouse Defines if mouse events can be treated as touch events
  25113. */
  25114. constructor(
  25115. /**
  25116. * Define if mouse events can be treated as touch events
  25117. */
  25118. allowMouse?: boolean);
  25119. /**
  25120. * Attach the input controls to a specific dom element to get the input from.
  25121. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25122. */
  25123. attachControl(noPreventDefault?: boolean): void;
  25124. /**
  25125. * Detach the current controls from the specified dom element.
  25126. */
  25127. detachControl(): void;
  25128. /**
  25129. * Update the current camera state depending on the inputs that have been used this frame.
  25130. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  25131. */
  25132. checkInputs(): void;
  25133. /**
  25134. * Gets the class name of the current intput.
  25135. * @returns the class name
  25136. */
  25137. getClassName(): string;
  25138. /**
  25139. * Get the friendly name associated with the input class.
  25140. * @returns the input friendly name
  25141. */
  25142. getSimpleName(): string;
  25143. }
  25144. }
  25145. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  25146. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25147. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25148. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  25149. import { FreeCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  25150. import { Nullable } from "babylonjs/types";
  25151. /**
  25152. * Default Inputs manager for the FreeCamera.
  25153. * It groups all the default supported inputs for ease of use.
  25154. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25155. */
  25156. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  25157. /**
  25158. * @hidden
  25159. */
  25160. _mouseInput: Nullable<FreeCameraMouseInput>;
  25161. /**
  25162. * @hidden
  25163. */
  25164. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  25165. /**
  25166. * Instantiates a new FreeCameraInputsManager.
  25167. * @param camera Defines the camera the inputs belong to
  25168. */
  25169. constructor(camera: FreeCamera);
  25170. /**
  25171. * Add keyboard input support to the input manager.
  25172. * @returns the current input manager
  25173. */
  25174. addKeyboard(): FreeCameraInputsManager;
  25175. /**
  25176. * Add mouse input support to the input manager.
  25177. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  25178. * @returns the current input manager
  25179. */
  25180. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  25181. /**
  25182. * Removes the mouse input support from the manager
  25183. * @returns the current input manager
  25184. */
  25185. removeMouse(): FreeCameraInputsManager;
  25186. /**
  25187. * Add mouse wheel input support to the input manager.
  25188. * @returns the current input manager
  25189. */
  25190. addMouseWheel(): FreeCameraInputsManager;
  25191. /**
  25192. * Removes the mouse wheel input support from the manager
  25193. * @returns the current input manager
  25194. */
  25195. removeMouseWheel(): FreeCameraInputsManager;
  25196. /**
  25197. * Add touch input support to the input manager.
  25198. * @returns the current input manager
  25199. */
  25200. addTouch(): FreeCameraInputsManager;
  25201. /**
  25202. * Remove all attached input methods from a camera
  25203. */
  25204. clear(): void;
  25205. }
  25206. }
  25207. declare module "babylonjs/Cameras/freeCamera" {
  25208. import { Vector3 } from "babylonjs/Maths/math.vector";
  25209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25210. import { Scene } from "babylonjs/scene";
  25211. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  25212. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  25213. /**
  25214. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25215. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25216. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25217. */
  25218. export class FreeCamera extends TargetCamera {
  25219. /**
  25220. * Define the collision ellipsoid of the camera.
  25221. * This is helpful to simulate a camera body like the player body around the camera
  25222. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25223. */
  25224. ellipsoid: Vector3;
  25225. /**
  25226. * Define an offset for the position of the ellipsoid around the camera.
  25227. * This can be helpful to determine the center of the body near the gravity center of the body
  25228. * instead of its head.
  25229. */
  25230. ellipsoidOffset: Vector3;
  25231. /**
  25232. * Enable or disable collisions of the camera with the rest of the scene objects.
  25233. */
  25234. checkCollisions: boolean;
  25235. /**
  25236. * Enable or disable gravity on the camera.
  25237. */
  25238. applyGravity: boolean;
  25239. /**
  25240. * Define the input manager associated to the camera.
  25241. */
  25242. inputs: FreeCameraInputsManager;
  25243. /**
  25244. * Gets the input sensibility for a mouse input. (default is 2000.0)
  25245. * Higher values reduce sensitivity.
  25246. */
  25247. get angularSensibility(): number;
  25248. /**
  25249. * Sets the input sensibility for a mouse input. (default is 2000.0)
  25250. * Higher values reduce sensitivity.
  25251. */
  25252. set angularSensibility(value: number);
  25253. /**
  25254. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  25255. */
  25256. get keysUp(): number[];
  25257. set keysUp(value: number[]);
  25258. /**
  25259. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  25260. */
  25261. get keysUpward(): number[];
  25262. set keysUpward(value: number[]);
  25263. /**
  25264. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  25265. */
  25266. get keysDown(): number[];
  25267. set keysDown(value: number[]);
  25268. /**
  25269. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  25270. */
  25271. get keysDownward(): number[];
  25272. set keysDownward(value: number[]);
  25273. /**
  25274. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  25275. */
  25276. get keysLeft(): number[];
  25277. set keysLeft(value: number[]);
  25278. /**
  25279. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  25280. */
  25281. get keysRight(): number[];
  25282. set keysRight(value: number[]);
  25283. /**
  25284. * Event raised when the camera collide with a mesh in the scene.
  25285. */
  25286. onCollide: (collidedMesh: AbstractMesh) => void;
  25287. private _collider;
  25288. private _needMoveForGravity;
  25289. private _oldPosition;
  25290. private _diffPosition;
  25291. private _newPosition;
  25292. /** @hidden */
  25293. _localDirection: Vector3;
  25294. /** @hidden */
  25295. _transformedDirection: Vector3;
  25296. /**
  25297. * Instantiates a Free Camera.
  25298. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25299. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  25300. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25301. * @param name Define the name of the camera in the scene
  25302. * @param position Define the start position of the camera in the scene
  25303. * @param scene Define the scene the camera belongs to
  25304. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  25305. */
  25306. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25307. /**
  25308. * Attach the input controls to a specific dom element to get the input from.
  25309. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25310. */
  25311. attachControl(noPreventDefault?: boolean): void;
  25312. /**
  25313. * Attach the input controls to a specific dom element to get the input from.
  25314. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  25315. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25316. * BACK COMPAT SIGNATURE ONLY.
  25317. */
  25318. attachControl(ignored: any, noPreventDefault?: boolean): void;
  25319. /**
  25320. * Detach the current controls from the specified dom element.
  25321. */
  25322. detachControl(): void;
  25323. /**
  25324. * Detach the current controls from the specified dom element.
  25325. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  25326. */
  25327. detachControl(ignored: any): void;
  25328. private _collisionMask;
  25329. /**
  25330. * Define a collision mask to limit the list of object the camera can collide with
  25331. */
  25332. get collisionMask(): number;
  25333. set collisionMask(mask: number);
  25334. /** @hidden */
  25335. _collideWithWorld(displacement: Vector3): void;
  25336. private _onCollisionPositionChange;
  25337. /** @hidden */
  25338. _checkInputs(): void;
  25339. /** @hidden */
  25340. _decideIfNeedsToMove(): boolean;
  25341. /** @hidden */
  25342. _updatePosition(): void;
  25343. /**
  25344. * Destroy the camera and release the current resources hold by it.
  25345. */
  25346. dispose(): void;
  25347. /**
  25348. * Gets the current object class name.
  25349. * @return the class name
  25350. */
  25351. getClassName(): string;
  25352. }
  25353. }
  25354. declare module "babylonjs/Gamepads/gamepad" {
  25355. import { Observable } from "babylonjs/Misc/observable";
  25356. /**
  25357. * Represents a gamepad control stick position
  25358. */
  25359. export class StickValues {
  25360. /**
  25361. * The x component of the control stick
  25362. */
  25363. x: number;
  25364. /**
  25365. * The y component of the control stick
  25366. */
  25367. y: number;
  25368. /**
  25369. * Initializes the gamepad x and y control stick values
  25370. * @param x The x component of the gamepad control stick value
  25371. * @param y The y component of the gamepad control stick value
  25372. */
  25373. constructor(
  25374. /**
  25375. * The x component of the control stick
  25376. */
  25377. x: number,
  25378. /**
  25379. * The y component of the control stick
  25380. */
  25381. y: number);
  25382. }
  25383. /**
  25384. * An interface which manages callbacks for gamepad button changes
  25385. */
  25386. export interface GamepadButtonChanges {
  25387. /**
  25388. * Called when a gamepad has been changed
  25389. */
  25390. changed: boolean;
  25391. /**
  25392. * Called when a gamepad press event has been triggered
  25393. */
  25394. pressChanged: boolean;
  25395. /**
  25396. * Called when a touch event has been triggered
  25397. */
  25398. touchChanged: boolean;
  25399. /**
  25400. * Called when a value has changed
  25401. */
  25402. valueChanged: boolean;
  25403. }
  25404. /**
  25405. * Represents a gamepad
  25406. */
  25407. export class Gamepad {
  25408. /**
  25409. * The id of the gamepad
  25410. */
  25411. id: string;
  25412. /**
  25413. * The index of the gamepad
  25414. */
  25415. index: number;
  25416. /**
  25417. * The browser gamepad
  25418. */
  25419. browserGamepad: any;
  25420. /**
  25421. * Specifies what type of gamepad this represents
  25422. */
  25423. type: number;
  25424. private _leftStick;
  25425. private _rightStick;
  25426. /** @hidden */
  25427. _isConnected: boolean;
  25428. private _leftStickAxisX;
  25429. private _leftStickAxisY;
  25430. private _rightStickAxisX;
  25431. private _rightStickAxisY;
  25432. /**
  25433. * Triggered when the left control stick has been changed
  25434. */
  25435. private _onleftstickchanged;
  25436. /**
  25437. * Triggered when the right control stick has been changed
  25438. */
  25439. private _onrightstickchanged;
  25440. /**
  25441. * Represents a gamepad controller
  25442. */
  25443. static GAMEPAD: number;
  25444. /**
  25445. * Represents a generic controller
  25446. */
  25447. static GENERIC: number;
  25448. /**
  25449. * Represents an XBox controller
  25450. */
  25451. static XBOX: number;
  25452. /**
  25453. * Represents a pose-enabled controller
  25454. */
  25455. static POSE_ENABLED: number;
  25456. /**
  25457. * Represents an Dual Shock controller
  25458. */
  25459. static DUALSHOCK: number;
  25460. /**
  25461. * Specifies whether the left control stick should be Y-inverted
  25462. */
  25463. protected _invertLeftStickY: boolean;
  25464. /**
  25465. * Specifies if the gamepad has been connected
  25466. */
  25467. get isConnected(): boolean;
  25468. /**
  25469. * Initializes the gamepad
  25470. * @param id The id of the gamepad
  25471. * @param index The index of the gamepad
  25472. * @param browserGamepad The browser gamepad
  25473. * @param leftStickX The x component of the left joystick
  25474. * @param leftStickY The y component of the left joystick
  25475. * @param rightStickX The x component of the right joystick
  25476. * @param rightStickY The y component of the right joystick
  25477. */
  25478. constructor(
  25479. /**
  25480. * The id of the gamepad
  25481. */
  25482. id: string,
  25483. /**
  25484. * The index of the gamepad
  25485. */
  25486. index: number,
  25487. /**
  25488. * The browser gamepad
  25489. */
  25490. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  25491. /**
  25492. * Callback triggered when the left joystick has changed
  25493. * @param callback
  25494. */
  25495. onleftstickchanged(callback: (values: StickValues) => void): void;
  25496. /**
  25497. * Callback triggered when the right joystick has changed
  25498. * @param callback
  25499. */
  25500. onrightstickchanged(callback: (values: StickValues) => void): void;
  25501. /**
  25502. * Gets the left joystick
  25503. */
  25504. get leftStick(): StickValues;
  25505. /**
  25506. * Sets the left joystick values
  25507. */
  25508. set leftStick(newValues: StickValues);
  25509. /**
  25510. * Gets the right joystick
  25511. */
  25512. get rightStick(): StickValues;
  25513. /**
  25514. * Sets the right joystick value
  25515. */
  25516. set rightStick(newValues: StickValues);
  25517. /**
  25518. * Updates the gamepad joystick positions
  25519. */
  25520. update(): void;
  25521. /**
  25522. * Disposes the gamepad
  25523. */
  25524. dispose(): void;
  25525. }
  25526. /**
  25527. * Represents a generic gamepad
  25528. */
  25529. export class GenericPad extends Gamepad {
  25530. private _buttons;
  25531. private _onbuttondown;
  25532. private _onbuttonup;
  25533. /**
  25534. * Observable triggered when a button has been pressed
  25535. */
  25536. onButtonDownObservable: Observable<number>;
  25537. /**
  25538. * Observable triggered when a button has been released
  25539. */
  25540. onButtonUpObservable: Observable<number>;
  25541. /**
  25542. * Callback triggered when a button has been pressed
  25543. * @param callback Called when a button has been pressed
  25544. */
  25545. onbuttondown(callback: (buttonPressed: number) => void): void;
  25546. /**
  25547. * Callback triggered when a button has been released
  25548. * @param callback Called when a button has been released
  25549. */
  25550. onbuttonup(callback: (buttonReleased: number) => void): void;
  25551. /**
  25552. * Initializes the generic gamepad
  25553. * @param id The id of the generic gamepad
  25554. * @param index The index of the generic gamepad
  25555. * @param browserGamepad The browser gamepad
  25556. */
  25557. constructor(id: string, index: number, browserGamepad: any);
  25558. private _setButtonValue;
  25559. /**
  25560. * Updates the generic gamepad
  25561. */
  25562. update(): void;
  25563. /**
  25564. * Disposes the generic gamepad
  25565. */
  25566. dispose(): void;
  25567. }
  25568. }
  25569. declare module "babylonjs/Animations/runtimeAnimation" {
  25570. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  25571. import { Animatable } from "babylonjs/Animations/animatable";
  25572. import { Scene } from "babylonjs/scene";
  25573. /**
  25574. * Defines a runtime animation
  25575. */
  25576. export class RuntimeAnimation {
  25577. private _events;
  25578. /**
  25579. * The current frame of the runtime animation
  25580. */
  25581. private _currentFrame;
  25582. /**
  25583. * The animation used by the runtime animation
  25584. */
  25585. private _animation;
  25586. /**
  25587. * The target of the runtime animation
  25588. */
  25589. private _target;
  25590. /**
  25591. * The initiating animatable
  25592. */
  25593. private _host;
  25594. /**
  25595. * The original value of the runtime animation
  25596. */
  25597. private _originalValue;
  25598. /**
  25599. * The original blend value of the runtime animation
  25600. */
  25601. private _originalBlendValue;
  25602. /**
  25603. * The offsets cache of the runtime animation
  25604. */
  25605. private _offsetsCache;
  25606. /**
  25607. * The high limits cache of the runtime animation
  25608. */
  25609. private _highLimitsCache;
  25610. /**
  25611. * Specifies if the runtime animation has been stopped
  25612. */
  25613. private _stopped;
  25614. /**
  25615. * The blending factor of the runtime animation
  25616. */
  25617. private _blendingFactor;
  25618. /**
  25619. * The BabylonJS scene
  25620. */
  25621. private _scene;
  25622. /**
  25623. * The current value of the runtime animation
  25624. */
  25625. private _currentValue;
  25626. /** @hidden */
  25627. _animationState: _IAnimationState;
  25628. /**
  25629. * The active target of the runtime animation
  25630. */
  25631. private _activeTargets;
  25632. private _currentActiveTarget;
  25633. private _directTarget;
  25634. /**
  25635. * The target path of the runtime animation
  25636. */
  25637. private _targetPath;
  25638. /**
  25639. * The weight of the runtime animation
  25640. */
  25641. private _weight;
  25642. /**
  25643. * The ratio offset of the runtime animation
  25644. */
  25645. private _ratioOffset;
  25646. /**
  25647. * The previous delay of the runtime animation
  25648. */
  25649. private _previousDelay;
  25650. /**
  25651. * The previous ratio of the runtime animation
  25652. */
  25653. private _previousRatio;
  25654. private _enableBlending;
  25655. private _keys;
  25656. private _minFrame;
  25657. private _maxFrame;
  25658. private _minValue;
  25659. private _maxValue;
  25660. private _targetIsArray;
  25661. /**
  25662. * Gets the current frame of the runtime animation
  25663. */
  25664. get currentFrame(): number;
  25665. /**
  25666. * Gets the weight of the runtime animation
  25667. */
  25668. get weight(): number;
  25669. /**
  25670. * Gets the current value of the runtime animation
  25671. */
  25672. get currentValue(): any;
  25673. /**
  25674. * Gets the target path of the runtime animation
  25675. */
  25676. get targetPath(): string;
  25677. /**
  25678. * Gets the actual target of the runtime animation
  25679. */
  25680. get target(): any;
  25681. /**
  25682. * Gets the additive state of the runtime animation
  25683. */
  25684. get isAdditive(): boolean;
  25685. /** @hidden */
  25686. _onLoop: () => void;
  25687. /**
  25688. * Create a new RuntimeAnimation object
  25689. * @param target defines the target of the animation
  25690. * @param animation defines the source animation object
  25691. * @param scene defines the hosting scene
  25692. * @param host defines the initiating Animatable
  25693. */
  25694. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  25695. private _preparePath;
  25696. /**
  25697. * Gets the animation from the runtime animation
  25698. */
  25699. get animation(): Animation;
  25700. /**
  25701. * Resets the runtime animation to the beginning
  25702. * @param restoreOriginal defines whether to restore the target property to the original value
  25703. */
  25704. reset(restoreOriginal?: boolean): void;
  25705. /**
  25706. * Specifies if the runtime animation is stopped
  25707. * @returns Boolean specifying if the runtime animation is stopped
  25708. */
  25709. isStopped(): boolean;
  25710. /**
  25711. * Disposes of the runtime animation
  25712. */
  25713. dispose(): void;
  25714. /**
  25715. * Apply the interpolated value to the target
  25716. * @param currentValue defines the value computed by the animation
  25717. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  25718. */
  25719. setValue(currentValue: any, weight: number): void;
  25720. private _getOriginalValues;
  25721. private _setValue;
  25722. /**
  25723. * Gets the loop pmode of the runtime animation
  25724. * @returns Loop Mode
  25725. */
  25726. private _getCorrectLoopMode;
  25727. /**
  25728. * Move the current animation to a given frame
  25729. * @param frame defines the frame to move to
  25730. */
  25731. goToFrame(frame: number): void;
  25732. /**
  25733. * @hidden Internal use only
  25734. */
  25735. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  25736. /**
  25737. * Execute the current animation
  25738. * @param delay defines the delay to add to the current frame
  25739. * @param from defines the lower bound of the animation range
  25740. * @param to defines the upper bound of the animation range
  25741. * @param loop defines if the current animation must loop
  25742. * @param speedRatio defines the current speed ratio
  25743. * @param weight defines the weight of the animation (default is -1 so no weight)
  25744. * @param onLoop optional callback called when animation loops
  25745. * @returns a boolean indicating if the animation is running
  25746. */
  25747. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  25748. }
  25749. }
  25750. declare module "babylonjs/Animations/animatable" {
  25751. import { Animation } from "babylonjs/Animations/animation";
  25752. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25753. import { Nullable } from "babylonjs/types";
  25754. import { Observable } from "babylonjs/Misc/observable";
  25755. import { Scene } from "babylonjs/scene";
  25756. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  25757. import { Node } from "babylonjs/node";
  25758. /**
  25759. * Class used to store an actual running animation
  25760. */
  25761. export class Animatable {
  25762. /** defines the target object */
  25763. target: any;
  25764. /** defines the starting frame number (default is 0) */
  25765. fromFrame: number;
  25766. /** defines the ending frame number (default is 100) */
  25767. toFrame: number;
  25768. /** defines if the animation must loop (default is false) */
  25769. loopAnimation: boolean;
  25770. /** defines a callback to call when animation ends if it is not looping */
  25771. onAnimationEnd?: (() => void) | null | undefined;
  25772. /** defines a callback to call when animation loops */
  25773. onAnimationLoop?: (() => void) | null | undefined;
  25774. /** defines whether the animation should be evaluated additively */
  25775. isAdditive: boolean;
  25776. private _localDelayOffset;
  25777. private _pausedDelay;
  25778. private _runtimeAnimations;
  25779. private _paused;
  25780. private _scene;
  25781. private _speedRatio;
  25782. private _weight;
  25783. private _syncRoot;
  25784. /**
  25785. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  25786. * This will only apply for non looping animation (default is true)
  25787. */
  25788. disposeOnEnd: boolean;
  25789. /**
  25790. * Gets a boolean indicating if the animation has started
  25791. */
  25792. animationStarted: boolean;
  25793. /**
  25794. * Observer raised when the animation ends
  25795. */
  25796. onAnimationEndObservable: Observable<Animatable>;
  25797. /**
  25798. * Observer raised when the animation loops
  25799. */
  25800. onAnimationLoopObservable: Observable<Animatable>;
  25801. /**
  25802. * Gets the root Animatable used to synchronize and normalize animations
  25803. */
  25804. get syncRoot(): Nullable<Animatable>;
  25805. /**
  25806. * Gets the current frame of the first RuntimeAnimation
  25807. * Used to synchronize Animatables
  25808. */
  25809. get masterFrame(): number;
  25810. /**
  25811. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  25812. */
  25813. get weight(): number;
  25814. set weight(value: number);
  25815. /**
  25816. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  25817. */
  25818. get speedRatio(): number;
  25819. set speedRatio(value: number);
  25820. /**
  25821. * Creates a new Animatable
  25822. * @param scene defines the hosting scene
  25823. * @param target defines the target object
  25824. * @param fromFrame defines the starting frame number (default is 0)
  25825. * @param toFrame defines the ending frame number (default is 100)
  25826. * @param loopAnimation defines if the animation must loop (default is false)
  25827. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  25828. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  25829. * @param animations defines a group of animation to add to the new Animatable
  25830. * @param onAnimationLoop defines a callback to call when animation loops
  25831. * @param isAdditive defines whether the animation should be evaluated additively
  25832. */
  25833. constructor(scene: Scene,
  25834. /** defines the target object */
  25835. target: any,
  25836. /** defines the starting frame number (default is 0) */
  25837. fromFrame?: number,
  25838. /** defines the ending frame number (default is 100) */
  25839. toFrame?: number,
  25840. /** defines if the animation must loop (default is false) */
  25841. loopAnimation?: boolean, speedRatio?: number,
  25842. /** defines a callback to call when animation ends if it is not looping */
  25843. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  25844. /** defines a callback to call when animation loops */
  25845. onAnimationLoop?: (() => void) | null | undefined,
  25846. /** defines whether the animation should be evaluated additively */
  25847. isAdditive?: boolean);
  25848. /**
  25849. * Synchronize and normalize current Animatable with a source Animatable
  25850. * This is useful when using animation weights and when animations are not of the same length
  25851. * @param root defines the root Animatable to synchronize with
  25852. * @returns the current Animatable
  25853. */
  25854. syncWith(root: Animatable): Animatable;
  25855. /**
  25856. * Gets the list of runtime animations
  25857. * @returns an array of RuntimeAnimation
  25858. */
  25859. getAnimations(): RuntimeAnimation[];
  25860. /**
  25861. * Adds more animations to the current animatable
  25862. * @param target defines the target of the animations
  25863. * @param animations defines the new animations to add
  25864. */
  25865. appendAnimations(target: any, animations: Animation[]): void;
  25866. /**
  25867. * Gets the source animation for a specific property
  25868. * @param property defines the propertyu to look for
  25869. * @returns null or the source animation for the given property
  25870. */
  25871. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  25872. /**
  25873. * Gets the runtime animation for a specific property
  25874. * @param property defines the propertyu to look for
  25875. * @returns null or the runtime animation for the given property
  25876. */
  25877. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  25878. /**
  25879. * Resets the animatable to its original state
  25880. */
  25881. reset(): void;
  25882. /**
  25883. * Allows the animatable to blend with current running animations
  25884. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25885. * @param blendingSpeed defines the blending speed to use
  25886. */
  25887. enableBlending(blendingSpeed: number): void;
  25888. /**
  25889. * Disable animation blending
  25890. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25891. */
  25892. disableBlending(): void;
  25893. /**
  25894. * Jump directly to a given frame
  25895. * @param frame defines the frame to jump to
  25896. */
  25897. goToFrame(frame: number): void;
  25898. /**
  25899. * Pause the animation
  25900. */
  25901. pause(): void;
  25902. /**
  25903. * Restart the animation
  25904. */
  25905. restart(): void;
  25906. private _raiseOnAnimationEnd;
  25907. /**
  25908. * Stop and delete the current animation
  25909. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  25910. * @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)
  25911. */
  25912. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  25913. /**
  25914. * Wait asynchronously for the animation to end
  25915. * @returns a promise which will be fullfilled when the animation ends
  25916. */
  25917. waitAsync(): Promise<Animatable>;
  25918. /** @hidden */
  25919. _animate(delay: number): boolean;
  25920. }
  25921. module "babylonjs/scene" {
  25922. interface Scene {
  25923. /** @hidden */
  25924. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  25925. /** @hidden */
  25926. _processLateAnimationBindingsForMatrices(holder: {
  25927. totalWeight: number;
  25928. totalAdditiveWeight: number;
  25929. animations: RuntimeAnimation[];
  25930. additiveAnimations: RuntimeAnimation[];
  25931. originalValue: Matrix;
  25932. }): any;
  25933. /** @hidden */
  25934. _processLateAnimationBindingsForQuaternions(holder: {
  25935. totalWeight: number;
  25936. totalAdditiveWeight: number;
  25937. animations: RuntimeAnimation[];
  25938. additiveAnimations: RuntimeAnimation[];
  25939. originalValue: Quaternion;
  25940. }, refQuaternion: Quaternion): Quaternion;
  25941. /** @hidden */
  25942. _processLateAnimationBindings(): void;
  25943. /**
  25944. * Will start the animation sequence of a given target
  25945. * @param target defines the target
  25946. * @param from defines from which frame should animation start
  25947. * @param to defines until which frame should animation run.
  25948. * @param weight defines the weight to apply to the animation (1.0 by default)
  25949. * @param loop defines if the animation loops
  25950. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25951. * @param onAnimationEnd defines the function to be executed when the animation ends
  25952. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25953. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25954. * @param onAnimationLoop defines the callback to call when an animation loops
  25955. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25956. * @returns the animatable object created for this animation
  25957. */
  25958. 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;
  25959. /**
  25960. * Will start the animation sequence of a given target
  25961. * @param target defines the target
  25962. * @param from defines from which frame should animation start
  25963. * @param to defines until which frame should animation run.
  25964. * @param loop defines if the animation loops
  25965. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25966. * @param onAnimationEnd defines the function to be executed when the animation ends
  25967. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25968. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25969. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  25970. * @param onAnimationLoop defines the callback to call when an animation loops
  25971. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25972. * @returns the animatable object created for this animation
  25973. */
  25974. 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;
  25975. /**
  25976. * Will start the animation sequence of a given target and its hierarchy
  25977. * @param target defines the target
  25978. * @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.
  25979. * @param from defines from which frame should animation start
  25980. * @param to defines until which frame should animation run.
  25981. * @param loop defines if the animation loops
  25982. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25983. * @param onAnimationEnd defines the function to be executed when the animation ends
  25984. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25985. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25986. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25987. * @param onAnimationLoop defines the callback to call when an animation loops
  25988. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25989. * @returns the list of created animatables
  25990. */
  25991. 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[];
  25992. /**
  25993. * Begin a new animation on a given node
  25994. * @param target defines the target where the animation will take place
  25995. * @param animations defines the list of animations to start
  25996. * @param from defines the initial value
  25997. * @param to defines the final value
  25998. * @param loop defines if you want animation to loop (off by default)
  25999. * @param speedRatio defines the speed ratio to apply to all animations
  26000. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26001. * @param onAnimationLoop defines the callback to call when an animation loops
  26002. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26003. * @returns the list of created animatables
  26004. */
  26005. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  26006. /**
  26007. * Begin a new animation on a given node and its hierarchy
  26008. * @param target defines the root node where the animation will take place
  26009. * @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.
  26010. * @param animations defines the list of animations to start
  26011. * @param from defines the initial value
  26012. * @param to defines the final value
  26013. * @param loop defines if you want animation to loop (off by default)
  26014. * @param speedRatio defines the speed ratio to apply to all animations
  26015. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26016. * @param onAnimationLoop defines the callback to call when an animation loops
  26017. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26018. * @returns the list of animatables created for all nodes
  26019. */
  26020. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  26021. /**
  26022. * Gets the animatable associated with a specific target
  26023. * @param target defines the target of the animatable
  26024. * @returns the required animatable if found
  26025. */
  26026. getAnimatableByTarget(target: any): Nullable<Animatable>;
  26027. /**
  26028. * Gets all animatables associated with a given target
  26029. * @param target defines the target to look animatables for
  26030. * @returns an array of Animatables
  26031. */
  26032. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  26033. /**
  26034. * Stops and removes all animations that have been applied to the scene
  26035. */
  26036. stopAllAnimations(): void;
  26037. /**
  26038. * Gets the current delta time used by animation engine
  26039. */
  26040. deltaTime: number;
  26041. }
  26042. }
  26043. module "babylonjs/Bones/bone" {
  26044. interface Bone {
  26045. /**
  26046. * Copy an animation range from another bone
  26047. * @param source defines the source bone
  26048. * @param rangeName defines the range name to copy
  26049. * @param frameOffset defines the frame offset
  26050. * @param rescaleAsRequired defines if rescaling must be applied if required
  26051. * @param skelDimensionsRatio defines the scaling ratio
  26052. * @returns true if operation was successful
  26053. */
  26054. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  26055. }
  26056. }
  26057. }
  26058. declare module "babylonjs/Animations/animationPropertiesOverride" {
  26059. /**
  26060. * Class used to override all child animations of a given target
  26061. */
  26062. export class AnimationPropertiesOverride {
  26063. /**
  26064. * Gets or sets a value indicating if animation blending must be used
  26065. */
  26066. enableBlending: boolean;
  26067. /**
  26068. * Gets or sets the blending speed to use when enableBlending is true
  26069. */
  26070. blendingSpeed: number;
  26071. /**
  26072. * Gets or sets the default loop mode to use
  26073. */
  26074. loopMode: number;
  26075. }
  26076. }
  26077. declare module "babylonjs/Bones/skeleton" {
  26078. import { Bone } from "babylonjs/Bones/bone";
  26079. import { Observable } from "babylonjs/Misc/observable";
  26080. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  26081. import { Scene } from "babylonjs/scene";
  26082. import { Nullable } from "babylonjs/types";
  26083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26084. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26085. import { Animatable } from "babylonjs/Animations/animatable";
  26086. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26087. import { Animation } from "babylonjs/Animations/animation";
  26088. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26089. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26090. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26091. /**
  26092. * Class used to handle skinning animations
  26093. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26094. */
  26095. export class Skeleton implements IAnimatable {
  26096. /** defines the skeleton name */
  26097. name: string;
  26098. /** defines the skeleton Id */
  26099. id: string;
  26100. /**
  26101. * Defines the list of child bones
  26102. */
  26103. bones: Bone[];
  26104. /**
  26105. * Defines an estimate of the dimension of the skeleton at rest
  26106. */
  26107. dimensionsAtRest: Vector3;
  26108. /**
  26109. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  26110. */
  26111. needInitialSkinMatrix: boolean;
  26112. /**
  26113. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  26114. */
  26115. overrideMesh: Nullable<AbstractMesh>;
  26116. /**
  26117. * Gets the list of animations attached to this skeleton
  26118. */
  26119. animations: Array<Animation>;
  26120. private _scene;
  26121. private _isDirty;
  26122. private _transformMatrices;
  26123. private _transformMatrixTexture;
  26124. private _meshesWithPoseMatrix;
  26125. private _animatables;
  26126. private _identity;
  26127. private _synchronizedWithMesh;
  26128. private _ranges;
  26129. private _lastAbsoluteTransformsUpdateId;
  26130. private _canUseTextureForBones;
  26131. private _uniqueId;
  26132. /** @hidden */
  26133. _numBonesWithLinkedTransformNode: number;
  26134. /** @hidden */
  26135. _hasWaitingData: Nullable<boolean>;
  26136. /** @hidden */
  26137. _waitingOverrideMeshId: Nullable<string>;
  26138. /**
  26139. * Specifies if the skeleton should be serialized
  26140. */
  26141. doNotSerialize: boolean;
  26142. private _useTextureToStoreBoneMatrices;
  26143. /**
  26144. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  26145. * Please note that this option is not available if the hardware does not support it
  26146. */
  26147. get useTextureToStoreBoneMatrices(): boolean;
  26148. set useTextureToStoreBoneMatrices(value: boolean);
  26149. private _animationPropertiesOverride;
  26150. /**
  26151. * Gets or sets the animation properties override
  26152. */
  26153. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26154. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26155. /**
  26156. * List of inspectable custom properties (used by the Inspector)
  26157. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26158. */
  26159. inspectableCustomProperties: IInspectable[];
  26160. /**
  26161. * An observable triggered before computing the skeleton's matrices
  26162. */
  26163. onBeforeComputeObservable: Observable<Skeleton>;
  26164. /**
  26165. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  26166. */
  26167. get isUsingTextureForMatrices(): boolean;
  26168. /**
  26169. * Gets the unique ID of this skeleton
  26170. */
  26171. get uniqueId(): number;
  26172. /**
  26173. * Creates a new skeleton
  26174. * @param name defines the skeleton name
  26175. * @param id defines the skeleton Id
  26176. * @param scene defines the hosting scene
  26177. */
  26178. constructor(
  26179. /** defines the skeleton name */
  26180. name: string,
  26181. /** defines the skeleton Id */
  26182. id: string, scene: Scene);
  26183. /**
  26184. * Gets the current object class name.
  26185. * @return the class name
  26186. */
  26187. getClassName(): string;
  26188. /**
  26189. * Returns an array containing the root bones
  26190. * @returns an array containing the root bones
  26191. */
  26192. getChildren(): Array<Bone>;
  26193. /**
  26194. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  26195. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26196. * @returns a Float32Array containing matrices data
  26197. */
  26198. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  26199. /**
  26200. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  26201. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26202. * @returns a raw texture containing the data
  26203. */
  26204. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  26205. /**
  26206. * Gets the current hosting scene
  26207. * @returns a scene object
  26208. */
  26209. getScene(): Scene;
  26210. /**
  26211. * Gets a string representing the current skeleton data
  26212. * @param fullDetails defines a boolean indicating if we want a verbose version
  26213. * @returns a string representing the current skeleton data
  26214. */
  26215. toString(fullDetails?: boolean): string;
  26216. /**
  26217. * Get bone's index searching by name
  26218. * @param name defines bone's name to search for
  26219. * @return the indice of the bone. Returns -1 if not found
  26220. */
  26221. getBoneIndexByName(name: string): number;
  26222. /**
  26223. * Creater a new animation range
  26224. * @param name defines the name of the range
  26225. * @param from defines the start key
  26226. * @param to defines the end key
  26227. */
  26228. createAnimationRange(name: string, from: number, to: number): void;
  26229. /**
  26230. * Delete a specific animation range
  26231. * @param name defines the name of the range
  26232. * @param deleteFrames defines if frames must be removed as well
  26233. */
  26234. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26235. /**
  26236. * Gets a specific animation range
  26237. * @param name defines the name of the range to look for
  26238. * @returns the requested animation range or null if not found
  26239. */
  26240. getAnimationRange(name: string): Nullable<AnimationRange>;
  26241. /**
  26242. * Gets the list of all animation ranges defined on this skeleton
  26243. * @returns an array
  26244. */
  26245. getAnimationRanges(): Nullable<AnimationRange>[];
  26246. /**
  26247. * Copy animation range from a source skeleton.
  26248. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  26249. * @param source defines the source skeleton
  26250. * @param name defines the name of the range to copy
  26251. * @param rescaleAsRequired defines if rescaling must be applied if required
  26252. * @returns true if operation was successful
  26253. */
  26254. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  26255. /**
  26256. * Forces the skeleton to go to rest pose
  26257. */
  26258. returnToRest(): void;
  26259. private _getHighestAnimationFrame;
  26260. /**
  26261. * Begin a specific animation range
  26262. * @param name defines the name of the range to start
  26263. * @param loop defines if looping must be turned on (false by default)
  26264. * @param speedRatio defines the speed ratio to apply (1 by default)
  26265. * @param onAnimationEnd defines a callback which will be called when animation will end
  26266. * @returns a new animatable
  26267. */
  26268. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26269. /**
  26270. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  26271. * @param skeleton defines the Skeleton containing the animation range to convert
  26272. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  26273. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  26274. * @returns the original skeleton
  26275. */
  26276. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  26277. /** @hidden */
  26278. _markAsDirty(): void;
  26279. /** @hidden */
  26280. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26281. /** @hidden */
  26282. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26283. private _computeTransformMatrices;
  26284. /**
  26285. * Build all resources required to render a skeleton
  26286. */
  26287. prepare(): void;
  26288. /**
  26289. * Gets the list of animatables currently running for this skeleton
  26290. * @returns an array of animatables
  26291. */
  26292. getAnimatables(): IAnimatable[];
  26293. /**
  26294. * Clone the current skeleton
  26295. * @param name defines the name of the new skeleton
  26296. * @param id defines the id of the new skeleton
  26297. * @returns the new skeleton
  26298. */
  26299. clone(name: string, id?: string): Skeleton;
  26300. /**
  26301. * Enable animation blending for this skeleton
  26302. * @param blendingSpeed defines the blending speed to apply
  26303. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26304. */
  26305. enableBlending(blendingSpeed?: number): void;
  26306. /**
  26307. * Releases all resources associated with the current skeleton
  26308. */
  26309. dispose(): void;
  26310. /**
  26311. * Serialize the skeleton in a JSON object
  26312. * @returns a JSON object
  26313. */
  26314. serialize(): any;
  26315. /**
  26316. * Creates a new skeleton from serialized data
  26317. * @param parsedSkeleton defines the serialized data
  26318. * @param scene defines the hosting scene
  26319. * @returns a new skeleton
  26320. */
  26321. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  26322. /**
  26323. * Compute all node absolute transforms
  26324. * @param forceUpdate defines if computation must be done even if cache is up to date
  26325. */
  26326. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  26327. /**
  26328. * Gets the root pose matrix
  26329. * @returns a matrix
  26330. */
  26331. getPoseMatrix(): Nullable<Matrix>;
  26332. /**
  26333. * Sorts bones per internal index
  26334. */
  26335. sortBones(): void;
  26336. private _sortBones;
  26337. /**
  26338. * Set the current local matrix as the restPose for all bones in the skeleton.
  26339. */
  26340. setCurrentPoseAsRest(): void;
  26341. }
  26342. }
  26343. declare module "babylonjs/Bones/bone" {
  26344. import { Skeleton } from "babylonjs/Bones/skeleton";
  26345. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  26346. import { Nullable } from "babylonjs/types";
  26347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26348. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26349. import { Node } from "babylonjs/node";
  26350. import { Space } from "babylonjs/Maths/math.axis";
  26351. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26352. /**
  26353. * Class used to store bone information
  26354. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26355. */
  26356. export class Bone extends Node {
  26357. /**
  26358. * defines the bone name
  26359. */
  26360. name: string;
  26361. private static _tmpVecs;
  26362. private static _tmpQuat;
  26363. private static _tmpMats;
  26364. /**
  26365. * Gets the list of child bones
  26366. */
  26367. children: Bone[];
  26368. /** Gets the animations associated with this bone */
  26369. animations: import("babylonjs/Animations/animation").Animation[];
  26370. /**
  26371. * Gets or sets bone length
  26372. */
  26373. length: number;
  26374. /**
  26375. * @hidden Internal only
  26376. * Set this value to map this bone to a different index in the transform matrices
  26377. * Set this value to -1 to exclude the bone from the transform matrices
  26378. */
  26379. _index: Nullable<number>;
  26380. private _skeleton;
  26381. private _localMatrix;
  26382. private _restPose;
  26383. private _bindPose;
  26384. private _baseMatrix;
  26385. private _absoluteTransform;
  26386. private _invertedAbsoluteTransform;
  26387. private _parent;
  26388. private _scalingDeterminant;
  26389. private _worldTransform;
  26390. private _localScaling;
  26391. private _localRotation;
  26392. private _localPosition;
  26393. private _needToDecompose;
  26394. private _needToCompose;
  26395. /** @hidden */
  26396. _linkedTransformNode: Nullable<TransformNode>;
  26397. /** @hidden */
  26398. _waitingTransformNodeId: Nullable<string>;
  26399. /** @hidden */
  26400. get _matrix(): Matrix;
  26401. /** @hidden */
  26402. set _matrix(value: Matrix);
  26403. /**
  26404. * Create a new bone
  26405. * @param name defines the bone name
  26406. * @param skeleton defines the parent skeleton
  26407. * @param parentBone defines the parent (can be null if the bone is the root)
  26408. * @param localMatrix defines the local matrix
  26409. * @param restPose defines the rest pose matrix
  26410. * @param baseMatrix defines the base matrix
  26411. * @param index defines index of the bone in the hiearchy
  26412. */
  26413. constructor(
  26414. /**
  26415. * defines the bone name
  26416. */
  26417. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  26418. /**
  26419. * Gets the current object class name.
  26420. * @return the class name
  26421. */
  26422. getClassName(): string;
  26423. /**
  26424. * Gets the parent skeleton
  26425. * @returns a skeleton
  26426. */
  26427. getSkeleton(): Skeleton;
  26428. /**
  26429. * Gets parent bone
  26430. * @returns a bone or null if the bone is the root of the bone hierarchy
  26431. */
  26432. getParent(): Nullable<Bone>;
  26433. /**
  26434. * Returns an array containing the root bones
  26435. * @returns an array containing the root bones
  26436. */
  26437. getChildren(): Array<Bone>;
  26438. /**
  26439. * Gets the node index in matrix array generated for rendering
  26440. * @returns the node index
  26441. */
  26442. getIndex(): number;
  26443. /**
  26444. * Sets the parent bone
  26445. * @param parent defines the parent (can be null if the bone is the root)
  26446. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26447. */
  26448. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  26449. /**
  26450. * Gets the local matrix
  26451. * @returns a matrix
  26452. */
  26453. getLocalMatrix(): Matrix;
  26454. /**
  26455. * Gets the base matrix (initial matrix which remains unchanged)
  26456. * @returns a matrix
  26457. */
  26458. getBaseMatrix(): Matrix;
  26459. /**
  26460. * Gets the rest pose matrix
  26461. * @returns a matrix
  26462. */
  26463. getRestPose(): Matrix;
  26464. /**
  26465. * Sets the rest pose matrix
  26466. * @param matrix the local-space rest pose to set for this bone
  26467. */
  26468. setRestPose(matrix: Matrix): void;
  26469. /**
  26470. * Gets the bind pose matrix
  26471. * @returns the bind pose matrix
  26472. */
  26473. getBindPose(): Matrix;
  26474. /**
  26475. * Sets the bind pose matrix
  26476. * @param matrix the local-space bind pose to set for this bone
  26477. */
  26478. setBindPose(matrix: Matrix): void;
  26479. /**
  26480. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  26481. */
  26482. getWorldMatrix(): Matrix;
  26483. /**
  26484. * Sets the local matrix to rest pose matrix
  26485. */
  26486. returnToRest(): void;
  26487. /**
  26488. * Gets the inverse of the absolute transform matrix.
  26489. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  26490. * @returns a matrix
  26491. */
  26492. getInvertedAbsoluteTransform(): Matrix;
  26493. /**
  26494. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  26495. * @returns a matrix
  26496. */
  26497. getAbsoluteTransform(): Matrix;
  26498. /**
  26499. * Links with the given transform node.
  26500. * The local matrix of this bone is copied from the transform node every frame.
  26501. * @param transformNode defines the transform node to link to
  26502. */
  26503. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  26504. /**
  26505. * Gets the node used to drive the bone's transformation
  26506. * @returns a transform node or null
  26507. */
  26508. getTransformNode(): Nullable<TransformNode>;
  26509. /** Gets or sets current position (in local space) */
  26510. get position(): Vector3;
  26511. set position(newPosition: Vector3);
  26512. /** Gets or sets current rotation (in local space) */
  26513. get rotation(): Vector3;
  26514. set rotation(newRotation: Vector3);
  26515. /** Gets or sets current rotation quaternion (in local space) */
  26516. get rotationQuaternion(): Quaternion;
  26517. set rotationQuaternion(newRotation: Quaternion);
  26518. /** Gets or sets current scaling (in local space) */
  26519. get scaling(): Vector3;
  26520. set scaling(newScaling: Vector3);
  26521. /**
  26522. * Gets the animation properties override
  26523. */
  26524. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26525. private _decompose;
  26526. private _compose;
  26527. /**
  26528. * Update the base and local matrices
  26529. * @param matrix defines the new base or local matrix
  26530. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26531. * @param updateLocalMatrix defines if the local matrix should be updated
  26532. */
  26533. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  26534. /** @hidden */
  26535. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  26536. /**
  26537. * Flag the bone as dirty (Forcing it to update everything)
  26538. */
  26539. markAsDirty(): void;
  26540. /** @hidden */
  26541. _markAsDirtyAndCompose(): void;
  26542. private _markAsDirtyAndDecompose;
  26543. /**
  26544. * Translate the bone in local or world space
  26545. * @param vec The amount to translate the bone
  26546. * @param space The space that the translation is in
  26547. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26548. */
  26549. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26550. /**
  26551. * Set the postion of the bone in local or world space
  26552. * @param position The position to set the bone
  26553. * @param space The space that the position is in
  26554. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26555. */
  26556. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26557. /**
  26558. * Set the absolute position of the bone (world space)
  26559. * @param position The position to set the bone
  26560. * @param mesh The mesh that this bone is attached to
  26561. */
  26562. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  26563. /**
  26564. * Scale the bone on the x, y and z axes (in local space)
  26565. * @param x The amount to scale the bone on the x axis
  26566. * @param y The amount to scale the bone on the y axis
  26567. * @param z The amount to scale the bone on the z axis
  26568. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  26569. */
  26570. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  26571. /**
  26572. * Set the bone scaling in local space
  26573. * @param scale defines the scaling vector
  26574. */
  26575. setScale(scale: Vector3): void;
  26576. /**
  26577. * Gets the current scaling in local space
  26578. * @returns the current scaling vector
  26579. */
  26580. getScale(): Vector3;
  26581. /**
  26582. * Gets the current scaling in local space and stores it in a target vector
  26583. * @param result defines the target vector
  26584. */
  26585. getScaleToRef(result: Vector3): void;
  26586. /**
  26587. * Set the yaw, pitch, and roll of the bone in local or world space
  26588. * @param yaw The rotation of the bone on the y axis
  26589. * @param pitch The rotation of the bone on the x axis
  26590. * @param roll The rotation of the bone on the z axis
  26591. * @param space The space that the axes of rotation are in
  26592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26593. */
  26594. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  26595. /**
  26596. * Add a rotation to the bone on an axis in local or world space
  26597. * @param axis The axis to rotate the bone on
  26598. * @param amount The amount to rotate the bone
  26599. * @param space The space that the axis is in
  26600. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26601. */
  26602. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  26603. /**
  26604. * Set the rotation of the bone to a particular axis angle in local or world space
  26605. * @param axis The axis to rotate the bone on
  26606. * @param angle The angle that the bone should be rotated to
  26607. * @param space The space that the axis is in
  26608. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26609. */
  26610. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  26611. /**
  26612. * Set the euler rotation of the bone in local or world space
  26613. * @param rotation The euler rotation that the bone should be set to
  26614. * @param space The space that the rotation is in
  26615. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26616. */
  26617. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26618. /**
  26619. * Set the quaternion rotation of the bone in local or world space
  26620. * @param quat The quaternion rotation that the bone should be set to
  26621. * @param space The space that the rotation is in
  26622. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26623. */
  26624. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  26625. /**
  26626. * Set the rotation matrix of the bone in local or world space
  26627. * @param rotMat The rotation matrix that the bone should be set to
  26628. * @param space The space that the rotation is in
  26629. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26630. */
  26631. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  26632. private _rotateWithMatrix;
  26633. private _getNegativeRotationToRef;
  26634. /**
  26635. * Get the position of the bone in local or world space
  26636. * @param space The space that the returned position is in
  26637. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26638. * @returns The position of the bone
  26639. */
  26640. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26641. /**
  26642. * Copy the position of the bone to a vector3 in local or world space
  26643. * @param space The space that the returned position is in
  26644. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26645. * @param result The vector3 to copy the position to
  26646. */
  26647. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  26648. /**
  26649. * Get the absolute position of the bone (world space)
  26650. * @param mesh The mesh that this bone is attached to
  26651. * @returns The absolute position of the bone
  26652. */
  26653. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  26654. /**
  26655. * Copy the absolute position of the bone (world space) to the result param
  26656. * @param mesh The mesh that this bone is attached to
  26657. * @param result The vector3 to copy the absolute position to
  26658. */
  26659. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  26660. /**
  26661. * Compute the absolute transforms of this bone and its children
  26662. */
  26663. computeAbsoluteTransforms(): void;
  26664. /**
  26665. * Get the world direction from an axis that is in the local space of the bone
  26666. * @param localAxis The local direction that is used to compute the world direction
  26667. * @param mesh The mesh that this bone is attached to
  26668. * @returns The world direction
  26669. */
  26670. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26671. /**
  26672. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  26673. * @param localAxis The local direction that is used to compute the world direction
  26674. * @param mesh The mesh that this bone is attached to
  26675. * @param result The vector3 that the world direction will be copied to
  26676. */
  26677. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26678. /**
  26679. * Get the euler rotation of the bone in local or world space
  26680. * @param space The space that the rotation should be in
  26681. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26682. * @returns The euler rotation
  26683. */
  26684. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26685. /**
  26686. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  26687. * @param space The space that the rotation should be in
  26688. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26689. * @param result The vector3 that the rotation should be copied to
  26690. */
  26691. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26692. /**
  26693. * Get the quaternion rotation of the bone in either local or world space
  26694. * @param space The space that the rotation should be in
  26695. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26696. * @returns The quaternion rotation
  26697. */
  26698. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  26699. /**
  26700. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  26701. * @param space The space that the rotation should be in
  26702. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26703. * @param result The quaternion that the rotation should be copied to
  26704. */
  26705. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  26706. /**
  26707. * Get the rotation matrix of the bone in local or world space
  26708. * @param space The space that the rotation should be in
  26709. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26710. * @returns The rotation matrix
  26711. */
  26712. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  26713. /**
  26714. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  26715. * @param space The space that the rotation should be in
  26716. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26717. * @param result The quaternion that the rotation should be copied to
  26718. */
  26719. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  26720. /**
  26721. * Get the world position of a point that is in the local space of the bone
  26722. * @param position The local position
  26723. * @param mesh The mesh that this bone is attached to
  26724. * @returns The world position
  26725. */
  26726. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26727. /**
  26728. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  26729. * @param position The local position
  26730. * @param mesh The mesh that this bone is attached to
  26731. * @param result The vector3 that the world position should be copied to
  26732. */
  26733. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26734. /**
  26735. * Get the local position of a point that is in world space
  26736. * @param position The world position
  26737. * @param mesh The mesh that this bone is attached to
  26738. * @returns The local position
  26739. */
  26740. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26741. /**
  26742. * Get the local position of a point that is in world space and copy it to the result param
  26743. * @param position The world position
  26744. * @param mesh The mesh that this bone is attached to
  26745. * @param result The vector3 that the local position should be copied to
  26746. */
  26747. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26748. /**
  26749. * Set the current local matrix as the restPose for this bone.
  26750. */
  26751. setCurrentPoseAsRest(): void;
  26752. }
  26753. }
  26754. declare module "babylonjs/Meshes/transformNode" {
  26755. import { DeepImmutable } from "babylonjs/types";
  26756. import { Observable } from "babylonjs/Misc/observable";
  26757. import { Nullable } from "babylonjs/types";
  26758. import { Camera } from "babylonjs/Cameras/camera";
  26759. import { Scene } from "babylonjs/scene";
  26760. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26761. import { Node } from "babylonjs/node";
  26762. import { Bone } from "babylonjs/Bones/bone";
  26763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26764. import { Space } from "babylonjs/Maths/math.axis";
  26765. /**
  26766. * 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.
  26767. * @see https://doc.babylonjs.com/how_to/transformnode
  26768. */
  26769. export class TransformNode extends Node {
  26770. /**
  26771. * Object will not rotate to face the camera
  26772. */
  26773. static BILLBOARDMODE_NONE: number;
  26774. /**
  26775. * Object will rotate to face the camera but only on the x axis
  26776. */
  26777. static BILLBOARDMODE_X: number;
  26778. /**
  26779. * Object will rotate to face the camera but only on the y axis
  26780. */
  26781. static BILLBOARDMODE_Y: number;
  26782. /**
  26783. * Object will rotate to face the camera but only on the z axis
  26784. */
  26785. static BILLBOARDMODE_Z: number;
  26786. /**
  26787. * Object will rotate to face the camera
  26788. */
  26789. static BILLBOARDMODE_ALL: number;
  26790. /**
  26791. * Object will rotate to face the camera's position instead of orientation
  26792. */
  26793. static BILLBOARDMODE_USE_POSITION: number;
  26794. private static _TmpRotation;
  26795. private static _TmpScaling;
  26796. private static _TmpTranslation;
  26797. private _forward;
  26798. private _forwardInverted;
  26799. private _up;
  26800. private _right;
  26801. private _rightInverted;
  26802. private _position;
  26803. private _rotation;
  26804. private _rotationQuaternion;
  26805. protected _scaling: Vector3;
  26806. protected _isDirty: boolean;
  26807. private _transformToBoneReferal;
  26808. private _isAbsoluteSynced;
  26809. private _billboardMode;
  26810. /**
  26811. * Gets or sets the billboard mode. Default is 0.
  26812. *
  26813. * | Value | Type | Description |
  26814. * | --- | --- | --- |
  26815. * | 0 | BILLBOARDMODE_NONE | |
  26816. * | 1 | BILLBOARDMODE_X | |
  26817. * | 2 | BILLBOARDMODE_Y | |
  26818. * | 4 | BILLBOARDMODE_Z | |
  26819. * | 7 | BILLBOARDMODE_ALL | |
  26820. *
  26821. */
  26822. get billboardMode(): number;
  26823. set billboardMode(value: number);
  26824. private _preserveParentRotationForBillboard;
  26825. /**
  26826. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  26827. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  26828. */
  26829. get preserveParentRotationForBillboard(): boolean;
  26830. set preserveParentRotationForBillboard(value: boolean);
  26831. /**
  26832. * 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
  26833. */
  26834. scalingDeterminant: number;
  26835. private _infiniteDistance;
  26836. /**
  26837. * Gets or sets the distance of the object to max, often used by skybox
  26838. */
  26839. get infiniteDistance(): boolean;
  26840. set infiniteDistance(value: boolean);
  26841. /**
  26842. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  26843. * By default the system will update normals to compensate
  26844. */
  26845. ignoreNonUniformScaling: boolean;
  26846. /**
  26847. * 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
  26848. */
  26849. reIntegrateRotationIntoRotationQuaternion: boolean;
  26850. /** @hidden */
  26851. _poseMatrix: Nullable<Matrix>;
  26852. /** @hidden */
  26853. _localMatrix: Matrix;
  26854. private _usePivotMatrix;
  26855. private _absolutePosition;
  26856. private _absoluteScaling;
  26857. private _absoluteRotationQuaternion;
  26858. private _pivotMatrix;
  26859. private _pivotMatrixInverse;
  26860. /** @hidden */
  26861. _postMultiplyPivotMatrix: boolean;
  26862. protected _isWorldMatrixFrozen: boolean;
  26863. /** @hidden */
  26864. _indexInSceneTransformNodesArray: number;
  26865. /**
  26866. * An event triggered after the world matrix is updated
  26867. */
  26868. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  26869. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  26870. /**
  26871. * Gets a string identifying the name of the class
  26872. * @returns "TransformNode" string
  26873. */
  26874. getClassName(): string;
  26875. /**
  26876. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  26877. */
  26878. get position(): Vector3;
  26879. set position(newPosition: Vector3);
  26880. /**
  26881. * 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)).
  26882. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  26883. */
  26884. get rotation(): Vector3;
  26885. set rotation(newRotation: Vector3);
  26886. /**
  26887. * 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)).
  26888. */
  26889. get scaling(): Vector3;
  26890. set scaling(newScaling: Vector3);
  26891. /**
  26892. * 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).
  26893. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  26894. */
  26895. get rotationQuaternion(): Nullable<Quaternion>;
  26896. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  26897. /**
  26898. * The forward direction of that transform in world space.
  26899. */
  26900. get forward(): Vector3;
  26901. /**
  26902. * The up direction of that transform in world space.
  26903. */
  26904. get up(): Vector3;
  26905. /**
  26906. * The right direction of that transform in world space.
  26907. */
  26908. get right(): Vector3;
  26909. /**
  26910. * Copies the parameter passed Matrix into the mesh Pose matrix.
  26911. * @param matrix the matrix to copy the pose from
  26912. * @returns this TransformNode.
  26913. */
  26914. updatePoseMatrix(matrix: Matrix): TransformNode;
  26915. /**
  26916. * Returns the mesh Pose matrix.
  26917. * @returns the pose matrix
  26918. */
  26919. getPoseMatrix(): Matrix;
  26920. /** @hidden */
  26921. _isSynchronized(): boolean;
  26922. /** @hidden */
  26923. _initCache(): void;
  26924. /**
  26925. * Flag the transform node as dirty (Forcing it to update everything)
  26926. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  26927. * @returns this transform node
  26928. */
  26929. markAsDirty(property: string): TransformNode;
  26930. /**
  26931. * Returns the current mesh absolute position.
  26932. * Returns a Vector3.
  26933. */
  26934. get absolutePosition(): Vector3;
  26935. /**
  26936. * Returns the current mesh absolute scaling.
  26937. * Returns a Vector3.
  26938. */
  26939. get absoluteScaling(): Vector3;
  26940. /**
  26941. * Returns the current mesh absolute rotation.
  26942. * Returns a Quaternion.
  26943. */
  26944. get absoluteRotationQuaternion(): Quaternion;
  26945. /**
  26946. * Sets a new matrix to apply before all other transformation
  26947. * @param matrix defines the transform matrix
  26948. * @returns the current TransformNode
  26949. */
  26950. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26951. /**
  26952. * Sets a new pivot matrix to the current node
  26953. * @param matrix defines the new pivot matrix to use
  26954. * @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
  26955. * @returns the current TransformNode
  26956. */
  26957. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  26958. /**
  26959. * Returns the mesh pivot matrix.
  26960. * Default : Identity.
  26961. * @returns the matrix
  26962. */
  26963. getPivotMatrix(): Matrix;
  26964. /**
  26965. * Instantiate (when possible) or clone that node with its hierarchy
  26966. * @param newParent defines the new parent to use for the instance (or clone)
  26967. * @param options defines options to configure how copy is done
  26968. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  26969. * @returns an instance (or a clone) of the current node with its hiearchy
  26970. */
  26971. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  26972. doNotInstantiate: boolean;
  26973. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  26974. /**
  26975. * Prevents the World matrix to be computed any longer
  26976. * @param newWorldMatrix defines an optional matrix to use as world matrix
  26977. * @returns the TransformNode.
  26978. */
  26979. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  26980. /**
  26981. * Allows back the World matrix computation.
  26982. * @returns the TransformNode.
  26983. */
  26984. unfreezeWorldMatrix(): this;
  26985. /**
  26986. * True if the World matrix has been frozen.
  26987. */
  26988. get isWorldMatrixFrozen(): boolean;
  26989. /**
  26990. * Retuns the mesh absolute position in the World.
  26991. * @returns a Vector3.
  26992. */
  26993. getAbsolutePosition(): Vector3;
  26994. /**
  26995. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  26996. * @param absolutePosition the absolute position to set
  26997. * @returns the TransformNode.
  26998. */
  26999. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27000. /**
  27001. * Sets the mesh position in its local space.
  27002. * @param vector3 the position to set in localspace
  27003. * @returns the TransformNode.
  27004. */
  27005. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  27006. /**
  27007. * Returns the mesh position in the local space from the current World matrix values.
  27008. * @returns a new Vector3.
  27009. */
  27010. getPositionExpressedInLocalSpace(): Vector3;
  27011. /**
  27012. * Translates the mesh along the passed Vector3 in its local space.
  27013. * @param vector3 the distance to translate in localspace
  27014. * @returns the TransformNode.
  27015. */
  27016. locallyTranslate(vector3: Vector3): TransformNode;
  27017. private static _lookAtVectorCache;
  27018. /**
  27019. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  27020. * @param targetPoint the position (must be in same space as current mesh) to look at
  27021. * @param yawCor optional yaw (y-axis) correction in radians
  27022. * @param pitchCor optional pitch (x-axis) correction in radians
  27023. * @param rollCor optional roll (z-axis) correction in radians
  27024. * @param space the choosen space of the target
  27025. * @returns the TransformNode.
  27026. */
  27027. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  27028. /**
  27029. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27030. * This Vector3 is expressed in the World space.
  27031. * @param localAxis axis to rotate
  27032. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27033. */
  27034. getDirection(localAxis: Vector3): Vector3;
  27035. /**
  27036. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  27037. * localAxis is expressed in the mesh local space.
  27038. * result is computed in the Wordl space from the mesh World matrix.
  27039. * @param localAxis axis to rotate
  27040. * @param result the resulting transformnode
  27041. * @returns this TransformNode.
  27042. */
  27043. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  27044. /**
  27045. * Sets this transform node rotation to the given local axis.
  27046. * @param localAxis the axis in local space
  27047. * @param yawCor optional yaw (y-axis) correction in radians
  27048. * @param pitchCor optional pitch (x-axis) correction in radians
  27049. * @param rollCor optional roll (z-axis) correction in radians
  27050. * @returns this TransformNode
  27051. */
  27052. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  27053. /**
  27054. * Sets a new pivot point to the current node
  27055. * @param point defines the new pivot point to use
  27056. * @param space defines if the point is in world or local space (local by default)
  27057. * @returns the current TransformNode
  27058. */
  27059. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  27060. /**
  27061. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  27062. * @returns the pivot point
  27063. */
  27064. getPivotPoint(): Vector3;
  27065. /**
  27066. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  27067. * @param result the vector3 to store the result
  27068. * @returns this TransformNode.
  27069. */
  27070. getPivotPointToRef(result: Vector3): TransformNode;
  27071. /**
  27072. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  27073. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  27074. */
  27075. getAbsolutePivotPoint(): Vector3;
  27076. /**
  27077. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  27078. * @param result vector3 to store the result
  27079. * @returns this TransformNode.
  27080. */
  27081. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  27082. /**
  27083. * Defines the passed node as the parent of the current node.
  27084. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  27085. * @see https://doc.babylonjs.com/how_to/parenting
  27086. * @param node the node ot set as the parent
  27087. * @returns this TransformNode.
  27088. */
  27089. setParent(node: Nullable<Node>): TransformNode;
  27090. private _nonUniformScaling;
  27091. /**
  27092. * True if the scaling property of this object is non uniform eg. (1,2,1)
  27093. */
  27094. get nonUniformScaling(): boolean;
  27095. /** @hidden */
  27096. _updateNonUniformScalingState(value: boolean): boolean;
  27097. /**
  27098. * Attach the current TransformNode to another TransformNode associated with a bone
  27099. * @param bone Bone affecting the TransformNode
  27100. * @param affectedTransformNode TransformNode associated with the bone
  27101. * @returns this object
  27102. */
  27103. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  27104. /**
  27105. * Detach the transform node if its associated with a bone
  27106. * @returns this object
  27107. */
  27108. detachFromBone(): TransformNode;
  27109. private static _rotationAxisCache;
  27110. /**
  27111. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  27112. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27113. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27114. * The passed axis is also normalized.
  27115. * @param axis the axis to rotate around
  27116. * @param amount the amount to rotate in radians
  27117. * @param space Space to rotate in (Default: local)
  27118. * @returns the TransformNode.
  27119. */
  27120. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27121. /**
  27122. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  27123. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27124. * The passed axis is also normalized. .
  27125. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  27126. * @param point the point to rotate around
  27127. * @param axis the axis to rotate around
  27128. * @param amount the amount to rotate in radians
  27129. * @returns the TransformNode
  27130. */
  27131. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  27132. /**
  27133. * Translates the mesh along the axis vector for the passed distance in the given space.
  27134. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27135. * @param axis the axis to translate in
  27136. * @param distance the distance to translate
  27137. * @param space Space to rotate in (Default: local)
  27138. * @returns the TransformNode.
  27139. */
  27140. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27141. /**
  27142. * Adds a rotation step to the mesh current rotation.
  27143. * x, y, z are Euler angles expressed in radians.
  27144. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  27145. * This means this rotation is made in the mesh local space only.
  27146. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  27147. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  27148. * ```javascript
  27149. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  27150. * ```
  27151. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  27152. * 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.
  27153. * @param x Rotation to add
  27154. * @param y Rotation to add
  27155. * @param z Rotation to add
  27156. * @returns the TransformNode.
  27157. */
  27158. addRotation(x: number, y: number, z: number): TransformNode;
  27159. /**
  27160. * @hidden
  27161. */
  27162. protected _getEffectiveParent(): Nullable<Node>;
  27163. /**
  27164. * Computes the world matrix of the node
  27165. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27166. * @returns the world matrix
  27167. */
  27168. computeWorldMatrix(force?: boolean): Matrix;
  27169. /**
  27170. * Resets this nodeTransform's local matrix to Matrix.Identity().
  27171. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  27172. */
  27173. resetLocalMatrix(independentOfChildren?: boolean): void;
  27174. protected _afterComputeWorldMatrix(): void;
  27175. /**
  27176. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  27177. * @param func callback function to add
  27178. *
  27179. * @returns the TransformNode.
  27180. */
  27181. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27182. /**
  27183. * Removes a registered callback function.
  27184. * @param func callback function to remove
  27185. * @returns the TransformNode.
  27186. */
  27187. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27188. /**
  27189. * Gets the position of the current mesh in camera space
  27190. * @param camera defines the camera to use
  27191. * @returns a position
  27192. */
  27193. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  27194. /**
  27195. * Returns the distance from the mesh to the active camera
  27196. * @param camera defines the camera to use
  27197. * @returns the distance
  27198. */
  27199. getDistanceToCamera(camera?: Nullable<Camera>): number;
  27200. /**
  27201. * Clone the current transform node
  27202. * @param name Name of the new clone
  27203. * @param newParent New parent for the clone
  27204. * @param doNotCloneChildren Do not clone children hierarchy
  27205. * @returns the new transform node
  27206. */
  27207. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  27208. /**
  27209. * Serializes the objects information.
  27210. * @param currentSerializationObject defines the object to serialize in
  27211. * @returns the serialized object
  27212. */
  27213. serialize(currentSerializationObject?: any): any;
  27214. /**
  27215. * Returns a new TransformNode object parsed from the source provided.
  27216. * @param parsedTransformNode is the source.
  27217. * @param scene the scne the object belongs to
  27218. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  27219. * @returns a new TransformNode object parsed from the source provided.
  27220. */
  27221. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  27222. /**
  27223. * Get all child-transformNodes of this node
  27224. * @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
  27225. * @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
  27226. * @returns an array of TransformNode
  27227. */
  27228. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  27229. /**
  27230. * Releases resources associated with this transform node.
  27231. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27232. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27233. */
  27234. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27235. /**
  27236. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27237. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27238. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27239. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27240. * @returns the current mesh
  27241. */
  27242. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  27243. private _syncAbsoluteScalingAndRotation;
  27244. }
  27245. }
  27246. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  27247. import { Observable } from "babylonjs/Misc/observable";
  27248. import { Nullable } from "babylonjs/types";
  27249. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27250. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27252. import { Ray } from "babylonjs/Culling/ray";
  27253. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  27254. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  27255. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  27256. /**
  27257. * Defines the types of pose enabled controllers that are supported
  27258. */
  27259. export enum PoseEnabledControllerType {
  27260. /**
  27261. * HTC Vive
  27262. */
  27263. VIVE = 0,
  27264. /**
  27265. * Oculus Rift
  27266. */
  27267. OCULUS = 1,
  27268. /**
  27269. * Windows mixed reality
  27270. */
  27271. WINDOWS = 2,
  27272. /**
  27273. * Samsung gear VR
  27274. */
  27275. GEAR_VR = 3,
  27276. /**
  27277. * Google Daydream
  27278. */
  27279. DAYDREAM = 4,
  27280. /**
  27281. * Generic
  27282. */
  27283. GENERIC = 5
  27284. }
  27285. /**
  27286. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27287. */
  27288. export interface MutableGamepadButton {
  27289. /**
  27290. * Value of the button/trigger
  27291. */
  27292. value: number;
  27293. /**
  27294. * If the button/trigger is currently touched
  27295. */
  27296. touched: boolean;
  27297. /**
  27298. * If the button/trigger is currently pressed
  27299. */
  27300. pressed: boolean;
  27301. }
  27302. /**
  27303. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27304. * @hidden
  27305. */
  27306. export interface ExtendedGamepadButton extends GamepadButton {
  27307. /**
  27308. * If the button/trigger is currently pressed
  27309. */
  27310. readonly pressed: boolean;
  27311. /**
  27312. * If the button/trigger is currently touched
  27313. */
  27314. readonly touched: boolean;
  27315. /**
  27316. * Value of the button/trigger
  27317. */
  27318. readonly value: number;
  27319. }
  27320. /** @hidden */
  27321. export interface _GamePadFactory {
  27322. /**
  27323. * Returns whether or not the current gamepad can be created for this type of controller.
  27324. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27325. * @returns true if it can be created, otherwise false
  27326. */
  27327. canCreate(gamepadInfo: any): boolean;
  27328. /**
  27329. * Creates a new instance of the Gamepad.
  27330. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27331. * @returns the new gamepad instance
  27332. */
  27333. create(gamepadInfo: any): Gamepad;
  27334. }
  27335. /**
  27336. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27337. */
  27338. export class PoseEnabledControllerHelper {
  27339. /** @hidden */
  27340. static _ControllerFactories: _GamePadFactory[];
  27341. /** @hidden */
  27342. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  27343. /**
  27344. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27345. * @param vrGamepad the gamepad to initialized
  27346. * @returns a vr controller of the type the gamepad identified as
  27347. */
  27348. static InitiateController(vrGamepad: any): Gamepad;
  27349. }
  27350. /**
  27351. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27352. */
  27353. export class PoseEnabledController extends Gamepad implements PoseControlled {
  27354. /**
  27355. * If the controller is used in a webXR session
  27356. */
  27357. isXR: boolean;
  27358. private _deviceRoomPosition;
  27359. private _deviceRoomRotationQuaternion;
  27360. /**
  27361. * The device position in babylon space
  27362. */
  27363. devicePosition: Vector3;
  27364. /**
  27365. * The device rotation in babylon space
  27366. */
  27367. deviceRotationQuaternion: Quaternion;
  27368. /**
  27369. * The scale factor of the device in babylon space
  27370. */
  27371. deviceScaleFactor: number;
  27372. /**
  27373. * (Likely devicePosition should be used instead) The device position in its room space
  27374. */
  27375. position: Vector3;
  27376. /**
  27377. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27378. */
  27379. rotationQuaternion: Quaternion;
  27380. /**
  27381. * The type of controller (Eg. Windows mixed reality)
  27382. */
  27383. controllerType: PoseEnabledControllerType;
  27384. protected _calculatedPosition: Vector3;
  27385. private _calculatedRotation;
  27386. /**
  27387. * The raw pose from the device
  27388. */
  27389. rawPose: DevicePose;
  27390. private _trackPosition;
  27391. private _maxRotationDistFromHeadset;
  27392. private _draggedRoomRotation;
  27393. /**
  27394. * @hidden
  27395. */
  27396. _disableTrackPosition(fixedPosition: Vector3): void;
  27397. /**
  27398. * Internal, the mesh attached to the controller
  27399. * @hidden
  27400. */
  27401. _mesh: Nullable<AbstractMesh>;
  27402. private _poseControlledCamera;
  27403. private _leftHandSystemQuaternion;
  27404. /**
  27405. * Internal, matrix used to convert room space to babylon space
  27406. * @hidden
  27407. */
  27408. _deviceToWorld: Matrix;
  27409. /**
  27410. * Node to be used when casting a ray from the controller
  27411. * @hidden
  27412. */
  27413. _pointingPoseNode: Nullable<TransformNode>;
  27414. /**
  27415. * Name of the child mesh that can be used to cast a ray from the controller
  27416. */
  27417. static readonly POINTING_POSE: string;
  27418. /**
  27419. * Creates a new PoseEnabledController from a gamepad
  27420. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27421. */
  27422. constructor(browserGamepad: any);
  27423. private _workingMatrix;
  27424. /**
  27425. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27426. */
  27427. update(): void;
  27428. /**
  27429. * Updates only the pose device and mesh without doing any button event checking
  27430. */
  27431. protected _updatePoseAndMesh(): void;
  27432. /**
  27433. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27434. * @param poseData raw pose fromthe device
  27435. */
  27436. updateFromDevice(poseData: DevicePose): void;
  27437. /**
  27438. * @hidden
  27439. */
  27440. _meshAttachedObservable: Observable<AbstractMesh>;
  27441. /**
  27442. * Attaches a mesh to the controller
  27443. * @param mesh the mesh to be attached
  27444. */
  27445. attachToMesh(mesh: AbstractMesh): void;
  27446. /**
  27447. * Attaches the controllers mesh to a camera
  27448. * @param camera the camera the mesh should be attached to
  27449. */
  27450. attachToPoseControlledCamera(camera: TargetCamera): void;
  27451. /**
  27452. * Disposes of the controller
  27453. */
  27454. dispose(): void;
  27455. /**
  27456. * The mesh that is attached to the controller
  27457. */
  27458. get mesh(): Nullable<AbstractMesh>;
  27459. /**
  27460. * Gets the ray of the controller in the direction the controller is pointing
  27461. * @param length the length the resulting ray should be
  27462. * @returns a ray in the direction the controller is pointing
  27463. */
  27464. getForwardRay(length?: number): Ray;
  27465. }
  27466. }
  27467. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  27468. import { Observable } from "babylonjs/Misc/observable";
  27469. import { Scene } from "babylonjs/scene";
  27470. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27471. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  27472. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  27473. import { Nullable } from "babylonjs/types";
  27474. /**
  27475. * Defines the WebVRController object that represents controllers tracked in 3D space
  27476. */
  27477. export abstract class WebVRController extends PoseEnabledController {
  27478. /**
  27479. * Internal, the default controller model for the controller
  27480. */
  27481. protected _defaultModel: Nullable<AbstractMesh>;
  27482. /**
  27483. * Fired when the trigger state has changed
  27484. */
  27485. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27486. /**
  27487. * Fired when the main button state has changed
  27488. */
  27489. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27490. /**
  27491. * Fired when the secondary button state has changed
  27492. */
  27493. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27494. /**
  27495. * Fired when the pad state has changed
  27496. */
  27497. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27498. /**
  27499. * Fired when controllers stick values have changed
  27500. */
  27501. onPadValuesChangedObservable: Observable<StickValues>;
  27502. /**
  27503. * Array of button availible on the controller
  27504. */
  27505. protected _buttons: Array<MutableGamepadButton>;
  27506. private _onButtonStateChange;
  27507. /**
  27508. * Fired when a controller button's state has changed
  27509. * @param callback the callback containing the button that was modified
  27510. */
  27511. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27512. /**
  27513. * X and Y axis corresponding to the controllers joystick
  27514. */
  27515. pad: StickValues;
  27516. /**
  27517. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27518. */
  27519. hand: string;
  27520. /**
  27521. * The default controller model for the controller
  27522. */
  27523. get defaultModel(): Nullable<AbstractMesh>;
  27524. /**
  27525. * Creates a new WebVRController from a gamepad
  27526. * @param vrGamepad the gamepad that the WebVRController should be created from
  27527. */
  27528. constructor(vrGamepad: any);
  27529. /**
  27530. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27531. */
  27532. update(): void;
  27533. /**
  27534. * Function to be called when a button is modified
  27535. */
  27536. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27537. /**
  27538. * Loads a mesh and attaches it to the controller
  27539. * @param scene the scene the mesh should be added to
  27540. * @param meshLoaded callback for when the mesh has been loaded
  27541. */
  27542. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27543. private _setButtonValue;
  27544. private _changes;
  27545. private _checkChanges;
  27546. /**
  27547. * Disposes of th webVRCOntroller
  27548. */
  27549. dispose(): void;
  27550. }
  27551. }
  27552. declare module "babylonjs/Lights/hemisphericLight" {
  27553. import { Nullable } from "babylonjs/types";
  27554. import { Scene } from "babylonjs/scene";
  27555. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27556. import { Color3 } from "babylonjs/Maths/math.color";
  27557. import { Effect } from "babylonjs/Materials/effect";
  27558. import { Light } from "babylonjs/Lights/light";
  27559. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  27560. /**
  27561. * The HemisphericLight simulates the ambient environment light,
  27562. * so the passed direction is the light reflection direction, not the incoming direction.
  27563. */
  27564. export class HemisphericLight extends Light {
  27565. /**
  27566. * The groundColor is the light in the opposite direction to the one specified during creation.
  27567. * 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.
  27568. */
  27569. groundColor: Color3;
  27570. /**
  27571. * The light reflection direction, not the incoming direction.
  27572. */
  27573. direction: Vector3;
  27574. /**
  27575. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  27576. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  27577. * The HemisphericLight can't cast shadows.
  27578. * Documentation : https://doc.babylonjs.com/babylon101/lights
  27579. * @param name The friendly name of the light
  27580. * @param direction The direction of the light reflection
  27581. * @param scene The scene the light belongs to
  27582. */
  27583. constructor(name: string, direction: Vector3, scene: Scene);
  27584. protected _buildUniformLayout(): void;
  27585. /**
  27586. * Returns the string "HemisphericLight".
  27587. * @return The class name
  27588. */
  27589. getClassName(): string;
  27590. /**
  27591. * Sets the HemisphericLight direction towards the passed target (Vector3).
  27592. * Returns the updated direction.
  27593. * @param target The target the direction should point to
  27594. * @return The computed direction
  27595. */
  27596. setDirectionToTarget(target: Vector3): Vector3;
  27597. /**
  27598. * Returns the shadow generator associated to the light.
  27599. * @returns Always null for hemispheric lights because it does not support shadows.
  27600. */
  27601. getShadowGenerator(): Nullable<IShadowGenerator>;
  27602. /**
  27603. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  27604. * @param effect The effect to update
  27605. * @param lightIndex The index of the light in the effect to update
  27606. * @returns The hemispheric light
  27607. */
  27608. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  27609. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  27610. /**
  27611. * Computes the world matrix of the node
  27612. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27613. * @param useWasUpdatedFlag defines a reserved property
  27614. * @returns the world matrix
  27615. */
  27616. computeWorldMatrix(): Matrix;
  27617. /**
  27618. * Returns the integer 3.
  27619. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  27620. */
  27621. getTypeID(): number;
  27622. /**
  27623. * Prepares the list of defines specific to the light type.
  27624. * @param defines the list of defines
  27625. * @param lightIndex defines the index of the light for the effect
  27626. */
  27627. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  27628. }
  27629. }
  27630. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  27631. /** @hidden */
  27632. export var vrMultiviewToSingleviewPixelShader: {
  27633. name: string;
  27634. shader: string;
  27635. };
  27636. }
  27637. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  27638. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27639. import { Scene } from "babylonjs/scene";
  27640. /**
  27641. * Renders to multiple views with a single draw call
  27642. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  27643. */
  27644. export class MultiviewRenderTarget extends RenderTargetTexture {
  27645. /**
  27646. * Creates a multiview render target
  27647. * @param scene scene used with the render target
  27648. * @param size the size of the render target (used for each view)
  27649. */
  27650. constructor(scene: Scene, size?: number | {
  27651. width: number;
  27652. height: number;
  27653. } | {
  27654. ratio: number;
  27655. });
  27656. /**
  27657. * @hidden
  27658. * @param faceIndex the face index, if its a cube texture
  27659. */
  27660. _bindFrameBuffer(faceIndex?: number): void;
  27661. /**
  27662. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  27663. * @returns the view count
  27664. */
  27665. getViewCount(): number;
  27666. }
  27667. }
  27668. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  27669. import { Camera } from "babylonjs/Cameras/camera";
  27670. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27671. import { Nullable } from "babylonjs/types";
  27672. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27673. import { Matrix } from "babylonjs/Maths/math.vector";
  27674. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27675. module "babylonjs/Engines/engine" {
  27676. interface Engine {
  27677. /**
  27678. * Creates a new multiview render target
  27679. * @param width defines the width of the texture
  27680. * @param height defines the height of the texture
  27681. * @returns the created multiview texture
  27682. */
  27683. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  27684. /**
  27685. * Binds a multiview framebuffer to be drawn to
  27686. * @param multiviewTexture texture to bind
  27687. */
  27688. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  27689. }
  27690. }
  27691. module "babylonjs/Cameras/camera" {
  27692. interface Camera {
  27693. /**
  27694. * @hidden
  27695. * 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)
  27696. */
  27697. _useMultiviewToSingleView: boolean;
  27698. /**
  27699. * @hidden
  27700. * 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)
  27701. */
  27702. _multiviewTexture: Nullable<RenderTargetTexture>;
  27703. /**
  27704. * @hidden
  27705. * ensures the multiview texture of the camera exists and has the specified width/height
  27706. * @param width height to set on the multiview texture
  27707. * @param height width to set on the multiview texture
  27708. */
  27709. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  27710. }
  27711. }
  27712. module "babylonjs/scene" {
  27713. interface Scene {
  27714. /** @hidden */
  27715. _transformMatrixR: Matrix;
  27716. /** @hidden */
  27717. _multiviewSceneUbo: Nullable<UniformBuffer>;
  27718. /** @hidden */
  27719. _createMultiviewUbo(): void;
  27720. /** @hidden */
  27721. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  27722. /** @hidden */
  27723. _renderMultiviewToSingleView(camera: Camera): void;
  27724. }
  27725. }
  27726. }
  27727. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  27728. import { Camera } from "babylonjs/Cameras/camera";
  27729. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27730. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  27731. import "babylonjs/Engines/Extensions/engine.multiview";
  27732. /**
  27733. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  27734. * This will not be used for webXR as it supports displaying texture arrays directly
  27735. */
  27736. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  27737. /**
  27738. * Gets a string identifying the name of the class
  27739. * @returns "VRMultiviewToSingleviewPostProcess" string
  27740. */
  27741. getClassName(): string;
  27742. /**
  27743. * Initializes a VRMultiviewToSingleview
  27744. * @param name name of the post process
  27745. * @param camera camera to be applied to
  27746. * @param scaleFactor scaling factor to the size of the output texture
  27747. */
  27748. constructor(name: string, camera: Camera, scaleFactor: number);
  27749. }
  27750. }
  27751. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  27752. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  27753. import { Nullable } from "babylonjs/types";
  27754. import { Size } from "babylonjs/Maths/math.size";
  27755. import { Observable } from "babylonjs/Misc/observable";
  27756. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  27757. /**
  27758. * Interface used to define additional presentation attributes
  27759. */
  27760. export interface IVRPresentationAttributes {
  27761. /**
  27762. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  27763. */
  27764. highRefreshRate: boolean;
  27765. /**
  27766. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  27767. */
  27768. foveationLevel: number;
  27769. }
  27770. module "babylonjs/Engines/engine" {
  27771. interface Engine {
  27772. /** @hidden */
  27773. _vrDisplay: any;
  27774. /** @hidden */
  27775. _vrSupported: boolean;
  27776. /** @hidden */
  27777. _oldSize: Size;
  27778. /** @hidden */
  27779. _oldHardwareScaleFactor: number;
  27780. /** @hidden */
  27781. _vrExclusivePointerMode: boolean;
  27782. /** @hidden */
  27783. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  27784. /** @hidden */
  27785. _onVRDisplayPointerRestricted: () => void;
  27786. /** @hidden */
  27787. _onVRDisplayPointerUnrestricted: () => void;
  27788. /** @hidden */
  27789. _onVrDisplayConnect: Nullable<(display: any) => void>;
  27790. /** @hidden */
  27791. _onVrDisplayDisconnect: Nullable<() => void>;
  27792. /** @hidden */
  27793. _onVrDisplayPresentChange: Nullable<() => void>;
  27794. /**
  27795. * Observable signaled when VR display mode changes
  27796. */
  27797. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27798. /**
  27799. * Observable signaled when VR request present is complete
  27800. */
  27801. onVRRequestPresentComplete: Observable<boolean>;
  27802. /**
  27803. * Observable signaled when VR request present starts
  27804. */
  27805. onVRRequestPresentStart: Observable<Engine>;
  27806. /**
  27807. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27808. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27809. */
  27810. isInVRExclusivePointerMode: boolean;
  27811. /**
  27812. * Gets a boolean indicating if a webVR device was detected
  27813. * @returns true if a webVR device was detected
  27814. */
  27815. isVRDevicePresent(): boolean;
  27816. /**
  27817. * Gets the current webVR device
  27818. * @returns the current webVR device (or null)
  27819. */
  27820. getVRDevice(): any;
  27821. /**
  27822. * Initializes a webVR display and starts listening to display change events
  27823. * The onVRDisplayChangedObservable will be notified upon these changes
  27824. * @returns A promise containing a VRDisplay and if vr is supported
  27825. */
  27826. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27827. /** @hidden */
  27828. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  27829. /**
  27830. * Gets or sets the presentation attributes used to configure VR rendering
  27831. */
  27832. vrPresentationAttributes?: IVRPresentationAttributes;
  27833. /**
  27834. * Call this function to switch to webVR mode
  27835. * Will do nothing if webVR is not supported or if there is no webVR device
  27836. * @param options the webvr options provided to the camera. mainly used for multiview
  27837. * @see https://doc.babylonjs.com/how_to/webvr_camera
  27838. */
  27839. enableVR(options: WebVROptions): void;
  27840. /** @hidden */
  27841. _onVRFullScreenTriggered(): void;
  27842. }
  27843. }
  27844. }
  27845. declare module "babylonjs/Cameras/VR/webVRCamera" {
  27846. import { Nullable } from "babylonjs/types";
  27847. import { Observable } from "babylonjs/Misc/observable";
  27848. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  27849. import { Scene } from "babylonjs/scene";
  27850. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27851. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  27852. import { Node } from "babylonjs/node";
  27853. import { Ray } from "babylonjs/Culling/ray";
  27854. import "babylonjs/Cameras/RigModes/webVRRigMode";
  27855. import "babylonjs/Engines/Extensions/engine.webVR";
  27856. /**
  27857. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  27858. * IMPORTANT!! The data is right-hand data.
  27859. * @export
  27860. * @interface DevicePose
  27861. */
  27862. export interface DevicePose {
  27863. /**
  27864. * The position of the device, values in array are [x,y,z].
  27865. */
  27866. readonly position: Nullable<Float32Array>;
  27867. /**
  27868. * The linearVelocity of the device, values in array are [x,y,z].
  27869. */
  27870. readonly linearVelocity: Nullable<Float32Array>;
  27871. /**
  27872. * The linearAcceleration of the device, values in array are [x,y,z].
  27873. */
  27874. readonly linearAcceleration: Nullable<Float32Array>;
  27875. /**
  27876. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  27877. */
  27878. readonly orientation: Nullable<Float32Array>;
  27879. /**
  27880. * The angularVelocity of the device, values in array are [x,y,z].
  27881. */
  27882. readonly angularVelocity: Nullable<Float32Array>;
  27883. /**
  27884. * The angularAcceleration of the device, values in array are [x,y,z].
  27885. */
  27886. readonly angularAcceleration: Nullable<Float32Array>;
  27887. }
  27888. /**
  27889. * Interface representing a pose controlled object in Babylon.
  27890. * A pose controlled object has both regular pose values as well as pose values
  27891. * from an external device such as a VR head mounted display
  27892. */
  27893. export interface PoseControlled {
  27894. /**
  27895. * The position of the object in babylon space.
  27896. */
  27897. position: Vector3;
  27898. /**
  27899. * The rotation quaternion of the object in babylon space.
  27900. */
  27901. rotationQuaternion: Quaternion;
  27902. /**
  27903. * The position of the device in babylon space.
  27904. */
  27905. devicePosition?: Vector3;
  27906. /**
  27907. * The rotation quaternion of the device in babylon space.
  27908. */
  27909. deviceRotationQuaternion: Quaternion;
  27910. /**
  27911. * The raw pose coming from the device.
  27912. */
  27913. rawPose: Nullable<DevicePose>;
  27914. /**
  27915. * The scale of the device to be used when translating from device space to babylon space.
  27916. */
  27917. deviceScaleFactor: number;
  27918. /**
  27919. * Updates the poseControlled values based on the input device pose.
  27920. * @param poseData the pose data to update the object with
  27921. */
  27922. updateFromDevice(poseData: DevicePose): void;
  27923. }
  27924. /**
  27925. * Set of options to customize the webVRCamera
  27926. */
  27927. export interface WebVROptions {
  27928. /**
  27929. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  27930. */
  27931. trackPosition?: boolean;
  27932. /**
  27933. * Sets the scale of the vrDevice in babylon space. (default: 1)
  27934. */
  27935. positionScale?: number;
  27936. /**
  27937. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  27938. */
  27939. displayName?: string;
  27940. /**
  27941. * Should the native controller meshes be initialized. (default: true)
  27942. */
  27943. controllerMeshes?: boolean;
  27944. /**
  27945. * Creating a default HemiLight only on controllers. (default: true)
  27946. */
  27947. defaultLightingOnControllers?: boolean;
  27948. /**
  27949. * If you don't want to use the default VR button of the helper. (default: false)
  27950. */
  27951. useCustomVRButton?: boolean;
  27952. /**
  27953. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  27954. */
  27955. customVRButton?: HTMLButtonElement;
  27956. /**
  27957. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  27958. */
  27959. rayLength?: number;
  27960. /**
  27961. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  27962. */
  27963. defaultHeight?: number;
  27964. /**
  27965. * If multiview should be used if availible (default: false)
  27966. */
  27967. useMultiview?: boolean;
  27968. }
  27969. /**
  27970. * This represents a WebVR camera.
  27971. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  27972. * @example https://doc.babylonjs.com/how_to/webvr_camera
  27973. */
  27974. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  27975. private webVROptions;
  27976. /**
  27977. * @hidden
  27978. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  27979. */
  27980. _vrDevice: any;
  27981. /**
  27982. * The rawPose of the vrDevice.
  27983. */
  27984. rawPose: Nullable<DevicePose>;
  27985. private _onVREnabled;
  27986. private _specsVersion;
  27987. private _attached;
  27988. private _frameData;
  27989. protected _descendants: Array<Node>;
  27990. private _deviceRoomPosition;
  27991. /** @hidden */
  27992. _deviceRoomRotationQuaternion: Quaternion;
  27993. private _standingMatrix;
  27994. /**
  27995. * Represents device position in babylon space.
  27996. */
  27997. devicePosition: Vector3;
  27998. /**
  27999. * Represents device rotation in babylon space.
  28000. */
  28001. deviceRotationQuaternion: Quaternion;
  28002. /**
  28003. * The scale of the device to be used when translating from device space to babylon space.
  28004. */
  28005. deviceScaleFactor: number;
  28006. private _deviceToWorld;
  28007. private _worldToDevice;
  28008. /**
  28009. * References to the webVR controllers for the vrDevice.
  28010. */
  28011. controllers: Array<WebVRController>;
  28012. /**
  28013. * Emits an event when a controller is attached.
  28014. */
  28015. onControllersAttachedObservable: Observable<WebVRController[]>;
  28016. /**
  28017. * Emits an event when a controller's mesh has been loaded;
  28018. */
  28019. onControllerMeshLoadedObservable: Observable<WebVRController>;
  28020. /**
  28021. * Emits an event when the HMD's pose has been updated.
  28022. */
  28023. onPoseUpdatedFromDeviceObservable: Observable<any>;
  28024. private _poseSet;
  28025. /**
  28026. * If the rig cameras be used as parent instead of this camera.
  28027. */
  28028. rigParenting: boolean;
  28029. private _lightOnControllers;
  28030. private _defaultHeight?;
  28031. /**
  28032. * Instantiates a WebVRFreeCamera.
  28033. * @param name The name of the WebVRFreeCamera
  28034. * @param position The starting anchor position for the camera
  28035. * @param scene The scene the camera belongs to
  28036. * @param webVROptions a set of customizable options for the webVRCamera
  28037. */
  28038. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  28039. /**
  28040. * Gets the device distance from the ground in meters.
  28041. * @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.
  28042. */
  28043. deviceDistanceToRoomGround(): number;
  28044. /**
  28045. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28046. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  28047. */
  28048. useStandingMatrix(callback?: (bool: boolean) => void): void;
  28049. /**
  28050. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28051. * @returns A promise with a boolean set to if the standing matrix is supported.
  28052. */
  28053. useStandingMatrixAsync(): Promise<boolean>;
  28054. /**
  28055. * Disposes the camera
  28056. */
  28057. dispose(): void;
  28058. /**
  28059. * Gets a vrController by name.
  28060. * @param name The name of the controller to retreive
  28061. * @returns the controller matching the name specified or null if not found
  28062. */
  28063. getControllerByName(name: string): Nullable<WebVRController>;
  28064. private _leftController;
  28065. /**
  28066. * The controller corresponding to the users left hand.
  28067. */
  28068. get leftController(): Nullable<WebVRController>;
  28069. private _rightController;
  28070. /**
  28071. * The controller corresponding to the users right hand.
  28072. */
  28073. get rightController(): Nullable<WebVRController>;
  28074. /**
  28075. * Casts a ray forward from the vrCamera's gaze.
  28076. * @param length Length of the ray (default: 100)
  28077. * @returns the ray corresponding to the gaze
  28078. */
  28079. getForwardRay(length?: number): Ray;
  28080. /**
  28081. * @hidden
  28082. * Updates the camera based on device's frame data
  28083. */
  28084. _checkInputs(): void;
  28085. /**
  28086. * Updates the poseControlled values based on the input device pose.
  28087. * @param poseData Pose coming from the device
  28088. */
  28089. updateFromDevice(poseData: DevicePose): void;
  28090. private _detachIfAttached;
  28091. /**
  28092. * WebVR's attach control will start broadcasting frames to the device.
  28093. * Note that in certain browsers (chrome for example) this function must be called
  28094. * within a user-interaction callback. Example:
  28095. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  28096. *
  28097. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  28098. */
  28099. attachControl(noPreventDefault?: boolean): void;
  28100. /**
  28101. * Detach the current controls from the specified dom element.
  28102. */
  28103. detachControl(): void;
  28104. /**
  28105. * @returns the name of this class
  28106. */
  28107. getClassName(): string;
  28108. /**
  28109. * Calls resetPose on the vrDisplay
  28110. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  28111. */
  28112. resetToCurrentRotation(): void;
  28113. /**
  28114. * @hidden
  28115. * Updates the rig cameras (left and right eye)
  28116. */
  28117. _updateRigCameras(): void;
  28118. private _workingVector;
  28119. private _oneVector;
  28120. private _workingMatrix;
  28121. private updateCacheCalled;
  28122. private _correctPositionIfNotTrackPosition;
  28123. /**
  28124. * @hidden
  28125. * Updates the cached values of the camera
  28126. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  28127. */
  28128. _updateCache(ignoreParentClass?: boolean): void;
  28129. /**
  28130. * @hidden
  28131. * Get current device position in babylon world
  28132. */
  28133. _computeDevicePosition(): void;
  28134. /**
  28135. * Updates the current device position and rotation in the babylon world
  28136. */
  28137. update(): void;
  28138. /**
  28139. * @hidden
  28140. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  28141. * @returns an identity matrix
  28142. */
  28143. _getViewMatrix(): Matrix;
  28144. private _tmpMatrix;
  28145. /**
  28146. * This function is called by the two RIG cameras.
  28147. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  28148. * @hidden
  28149. */
  28150. _getWebVRViewMatrix(): Matrix;
  28151. /** @hidden */
  28152. _getWebVRProjectionMatrix(): Matrix;
  28153. private _onGamepadConnectedObserver;
  28154. private _onGamepadDisconnectedObserver;
  28155. private _updateCacheWhenTrackingDisabledObserver;
  28156. /**
  28157. * Initializes the controllers and their meshes
  28158. */
  28159. initControllers(): void;
  28160. }
  28161. }
  28162. declare module "babylonjs/Materials/materialHelper" {
  28163. import { Nullable } from "babylonjs/types";
  28164. import { Scene } from "babylonjs/scene";
  28165. import { Engine } from "babylonjs/Engines/engine";
  28166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28167. import { Light } from "babylonjs/Lights/light";
  28168. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  28169. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28170. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  28171. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28172. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  28173. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  28174. /**
  28175. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  28176. *
  28177. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  28178. *
  28179. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  28180. */
  28181. export class MaterialHelper {
  28182. /**
  28183. * Bind the current view position to an effect.
  28184. * @param effect The effect to be bound
  28185. * @param scene The scene the eyes position is used from
  28186. * @param variableName name of the shader variable that will hold the eye position
  28187. */
  28188. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  28189. /**
  28190. * Helps preparing the defines values about the UVs in used in the effect.
  28191. * UVs are shared as much as we can accross channels in the shaders.
  28192. * @param texture The texture we are preparing the UVs for
  28193. * @param defines The defines to update
  28194. * @param key The channel key "diffuse", "specular"... used in the shader
  28195. */
  28196. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  28197. /**
  28198. * Binds a texture matrix value to its corrsponding uniform
  28199. * @param texture The texture to bind the matrix for
  28200. * @param uniformBuffer The uniform buffer receivin the data
  28201. * @param key The channel key "diffuse", "specular"... used in the shader
  28202. */
  28203. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  28204. /**
  28205. * Gets the current status of the fog (should it be enabled?)
  28206. * @param mesh defines the mesh to evaluate for fog support
  28207. * @param scene defines the hosting scene
  28208. * @returns true if fog must be enabled
  28209. */
  28210. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  28211. /**
  28212. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  28213. * @param mesh defines the current mesh
  28214. * @param scene defines the current scene
  28215. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  28216. * @param pointsCloud defines if point cloud rendering has to be turned on
  28217. * @param fogEnabled defines if fog has to be turned on
  28218. * @param alphaTest defines if alpha testing has to be turned on
  28219. * @param defines defines the current list of defines
  28220. */
  28221. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  28222. /**
  28223. * Helper used to prepare the list of defines associated with frame values for shader compilation
  28224. * @param scene defines the current scene
  28225. * @param engine defines the current engine
  28226. * @param defines specifies the list of active defines
  28227. * @param useInstances defines if instances have to be turned on
  28228. * @param useClipPlane defines if clip plane have to be turned on
  28229. * @param useInstances defines if instances have to be turned on
  28230. * @param useThinInstances defines if thin instances have to be turned on
  28231. */
  28232. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  28233. /**
  28234. * Prepares the defines for bones
  28235. * @param mesh The mesh containing the geometry data we will draw
  28236. * @param defines The defines to update
  28237. */
  28238. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  28239. /**
  28240. * Prepares the defines for morph targets
  28241. * @param mesh The mesh containing the geometry data we will draw
  28242. * @param defines The defines to update
  28243. */
  28244. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  28245. /**
  28246. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  28247. * @param mesh The mesh containing the geometry data we will draw
  28248. * @param defines The defines to update
  28249. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  28250. * @param useBones Precise whether bones should be used or not (override mesh info)
  28251. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  28252. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  28253. * @returns false if defines are considered not dirty and have not been checked
  28254. */
  28255. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  28256. /**
  28257. * Prepares the defines related to multiview
  28258. * @param scene The scene we are intending to draw
  28259. * @param defines The defines to update
  28260. */
  28261. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  28262. /**
  28263. * Prepares the defines related to the prepass
  28264. * @param scene The scene we are intending to draw
  28265. * @param defines The defines to update
  28266. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  28267. */
  28268. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  28269. /**
  28270. * Prepares the defines related to the light information passed in parameter
  28271. * @param scene The scene we are intending to draw
  28272. * @param mesh The mesh the effect is compiling for
  28273. * @param light The light the effect is compiling for
  28274. * @param lightIndex The index of the light
  28275. * @param defines The defines to update
  28276. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28277. * @param state Defines the current state regarding what is needed (normals, etc...)
  28278. */
  28279. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  28280. needNormals: boolean;
  28281. needRebuild: boolean;
  28282. shadowEnabled: boolean;
  28283. specularEnabled: boolean;
  28284. lightmapMode: boolean;
  28285. }): void;
  28286. /**
  28287. * Prepares the defines related to the light information passed in parameter
  28288. * @param scene The scene we are intending to draw
  28289. * @param mesh The mesh the effect is compiling for
  28290. * @param defines The defines to update
  28291. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28292. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  28293. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  28294. * @returns true if normals will be required for the rest of the effect
  28295. */
  28296. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  28297. /**
  28298. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  28299. * @param lightIndex defines the light index
  28300. * @param uniformsList The uniform list
  28301. * @param samplersList The sampler list
  28302. * @param projectedLightTexture defines if projected texture must be used
  28303. * @param uniformBuffersList defines an optional list of uniform buffers
  28304. */
  28305. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  28306. /**
  28307. * Prepares the uniforms and samplers list to be used in the effect
  28308. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  28309. * @param samplersList The sampler list
  28310. * @param defines The defines helping in the list generation
  28311. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  28312. */
  28313. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  28314. /**
  28315. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  28316. * @param defines The defines to update while falling back
  28317. * @param fallbacks The authorized effect fallbacks
  28318. * @param maxSimultaneousLights The maximum number of lights allowed
  28319. * @param rank the current rank of the Effect
  28320. * @returns The newly affected rank
  28321. */
  28322. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  28323. private static _TmpMorphInfluencers;
  28324. /**
  28325. * Prepares the list of attributes required for morph targets according to the effect defines.
  28326. * @param attribs The current list of supported attribs
  28327. * @param mesh The mesh to prepare the morph targets attributes for
  28328. * @param influencers The number of influencers
  28329. */
  28330. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  28331. /**
  28332. * Prepares the list of attributes required for morph targets according to the effect defines.
  28333. * @param attribs The current list of supported attribs
  28334. * @param mesh The mesh to prepare the morph targets attributes for
  28335. * @param defines The current Defines of the effect
  28336. */
  28337. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  28338. /**
  28339. * Prepares the list of attributes required for bones according to the effect defines.
  28340. * @param attribs The current list of supported attribs
  28341. * @param mesh The mesh to prepare the bones attributes for
  28342. * @param defines The current Defines of the effect
  28343. * @param fallbacks The current efffect fallback strategy
  28344. */
  28345. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  28346. /**
  28347. * Check and prepare the list of attributes required for instances according to the effect defines.
  28348. * @param attribs The current list of supported attribs
  28349. * @param defines The current MaterialDefines of the effect
  28350. */
  28351. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  28352. /**
  28353. * Add the list of attributes required for instances to the attribs array.
  28354. * @param attribs The current list of supported attribs
  28355. */
  28356. static PushAttributesForInstances(attribs: string[]): void;
  28357. /**
  28358. * Binds the light information to the effect.
  28359. * @param light The light containing the generator
  28360. * @param effect The effect we are binding the data to
  28361. * @param lightIndex The light index in the effect used to render
  28362. */
  28363. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  28364. /**
  28365. * Binds the lights information from the scene to the effect for the given mesh.
  28366. * @param light Light to bind
  28367. * @param lightIndex Light index
  28368. * @param scene The scene where the light belongs to
  28369. * @param effect The effect we are binding the data to
  28370. * @param useSpecular Defines if specular is supported
  28371. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28372. */
  28373. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  28374. /**
  28375. * Binds the lights information from the scene to the effect for the given mesh.
  28376. * @param scene The scene the lights belongs to
  28377. * @param mesh The mesh we are binding the information to render
  28378. * @param effect The effect we are binding the data to
  28379. * @param defines The generated defines for the effect
  28380. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  28381. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28382. */
  28383. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  28384. private static _tempFogColor;
  28385. /**
  28386. * Binds the fog information from the scene to the effect for the given mesh.
  28387. * @param scene The scene the lights belongs to
  28388. * @param mesh The mesh we are binding the information to render
  28389. * @param effect The effect we are binding the data to
  28390. * @param linearSpace Defines if the fog effect is applied in linear space
  28391. */
  28392. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  28393. /**
  28394. * Binds the bones information from the mesh to the effect.
  28395. * @param mesh The mesh we are binding the information to render
  28396. * @param effect The effect we are binding the data to
  28397. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  28398. */
  28399. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  28400. private static _CopyBonesTransformationMatrices;
  28401. /**
  28402. * Binds the morph targets information from the mesh to the effect.
  28403. * @param abstractMesh The mesh we are binding the information to render
  28404. * @param effect The effect we are binding the data to
  28405. */
  28406. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  28407. /**
  28408. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  28409. * @param defines The generated defines used in the effect
  28410. * @param effect The effect we are binding the data to
  28411. * @param scene The scene we are willing to render with logarithmic scale for
  28412. */
  28413. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  28414. /**
  28415. * Binds the clip plane information from the scene to the effect.
  28416. * @param scene The scene the clip plane information are extracted from
  28417. * @param effect The effect we are binding the data to
  28418. */
  28419. static BindClipPlane(effect: Effect, scene: Scene): void;
  28420. }
  28421. }
  28422. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  28423. /** @hidden */
  28424. export var bayerDitherFunctions: {
  28425. name: string;
  28426. shader: string;
  28427. };
  28428. }
  28429. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  28430. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  28431. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  28432. /** @hidden */
  28433. export var shadowMapFragmentDeclaration: {
  28434. name: string;
  28435. shader: string;
  28436. };
  28437. }
  28438. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  28439. /** @hidden */
  28440. export var shadowMapFragment: {
  28441. name: string;
  28442. shader: string;
  28443. };
  28444. }
  28445. declare module "babylonjs/Shaders/shadowMap.fragment" {
  28446. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  28447. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  28448. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  28449. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  28450. /** @hidden */
  28451. export var shadowMapPixelShader: {
  28452. name: string;
  28453. shader: string;
  28454. };
  28455. }
  28456. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  28457. /** @hidden */
  28458. export var shadowMapVertexDeclaration: {
  28459. name: string;
  28460. shader: string;
  28461. };
  28462. }
  28463. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  28464. /** @hidden */
  28465. export var shadowMapVertexNormalBias: {
  28466. name: string;
  28467. shader: string;
  28468. };
  28469. }
  28470. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  28471. /** @hidden */
  28472. export var shadowMapVertexMetric: {
  28473. name: string;
  28474. shader: string;
  28475. };
  28476. }
  28477. declare module "babylonjs/Shaders/shadowMap.vertex" {
  28478. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  28479. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  28480. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  28481. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  28482. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  28483. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  28484. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  28485. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  28486. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  28487. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  28488. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  28489. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  28490. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  28491. /** @hidden */
  28492. export var shadowMapVertexShader: {
  28493. name: string;
  28494. shader: string;
  28495. };
  28496. }
  28497. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  28498. /** @hidden */
  28499. export var depthBoxBlurPixelShader: {
  28500. name: string;
  28501. shader: string;
  28502. };
  28503. }
  28504. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  28505. /** @hidden */
  28506. export var shadowMapFragmentSoftTransparentShadow: {
  28507. name: string;
  28508. shader: string;
  28509. };
  28510. }
  28511. declare module "babylonjs/Meshes/instancedMesh" {
  28512. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28513. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  28514. import { Camera } from "babylonjs/Cameras/camera";
  28515. import { Node } from "babylonjs/node";
  28516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28517. import { Mesh } from "babylonjs/Meshes/mesh";
  28518. import { Material } from "babylonjs/Materials/material";
  28519. import { Skeleton } from "babylonjs/Bones/skeleton";
  28520. import { Light } from "babylonjs/Lights/light";
  28521. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28522. /**
  28523. * Creates an instance based on a source mesh.
  28524. */
  28525. export class InstancedMesh extends AbstractMesh {
  28526. private _sourceMesh;
  28527. private _currentLOD;
  28528. /** @hidden */
  28529. _indexInSourceMeshInstanceArray: number;
  28530. constructor(name: string, source: Mesh);
  28531. /**
  28532. * Returns the string "InstancedMesh".
  28533. */
  28534. getClassName(): string;
  28535. /** Gets the list of lights affecting that mesh */
  28536. get lightSources(): Light[];
  28537. _resyncLightSources(): void;
  28538. _resyncLightSource(light: Light): void;
  28539. _removeLightSource(light: Light, dispose: boolean): void;
  28540. /**
  28541. * If the source mesh receives shadows
  28542. */
  28543. get receiveShadows(): boolean;
  28544. /**
  28545. * The material of the source mesh
  28546. */
  28547. get material(): Nullable<Material>;
  28548. /**
  28549. * Visibility of the source mesh
  28550. */
  28551. get visibility(): number;
  28552. /**
  28553. * Skeleton of the source mesh
  28554. */
  28555. get skeleton(): Nullable<Skeleton>;
  28556. /**
  28557. * Rendering ground id of the source mesh
  28558. */
  28559. get renderingGroupId(): number;
  28560. set renderingGroupId(value: number);
  28561. /**
  28562. * Returns the total number of vertices (integer).
  28563. */
  28564. getTotalVertices(): number;
  28565. /**
  28566. * Returns a positive integer : the total number of indices in this mesh geometry.
  28567. * @returns the numner of indices or zero if the mesh has no geometry.
  28568. */
  28569. getTotalIndices(): number;
  28570. /**
  28571. * The source mesh of the instance
  28572. */
  28573. get sourceMesh(): Mesh;
  28574. /**
  28575. * Creates a new InstancedMesh object from the mesh model.
  28576. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28577. * @param name defines the name of the new instance
  28578. * @returns a new InstancedMesh
  28579. */
  28580. createInstance(name: string): InstancedMesh;
  28581. /**
  28582. * Is this node ready to be used/rendered
  28583. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28584. * @return {boolean} is it ready
  28585. */
  28586. isReady(completeCheck?: boolean): boolean;
  28587. /**
  28588. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28589. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  28590. * @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.
  28591. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  28592. */
  28593. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  28594. /**
  28595. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28596. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28597. * The `data` are either a numeric array either a Float32Array.
  28598. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  28599. * 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).
  28600. * Note that a new underlying VertexBuffer object is created each call.
  28601. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28602. *
  28603. * Possible `kind` values :
  28604. * - VertexBuffer.PositionKind
  28605. * - VertexBuffer.UVKind
  28606. * - VertexBuffer.UV2Kind
  28607. * - VertexBuffer.UV3Kind
  28608. * - VertexBuffer.UV4Kind
  28609. * - VertexBuffer.UV5Kind
  28610. * - VertexBuffer.UV6Kind
  28611. * - VertexBuffer.ColorKind
  28612. * - VertexBuffer.MatricesIndicesKind
  28613. * - VertexBuffer.MatricesIndicesExtraKind
  28614. * - VertexBuffer.MatricesWeightsKind
  28615. * - VertexBuffer.MatricesWeightsExtraKind
  28616. *
  28617. * Returns the Mesh.
  28618. */
  28619. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28620. /**
  28621. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28622. * If the mesh has no geometry, it is simply returned as it is.
  28623. * The `data` are either a numeric array either a Float32Array.
  28624. * No new underlying VertexBuffer object is created.
  28625. * 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.
  28626. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  28627. *
  28628. * Possible `kind` values :
  28629. * - VertexBuffer.PositionKind
  28630. * - VertexBuffer.UVKind
  28631. * - VertexBuffer.UV2Kind
  28632. * - VertexBuffer.UV3Kind
  28633. * - VertexBuffer.UV4Kind
  28634. * - VertexBuffer.UV5Kind
  28635. * - VertexBuffer.UV6Kind
  28636. * - VertexBuffer.ColorKind
  28637. * - VertexBuffer.MatricesIndicesKind
  28638. * - VertexBuffer.MatricesIndicesExtraKind
  28639. * - VertexBuffer.MatricesWeightsKind
  28640. * - VertexBuffer.MatricesWeightsExtraKind
  28641. *
  28642. * Returns the Mesh.
  28643. */
  28644. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  28645. /**
  28646. * Sets the mesh indices.
  28647. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  28648. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28649. * This method creates a new index buffer each call.
  28650. * Returns the Mesh.
  28651. */
  28652. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  28653. /**
  28654. * Boolean : True if the mesh owns the requested kind of data.
  28655. */
  28656. isVerticesDataPresent(kind: string): boolean;
  28657. /**
  28658. * Returns an array of indices (IndicesArray).
  28659. */
  28660. getIndices(): Nullable<IndicesArray>;
  28661. get _positions(): Nullable<Vector3[]>;
  28662. /**
  28663. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28664. * This means the mesh underlying bounding box and sphere are recomputed.
  28665. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28666. * @returns the current mesh
  28667. */
  28668. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  28669. /** @hidden */
  28670. _preActivate(): InstancedMesh;
  28671. /** @hidden */
  28672. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28673. /** @hidden */
  28674. _postActivate(): void;
  28675. getWorldMatrix(): Matrix;
  28676. get isAnInstance(): boolean;
  28677. /**
  28678. * Returns the current associated LOD AbstractMesh.
  28679. */
  28680. getLOD(camera: Camera): AbstractMesh;
  28681. /** @hidden */
  28682. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28683. /** @hidden */
  28684. _syncSubMeshes(): InstancedMesh;
  28685. /** @hidden */
  28686. _generatePointsArray(): boolean;
  28687. /** @hidden */
  28688. _updateBoundingInfo(): AbstractMesh;
  28689. /**
  28690. * Creates a new InstancedMesh from the current mesh.
  28691. * - name (string) : the cloned mesh name
  28692. * - newParent (optional Node) : the optional Node to parent the clone to.
  28693. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  28694. *
  28695. * Returns the clone.
  28696. */
  28697. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  28698. /**
  28699. * Disposes the InstancedMesh.
  28700. * Returns nothing.
  28701. */
  28702. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28703. }
  28704. module "babylonjs/Meshes/mesh" {
  28705. interface Mesh {
  28706. /**
  28707. * Register a custom buffer that will be instanced
  28708. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28709. * @param kind defines the buffer kind
  28710. * @param stride defines the stride in floats
  28711. */
  28712. registerInstancedBuffer(kind: string, stride: number): void;
  28713. /**
  28714. * true to use the edge renderer for all instances of this mesh
  28715. */
  28716. edgesShareWithInstances: boolean;
  28717. /** @hidden */
  28718. _userInstancedBuffersStorage: {
  28719. data: {
  28720. [key: string]: Float32Array;
  28721. };
  28722. sizes: {
  28723. [key: string]: number;
  28724. };
  28725. vertexBuffers: {
  28726. [key: string]: Nullable<VertexBuffer>;
  28727. };
  28728. strides: {
  28729. [key: string]: number;
  28730. };
  28731. };
  28732. }
  28733. }
  28734. module "babylonjs/Meshes/abstractMesh" {
  28735. interface AbstractMesh {
  28736. /**
  28737. * Object used to store instanced buffers defined by user
  28738. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28739. */
  28740. instancedBuffers: {
  28741. [key: string]: any;
  28742. };
  28743. }
  28744. }
  28745. }
  28746. declare module "babylonjs/Materials/shaderMaterial" {
  28747. import { Nullable } from "babylonjs/types";
  28748. import { Scene } from "babylonjs/scene";
  28749. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28750. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28751. import { Mesh } from "babylonjs/Meshes/mesh";
  28752. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28753. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28754. import { Effect } from "babylonjs/Materials/effect";
  28755. import { Material } from "babylonjs/Materials/material";
  28756. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28757. /**
  28758. * Defines the options associated with the creation of a shader material.
  28759. */
  28760. export interface IShaderMaterialOptions {
  28761. /**
  28762. * Does the material work in alpha blend mode
  28763. */
  28764. needAlphaBlending: boolean;
  28765. /**
  28766. * Does the material work in alpha test mode
  28767. */
  28768. needAlphaTesting: boolean;
  28769. /**
  28770. * The list of attribute names used in the shader
  28771. */
  28772. attributes: string[];
  28773. /**
  28774. * The list of unifrom names used in the shader
  28775. */
  28776. uniforms: string[];
  28777. /**
  28778. * The list of UBO names used in the shader
  28779. */
  28780. uniformBuffers: string[];
  28781. /**
  28782. * The list of sampler names used in the shader
  28783. */
  28784. samplers: string[];
  28785. /**
  28786. * The list of defines used in the shader
  28787. */
  28788. defines: string[];
  28789. }
  28790. /**
  28791. * 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.
  28792. *
  28793. * This returned material effects how the mesh will look based on the code in the shaders.
  28794. *
  28795. * @see https://doc.babylonjs.com/how_to/shader_material
  28796. */
  28797. export class ShaderMaterial extends Material {
  28798. private _shaderPath;
  28799. private _options;
  28800. private _textures;
  28801. private _textureArrays;
  28802. private _floats;
  28803. private _ints;
  28804. private _floatsArrays;
  28805. private _colors3;
  28806. private _colors3Arrays;
  28807. private _colors4;
  28808. private _colors4Arrays;
  28809. private _vectors2;
  28810. private _vectors3;
  28811. private _vectors4;
  28812. private _matrices;
  28813. private _matrixArrays;
  28814. private _matrices3x3;
  28815. private _matrices2x2;
  28816. private _vectors2Arrays;
  28817. private _vectors3Arrays;
  28818. private _vectors4Arrays;
  28819. private _cachedWorldViewMatrix;
  28820. private _cachedWorldViewProjectionMatrix;
  28821. private _renderId;
  28822. private _multiview;
  28823. private _cachedDefines;
  28824. /** Define the Url to load snippets */
  28825. static SnippetUrl: string;
  28826. /** Snippet ID if the material was created from the snippet server */
  28827. snippetId: string;
  28828. /**
  28829. * Instantiate a new shader material.
  28830. * 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.
  28831. * This returned material effects how the mesh will look based on the code in the shaders.
  28832. * @see https://doc.babylonjs.com/how_to/shader_material
  28833. * @param name Define the name of the material in the scene
  28834. * @param scene Define the scene the material belongs to
  28835. * @param shaderPath Defines the route to the shader code in one of three ways:
  28836. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  28837. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  28838. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  28839. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  28840. * @param options Define the options used to create the shader
  28841. */
  28842. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  28843. /**
  28844. * Gets the shader path used to define the shader code
  28845. * It can be modified to trigger a new compilation
  28846. */
  28847. get shaderPath(): any;
  28848. /**
  28849. * Sets the shader path used to define the shader code
  28850. * It can be modified to trigger a new compilation
  28851. */
  28852. set shaderPath(shaderPath: any);
  28853. /**
  28854. * Gets the options used to compile the shader.
  28855. * They can be modified to trigger a new compilation
  28856. */
  28857. get options(): IShaderMaterialOptions;
  28858. /**
  28859. * Gets the current class name of the material e.g. "ShaderMaterial"
  28860. * Mainly use in serialization.
  28861. * @returns the class name
  28862. */
  28863. getClassName(): string;
  28864. /**
  28865. * Specifies if the material will require alpha blending
  28866. * @returns a boolean specifying if alpha blending is needed
  28867. */
  28868. needAlphaBlending(): boolean;
  28869. /**
  28870. * Specifies if this material should be rendered in alpha test mode
  28871. * @returns a boolean specifying if an alpha test is needed.
  28872. */
  28873. needAlphaTesting(): boolean;
  28874. private _checkUniform;
  28875. /**
  28876. * Set a texture in the shader.
  28877. * @param name Define the name of the uniform samplers as defined in the shader
  28878. * @param texture Define the texture to bind to this sampler
  28879. * @return the material itself allowing "fluent" like uniform updates
  28880. */
  28881. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  28882. /**
  28883. * Set a texture array in the shader.
  28884. * @param name Define the name of the uniform sampler array as defined in the shader
  28885. * @param textures Define the list of textures to bind to this sampler
  28886. * @return the material itself allowing "fluent" like uniform updates
  28887. */
  28888. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  28889. /**
  28890. * Set a float in the shader.
  28891. * @param name Define the name of the uniform as defined in the shader
  28892. * @param value Define the value to give to the uniform
  28893. * @return the material itself allowing "fluent" like uniform updates
  28894. */
  28895. setFloat(name: string, value: number): ShaderMaterial;
  28896. /**
  28897. * Set a int in the shader.
  28898. * @param name Define the name of the uniform as defined in the shader
  28899. * @param value Define the value to give to the uniform
  28900. * @return the material itself allowing "fluent" like uniform updates
  28901. */
  28902. setInt(name: string, value: number): ShaderMaterial;
  28903. /**
  28904. * Set an array of floats in the shader.
  28905. * @param name Define the name of the uniform as defined in the shader
  28906. * @param value Define the value to give to the uniform
  28907. * @return the material itself allowing "fluent" like uniform updates
  28908. */
  28909. setFloats(name: string, value: number[]): ShaderMaterial;
  28910. /**
  28911. * Set a vec3 in the shader from a Color3.
  28912. * @param name Define the name of the uniform as defined in the shader
  28913. * @param value Define the value to give to the uniform
  28914. * @return the material itself allowing "fluent" like uniform updates
  28915. */
  28916. setColor3(name: string, value: Color3): ShaderMaterial;
  28917. /**
  28918. * Set a vec3 array in the shader from a Color3 array.
  28919. * @param name Define the name of the uniform as defined in the shader
  28920. * @param value Define the value to give to the uniform
  28921. * @return the material itself allowing "fluent" like uniform updates
  28922. */
  28923. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  28924. /**
  28925. * Set a vec4 in the shader from a Color4.
  28926. * @param name Define the name of the uniform as defined in the shader
  28927. * @param value Define the value to give to the uniform
  28928. * @return the material itself allowing "fluent" like uniform updates
  28929. */
  28930. setColor4(name: string, value: Color4): ShaderMaterial;
  28931. /**
  28932. * Set a vec4 array in the shader from a Color4 array.
  28933. * @param name Define the name of the uniform as defined in the shader
  28934. * @param value Define the value to give to the uniform
  28935. * @return the material itself allowing "fluent" like uniform updates
  28936. */
  28937. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  28938. /**
  28939. * Set a vec2 in the shader from a Vector2.
  28940. * @param name Define the name of the uniform as defined in the shader
  28941. * @param value Define the value to give to the uniform
  28942. * @return the material itself allowing "fluent" like uniform updates
  28943. */
  28944. setVector2(name: string, value: Vector2): ShaderMaterial;
  28945. /**
  28946. * Set a vec3 in the shader from a Vector3.
  28947. * @param name Define the name of the uniform as defined in the shader
  28948. * @param value Define the value to give to the uniform
  28949. * @return the material itself allowing "fluent" like uniform updates
  28950. */
  28951. setVector3(name: string, value: Vector3): ShaderMaterial;
  28952. /**
  28953. * Set a vec4 in the shader from a Vector4.
  28954. * @param name Define the name of the uniform as defined in the shader
  28955. * @param value Define the value to give to the uniform
  28956. * @return the material itself allowing "fluent" like uniform updates
  28957. */
  28958. setVector4(name: string, value: Vector4): ShaderMaterial;
  28959. /**
  28960. * Set a mat4 in the shader from a Matrix.
  28961. * @param name Define the name of the uniform as defined in the shader
  28962. * @param value Define the value to give to the uniform
  28963. * @return the material itself allowing "fluent" like uniform updates
  28964. */
  28965. setMatrix(name: string, value: Matrix): ShaderMaterial;
  28966. /**
  28967. * Set a float32Array in the shader from a matrix array.
  28968. * @param name Define the name of the uniform as defined in the shader
  28969. * @param value Define the value to give to the uniform
  28970. * @return the material itself allowing "fluent" like uniform updates
  28971. */
  28972. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  28973. /**
  28974. * Set a mat3 in the shader from a Float32Array.
  28975. * @param name Define the name of the uniform as defined in the shader
  28976. * @param value Define the value to give to the uniform
  28977. * @return the material itself allowing "fluent" like uniform updates
  28978. */
  28979. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28980. /**
  28981. * Set a mat2 in the shader from a Float32Array.
  28982. * @param name Define the name of the uniform as defined in the shader
  28983. * @param value Define the value to give to the uniform
  28984. * @return the material itself allowing "fluent" like uniform updates
  28985. */
  28986. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28987. /**
  28988. * Set a vec2 array in the shader from a number array.
  28989. * @param name Define the name of the uniform as defined in the shader
  28990. * @param value Define the value to give to the uniform
  28991. * @return the material itself allowing "fluent" like uniform updates
  28992. */
  28993. setArray2(name: string, value: number[]): ShaderMaterial;
  28994. /**
  28995. * Set a vec3 array in the shader from a number array.
  28996. * @param name Define the name of the uniform as defined in the shader
  28997. * @param value Define the value to give to the uniform
  28998. * @return the material itself allowing "fluent" like uniform updates
  28999. */
  29000. setArray3(name: string, value: number[]): ShaderMaterial;
  29001. /**
  29002. * Set a vec4 array in the shader from a number array.
  29003. * @param name Define the name of the uniform as defined in the shader
  29004. * @param value Define the value to give to the uniform
  29005. * @return the material itself allowing "fluent" like uniform updates
  29006. */
  29007. setArray4(name: string, value: number[]): ShaderMaterial;
  29008. private _checkCache;
  29009. /**
  29010. * Specifies that the submesh is ready to be used
  29011. * @param mesh defines the mesh to check
  29012. * @param subMesh defines which submesh to check
  29013. * @param useInstances specifies that instances should be used
  29014. * @returns a boolean indicating that the submesh is ready or not
  29015. */
  29016. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29017. /**
  29018. * Checks if the material is ready to render the requested mesh
  29019. * @param mesh Define the mesh to render
  29020. * @param useInstances Define whether or not the material is used with instances
  29021. * @returns true if ready, otherwise false
  29022. */
  29023. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29024. /**
  29025. * Binds the world matrix to the material
  29026. * @param world defines the world transformation matrix
  29027. * @param effectOverride - If provided, use this effect instead of internal effect
  29028. */
  29029. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  29030. /**
  29031. * Binds the submesh to this material by preparing the effect and shader to draw
  29032. * @param world defines the world transformation matrix
  29033. * @param mesh defines the mesh containing the submesh
  29034. * @param subMesh defines the submesh to bind the material to
  29035. */
  29036. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29037. /**
  29038. * Binds the material to the mesh
  29039. * @param world defines the world transformation matrix
  29040. * @param mesh defines the mesh to bind the material to
  29041. * @param effectOverride - If provided, use this effect instead of internal effect
  29042. */
  29043. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  29044. protected _afterBind(mesh?: Mesh): void;
  29045. /**
  29046. * Gets the active textures from the material
  29047. * @returns an array of textures
  29048. */
  29049. getActiveTextures(): BaseTexture[];
  29050. /**
  29051. * Specifies if the material uses a texture
  29052. * @param texture defines the texture to check against the material
  29053. * @returns a boolean specifying if the material uses the texture
  29054. */
  29055. hasTexture(texture: BaseTexture): boolean;
  29056. /**
  29057. * Makes a duplicate of the material, and gives it a new name
  29058. * @param name defines the new name for the duplicated material
  29059. * @returns the cloned material
  29060. */
  29061. clone(name: string): ShaderMaterial;
  29062. /**
  29063. * Disposes the material
  29064. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29065. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29066. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29067. */
  29068. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29069. /**
  29070. * Serializes this material in a JSON representation
  29071. * @returns the serialized material object
  29072. */
  29073. serialize(): any;
  29074. /**
  29075. * Creates a shader material from parsed shader material data
  29076. * @param source defines the JSON represnetation of the material
  29077. * @param scene defines the hosting scene
  29078. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29079. * @returns a new material
  29080. */
  29081. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  29082. /**
  29083. * Creates a new ShaderMaterial from a snippet saved in a remote file
  29084. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  29085. * @param url defines the url to load from
  29086. * @param scene defines the hosting scene
  29087. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29088. * @returns a promise that will resolve to the new ShaderMaterial
  29089. */
  29090. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29091. /**
  29092. * Creates a ShaderMaterial from a snippet saved by the Inspector
  29093. * @param snippetId defines the snippet to load
  29094. * @param scene defines the hosting scene
  29095. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29096. * @returns a promise that will resolve to the new ShaderMaterial
  29097. */
  29098. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29099. }
  29100. }
  29101. declare module "babylonjs/Shaders/color.fragment" {
  29102. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  29103. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  29104. /** @hidden */
  29105. export var colorPixelShader: {
  29106. name: string;
  29107. shader: string;
  29108. };
  29109. }
  29110. declare module "babylonjs/Shaders/color.vertex" {
  29111. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  29112. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  29113. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  29114. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  29115. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  29116. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  29117. /** @hidden */
  29118. export var colorVertexShader: {
  29119. name: string;
  29120. shader: string;
  29121. };
  29122. }
  29123. declare module "babylonjs/Meshes/linesMesh" {
  29124. import { Nullable } from "babylonjs/types";
  29125. import { Scene } from "babylonjs/scene";
  29126. import { Color3 } from "babylonjs/Maths/math.color";
  29127. import { Node } from "babylonjs/node";
  29128. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29129. import { Mesh } from "babylonjs/Meshes/mesh";
  29130. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29131. import { Effect } from "babylonjs/Materials/effect";
  29132. import { Material } from "babylonjs/Materials/material";
  29133. import "babylonjs/Shaders/color.fragment";
  29134. import "babylonjs/Shaders/color.vertex";
  29135. /**
  29136. * Line mesh
  29137. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  29138. */
  29139. export class LinesMesh extends Mesh {
  29140. /**
  29141. * If vertex color should be applied to the mesh
  29142. */
  29143. readonly useVertexColor?: boolean | undefined;
  29144. /**
  29145. * If vertex alpha should be applied to the mesh
  29146. */
  29147. readonly useVertexAlpha?: boolean | undefined;
  29148. /**
  29149. * Color of the line (Default: White)
  29150. */
  29151. color: Color3;
  29152. /**
  29153. * Alpha of the line (Default: 1)
  29154. */
  29155. alpha: number;
  29156. /**
  29157. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29158. * This margin is expressed in world space coordinates, so its value may vary.
  29159. * Default value is 0.1
  29160. */
  29161. intersectionThreshold: number;
  29162. private _colorShader;
  29163. private color4;
  29164. /**
  29165. * Creates a new LinesMesh
  29166. * @param name defines the name
  29167. * @param scene defines the hosting scene
  29168. * @param parent defines the parent mesh if any
  29169. * @param source defines the optional source LinesMesh used to clone data from
  29170. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29171. * When false, achieved by calling a clone(), also passing False.
  29172. * This will make creation of children, recursive.
  29173. * @param useVertexColor defines if this LinesMesh supports vertex color
  29174. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  29175. */
  29176. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  29177. /**
  29178. * If vertex color should be applied to the mesh
  29179. */
  29180. useVertexColor?: boolean | undefined,
  29181. /**
  29182. * If vertex alpha should be applied to the mesh
  29183. */
  29184. useVertexAlpha?: boolean | undefined);
  29185. private _addClipPlaneDefine;
  29186. private _removeClipPlaneDefine;
  29187. isReady(): boolean;
  29188. /**
  29189. * Returns the string "LineMesh"
  29190. */
  29191. getClassName(): string;
  29192. /**
  29193. * @hidden
  29194. */
  29195. get material(): Material;
  29196. /**
  29197. * @hidden
  29198. */
  29199. set material(value: Material);
  29200. /**
  29201. * @hidden
  29202. */
  29203. get checkCollisions(): boolean;
  29204. /** @hidden */
  29205. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29206. /** @hidden */
  29207. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29208. /**
  29209. * Disposes of the line mesh
  29210. * @param doNotRecurse If children should be disposed
  29211. */
  29212. dispose(doNotRecurse?: boolean): void;
  29213. /**
  29214. * Returns a new LineMesh object cloned from the current one.
  29215. */
  29216. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  29217. /**
  29218. * Creates a new InstancedLinesMesh object from the mesh model.
  29219. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29220. * @param name defines the name of the new instance
  29221. * @returns a new InstancedLinesMesh
  29222. */
  29223. createInstance(name: string): InstancedLinesMesh;
  29224. }
  29225. /**
  29226. * Creates an instance based on a source LinesMesh
  29227. */
  29228. export class InstancedLinesMesh extends InstancedMesh {
  29229. /**
  29230. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29231. * This margin is expressed in world space coordinates, so its value may vary.
  29232. * Initilized with the intersectionThreshold value of the source LinesMesh
  29233. */
  29234. intersectionThreshold: number;
  29235. constructor(name: string, source: LinesMesh);
  29236. /**
  29237. * Returns the string "InstancedLinesMesh".
  29238. */
  29239. getClassName(): string;
  29240. }
  29241. }
  29242. declare module "babylonjs/Shaders/line.fragment" {
  29243. /** @hidden */
  29244. export var linePixelShader: {
  29245. name: string;
  29246. shader: string;
  29247. };
  29248. }
  29249. declare module "babylonjs/Shaders/line.vertex" {
  29250. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  29251. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  29252. /** @hidden */
  29253. export var lineVertexShader: {
  29254. name: string;
  29255. shader: string;
  29256. };
  29257. }
  29258. declare module "babylonjs/Rendering/edgesRenderer" {
  29259. import { Immutable, Nullable } from "babylonjs/types";
  29260. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29262. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  29263. import { IDisposable } from "babylonjs/scene";
  29264. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  29265. import "babylonjs/Shaders/line.fragment";
  29266. import "babylonjs/Shaders/line.vertex";
  29267. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29268. import { SmartArray } from "babylonjs/Misc/smartArray";
  29269. module "babylonjs/scene" {
  29270. interface Scene {
  29271. /** @hidden */
  29272. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  29273. }
  29274. }
  29275. module "babylonjs/Meshes/abstractMesh" {
  29276. interface AbstractMesh {
  29277. /**
  29278. * Gets the edgesRenderer associated with the mesh
  29279. */
  29280. edgesRenderer: Nullable<EdgesRenderer>;
  29281. }
  29282. }
  29283. module "babylonjs/Meshes/linesMesh" {
  29284. interface LinesMesh {
  29285. /**
  29286. * Enables the edge rendering mode on the mesh.
  29287. * This mode makes the mesh edges visible
  29288. * @param epsilon defines the maximal distance between two angles to detect a face
  29289. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29290. * @returns the currentAbstractMesh
  29291. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29292. */
  29293. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29294. }
  29295. }
  29296. module "babylonjs/Meshes/linesMesh" {
  29297. interface InstancedLinesMesh {
  29298. /**
  29299. * Enables the edge rendering mode on the mesh.
  29300. * This mode makes the mesh edges visible
  29301. * @param epsilon defines the maximal distance between two angles to detect a face
  29302. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29303. * @returns the current InstancedLinesMesh
  29304. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29305. */
  29306. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  29307. }
  29308. }
  29309. /**
  29310. * Defines the minimum contract an Edges renderer should follow.
  29311. */
  29312. export interface IEdgesRenderer extends IDisposable {
  29313. /**
  29314. * Gets or sets a boolean indicating if the edgesRenderer is active
  29315. */
  29316. isEnabled: boolean;
  29317. /**
  29318. * Renders the edges of the attached mesh,
  29319. */
  29320. render(): void;
  29321. /**
  29322. * Checks wether or not the edges renderer is ready to render.
  29323. * @return true if ready, otherwise false.
  29324. */
  29325. isReady(): boolean;
  29326. /**
  29327. * List of instances to render in case the source mesh has instances
  29328. */
  29329. customInstances: SmartArray<Matrix>;
  29330. }
  29331. /**
  29332. * Defines the additional options of the edges renderer
  29333. */
  29334. export interface IEdgesRendererOptions {
  29335. /**
  29336. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  29337. * If not defined, the default value is true
  29338. */
  29339. useAlternateEdgeFinder?: boolean;
  29340. /**
  29341. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  29342. * If not defined, the default value is true.
  29343. * 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)
  29344. * This option is used only if useAlternateEdgeFinder = true
  29345. */
  29346. useFastVertexMerger?: boolean;
  29347. /**
  29348. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  29349. * The default value is 1e-6
  29350. * This option is used only if useAlternateEdgeFinder = true
  29351. */
  29352. epsilonVertexMerge?: number;
  29353. /**
  29354. * 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
  29355. * 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.
  29356. * This option is used only if useAlternateEdgeFinder = true
  29357. */
  29358. applyTessellation?: boolean;
  29359. /**
  29360. * 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
  29361. * The default value is 1e-6
  29362. * This option is used only if useAlternateEdgeFinder = true
  29363. */
  29364. epsilonVertexAligned?: number;
  29365. }
  29366. /**
  29367. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  29368. */
  29369. export class EdgesRenderer implements IEdgesRenderer {
  29370. /**
  29371. * Define the size of the edges with an orthographic camera
  29372. */
  29373. edgesWidthScalerForOrthographic: number;
  29374. /**
  29375. * Define the size of the edges with a perspective camera
  29376. */
  29377. edgesWidthScalerForPerspective: number;
  29378. protected _source: AbstractMesh;
  29379. protected _linesPositions: number[];
  29380. protected _linesNormals: number[];
  29381. protected _linesIndices: number[];
  29382. protected _epsilon: number;
  29383. protected _indicesCount: number;
  29384. protected _lineShader: ShaderMaterial;
  29385. protected _ib: DataBuffer;
  29386. protected _buffers: {
  29387. [key: string]: Nullable<VertexBuffer>;
  29388. };
  29389. protected _buffersForInstances: {
  29390. [key: string]: Nullable<VertexBuffer>;
  29391. };
  29392. protected _checkVerticesInsteadOfIndices: boolean;
  29393. protected _options: Nullable<IEdgesRendererOptions>;
  29394. private _meshRebuildObserver;
  29395. private _meshDisposeObserver;
  29396. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29397. isEnabled: boolean;
  29398. /** Gets the vertices generated by the edge renderer */
  29399. get linesPositions(): Immutable<Array<number>>;
  29400. /** Gets the normals generated by the edge renderer */
  29401. get linesNormals(): Immutable<Array<number>>;
  29402. /** Gets the indices generated by the edge renderer */
  29403. get linesIndices(): Immutable<Array<number>>;
  29404. /**
  29405. * List of instances to render in case the source mesh has instances
  29406. */
  29407. customInstances: SmartArray<Matrix>;
  29408. private static GetShader;
  29409. /**
  29410. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29411. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29412. * @param source Mesh used to create edges
  29413. * @param epsilon sum of angles in adjacency to check for edge
  29414. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  29415. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29416. * @param options The options to apply when generating the edges
  29417. */
  29418. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  29419. protected _prepareRessources(): void;
  29420. /** @hidden */
  29421. _rebuild(): void;
  29422. /**
  29423. * Releases the required resources for the edges renderer
  29424. */
  29425. dispose(): void;
  29426. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29427. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29428. /**
  29429. * Checks if the pair of p0 and p1 is en edge
  29430. * @param faceIndex
  29431. * @param edge
  29432. * @param faceNormals
  29433. * @param p0
  29434. * @param p1
  29435. * @private
  29436. */
  29437. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29438. /**
  29439. * push line into the position, normal and index buffer
  29440. * @protected
  29441. */
  29442. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  29443. /**
  29444. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  29445. */
  29446. private _tessellateTriangle;
  29447. private _generateEdgesLinesAlternate;
  29448. /**
  29449. * Generates lines edges from adjacencjes
  29450. * @private
  29451. */
  29452. _generateEdgesLines(): void;
  29453. /**
  29454. * Checks wether or not the edges renderer is ready to render.
  29455. * @return true if ready, otherwise false.
  29456. */
  29457. isReady(): boolean;
  29458. /**
  29459. * Renders the edges of the attached mesh,
  29460. */
  29461. render(): void;
  29462. }
  29463. /**
  29464. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29465. */
  29466. export class LineEdgesRenderer extends EdgesRenderer {
  29467. /**
  29468. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29469. * @param source LineMesh used to generate edges
  29470. * @param epsilon not important (specified angle for edge detection)
  29471. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29472. */
  29473. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29474. /**
  29475. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29476. */
  29477. _generateEdgesLines(): void;
  29478. }
  29479. }
  29480. declare module "babylonjs/Rendering/renderingGroup" {
  29481. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  29482. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29484. import { Nullable } from "babylonjs/types";
  29485. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  29486. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  29487. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  29488. import { Material } from "babylonjs/Materials/material";
  29489. import { Scene } from "babylonjs/scene";
  29490. /**
  29491. * This represents the object necessary to create a rendering group.
  29492. * This is exclusively used and created by the rendering manager.
  29493. * To modify the behavior, you use the available helpers in your scene or meshes.
  29494. * @hidden
  29495. */
  29496. export class RenderingGroup {
  29497. index: number;
  29498. private static _zeroVector;
  29499. private _scene;
  29500. private _opaqueSubMeshes;
  29501. private _transparentSubMeshes;
  29502. private _alphaTestSubMeshes;
  29503. private _depthOnlySubMeshes;
  29504. private _particleSystems;
  29505. private _spriteManagers;
  29506. private _opaqueSortCompareFn;
  29507. private _alphaTestSortCompareFn;
  29508. private _transparentSortCompareFn;
  29509. private _renderOpaque;
  29510. private _renderAlphaTest;
  29511. private _renderTransparent;
  29512. /** @hidden */
  29513. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  29514. onBeforeTransparentRendering: () => void;
  29515. /**
  29516. * Set the opaque sort comparison function.
  29517. * If null the sub meshes will be render in the order they were created
  29518. */
  29519. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29520. /**
  29521. * Set the alpha test sort comparison function.
  29522. * If null the sub meshes will be render in the order they were created
  29523. */
  29524. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29525. /**
  29526. * Set the transparent sort comparison function.
  29527. * If null the sub meshes will be render in the order they were created
  29528. */
  29529. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29530. /**
  29531. * Creates a new rendering group.
  29532. * @param index The rendering group index
  29533. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29534. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29535. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29536. */
  29537. 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>);
  29538. /**
  29539. * Render all the sub meshes contained in the group.
  29540. * @param customRenderFunction Used to override the default render behaviour of the group.
  29541. * @returns true if rendered some submeshes.
  29542. */
  29543. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29544. /**
  29545. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29546. * @param subMeshes The submeshes to render
  29547. */
  29548. private renderOpaqueSorted;
  29549. /**
  29550. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29551. * @param subMeshes The submeshes to render
  29552. */
  29553. private renderAlphaTestSorted;
  29554. /**
  29555. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29556. * @param subMeshes The submeshes to render
  29557. */
  29558. private renderTransparentSorted;
  29559. /**
  29560. * Renders the submeshes in a specified order.
  29561. * @param subMeshes The submeshes to sort before render
  29562. * @param sortCompareFn The comparison function use to sort
  29563. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29564. * @param transparent Specifies to activate blending if true
  29565. */
  29566. private static renderSorted;
  29567. /**
  29568. * Renders the submeshes in the order they were dispatched (no sort applied).
  29569. * @param subMeshes The submeshes to render
  29570. */
  29571. private static renderUnsorted;
  29572. /**
  29573. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29574. * are rendered back to front if in the same alpha index.
  29575. *
  29576. * @param a The first submesh
  29577. * @param b The second submesh
  29578. * @returns The result of the comparison
  29579. */
  29580. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29581. /**
  29582. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29583. * are rendered back to front.
  29584. *
  29585. * @param a The first submesh
  29586. * @param b The second submesh
  29587. * @returns The result of the comparison
  29588. */
  29589. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29590. /**
  29591. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29592. * are rendered front to back (prevent overdraw).
  29593. *
  29594. * @param a The first submesh
  29595. * @param b The second submesh
  29596. * @returns The result of the comparison
  29597. */
  29598. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29599. /**
  29600. * Resets the different lists of submeshes to prepare a new frame.
  29601. */
  29602. prepare(): void;
  29603. dispose(): void;
  29604. /**
  29605. * Inserts the submesh in its correct queue depending on its material.
  29606. * @param subMesh The submesh to dispatch
  29607. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29608. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29609. */
  29610. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29611. dispatchSprites(spriteManager: ISpriteManager): void;
  29612. dispatchParticles(particleSystem: IParticleSystem): void;
  29613. private _renderParticles;
  29614. private _renderSprites;
  29615. }
  29616. }
  29617. declare module "babylonjs/Rendering/renderingManager" {
  29618. import { Nullable } from "babylonjs/types";
  29619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29620. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29621. import { SmartArray } from "babylonjs/Misc/smartArray";
  29622. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  29623. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  29624. import { Material } from "babylonjs/Materials/material";
  29625. import { Scene } from "babylonjs/scene";
  29626. import { Camera } from "babylonjs/Cameras/camera";
  29627. /**
  29628. * Interface describing the different options available in the rendering manager
  29629. * regarding Auto Clear between groups.
  29630. */
  29631. export interface IRenderingManagerAutoClearSetup {
  29632. /**
  29633. * Defines whether or not autoclear is enable.
  29634. */
  29635. autoClear: boolean;
  29636. /**
  29637. * Defines whether or not to autoclear the depth buffer.
  29638. */
  29639. depth: boolean;
  29640. /**
  29641. * Defines whether or not to autoclear the stencil buffer.
  29642. */
  29643. stencil: boolean;
  29644. }
  29645. /**
  29646. * This class is used by the onRenderingGroupObservable
  29647. */
  29648. export class RenderingGroupInfo {
  29649. /**
  29650. * The Scene that being rendered
  29651. */
  29652. scene: Scene;
  29653. /**
  29654. * The camera currently used for the rendering pass
  29655. */
  29656. camera: Nullable<Camera>;
  29657. /**
  29658. * The ID of the renderingGroup being processed
  29659. */
  29660. renderingGroupId: number;
  29661. }
  29662. /**
  29663. * This is the manager responsible of all the rendering for meshes sprites and particles.
  29664. * It is enable to manage the different groups as well as the different necessary sort functions.
  29665. * This should not be used directly aside of the few static configurations
  29666. */
  29667. export class RenderingManager {
  29668. /**
  29669. * The max id used for rendering groups (not included)
  29670. */
  29671. static MAX_RENDERINGGROUPS: number;
  29672. /**
  29673. * The min id used for rendering groups (included)
  29674. */
  29675. static MIN_RENDERINGGROUPS: number;
  29676. /**
  29677. * Used to globally prevent autoclearing scenes.
  29678. */
  29679. static AUTOCLEAR: boolean;
  29680. /**
  29681. * @hidden
  29682. */
  29683. _useSceneAutoClearSetup: boolean;
  29684. private _scene;
  29685. private _renderingGroups;
  29686. private _depthStencilBufferAlreadyCleaned;
  29687. private _autoClearDepthStencil;
  29688. private _customOpaqueSortCompareFn;
  29689. private _customAlphaTestSortCompareFn;
  29690. private _customTransparentSortCompareFn;
  29691. private _renderingGroupInfo;
  29692. /**
  29693. * Instantiates a new rendering group for a particular scene
  29694. * @param scene Defines the scene the groups belongs to
  29695. */
  29696. constructor(scene: Scene);
  29697. private _clearDepthStencilBuffer;
  29698. /**
  29699. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  29700. * @hidden
  29701. */
  29702. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29703. /**
  29704. * Resets the different information of the group to prepare a new frame
  29705. * @hidden
  29706. */
  29707. reset(): void;
  29708. /**
  29709. * Dispose and release the group and its associated resources.
  29710. * @hidden
  29711. */
  29712. dispose(): void;
  29713. /**
  29714. * Clear the info related to rendering groups preventing retention points during dispose.
  29715. */
  29716. freeRenderingGroups(): void;
  29717. private _prepareRenderingGroup;
  29718. /**
  29719. * Add a sprite manager to the rendering manager in order to render it this frame.
  29720. * @param spriteManager Define the sprite manager to render
  29721. */
  29722. dispatchSprites(spriteManager: ISpriteManager): void;
  29723. /**
  29724. * Add a particle system to the rendering manager in order to render it this frame.
  29725. * @param particleSystem Define the particle system to render
  29726. */
  29727. dispatchParticles(particleSystem: IParticleSystem): void;
  29728. /**
  29729. * Add a submesh to the manager in order to render it this frame
  29730. * @param subMesh The submesh to dispatch
  29731. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29732. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29733. */
  29734. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29735. /**
  29736. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29737. * This allowed control for front to back rendering or reversly depending of the special needs.
  29738. *
  29739. * @param renderingGroupId The rendering group id corresponding to its index
  29740. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29741. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29742. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29743. */
  29744. 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;
  29745. /**
  29746. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29747. *
  29748. * @param renderingGroupId The rendering group id corresponding to its index
  29749. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29750. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29751. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29752. */
  29753. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29754. /**
  29755. * Gets the current auto clear configuration for one rendering group of the rendering
  29756. * manager.
  29757. * @param index the rendering group index to get the information for
  29758. * @returns The auto clear setup for the requested rendering group
  29759. */
  29760. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29761. }
  29762. }
  29763. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  29764. import { SmartArray } from "babylonjs/Misc/smartArray";
  29765. import { Nullable } from "babylonjs/types";
  29766. import { Scene } from "babylonjs/scene";
  29767. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29768. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29770. import { Mesh } from "babylonjs/Meshes/mesh";
  29771. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  29772. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29773. import { Effect } from "babylonjs/Materials/effect";
  29774. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29775. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29776. import "babylonjs/Shaders/shadowMap.fragment";
  29777. import "babylonjs/Shaders/shadowMap.vertex";
  29778. import "babylonjs/Shaders/depthBoxBlur.fragment";
  29779. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  29780. import { Observable } from "babylonjs/Misc/observable";
  29781. /**
  29782. * Defines the options associated with the creation of a custom shader for a shadow generator.
  29783. */
  29784. export interface ICustomShaderOptions {
  29785. /**
  29786. * Gets or sets the custom shader name to use
  29787. */
  29788. shaderName: string;
  29789. /**
  29790. * The list of attribute names used in the shader
  29791. */
  29792. attributes?: string[];
  29793. /**
  29794. * The list of unifrom names used in the shader
  29795. */
  29796. uniforms?: string[];
  29797. /**
  29798. * The list of sampler names used in the shader
  29799. */
  29800. samplers?: string[];
  29801. /**
  29802. * The list of defines used in the shader
  29803. */
  29804. defines?: string[];
  29805. }
  29806. /**
  29807. * Interface to implement to create a shadow generator compatible with BJS.
  29808. */
  29809. export interface IShadowGenerator {
  29810. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29811. id: string;
  29812. /**
  29813. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29814. * @returns The render target texture if present otherwise, null
  29815. */
  29816. getShadowMap(): Nullable<RenderTargetTexture>;
  29817. /**
  29818. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29819. * @param subMesh The submesh we want to render in the shadow map
  29820. * @param useInstances Defines wether will draw in the map using instances
  29821. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29822. * @returns true if ready otherwise, false
  29823. */
  29824. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29825. /**
  29826. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29827. * @param defines Defines of the material we want to update
  29828. * @param lightIndex Index of the light in the enabled light list of the material
  29829. */
  29830. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29831. /**
  29832. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29833. * defined in the generator but impacting the effect).
  29834. * It implies the unifroms available on the materials are the standard BJS ones.
  29835. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29836. * @param effect The effect we are binfing the information for
  29837. */
  29838. bindShadowLight(lightIndex: string, effect: Effect): void;
  29839. /**
  29840. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29841. * (eq to shadow prjection matrix * light transform matrix)
  29842. * @returns The transform matrix used to create the shadow map
  29843. */
  29844. getTransformMatrix(): Matrix;
  29845. /**
  29846. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29847. * Cube and 2D textures for instance.
  29848. */
  29849. recreateShadowMap(): void;
  29850. /**
  29851. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29852. * @param onCompiled Callback triggered at the and of the effects compilation
  29853. * @param options Sets of optional options forcing the compilation with different modes
  29854. */
  29855. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29856. useInstances: boolean;
  29857. }>): void;
  29858. /**
  29859. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29860. * @param options Sets of optional options forcing the compilation with different modes
  29861. * @returns A promise that resolves when the compilation completes
  29862. */
  29863. forceCompilationAsync(options?: Partial<{
  29864. useInstances: boolean;
  29865. }>): Promise<void>;
  29866. /**
  29867. * Serializes the shadow generator setup to a json object.
  29868. * @returns The serialized JSON object
  29869. */
  29870. serialize(): any;
  29871. /**
  29872. * Disposes the Shadow map and related Textures and effects.
  29873. */
  29874. dispose(): void;
  29875. }
  29876. /**
  29877. * Default implementation IShadowGenerator.
  29878. * This is the main object responsible of generating shadows in the framework.
  29879. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  29880. */
  29881. export class ShadowGenerator implements IShadowGenerator {
  29882. /**
  29883. * Name of the shadow generator class
  29884. */
  29885. static CLASSNAME: string;
  29886. /**
  29887. * Shadow generator mode None: no filtering applied.
  29888. */
  29889. static readonly FILTER_NONE: number;
  29890. /**
  29891. * Shadow generator mode ESM: Exponential Shadow Mapping.
  29892. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29893. */
  29894. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29895. /**
  29896. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  29897. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  29898. */
  29899. static readonly FILTER_POISSONSAMPLING: number;
  29900. /**
  29901. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  29902. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29903. */
  29904. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  29905. /**
  29906. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  29907. * edge artifacts on steep falloff.
  29908. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29909. */
  29910. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  29911. /**
  29912. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  29913. * edge artifacts on steep falloff.
  29914. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29915. */
  29916. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  29917. /**
  29918. * Shadow generator mode PCF: Percentage Closer Filtering
  29919. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29920. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  29921. */
  29922. static readonly FILTER_PCF: number;
  29923. /**
  29924. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  29925. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29926. * Contact Hardening
  29927. */
  29928. static readonly FILTER_PCSS: number;
  29929. /**
  29930. * Reserved for PCF and PCSS
  29931. * Highest Quality.
  29932. *
  29933. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  29934. *
  29935. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  29936. */
  29937. static readonly QUALITY_HIGH: number;
  29938. /**
  29939. * Reserved for PCF and PCSS
  29940. * Good tradeoff for quality/perf cross devices
  29941. *
  29942. * Execute PCF on a 3*3 kernel.
  29943. *
  29944. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  29945. */
  29946. static readonly QUALITY_MEDIUM: number;
  29947. /**
  29948. * Reserved for PCF and PCSS
  29949. * The lowest quality but the fastest.
  29950. *
  29951. * Execute PCF on a 1*1 kernel.
  29952. *
  29953. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  29954. */
  29955. static readonly QUALITY_LOW: number;
  29956. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29957. id: string;
  29958. /** Gets or sets the custom shader name to use */
  29959. customShaderOptions: ICustomShaderOptions;
  29960. /**
  29961. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  29962. */
  29963. onBeforeShadowMapRenderObservable: Observable<Effect>;
  29964. /**
  29965. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  29966. */
  29967. onAfterShadowMapRenderObservable: Observable<Effect>;
  29968. /**
  29969. * Observable triggered before a mesh is rendered in the shadow map.
  29970. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  29971. */
  29972. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  29973. /**
  29974. * Observable triggered after a mesh is rendered in the shadow map.
  29975. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  29976. */
  29977. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  29978. protected _bias: number;
  29979. /**
  29980. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  29981. */
  29982. get bias(): number;
  29983. /**
  29984. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  29985. */
  29986. set bias(bias: number);
  29987. protected _normalBias: number;
  29988. /**
  29989. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29990. */
  29991. get normalBias(): number;
  29992. /**
  29993. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29994. */
  29995. set normalBias(normalBias: number);
  29996. protected _blurBoxOffset: number;
  29997. /**
  29998. * Gets the blur box offset: offset applied during the blur pass.
  29999. * Only useful if useKernelBlur = false
  30000. */
  30001. get blurBoxOffset(): number;
  30002. /**
  30003. * Sets the blur box offset: offset applied during the blur pass.
  30004. * Only useful if useKernelBlur = false
  30005. */
  30006. set blurBoxOffset(value: number);
  30007. protected _blurScale: number;
  30008. /**
  30009. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  30010. * 2 means half of the size.
  30011. */
  30012. get blurScale(): number;
  30013. /**
  30014. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  30015. * 2 means half of the size.
  30016. */
  30017. set blurScale(value: number);
  30018. protected _blurKernel: number;
  30019. /**
  30020. * Gets the blur kernel: kernel size of the blur pass.
  30021. * Only useful if useKernelBlur = true
  30022. */
  30023. get blurKernel(): number;
  30024. /**
  30025. * Sets the blur kernel: kernel size of the blur pass.
  30026. * Only useful if useKernelBlur = true
  30027. */
  30028. set blurKernel(value: number);
  30029. protected _useKernelBlur: boolean;
  30030. /**
  30031. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  30032. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30033. */
  30034. get useKernelBlur(): boolean;
  30035. /**
  30036. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  30037. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30038. */
  30039. set useKernelBlur(value: boolean);
  30040. protected _depthScale: number;
  30041. /**
  30042. * Gets the depth scale used in ESM mode.
  30043. */
  30044. get depthScale(): number;
  30045. /**
  30046. * Sets the depth scale used in ESM mode.
  30047. * This can override the scale stored on the light.
  30048. */
  30049. set depthScale(value: number);
  30050. protected _validateFilter(filter: number): number;
  30051. protected _filter: number;
  30052. /**
  30053. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  30054. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30055. */
  30056. get filter(): number;
  30057. /**
  30058. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  30059. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30060. */
  30061. set filter(value: number);
  30062. /**
  30063. * Gets if the current filter is set to Poisson Sampling.
  30064. */
  30065. get usePoissonSampling(): boolean;
  30066. /**
  30067. * Sets the current filter to Poisson Sampling.
  30068. */
  30069. set usePoissonSampling(value: boolean);
  30070. /**
  30071. * Gets if the current filter is set to ESM.
  30072. */
  30073. get useExponentialShadowMap(): boolean;
  30074. /**
  30075. * Sets the current filter is to ESM.
  30076. */
  30077. set useExponentialShadowMap(value: boolean);
  30078. /**
  30079. * Gets if the current filter is set to filtered ESM.
  30080. */
  30081. get useBlurExponentialShadowMap(): boolean;
  30082. /**
  30083. * Gets if the current filter is set to filtered ESM.
  30084. */
  30085. set useBlurExponentialShadowMap(value: boolean);
  30086. /**
  30087. * Gets if the current filter is set to "close ESM" (using the inverse of the
  30088. * exponential to prevent steep falloff artifacts).
  30089. */
  30090. get useCloseExponentialShadowMap(): boolean;
  30091. /**
  30092. * Sets the current filter to "close ESM" (using the inverse of the
  30093. * exponential to prevent steep falloff artifacts).
  30094. */
  30095. set useCloseExponentialShadowMap(value: boolean);
  30096. /**
  30097. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  30098. * exponential to prevent steep falloff artifacts).
  30099. */
  30100. get useBlurCloseExponentialShadowMap(): boolean;
  30101. /**
  30102. * Sets the current filter to filtered "close ESM" (using the inverse of the
  30103. * exponential to prevent steep falloff artifacts).
  30104. */
  30105. set useBlurCloseExponentialShadowMap(value: boolean);
  30106. /**
  30107. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  30108. */
  30109. get usePercentageCloserFiltering(): boolean;
  30110. /**
  30111. * Sets the current filter to "PCF" (percentage closer filtering).
  30112. */
  30113. set usePercentageCloserFiltering(value: boolean);
  30114. protected _filteringQuality: number;
  30115. /**
  30116. * Gets the PCF or PCSS Quality.
  30117. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30118. */
  30119. get filteringQuality(): number;
  30120. /**
  30121. * Sets the PCF or PCSS Quality.
  30122. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30123. */
  30124. set filteringQuality(filteringQuality: number);
  30125. /**
  30126. * Gets if the current filter is set to "PCSS" (contact hardening).
  30127. */
  30128. get useContactHardeningShadow(): boolean;
  30129. /**
  30130. * Sets the current filter to "PCSS" (contact hardening).
  30131. */
  30132. set useContactHardeningShadow(value: boolean);
  30133. protected _contactHardeningLightSizeUVRatio: number;
  30134. /**
  30135. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30136. * Using a ratio helps keeping shape stability independently of the map size.
  30137. *
  30138. * It does not account for the light projection as it was having too much
  30139. * instability during the light setup or during light position changes.
  30140. *
  30141. * Only valid if useContactHardeningShadow is true.
  30142. */
  30143. get contactHardeningLightSizeUVRatio(): number;
  30144. /**
  30145. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30146. * Using a ratio helps keeping shape stability independently of the map size.
  30147. *
  30148. * It does not account for the light projection as it was having too much
  30149. * instability during the light setup or during light position changes.
  30150. *
  30151. * Only valid if useContactHardeningShadow is true.
  30152. */
  30153. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  30154. protected _darkness: number;
  30155. /** Gets or sets the actual darkness of a shadow */
  30156. get darkness(): number;
  30157. set darkness(value: number);
  30158. /**
  30159. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  30160. * 0 means strongest and 1 would means no shadow.
  30161. * @returns the darkness.
  30162. */
  30163. getDarkness(): number;
  30164. /**
  30165. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  30166. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  30167. * @returns the shadow generator allowing fluent coding.
  30168. */
  30169. setDarkness(darkness: number): ShadowGenerator;
  30170. protected _transparencyShadow: boolean;
  30171. /** Gets or sets the ability to have transparent shadow */
  30172. get transparencyShadow(): boolean;
  30173. set transparencyShadow(value: boolean);
  30174. /**
  30175. * Sets the ability to have transparent shadow (boolean).
  30176. * @param transparent True if transparent else False
  30177. * @returns the shadow generator allowing fluent coding
  30178. */
  30179. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  30180. /**
  30181. * Enables or disables shadows with varying strength based on the transparency
  30182. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  30183. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  30184. * mesh.visibility * alphaTexture.a
  30185. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  30186. */
  30187. enableSoftTransparentShadow: boolean;
  30188. protected _shadowMap: Nullable<RenderTargetTexture>;
  30189. protected _shadowMap2: Nullable<RenderTargetTexture>;
  30190. /**
  30191. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30192. * @returns The render target texture if present otherwise, null
  30193. */
  30194. getShadowMap(): Nullable<RenderTargetTexture>;
  30195. /**
  30196. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30197. * @returns The render target texture if the shadow map is present otherwise, null
  30198. */
  30199. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30200. /**
  30201. * Gets the class name of that object
  30202. * @returns "ShadowGenerator"
  30203. */
  30204. getClassName(): string;
  30205. /**
  30206. * Helper function to add a mesh and its descendants to the list of shadow casters.
  30207. * @param mesh Mesh to add
  30208. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  30209. * @returns the Shadow Generator itself
  30210. */
  30211. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30212. /**
  30213. * Helper function to remove a mesh and its descendants from the list of shadow casters
  30214. * @param mesh Mesh to remove
  30215. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  30216. * @returns the Shadow Generator itself
  30217. */
  30218. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30219. /**
  30220. * Controls the extent to which the shadows fade out at the edge of the frustum
  30221. */
  30222. frustumEdgeFalloff: number;
  30223. protected _light: IShadowLight;
  30224. /**
  30225. * Returns the associated light object.
  30226. * @returns the light generating the shadow
  30227. */
  30228. getLight(): IShadowLight;
  30229. /**
  30230. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  30231. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  30232. * It might on the other hand introduce peter panning.
  30233. */
  30234. forceBackFacesOnly: boolean;
  30235. protected _scene: Scene;
  30236. protected _lightDirection: Vector3;
  30237. protected _effect: Effect;
  30238. protected _viewMatrix: Matrix;
  30239. protected _projectionMatrix: Matrix;
  30240. protected _transformMatrix: Matrix;
  30241. protected _cachedPosition: Vector3;
  30242. protected _cachedDirection: Vector3;
  30243. protected _cachedDefines: string;
  30244. protected _currentRenderID: number;
  30245. protected _boxBlurPostprocess: Nullable<PostProcess>;
  30246. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  30247. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  30248. protected _blurPostProcesses: PostProcess[];
  30249. protected _mapSize: number;
  30250. protected _currentFaceIndex: number;
  30251. protected _currentFaceIndexCache: number;
  30252. protected _textureType: number;
  30253. protected _defaultTextureMatrix: Matrix;
  30254. protected _storedUniqueId: Nullable<number>;
  30255. /** @hidden */
  30256. static _SceneComponentInitialization: (scene: Scene) => void;
  30257. /**
  30258. * Gets or sets the size of the texture what stores the shadows
  30259. */
  30260. get mapSize(): number;
  30261. set mapSize(size: number);
  30262. /**
  30263. * Creates a ShadowGenerator object.
  30264. * A ShadowGenerator is the required tool to use the shadows.
  30265. * Each light casting shadows needs to use its own ShadowGenerator.
  30266. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  30267. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  30268. * @param light The light object generating the shadows.
  30269. * @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.
  30270. */
  30271. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  30272. protected _initializeGenerator(): void;
  30273. protected _createTargetRenderTexture(): void;
  30274. protected _initializeShadowMap(): void;
  30275. protected _initializeBlurRTTAndPostProcesses(): void;
  30276. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  30277. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  30278. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  30279. protected _applyFilterValues(): void;
  30280. /**
  30281. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30282. * @param onCompiled Callback triggered at the and of the effects compilation
  30283. * @param options Sets of optional options forcing the compilation with different modes
  30284. */
  30285. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  30286. useInstances: boolean;
  30287. }>): void;
  30288. /**
  30289. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30290. * @param options Sets of optional options forcing the compilation with different modes
  30291. * @returns A promise that resolves when the compilation completes
  30292. */
  30293. forceCompilationAsync(options?: Partial<{
  30294. useInstances: boolean;
  30295. }>): Promise<void>;
  30296. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  30297. private _prepareShadowDefines;
  30298. /**
  30299. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30300. * @param subMesh The submesh we want to render in the shadow map
  30301. * @param useInstances Defines wether will draw in the map using instances
  30302. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  30303. * @returns true if ready otherwise, false
  30304. */
  30305. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  30306. /**
  30307. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30308. * @param defines Defines of the material we want to update
  30309. * @param lightIndex Index of the light in the enabled light list of the material
  30310. */
  30311. prepareDefines(defines: any, lightIndex: number): void;
  30312. /**
  30313. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30314. * defined in the generator but impacting the effect).
  30315. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30316. * @param effect The effect we are binfing the information for
  30317. */
  30318. bindShadowLight(lightIndex: string, effect: Effect): void;
  30319. /**
  30320. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30321. * (eq to shadow prjection matrix * light transform matrix)
  30322. * @returns The transform matrix used to create the shadow map
  30323. */
  30324. getTransformMatrix(): Matrix;
  30325. /**
  30326. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30327. * Cube and 2D textures for instance.
  30328. */
  30329. recreateShadowMap(): void;
  30330. protected _disposeBlurPostProcesses(): void;
  30331. protected _disposeRTTandPostProcesses(): void;
  30332. /**
  30333. * Disposes the ShadowGenerator.
  30334. * Returns nothing.
  30335. */
  30336. dispose(): void;
  30337. /**
  30338. * Serializes the shadow generator setup to a json object.
  30339. * @returns The serialized JSON object
  30340. */
  30341. serialize(): any;
  30342. /**
  30343. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  30344. * @param parsedShadowGenerator The JSON object to parse
  30345. * @param scene The scene to create the shadow map for
  30346. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  30347. * @returns The parsed shadow generator
  30348. */
  30349. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  30350. }
  30351. }
  30352. declare module "babylonjs/Materials/shadowDepthWrapper" {
  30353. import { Nullable } from "babylonjs/types";
  30354. import { Scene } from "babylonjs/scene";
  30355. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30356. import { Material } from "babylonjs/Materials/material";
  30357. import { Effect } from "babylonjs/Materials/effect";
  30358. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  30359. /**
  30360. * Options to be used when creating a shadow depth material
  30361. */
  30362. export interface IIOptionShadowDepthMaterial {
  30363. /** Variables in the vertex shader code that need to have their names remapped.
  30364. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  30365. * "var_name" should be either: worldPos or vNormalW
  30366. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  30367. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  30368. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  30369. */
  30370. remappedVariables?: string[];
  30371. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  30372. standalone?: boolean;
  30373. }
  30374. /**
  30375. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  30376. */
  30377. export class ShadowDepthWrapper {
  30378. private _scene;
  30379. private _options?;
  30380. private _baseMaterial;
  30381. private _onEffectCreatedObserver;
  30382. private _subMeshToEffect;
  30383. private _subMeshToDepthEffect;
  30384. private _meshes;
  30385. /** @hidden */
  30386. _matriceNames: any;
  30387. /** Gets the standalone status of the wrapper */
  30388. get standalone(): boolean;
  30389. /** Gets the base material the wrapper is built upon */
  30390. get baseMaterial(): Material;
  30391. /**
  30392. * Instantiate a new shadow depth wrapper.
  30393. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  30394. * generate the shadow depth map. For more information, please refer to the documentation:
  30395. * https://doc.babylonjs.com/babylon101/shadows
  30396. * @param baseMaterial Material to wrap
  30397. * @param scene Define the scene the material belongs to
  30398. * @param options Options used to create the wrapper
  30399. */
  30400. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  30401. /**
  30402. * Gets the effect to use to generate the depth map
  30403. * @param subMesh subMesh to get the effect for
  30404. * @param shadowGenerator shadow generator to get the effect for
  30405. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  30406. */
  30407. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  30408. /**
  30409. * Specifies that the submesh is ready to be used for depth rendering
  30410. * @param subMesh submesh to check
  30411. * @param defines the list of defines to take into account when checking the effect
  30412. * @param shadowGenerator combined with subMesh, it defines the effect to check
  30413. * @param useInstances specifies that instances should be used
  30414. * @returns a boolean indicating that the submesh is ready or not
  30415. */
  30416. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  30417. /**
  30418. * Disposes the resources
  30419. */
  30420. dispose(): void;
  30421. private _makeEffect;
  30422. }
  30423. }
  30424. declare module "babylonjs/Materials/material" {
  30425. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30426. import { SmartArray } from "babylonjs/Misc/smartArray";
  30427. import { Observable } from "babylonjs/Misc/observable";
  30428. import { Nullable } from "babylonjs/types";
  30429. import { Scene } from "babylonjs/scene";
  30430. import { Matrix } from "babylonjs/Maths/math.vector";
  30431. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30433. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30434. import { Effect } from "babylonjs/Materials/effect";
  30435. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30436. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30437. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30438. import { IInspectable } from "babylonjs/Misc/iInspectable";
  30439. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  30440. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  30441. import { Mesh } from "babylonjs/Meshes/mesh";
  30442. import { Animation } from "babylonjs/Animations/animation";
  30443. /**
  30444. * Options for compiling materials.
  30445. */
  30446. export interface IMaterialCompilationOptions {
  30447. /**
  30448. * Defines whether clip planes are enabled.
  30449. */
  30450. clipPlane: boolean;
  30451. /**
  30452. * Defines whether instances are enabled.
  30453. */
  30454. useInstances: boolean;
  30455. }
  30456. /**
  30457. * Options passed when calling customShaderNameResolve
  30458. */
  30459. export interface ICustomShaderNameResolveOptions {
  30460. /**
  30461. * 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
  30462. */
  30463. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30464. }
  30465. /**
  30466. * Base class for the main features of a material in Babylon.js
  30467. */
  30468. export class Material implements IAnimatable {
  30469. /**
  30470. * Returns the triangle fill mode
  30471. */
  30472. static readonly TriangleFillMode: number;
  30473. /**
  30474. * Returns the wireframe mode
  30475. */
  30476. static readonly WireFrameFillMode: number;
  30477. /**
  30478. * Returns the point fill mode
  30479. */
  30480. static readonly PointFillMode: number;
  30481. /**
  30482. * Returns the point list draw mode
  30483. */
  30484. static readonly PointListDrawMode: number;
  30485. /**
  30486. * Returns the line list draw mode
  30487. */
  30488. static readonly LineListDrawMode: number;
  30489. /**
  30490. * Returns the line loop draw mode
  30491. */
  30492. static readonly LineLoopDrawMode: number;
  30493. /**
  30494. * Returns the line strip draw mode
  30495. */
  30496. static readonly LineStripDrawMode: number;
  30497. /**
  30498. * Returns the triangle strip draw mode
  30499. */
  30500. static readonly TriangleStripDrawMode: number;
  30501. /**
  30502. * Returns the triangle fan draw mode
  30503. */
  30504. static readonly TriangleFanDrawMode: number;
  30505. /**
  30506. * Stores the clock-wise side orientation
  30507. */
  30508. static readonly ClockWiseSideOrientation: number;
  30509. /**
  30510. * Stores the counter clock-wise side orientation
  30511. */
  30512. static readonly CounterClockWiseSideOrientation: number;
  30513. /**
  30514. * The dirty texture flag value
  30515. */
  30516. static readonly TextureDirtyFlag: number;
  30517. /**
  30518. * The dirty light flag value
  30519. */
  30520. static readonly LightDirtyFlag: number;
  30521. /**
  30522. * The dirty fresnel flag value
  30523. */
  30524. static readonly FresnelDirtyFlag: number;
  30525. /**
  30526. * The dirty attribute flag value
  30527. */
  30528. static readonly AttributesDirtyFlag: number;
  30529. /**
  30530. * The dirty misc flag value
  30531. */
  30532. static readonly MiscDirtyFlag: number;
  30533. /**
  30534. * The dirty prepass flag value
  30535. */
  30536. static readonly PrePassDirtyFlag: number;
  30537. /**
  30538. * The all dirty flag value
  30539. */
  30540. static readonly AllDirtyFlag: number;
  30541. /**
  30542. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30543. */
  30544. static readonly MATERIAL_OPAQUE: number;
  30545. /**
  30546. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30547. */
  30548. static readonly MATERIAL_ALPHATEST: number;
  30549. /**
  30550. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30551. */
  30552. static readonly MATERIAL_ALPHABLEND: number;
  30553. /**
  30554. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30555. * They are also discarded below the alpha cutoff threshold to improve performances.
  30556. */
  30557. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30558. /**
  30559. * The Whiteout method is used to blend normals.
  30560. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30561. */
  30562. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30563. /**
  30564. * The Reoriented Normal Mapping method is used to blend normals.
  30565. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30566. */
  30567. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30568. /**
  30569. * Custom callback helping to override the default shader used in the material.
  30570. */
  30571. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30572. /**
  30573. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30574. */
  30575. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30576. /**
  30577. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30578. * This means that the material can keep using a previous shader while a new one is being compiled.
  30579. * This is mostly used when shader parallel compilation is supported (true by default)
  30580. */
  30581. allowShaderHotSwapping: boolean;
  30582. /**
  30583. * The ID of the material
  30584. */
  30585. id: string;
  30586. /**
  30587. * Gets or sets the unique id of the material
  30588. */
  30589. uniqueId: number;
  30590. /**
  30591. * The name of the material
  30592. */
  30593. name: string;
  30594. /**
  30595. * Gets or sets user defined metadata
  30596. */
  30597. metadata: any;
  30598. /**
  30599. * For internal use only. Please do not use.
  30600. */
  30601. reservedDataStore: any;
  30602. /**
  30603. * Specifies if the ready state should be checked on each call
  30604. */
  30605. checkReadyOnEveryCall: boolean;
  30606. /**
  30607. * Specifies if the ready state should be checked once
  30608. */
  30609. checkReadyOnlyOnce: boolean;
  30610. /**
  30611. * The state of the material
  30612. */
  30613. state: string;
  30614. /**
  30615. * If the material can be rendered to several textures with MRT extension
  30616. */
  30617. get canRenderToMRT(): boolean;
  30618. /**
  30619. * The alpha value of the material
  30620. */
  30621. protected _alpha: number;
  30622. /**
  30623. * List of inspectable custom properties (used by the Inspector)
  30624. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30625. */
  30626. inspectableCustomProperties: IInspectable[];
  30627. /**
  30628. * Sets the alpha value of the material
  30629. */
  30630. set alpha(value: number);
  30631. /**
  30632. * Gets the alpha value of the material
  30633. */
  30634. get alpha(): number;
  30635. /**
  30636. * Specifies if back face culling is enabled
  30637. */
  30638. protected _backFaceCulling: boolean;
  30639. /**
  30640. * Sets the back-face culling state
  30641. */
  30642. set backFaceCulling(value: boolean);
  30643. /**
  30644. * Gets the back-face culling state
  30645. */
  30646. get backFaceCulling(): boolean;
  30647. /**
  30648. * Stores the value for side orientation
  30649. */
  30650. sideOrientation: number;
  30651. /**
  30652. * Callback triggered when the material is compiled
  30653. */
  30654. onCompiled: Nullable<(effect: Effect) => void>;
  30655. /**
  30656. * Callback triggered when an error occurs
  30657. */
  30658. onError: Nullable<(effect: Effect, errors: string) => void>;
  30659. /**
  30660. * Callback triggered to get the render target textures
  30661. */
  30662. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30663. /**
  30664. * Gets a boolean indicating that current material needs to register RTT
  30665. */
  30666. get hasRenderTargetTextures(): boolean;
  30667. /**
  30668. * Specifies if the material should be serialized
  30669. */
  30670. doNotSerialize: boolean;
  30671. /**
  30672. * @hidden
  30673. */
  30674. _storeEffectOnSubMeshes: boolean;
  30675. /**
  30676. * Stores the animations for the material
  30677. */
  30678. animations: Nullable<Array<Animation>>;
  30679. /**
  30680. * An event triggered when the material is disposed
  30681. */
  30682. onDisposeObservable: Observable<Material>;
  30683. /**
  30684. * An observer which watches for dispose events
  30685. */
  30686. private _onDisposeObserver;
  30687. private _onUnBindObservable;
  30688. /**
  30689. * Called during a dispose event
  30690. */
  30691. set onDispose(callback: () => void);
  30692. private _onBindObservable;
  30693. /**
  30694. * An event triggered when the material is bound
  30695. */
  30696. get onBindObservable(): Observable<AbstractMesh>;
  30697. /**
  30698. * An observer which watches for bind events
  30699. */
  30700. private _onBindObserver;
  30701. /**
  30702. * Called during a bind event
  30703. */
  30704. set onBind(callback: (Mesh: AbstractMesh) => void);
  30705. /**
  30706. * An event triggered when the material is unbound
  30707. */
  30708. get onUnBindObservable(): Observable<Material>;
  30709. protected _onEffectCreatedObservable: Nullable<Observable<{
  30710. effect: Effect;
  30711. subMesh: Nullable<SubMesh>;
  30712. }>>;
  30713. /**
  30714. * An event triggered when the effect is (re)created
  30715. */
  30716. get onEffectCreatedObservable(): Observable<{
  30717. effect: Effect;
  30718. subMesh: Nullable<SubMesh>;
  30719. }>;
  30720. /**
  30721. * Stores the value of the alpha mode
  30722. */
  30723. private _alphaMode;
  30724. /**
  30725. * Sets the value of the alpha mode.
  30726. *
  30727. * | Value | Type | Description |
  30728. * | --- | --- | --- |
  30729. * | 0 | ALPHA_DISABLE | |
  30730. * | 1 | ALPHA_ADD | |
  30731. * | 2 | ALPHA_COMBINE | |
  30732. * | 3 | ALPHA_SUBTRACT | |
  30733. * | 4 | ALPHA_MULTIPLY | |
  30734. * | 5 | ALPHA_MAXIMIZED | |
  30735. * | 6 | ALPHA_ONEONE | |
  30736. * | 7 | ALPHA_PREMULTIPLIED | |
  30737. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30738. * | 9 | ALPHA_INTERPOLATE | |
  30739. * | 10 | ALPHA_SCREENMODE | |
  30740. *
  30741. */
  30742. set alphaMode(value: number);
  30743. /**
  30744. * Gets the value of the alpha mode
  30745. */
  30746. get alphaMode(): number;
  30747. /**
  30748. * Stores the state of the need depth pre-pass value
  30749. */
  30750. private _needDepthPrePass;
  30751. /**
  30752. * Sets the need depth pre-pass value
  30753. */
  30754. set needDepthPrePass(value: boolean);
  30755. /**
  30756. * Gets the depth pre-pass value
  30757. */
  30758. get needDepthPrePass(): boolean;
  30759. /**
  30760. * Specifies if depth writing should be disabled
  30761. */
  30762. disableDepthWrite: boolean;
  30763. /**
  30764. * Specifies if color writing should be disabled
  30765. */
  30766. disableColorWrite: boolean;
  30767. /**
  30768. * Specifies if depth writing should be forced
  30769. */
  30770. forceDepthWrite: boolean;
  30771. /**
  30772. * Specifies the depth function that should be used. 0 means the default engine function
  30773. */
  30774. depthFunction: number;
  30775. /**
  30776. * Specifies if there should be a separate pass for culling
  30777. */
  30778. separateCullingPass: boolean;
  30779. /**
  30780. * Stores the state specifing if fog should be enabled
  30781. */
  30782. private _fogEnabled;
  30783. /**
  30784. * Sets the state for enabling fog
  30785. */
  30786. set fogEnabled(value: boolean);
  30787. /**
  30788. * Gets the value of the fog enabled state
  30789. */
  30790. get fogEnabled(): boolean;
  30791. /**
  30792. * Stores the size of points
  30793. */
  30794. pointSize: number;
  30795. /**
  30796. * Stores the z offset value
  30797. */
  30798. zOffset: number;
  30799. get wireframe(): boolean;
  30800. /**
  30801. * Sets the state of wireframe mode
  30802. */
  30803. set wireframe(value: boolean);
  30804. /**
  30805. * Gets the value specifying if point clouds are enabled
  30806. */
  30807. get pointsCloud(): boolean;
  30808. /**
  30809. * Sets the state of point cloud mode
  30810. */
  30811. set pointsCloud(value: boolean);
  30812. /**
  30813. * Gets the material fill mode
  30814. */
  30815. get fillMode(): number;
  30816. /**
  30817. * Sets the material fill mode
  30818. */
  30819. set fillMode(value: number);
  30820. /**
  30821. * @hidden
  30822. * Stores the effects for the material
  30823. */
  30824. _effect: Nullable<Effect>;
  30825. /**
  30826. * Specifies if uniform buffers should be used
  30827. */
  30828. private _useUBO;
  30829. /**
  30830. * Stores a reference to the scene
  30831. */
  30832. private _scene;
  30833. /**
  30834. * Stores the fill mode state
  30835. */
  30836. private _fillMode;
  30837. /**
  30838. * Specifies if the depth write state should be cached
  30839. */
  30840. private _cachedDepthWriteState;
  30841. /**
  30842. * Specifies if the color write state should be cached
  30843. */
  30844. private _cachedColorWriteState;
  30845. /**
  30846. * Specifies if the depth function state should be cached
  30847. */
  30848. private _cachedDepthFunctionState;
  30849. /**
  30850. * Stores the uniform buffer
  30851. */
  30852. protected _uniformBuffer: UniformBuffer;
  30853. /** @hidden */
  30854. _indexInSceneMaterialArray: number;
  30855. /** @hidden */
  30856. meshMap: Nullable<{
  30857. [id: string]: AbstractMesh | undefined;
  30858. }>;
  30859. /**
  30860. * Creates a material instance
  30861. * @param name defines the name of the material
  30862. * @param scene defines the scene to reference
  30863. * @param doNotAdd specifies if the material should be added to the scene
  30864. */
  30865. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30866. /**
  30867. * Returns a string representation of the current material
  30868. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30869. * @returns a string with material information
  30870. */
  30871. toString(fullDetails?: boolean): string;
  30872. /**
  30873. * Gets the class name of the material
  30874. * @returns a string with the class name of the material
  30875. */
  30876. getClassName(): string;
  30877. /**
  30878. * Specifies if updates for the material been locked
  30879. */
  30880. get isFrozen(): boolean;
  30881. /**
  30882. * Locks updates for the material
  30883. */
  30884. freeze(): void;
  30885. /**
  30886. * Unlocks updates for the material
  30887. */
  30888. unfreeze(): void;
  30889. /**
  30890. * Specifies if the material is ready to be used
  30891. * @param mesh defines the mesh to check
  30892. * @param useInstances specifies if instances should be used
  30893. * @returns a boolean indicating if the material is ready to be used
  30894. */
  30895. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30896. /**
  30897. * Specifies that the submesh is ready to be used
  30898. * @param mesh defines the mesh to check
  30899. * @param subMesh defines which submesh to check
  30900. * @param useInstances specifies that instances should be used
  30901. * @returns a boolean indicating that the submesh is ready or not
  30902. */
  30903. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30904. /**
  30905. * Returns the material effect
  30906. * @returns the effect associated with the material
  30907. */
  30908. getEffect(): Nullable<Effect>;
  30909. /**
  30910. * Returns the current scene
  30911. * @returns a Scene
  30912. */
  30913. getScene(): Scene;
  30914. /**
  30915. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30916. */
  30917. protected _forceAlphaTest: boolean;
  30918. /**
  30919. * The transparency mode of the material.
  30920. */
  30921. protected _transparencyMode: Nullable<number>;
  30922. /**
  30923. * Gets the current transparency mode.
  30924. */
  30925. get transparencyMode(): Nullable<number>;
  30926. /**
  30927. * Sets the transparency mode of the material.
  30928. *
  30929. * | Value | Type | Description |
  30930. * | ----- | ----------------------------------- | ----------- |
  30931. * | 0 | OPAQUE | |
  30932. * | 1 | ALPHATEST | |
  30933. * | 2 | ALPHABLEND | |
  30934. * | 3 | ALPHATESTANDBLEND | |
  30935. *
  30936. */
  30937. set transparencyMode(value: Nullable<number>);
  30938. /**
  30939. * Returns true if alpha blending should be disabled.
  30940. */
  30941. protected get _disableAlphaBlending(): boolean;
  30942. /**
  30943. * Specifies whether or not this material should be rendered in alpha blend mode.
  30944. * @returns a boolean specifying if alpha blending is needed
  30945. */
  30946. needAlphaBlending(): boolean;
  30947. /**
  30948. * Specifies if the mesh will require alpha blending
  30949. * @param mesh defines the mesh to check
  30950. * @returns a boolean specifying if alpha blending is needed for the mesh
  30951. */
  30952. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30953. /**
  30954. * Specifies whether or not this material should be rendered in alpha test mode.
  30955. * @returns a boolean specifying if an alpha test is needed.
  30956. */
  30957. needAlphaTesting(): boolean;
  30958. /**
  30959. * Specifies if material alpha testing should be turned on for the mesh
  30960. * @param mesh defines the mesh to check
  30961. */
  30962. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30963. /**
  30964. * Gets the texture used for the alpha test
  30965. * @returns the texture to use for alpha testing
  30966. */
  30967. getAlphaTestTexture(): Nullable<BaseTexture>;
  30968. /**
  30969. * Marks the material to indicate that it needs to be re-calculated
  30970. */
  30971. markDirty(): void;
  30972. /** @hidden */
  30973. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30974. /**
  30975. * Binds the material to the mesh
  30976. * @param world defines the world transformation matrix
  30977. * @param mesh defines the mesh to bind the material to
  30978. */
  30979. bind(world: Matrix, mesh?: Mesh): void;
  30980. /**
  30981. * Binds the submesh to the material
  30982. * @param world defines the world transformation matrix
  30983. * @param mesh defines the mesh containing the submesh
  30984. * @param subMesh defines the submesh to bind the material to
  30985. */
  30986. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30987. /**
  30988. * Binds the world matrix to the material
  30989. * @param world defines the world transformation matrix
  30990. */
  30991. bindOnlyWorldMatrix(world: Matrix): void;
  30992. /**
  30993. * Binds the scene's uniform buffer to the effect.
  30994. * @param effect defines the effect to bind to the scene uniform buffer
  30995. * @param sceneUbo defines the uniform buffer storing scene data
  30996. */
  30997. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30998. /**
  30999. * Binds the view matrix to the effect
  31000. * @param effect defines the effect to bind the view matrix to
  31001. */
  31002. bindView(effect: Effect): void;
  31003. /**
  31004. * Binds the view projection matrix to the effect
  31005. * @param effect defines the effect to bind the view projection matrix to
  31006. */
  31007. bindViewProjection(effect: Effect): void;
  31008. /**
  31009. * Processes to execute after binding the material to a mesh
  31010. * @param mesh defines the rendered mesh
  31011. */
  31012. protected _afterBind(mesh?: Mesh): void;
  31013. /**
  31014. * Unbinds the material from the mesh
  31015. */
  31016. unbind(): void;
  31017. /**
  31018. * Gets the active textures from the material
  31019. * @returns an array of textures
  31020. */
  31021. getActiveTextures(): BaseTexture[];
  31022. /**
  31023. * Specifies if the material uses a texture
  31024. * @param texture defines the texture to check against the material
  31025. * @returns a boolean specifying if the material uses the texture
  31026. */
  31027. hasTexture(texture: BaseTexture): boolean;
  31028. /**
  31029. * Makes a duplicate of the material, and gives it a new name
  31030. * @param name defines the new name for the duplicated material
  31031. * @returns the cloned material
  31032. */
  31033. clone(name: string): Nullable<Material>;
  31034. /**
  31035. * Gets the meshes bound to the material
  31036. * @returns an array of meshes bound to the material
  31037. */
  31038. getBindedMeshes(): AbstractMesh[];
  31039. /**
  31040. * Force shader compilation
  31041. * @param mesh defines the mesh associated with this material
  31042. * @param onCompiled defines a function to execute once the material is compiled
  31043. * @param options defines the options to configure the compilation
  31044. * @param onError defines a function to execute if the material fails compiling
  31045. */
  31046. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  31047. /**
  31048. * Force shader compilation
  31049. * @param mesh defines the mesh that will use this material
  31050. * @param options defines additional options for compiling the shaders
  31051. * @returns a promise that resolves when the compilation completes
  31052. */
  31053. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  31054. private static readonly _AllDirtyCallBack;
  31055. private static readonly _ImageProcessingDirtyCallBack;
  31056. private static readonly _TextureDirtyCallBack;
  31057. private static readonly _FresnelDirtyCallBack;
  31058. private static readonly _MiscDirtyCallBack;
  31059. private static readonly _PrePassDirtyCallBack;
  31060. private static readonly _LightsDirtyCallBack;
  31061. private static readonly _AttributeDirtyCallBack;
  31062. private static _FresnelAndMiscDirtyCallBack;
  31063. private static _TextureAndMiscDirtyCallBack;
  31064. private static readonly _DirtyCallbackArray;
  31065. private static readonly _RunDirtyCallBacks;
  31066. /**
  31067. * Marks a define in the material to indicate that it needs to be re-computed
  31068. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  31069. */
  31070. markAsDirty(flag: number): void;
  31071. /**
  31072. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  31073. * @param func defines a function which checks material defines against the submeshes
  31074. */
  31075. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  31076. /**
  31077. * Indicates that the scene should check if the rendering now needs a prepass
  31078. */
  31079. protected _markScenePrePassDirty(): void;
  31080. /**
  31081. * Indicates that we need to re-calculated for all submeshes
  31082. */
  31083. protected _markAllSubMeshesAsAllDirty(): void;
  31084. /**
  31085. * Indicates that image processing needs to be re-calculated for all submeshes
  31086. */
  31087. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  31088. /**
  31089. * Indicates that textures need to be re-calculated for all submeshes
  31090. */
  31091. protected _markAllSubMeshesAsTexturesDirty(): void;
  31092. /**
  31093. * Indicates that fresnel needs to be re-calculated for all submeshes
  31094. */
  31095. protected _markAllSubMeshesAsFresnelDirty(): void;
  31096. /**
  31097. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  31098. */
  31099. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  31100. /**
  31101. * Indicates that lights need to be re-calculated for all submeshes
  31102. */
  31103. protected _markAllSubMeshesAsLightsDirty(): void;
  31104. /**
  31105. * Indicates that attributes need to be re-calculated for all submeshes
  31106. */
  31107. protected _markAllSubMeshesAsAttributesDirty(): void;
  31108. /**
  31109. * Indicates that misc needs to be re-calculated for all submeshes
  31110. */
  31111. protected _markAllSubMeshesAsMiscDirty(): void;
  31112. /**
  31113. * Indicates that prepass needs to be re-calculated for all submeshes
  31114. */
  31115. protected _markAllSubMeshesAsPrePassDirty(): void;
  31116. /**
  31117. * Indicates that textures and misc need to be re-calculated for all submeshes
  31118. */
  31119. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  31120. /**
  31121. * Sets the required values to the prepass renderer.
  31122. * @param prePassRenderer defines the prepass renderer to setup.
  31123. * @returns true if the pre pass is needed.
  31124. */
  31125. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  31126. /**
  31127. * Disposes the material
  31128. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31129. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31130. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  31131. */
  31132. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  31133. /** @hidden */
  31134. private releaseVertexArrayObject;
  31135. /**
  31136. * Serializes this material
  31137. * @returns the serialized material object
  31138. */
  31139. serialize(): any;
  31140. /**
  31141. * Creates a material from parsed material data
  31142. * @param parsedMaterial defines parsed material data
  31143. * @param scene defines the hosting scene
  31144. * @param rootUrl defines the root URL to use to load textures
  31145. * @returns a new material
  31146. */
  31147. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  31148. }
  31149. }
  31150. declare module "babylonjs/Materials/multiMaterial" {
  31151. import { Nullable } from "babylonjs/types";
  31152. import { Scene } from "babylonjs/scene";
  31153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31154. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31155. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31156. import { Material } from "babylonjs/Materials/material";
  31157. /**
  31158. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31159. * separate meshes. This can be use to improve performances.
  31160. * @see https://doc.babylonjs.com/how_to/multi_materials
  31161. */
  31162. export class MultiMaterial extends Material {
  31163. private _subMaterials;
  31164. /**
  31165. * Gets or Sets the list of Materials used within the multi material.
  31166. * They need to be ordered according to the submeshes order in the associated mesh
  31167. */
  31168. get subMaterials(): Nullable<Material>[];
  31169. set subMaterials(value: Nullable<Material>[]);
  31170. /**
  31171. * Function used to align with Node.getChildren()
  31172. * @returns the list of Materials used within the multi material
  31173. */
  31174. getChildren(): Nullable<Material>[];
  31175. /**
  31176. * Instantiates a new Multi Material
  31177. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31178. * separate meshes. This can be use to improve performances.
  31179. * @see https://doc.babylonjs.com/how_to/multi_materials
  31180. * @param name Define the name in the scene
  31181. * @param scene Define the scene the material belongs to
  31182. */
  31183. constructor(name: string, scene: Scene);
  31184. private _hookArray;
  31185. /**
  31186. * Get one of the submaterial by its index in the submaterials array
  31187. * @param index The index to look the sub material at
  31188. * @returns The Material if the index has been defined
  31189. */
  31190. getSubMaterial(index: number): Nullable<Material>;
  31191. /**
  31192. * Get the list of active textures for the whole sub materials list.
  31193. * @returns All the textures that will be used during the rendering
  31194. */
  31195. getActiveTextures(): BaseTexture[];
  31196. /**
  31197. * Gets the current class name of the material e.g. "MultiMaterial"
  31198. * Mainly use in serialization.
  31199. * @returns the class name
  31200. */
  31201. getClassName(): string;
  31202. /**
  31203. * Checks if the material is ready to render the requested sub mesh
  31204. * @param mesh Define the mesh the submesh belongs to
  31205. * @param subMesh Define the sub mesh to look readyness for
  31206. * @param useInstances Define whether or not the material is used with instances
  31207. * @returns true if ready, otherwise false
  31208. */
  31209. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31210. /**
  31211. * Clones the current material and its related sub materials
  31212. * @param name Define the name of the newly cloned material
  31213. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  31214. * @returns the cloned material
  31215. */
  31216. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  31217. /**
  31218. * Serializes the materials into a JSON representation.
  31219. * @returns the JSON representation
  31220. */
  31221. serialize(): any;
  31222. /**
  31223. * Dispose the material and release its associated resources
  31224. * @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)
  31225. * @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)
  31226. * @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)
  31227. */
  31228. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  31229. /**
  31230. * Creates a MultiMaterial from parsed MultiMaterial data.
  31231. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  31232. * @param scene defines the hosting scene
  31233. * @returns a new MultiMaterial
  31234. */
  31235. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  31236. }
  31237. }
  31238. declare module "babylonjs/Meshes/subMesh" {
  31239. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  31240. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  31241. import { Engine } from "babylonjs/Engines/engine";
  31242. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  31243. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31244. import { Effect } from "babylonjs/Materials/effect";
  31245. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31246. import { Plane } from "babylonjs/Maths/math.plane";
  31247. import { Collider } from "babylonjs/Collisions/collider";
  31248. import { Material } from "babylonjs/Materials/material";
  31249. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31251. import { Mesh } from "babylonjs/Meshes/mesh";
  31252. import { Ray } from "babylonjs/Culling/ray";
  31253. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31254. /**
  31255. * Defines a subdivision inside a mesh
  31256. */
  31257. export class SubMesh implements ICullable {
  31258. /** the material index to use */
  31259. materialIndex: number;
  31260. /** vertex index start */
  31261. verticesStart: number;
  31262. /** vertices count */
  31263. verticesCount: number;
  31264. /** index start */
  31265. indexStart: number;
  31266. /** indices count */
  31267. indexCount: number;
  31268. /** @hidden */
  31269. _materialDefines: Nullable<MaterialDefines>;
  31270. /** @hidden */
  31271. _materialEffect: Nullable<Effect>;
  31272. /** @hidden */
  31273. _effectOverride: Nullable<Effect>;
  31274. /**
  31275. * Gets material defines used by the effect associated to the sub mesh
  31276. */
  31277. get materialDefines(): Nullable<MaterialDefines>;
  31278. /**
  31279. * Sets material defines used by the effect associated to the sub mesh
  31280. */
  31281. set materialDefines(defines: Nullable<MaterialDefines>);
  31282. /**
  31283. * Gets associated effect
  31284. */
  31285. get effect(): Nullable<Effect>;
  31286. /**
  31287. * Sets associated effect (effect used to render this submesh)
  31288. * @param effect defines the effect to associate with
  31289. * @param defines defines the set of defines used to compile this effect
  31290. */
  31291. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  31292. /** @hidden */
  31293. _linesIndexCount: number;
  31294. private _mesh;
  31295. private _renderingMesh;
  31296. private _boundingInfo;
  31297. private _linesIndexBuffer;
  31298. /** @hidden */
  31299. _lastColliderWorldVertices: Nullable<Vector3[]>;
  31300. /** @hidden */
  31301. _trianglePlanes: Plane[];
  31302. /** @hidden */
  31303. _lastColliderTransformMatrix: Nullable<Matrix>;
  31304. /** @hidden */
  31305. _renderId: number;
  31306. /** @hidden */
  31307. _alphaIndex: number;
  31308. /** @hidden */
  31309. _distanceToCamera: number;
  31310. /** @hidden */
  31311. _id: number;
  31312. private _currentMaterial;
  31313. /**
  31314. * Add a new submesh to a mesh
  31315. * @param materialIndex defines the material index to use
  31316. * @param verticesStart defines vertex index start
  31317. * @param verticesCount defines vertices count
  31318. * @param indexStart defines index start
  31319. * @param indexCount defines indices count
  31320. * @param mesh defines the parent mesh
  31321. * @param renderingMesh defines an optional rendering mesh
  31322. * @param createBoundingBox defines if bounding box should be created for this submesh
  31323. * @returns the new submesh
  31324. */
  31325. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  31326. /**
  31327. * Creates a new submesh
  31328. * @param materialIndex defines the material index to use
  31329. * @param verticesStart defines vertex index start
  31330. * @param verticesCount defines vertices count
  31331. * @param indexStart defines index start
  31332. * @param indexCount defines indices count
  31333. * @param mesh defines the parent mesh
  31334. * @param renderingMesh defines an optional rendering mesh
  31335. * @param createBoundingBox defines if bounding box should be created for this submesh
  31336. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  31337. */
  31338. constructor(
  31339. /** the material index to use */
  31340. materialIndex: number,
  31341. /** vertex index start */
  31342. verticesStart: number,
  31343. /** vertices count */
  31344. verticesCount: number,
  31345. /** index start */
  31346. indexStart: number,
  31347. /** indices count */
  31348. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  31349. /**
  31350. * Returns true if this submesh covers the entire parent mesh
  31351. * @ignorenaming
  31352. */
  31353. get IsGlobal(): boolean;
  31354. /**
  31355. * Returns the submesh BoudingInfo object
  31356. * @returns current bounding info (or mesh's one if the submesh is global)
  31357. */
  31358. getBoundingInfo(): BoundingInfo;
  31359. /**
  31360. * Sets the submesh BoundingInfo
  31361. * @param boundingInfo defines the new bounding info to use
  31362. * @returns the SubMesh
  31363. */
  31364. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  31365. /**
  31366. * Returns the mesh of the current submesh
  31367. * @return the parent mesh
  31368. */
  31369. getMesh(): AbstractMesh;
  31370. /**
  31371. * Returns the rendering mesh of the submesh
  31372. * @returns the rendering mesh (could be different from parent mesh)
  31373. */
  31374. getRenderingMesh(): Mesh;
  31375. /**
  31376. * Returns the replacement mesh of the submesh
  31377. * @returns the replacement mesh (could be different from parent mesh)
  31378. */
  31379. getReplacementMesh(): Nullable<AbstractMesh>;
  31380. /**
  31381. * Returns the effective mesh of the submesh
  31382. * @returns the effective mesh (could be different from parent mesh)
  31383. */
  31384. getEffectiveMesh(): AbstractMesh;
  31385. /**
  31386. * Returns the submesh material
  31387. * @returns null or the current material
  31388. */
  31389. getMaterial(): Nullable<Material>;
  31390. private _IsMultiMaterial;
  31391. /**
  31392. * Sets a new updated BoundingInfo object to the submesh
  31393. * @param data defines an optional position array to use to determine the bounding info
  31394. * @returns the SubMesh
  31395. */
  31396. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  31397. /** @hidden */
  31398. _checkCollision(collider: Collider): boolean;
  31399. /**
  31400. * Updates the submesh BoundingInfo
  31401. * @param world defines the world matrix to use to update the bounding info
  31402. * @returns the submesh
  31403. */
  31404. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  31405. /**
  31406. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  31407. * @param frustumPlanes defines the frustum planes
  31408. * @returns true if the submesh is intersecting with the frustum
  31409. */
  31410. isInFrustum(frustumPlanes: Plane[]): boolean;
  31411. /**
  31412. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  31413. * @param frustumPlanes defines the frustum planes
  31414. * @returns true if the submesh is inside the frustum
  31415. */
  31416. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31417. /**
  31418. * Renders the submesh
  31419. * @param enableAlphaMode defines if alpha needs to be used
  31420. * @returns the submesh
  31421. */
  31422. render(enableAlphaMode: boolean): SubMesh;
  31423. /**
  31424. * @hidden
  31425. */
  31426. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  31427. /**
  31428. * Checks if the submesh intersects with a ray
  31429. * @param ray defines the ray to test
  31430. * @returns true is the passed ray intersects the submesh bounding box
  31431. */
  31432. canIntersects(ray: Ray): boolean;
  31433. /**
  31434. * Intersects current submesh with a ray
  31435. * @param ray defines the ray to test
  31436. * @param positions defines mesh's positions array
  31437. * @param indices defines mesh's indices array
  31438. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31439. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31440. * @returns intersection info or null if no intersection
  31441. */
  31442. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31443. /** @hidden */
  31444. private _intersectLines;
  31445. /** @hidden */
  31446. private _intersectUnIndexedLines;
  31447. /** @hidden */
  31448. private _intersectTriangles;
  31449. /** @hidden */
  31450. private _intersectUnIndexedTriangles;
  31451. /** @hidden */
  31452. _rebuild(): void;
  31453. /**
  31454. * Creates a new submesh from the passed mesh
  31455. * @param newMesh defines the new hosting mesh
  31456. * @param newRenderingMesh defines an optional rendering mesh
  31457. * @returns the new submesh
  31458. */
  31459. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31460. /**
  31461. * Release associated resources
  31462. */
  31463. dispose(): void;
  31464. /**
  31465. * Gets the class name
  31466. * @returns the string "SubMesh".
  31467. */
  31468. getClassName(): string;
  31469. /**
  31470. * Creates a new submesh from indices data
  31471. * @param materialIndex the index of the main mesh material
  31472. * @param startIndex the index where to start the copy in the mesh indices array
  31473. * @param indexCount the number of indices to copy then from the startIndex
  31474. * @param mesh the main mesh to create the submesh from
  31475. * @param renderingMesh the optional rendering mesh
  31476. * @returns a new submesh
  31477. */
  31478. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31479. }
  31480. }
  31481. declare module "babylonjs/Loading/sceneLoaderFlags" {
  31482. /**
  31483. * Class used to represent data loading progression
  31484. */
  31485. export class SceneLoaderFlags {
  31486. private static _ForceFullSceneLoadingForIncremental;
  31487. private static _ShowLoadingScreen;
  31488. private static _CleanBoneMatrixWeights;
  31489. private static _loggingLevel;
  31490. /**
  31491. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31492. */
  31493. static get ForceFullSceneLoadingForIncremental(): boolean;
  31494. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31495. /**
  31496. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31497. */
  31498. static get ShowLoadingScreen(): boolean;
  31499. static set ShowLoadingScreen(value: boolean);
  31500. /**
  31501. * Defines the current logging level (while loading the scene)
  31502. * @ignorenaming
  31503. */
  31504. static get loggingLevel(): number;
  31505. static set loggingLevel(value: number);
  31506. /**
  31507. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31508. */
  31509. static get CleanBoneMatrixWeights(): boolean;
  31510. static set CleanBoneMatrixWeights(value: boolean);
  31511. }
  31512. }
  31513. declare module "babylonjs/Meshes/geometry" {
  31514. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  31515. import { Scene } from "babylonjs/scene";
  31516. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31517. import { Engine } from "babylonjs/Engines/engine";
  31518. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  31519. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31520. import { Effect } from "babylonjs/Materials/effect";
  31521. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31522. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31523. import { Mesh } from "babylonjs/Meshes/mesh";
  31524. /**
  31525. * Class used to store geometry data (vertex buffers + index buffer)
  31526. */
  31527. export class Geometry implements IGetSetVerticesData {
  31528. /**
  31529. * Gets or sets the ID of the geometry
  31530. */
  31531. id: string;
  31532. /**
  31533. * Gets or sets the unique ID of the geometry
  31534. */
  31535. uniqueId: number;
  31536. /**
  31537. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31538. */
  31539. delayLoadState: number;
  31540. /**
  31541. * Gets the file containing the data to load when running in delay load state
  31542. */
  31543. delayLoadingFile: Nullable<string>;
  31544. /**
  31545. * Callback called when the geometry is updated
  31546. */
  31547. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31548. private _scene;
  31549. private _engine;
  31550. private _meshes;
  31551. private _totalVertices;
  31552. /** @hidden */
  31553. _indices: IndicesArray;
  31554. /** @hidden */
  31555. _vertexBuffers: {
  31556. [key: string]: VertexBuffer;
  31557. };
  31558. private _isDisposed;
  31559. private _extend;
  31560. private _boundingBias;
  31561. /** @hidden */
  31562. _delayInfo: Array<string>;
  31563. private _indexBuffer;
  31564. private _indexBufferIsUpdatable;
  31565. /** @hidden */
  31566. _boundingInfo: Nullable<BoundingInfo>;
  31567. /** @hidden */
  31568. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31569. /** @hidden */
  31570. _softwareSkinningFrameId: number;
  31571. private _vertexArrayObjects;
  31572. private _updatable;
  31573. /** @hidden */
  31574. _positions: Nullable<Vector3[]>;
  31575. private _positionsCache;
  31576. /**
  31577. * 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
  31578. */
  31579. get boundingBias(): Vector2;
  31580. /**
  31581. * 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
  31582. */
  31583. set boundingBias(value: Vector2);
  31584. /**
  31585. * Static function used to attach a new empty geometry to a mesh
  31586. * @param mesh defines the mesh to attach the geometry to
  31587. * @returns the new Geometry
  31588. */
  31589. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31590. /** Get the list of meshes using this geometry */
  31591. get meshes(): Mesh[];
  31592. /**
  31593. * 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
  31594. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31595. */
  31596. useBoundingInfoFromGeometry: boolean;
  31597. /**
  31598. * Creates a new geometry
  31599. * @param id defines the unique ID
  31600. * @param scene defines the hosting scene
  31601. * @param vertexData defines the VertexData used to get geometry data
  31602. * @param updatable defines if geometry must be updatable (false by default)
  31603. * @param mesh defines the mesh that will be associated with the geometry
  31604. */
  31605. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31606. /**
  31607. * Gets the current extend of the geometry
  31608. */
  31609. get extend(): {
  31610. minimum: Vector3;
  31611. maximum: Vector3;
  31612. };
  31613. /**
  31614. * Gets the hosting scene
  31615. * @returns the hosting Scene
  31616. */
  31617. getScene(): Scene;
  31618. /**
  31619. * Gets the hosting engine
  31620. * @returns the hosting Engine
  31621. */
  31622. getEngine(): Engine;
  31623. /**
  31624. * Defines if the geometry is ready to use
  31625. * @returns true if the geometry is ready to be used
  31626. */
  31627. isReady(): boolean;
  31628. /**
  31629. * Gets a value indicating that the geometry should not be serialized
  31630. */
  31631. get doNotSerialize(): boolean;
  31632. /** @hidden */
  31633. _rebuild(): void;
  31634. /**
  31635. * Affects all geometry data in one call
  31636. * @param vertexData defines the geometry data
  31637. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31638. */
  31639. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31640. /**
  31641. * Set specific vertex data
  31642. * @param kind defines the data kind (Position, normal, etc...)
  31643. * @param data defines the vertex data to use
  31644. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31645. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31646. */
  31647. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31648. /**
  31649. * Removes a specific vertex data
  31650. * @param kind defines the data kind (Position, normal, etc...)
  31651. */
  31652. removeVerticesData(kind: string): void;
  31653. /**
  31654. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31655. * @param buffer defines the vertex buffer to use
  31656. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31657. */
  31658. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31659. /**
  31660. * Update a specific vertex buffer
  31661. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31662. * It will do nothing if the buffer is not updatable
  31663. * @param kind defines the data kind (Position, normal, etc...)
  31664. * @param data defines the data to use
  31665. * @param offset defines the offset in the target buffer where to store the data
  31666. * @param useBytes set to true if the offset is in bytes
  31667. */
  31668. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31669. /**
  31670. * Update a specific vertex buffer
  31671. * This function will create a new buffer if the current one is not updatable
  31672. * @param kind defines the data kind (Position, normal, etc...)
  31673. * @param data defines the data to use
  31674. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31675. */
  31676. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31677. private _updateBoundingInfo;
  31678. /** @hidden */
  31679. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31680. /**
  31681. * Gets total number of vertices
  31682. * @returns the total number of vertices
  31683. */
  31684. getTotalVertices(): number;
  31685. /**
  31686. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31687. * @param kind defines the data kind (Position, normal, etc...)
  31688. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31689. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31690. * @returns a float array containing vertex data
  31691. */
  31692. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31693. /**
  31694. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31695. * @param kind defines the data kind (Position, normal, etc...)
  31696. * @returns true if the vertex buffer with the specified kind is updatable
  31697. */
  31698. isVertexBufferUpdatable(kind: string): boolean;
  31699. /**
  31700. * Gets a specific vertex buffer
  31701. * @param kind defines the data kind (Position, normal, etc...)
  31702. * @returns a VertexBuffer
  31703. */
  31704. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31705. /**
  31706. * Returns all vertex buffers
  31707. * @return an object holding all vertex buffers indexed by kind
  31708. */
  31709. getVertexBuffers(): Nullable<{
  31710. [key: string]: VertexBuffer;
  31711. }>;
  31712. /**
  31713. * Gets a boolean indicating if specific vertex buffer is present
  31714. * @param kind defines the data kind (Position, normal, etc...)
  31715. * @returns true if data is present
  31716. */
  31717. isVerticesDataPresent(kind: string): boolean;
  31718. /**
  31719. * Gets a list of all attached data kinds (Position, normal, etc...)
  31720. * @returns a list of string containing all kinds
  31721. */
  31722. getVerticesDataKinds(): string[];
  31723. /**
  31724. * Update index buffer
  31725. * @param indices defines the indices to store in the index buffer
  31726. * @param offset defines the offset in the target buffer where to store the data
  31727. * @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)
  31728. */
  31729. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31730. /**
  31731. * Creates a new index buffer
  31732. * @param indices defines the indices to store in the index buffer
  31733. * @param totalVertices defines the total number of vertices (could be null)
  31734. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31735. */
  31736. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31737. /**
  31738. * Return the total number of indices
  31739. * @returns the total number of indices
  31740. */
  31741. getTotalIndices(): number;
  31742. /**
  31743. * Gets the index buffer array
  31744. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31745. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31746. * @returns the index buffer array
  31747. */
  31748. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31749. /**
  31750. * Gets the index buffer
  31751. * @return the index buffer
  31752. */
  31753. getIndexBuffer(): Nullable<DataBuffer>;
  31754. /** @hidden */
  31755. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31756. /**
  31757. * Release the associated resources for a specific mesh
  31758. * @param mesh defines the source mesh
  31759. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31760. */
  31761. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31762. /**
  31763. * Apply current geometry to a given mesh
  31764. * @param mesh defines the mesh to apply geometry to
  31765. */
  31766. applyToMesh(mesh: Mesh): void;
  31767. private _updateExtend;
  31768. private _applyToMesh;
  31769. private notifyUpdate;
  31770. /**
  31771. * Load the geometry if it was flagged as delay loaded
  31772. * @param scene defines the hosting scene
  31773. * @param onLoaded defines a callback called when the geometry is loaded
  31774. */
  31775. load(scene: Scene, onLoaded?: () => void): void;
  31776. private _queueLoad;
  31777. /**
  31778. * Invert the geometry to move from a right handed system to a left handed one.
  31779. */
  31780. toLeftHanded(): void;
  31781. /** @hidden */
  31782. _resetPointsArrayCache(): void;
  31783. /** @hidden */
  31784. _generatePointsArray(): boolean;
  31785. /**
  31786. * Gets a value indicating if the geometry is disposed
  31787. * @returns true if the geometry was disposed
  31788. */
  31789. isDisposed(): boolean;
  31790. private _disposeVertexArrayObjects;
  31791. /**
  31792. * Free all associated resources
  31793. */
  31794. dispose(): void;
  31795. /**
  31796. * Clone the current geometry into a new geometry
  31797. * @param id defines the unique ID of the new geometry
  31798. * @returns a new geometry object
  31799. */
  31800. copy(id: string): Geometry;
  31801. /**
  31802. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31803. * @return a JSON representation of the current geometry data (without the vertices data)
  31804. */
  31805. serialize(): any;
  31806. private toNumberArray;
  31807. /**
  31808. * Serialize all vertices data into a JSON oject
  31809. * @returns a JSON representation of the current geometry data
  31810. */
  31811. serializeVerticeData(): any;
  31812. /**
  31813. * Extracts a clone of a mesh geometry
  31814. * @param mesh defines the source mesh
  31815. * @param id defines the unique ID of the new geometry object
  31816. * @returns the new geometry object
  31817. */
  31818. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31819. /**
  31820. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31821. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31822. * Be aware Math.random() could cause collisions, but:
  31823. * "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"
  31824. * @returns a string containing a new GUID
  31825. */
  31826. static RandomId(): string;
  31827. /** @hidden */
  31828. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31829. private static _CleanMatricesWeights;
  31830. /**
  31831. * Create a new geometry from persisted data (Using .babylon file format)
  31832. * @param parsedVertexData defines the persisted data
  31833. * @param scene defines the hosting scene
  31834. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31835. * @returns the new geometry object
  31836. */
  31837. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31838. }
  31839. }
  31840. declare module "babylonjs/Morph/morphTarget" {
  31841. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31842. import { Observable } from "babylonjs/Misc/observable";
  31843. import { Nullable, FloatArray } from "babylonjs/types";
  31844. import { Scene } from "babylonjs/scene";
  31845. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31846. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31847. /**
  31848. * Defines a target to use with MorphTargetManager
  31849. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31850. */
  31851. export class MorphTarget implements IAnimatable {
  31852. /** defines the name of the target */
  31853. name: string;
  31854. /**
  31855. * Gets or sets the list of animations
  31856. */
  31857. animations: import("babylonjs/Animations/animation").Animation[];
  31858. private _scene;
  31859. private _positions;
  31860. private _normals;
  31861. private _tangents;
  31862. private _uvs;
  31863. private _influence;
  31864. private _uniqueId;
  31865. /**
  31866. * Observable raised when the influence changes
  31867. */
  31868. onInfluenceChanged: Observable<boolean>;
  31869. /** @hidden */
  31870. _onDataLayoutChanged: Observable<void>;
  31871. /**
  31872. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31873. */
  31874. get influence(): number;
  31875. set influence(influence: number);
  31876. /**
  31877. * Gets or sets the id of the morph Target
  31878. */
  31879. id: string;
  31880. private _animationPropertiesOverride;
  31881. /**
  31882. * Gets or sets the animation properties override
  31883. */
  31884. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31885. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31886. /**
  31887. * Creates a new MorphTarget
  31888. * @param name defines the name of the target
  31889. * @param influence defines the influence to use
  31890. * @param scene defines the scene the morphtarget belongs to
  31891. */
  31892. constructor(
  31893. /** defines the name of the target */
  31894. name: string, influence?: number, scene?: Nullable<Scene>);
  31895. /**
  31896. * Gets the unique ID of this manager
  31897. */
  31898. get uniqueId(): number;
  31899. /**
  31900. * Gets a boolean defining if the target contains position data
  31901. */
  31902. get hasPositions(): boolean;
  31903. /**
  31904. * Gets a boolean defining if the target contains normal data
  31905. */
  31906. get hasNormals(): boolean;
  31907. /**
  31908. * Gets a boolean defining if the target contains tangent data
  31909. */
  31910. get hasTangents(): boolean;
  31911. /**
  31912. * Gets a boolean defining if the target contains texture coordinates data
  31913. */
  31914. get hasUVs(): boolean;
  31915. /**
  31916. * Affects position data to this target
  31917. * @param data defines the position data to use
  31918. */
  31919. setPositions(data: Nullable<FloatArray>): void;
  31920. /**
  31921. * Gets the position data stored in this target
  31922. * @returns a FloatArray containing the position data (or null if not present)
  31923. */
  31924. getPositions(): Nullable<FloatArray>;
  31925. /**
  31926. * Affects normal data to this target
  31927. * @param data defines the normal data to use
  31928. */
  31929. setNormals(data: Nullable<FloatArray>): void;
  31930. /**
  31931. * Gets the normal data stored in this target
  31932. * @returns a FloatArray containing the normal data (or null if not present)
  31933. */
  31934. getNormals(): Nullable<FloatArray>;
  31935. /**
  31936. * Affects tangent data to this target
  31937. * @param data defines the tangent data to use
  31938. */
  31939. setTangents(data: Nullable<FloatArray>): void;
  31940. /**
  31941. * Gets the tangent data stored in this target
  31942. * @returns a FloatArray containing the tangent data (or null if not present)
  31943. */
  31944. getTangents(): Nullable<FloatArray>;
  31945. /**
  31946. * Affects texture coordinates data to this target
  31947. * @param data defines the texture coordinates data to use
  31948. */
  31949. setUVs(data: Nullable<FloatArray>): void;
  31950. /**
  31951. * Gets the texture coordinates data stored in this target
  31952. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31953. */
  31954. getUVs(): Nullable<FloatArray>;
  31955. /**
  31956. * Clone the current target
  31957. * @returns a new MorphTarget
  31958. */
  31959. clone(): MorphTarget;
  31960. /**
  31961. * Serializes the current target into a Serialization object
  31962. * @returns the serialized object
  31963. */
  31964. serialize(): any;
  31965. /**
  31966. * Returns the string "MorphTarget"
  31967. * @returns "MorphTarget"
  31968. */
  31969. getClassName(): string;
  31970. /**
  31971. * Creates a new target from serialized data
  31972. * @param serializationObject defines the serialized data to use
  31973. * @returns a new MorphTarget
  31974. */
  31975. static Parse(serializationObject: any): MorphTarget;
  31976. /**
  31977. * Creates a MorphTarget from mesh data
  31978. * @param mesh defines the source mesh
  31979. * @param name defines the name to use for the new target
  31980. * @param influence defines the influence to attach to the target
  31981. * @returns a new MorphTarget
  31982. */
  31983. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31984. }
  31985. }
  31986. declare module "babylonjs/Morph/morphTargetManager" {
  31987. import { Nullable } from "babylonjs/types";
  31988. import { Scene } from "babylonjs/scene";
  31989. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31990. /**
  31991. * This class is used to deform meshes using morphing between different targets
  31992. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31993. */
  31994. export class MorphTargetManager {
  31995. private _targets;
  31996. private _targetInfluenceChangedObservers;
  31997. private _targetDataLayoutChangedObservers;
  31998. private _activeTargets;
  31999. private _scene;
  32000. private _influences;
  32001. private _supportsNormals;
  32002. private _supportsTangents;
  32003. private _supportsUVs;
  32004. private _vertexCount;
  32005. private _uniqueId;
  32006. private _tempInfluences;
  32007. /**
  32008. * Gets or sets a boolean indicating if normals must be morphed
  32009. */
  32010. enableNormalMorphing: boolean;
  32011. /**
  32012. * Gets or sets a boolean indicating if tangents must be morphed
  32013. */
  32014. enableTangentMorphing: boolean;
  32015. /**
  32016. * Gets or sets a boolean indicating if UV must be morphed
  32017. */
  32018. enableUVMorphing: boolean;
  32019. /**
  32020. * Creates a new MorphTargetManager
  32021. * @param scene defines the current scene
  32022. */
  32023. constructor(scene?: Nullable<Scene>);
  32024. /**
  32025. * Gets the unique ID of this manager
  32026. */
  32027. get uniqueId(): number;
  32028. /**
  32029. * Gets the number of vertices handled by this manager
  32030. */
  32031. get vertexCount(): number;
  32032. /**
  32033. * Gets a boolean indicating if this manager supports morphing of normals
  32034. */
  32035. get supportsNormals(): boolean;
  32036. /**
  32037. * Gets a boolean indicating if this manager supports morphing of tangents
  32038. */
  32039. get supportsTangents(): boolean;
  32040. /**
  32041. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32042. */
  32043. get supportsUVs(): boolean;
  32044. /**
  32045. * Gets the number of targets stored in this manager
  32046. */
  32047. get numTargets(): number;
  32048. /**
  32049. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32050. */
  32051. get numInfluencers(): number;
  32052. /**
  32053. * Gets the list of influences (one per target)
  32054. */
  32055. get influences(): Float32Array;
  32056. /**
  32057. * Gets the active target at specified index. An active target is a target with an influence > 0
  32058. * @param index defines the index to check
  32059. * @returns the requested target
  32060. */
  32061. getActiveTarget(index: number): MorphTarget;
  32062. /**
  32063. * Gets the target at specified index
  32064. * @param index defines the index to check
  32065. * @returns the requested target
  32066. */
  32067. getTarget(index: number): MorphTarget;
  32068. /**
  32069. * Add a new target to this manager
  32070. * @param target defines the target to add
  32071. */
  32072. addTarget(target: MorphTarget): void;
  32073. /**
  32074. * Removes a target from the manager
  32075. * @param target defines the target to remove
  32076. */
  32077. removeTarget(target: MorphTarget): void;
  32078. /**
  32079. * Clone the current manager
  32080. * @returns a new MorphTargetManager
  32081. */
  32082. clone(): MorphTargetManager;
  32083. /**
  32084. * Serializes the current manager into a Serialization object
  32085. * @returns the serialized object
  32086. */
  32087. serialize(): any;
  32088. private _syncActiveTargets;
  32089. /**
  32090. * Syncrhonize the targets with all the meshes using this morph target manager
  32091. */
  32092. synchronize(): void;
  32093. /**
  32094. * Creates a new MorphTargetManager from serialized data
  32095. * @param serializationObject defines the serialized data
  32096. * @param scene defines the hosting scene
  32097. * @returns the new MorphTargetManager
  32098. */
  32099. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32100. }
  32101. }
  32102. declare module "babylonjs/Meshes/meshLODLevel" {
  32103. import { Mesh } from "babylonjs/Meshes/mesh";
  32104. import { Nullable } from "babylonjs/types";
  32105. /**
  32106. * Class used to represent a specific level of detail of a mesh
  32107. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32108. */
  32109. export class MeshLODLevel {
  32110. /** Defines the distance where this level should start being displayed */
  32111. distance: number;
  32112. /** Defines the mesh to use to render this level */
  32113. mesh: Nullable<Mesh>;
  32114. /**
  32115. * Creates a new LOD level
  32116. * @param distance defines the distance where this level should star being displayed
  32117. * @param mesh defines the mesh to use to render this level
  32118. */
  32119. constructor(
  32120. /** Defines the distance where this level should start being displayed */
  32121. distance: number,
  32122. /** Defines the mesh to use to render this level */
  32123. mesh: Nullable<Mesh>);
  32124. }
  32125. }
  32126. declare module "babylonjs/Misc/canvasGenerator" {
  32127. /**
  32128. * Helper class used to generate a canvas to manipulate images
  32129. */
  32130. export class CanvasGenerator {
  32131. /**
  32132. * Create a new canvas (or offscreen canvas depending on the context)
  32133. * @param width defines the expected width
  32134. * @param height defines the expected height
  32135. * @return a new canvas or offscreen canvas
  32136. */
  32137. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32138. }
  32139. }
  32140. declare module "babylonjs/Meshes/groundMesh" {
  32141. import { Scene } from "babylonjs/scene";
  32142. import { Vector3 } from "babylonjs/Maths/math.vector";
  32143. import { Mesh } from "babylonjs/Meshes/mesh";
  32144. /**
  32145. * Mesh representing the gorund
  32146. */
  32147. export class GroundMesh extends Mesh {
  32148. /** If octree should be generated */
  32149. generateOctree: boolean;
  32150. private _heightQuads;
  32151. /** @hidden */
  32152. _subdivisionsX: number;
  32153. /** @hidden */
  32154. _subdivisionsY: number;
  32155. /** @hidden */
  32156. _width: number;
  32157. /** @hidden */
  32158. _height: number;
  32159. /** @hidden */
  32160. _minX: number;
  32161. /** @hidden */
  32162. _maxX: number;
  32163. /** @hidden */
  32164. _minZ: number;
  32165. /** @hidden */
  32166. _maxZ: number;
  32167. constructor(name: string, scene: Scene);
  32168. /**
  32169. * "GroundMesh"
  32170. * @returns "GroundMesh"
  32171. */
  32172. getClassName(): string;
  32173. /**
  32174. * The minimum of x and y subdivisions
  32175. */
  32176. get subdivisions(): number;
  32177. /**
  32178. * X subdivisions
  32179. */
  32180. get subdivisionsX(): number;
  32181. /**
  32182. * Y subdivisions
  32183. */
  32184. get subdivisionsY(): number;
  32185. /**
  32186. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32187. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32188. * @param chunksCount the number of subdivisions for x and y
  32189. * @param octreeBlocksSize (Default: 32)
  32190. */
  32191. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32192. /**
  32193. * Returns a height (y) value in the Worl system :
  32194. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32195. * @param x x coordinate
  32196. * @param z z coordinate
  32197. * @returns the ground y position if (x, z) are outside the ground surface.
  32198. */
  32199. getHeightAtCoordinates(x: number, z: number): number;
  32200. /**
  32201. * Returns a normalized vector (Vector3) orthogonal to the ground
  32202. * at the ground coordinates (x, z) expressed in the World system.
  32203. * @param x x coordinate
  32204. * @param z z coordinate
  32205. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32206. */
  32207. getNormalAtCoordinates(x: number, z: number): Vector3;
  32208. /**
  32209. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32210. * at the ground coordinates (x, z) expressed in the World system.
  32211. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  32212. * @param x x coordinate
  32213. * @param z z coordinate
  32214. * @param ref vector to store the result
  32215. * @returns the GroundMesh.
  32216. */
  32217. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32218. /**
  32219. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32220. * if the ground has been updated.
  32221. * This can be used in the render loop.
  32222. * @returns the GroundMesh.
  32223. */
  32224. updateCoordinateHeights(): GroundMesh;
  32225. private _getFacetAt;
  32226. private _initHeightQuads;
  32227. private _computeHeightQuads;
  32228. /**
  32229. * Serializes this ground mesh
  32230. * @param serializationObject object to write serialization to
  32231. */
  32232. serialize(serializationObject: any): void;
  32233. /**
  32234. * Parses a serialized ground mesh
  32235. * @param parsedMesh the serialized mesh
  32236. * @param scene the scene to create the ground mesh in
  32237. * @returns the created ground mesh
  32238. */
  32239. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32240. }
  32241. }
  32242. declare module "babylonjs/Physics/physicsJoint" {
  32243. import { Vector3 } from "babylonjs/Maths/math.vector";
  32244. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  32245. /**
  32246. * Interface for Physics-Joint data
  32247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32248. */
  32249. export interface PhysicsJointData {
  32250. /**
  32251. * The main pivot of the joint
  32252. */
  32253. mainPivot?: Vector3;
  32254. /**
  32255. * The connected pivot of the joint
  32256. */
  32257. connectedPivot?: Vector3;
  32258. /**
  32259. * The main axis of the joint
  32260. */
  32261. mainAxis?: Vector3;
  32262. /**
  32263. * The connected axis of the joint
  32264. */
  32265. connectedAxis?: Vector3;
  32266. /**
  32267. * The collision of the joint
  32268. */
  32269. collision?: boolean;
  32270. /**
  32271. * Native Oimo/Cannon/Energy data
  32272. */
  32273. nativeParams?: any;
  32274. }
  32275. /**
  32276. * This is a holder class for the physics joint created by the physics plugin
  32277. * It holds a set of functions to control the underlying joint
  32278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32279. */
  32280. export class PhysicsJoint {
  32281. /**
  32282. * The type of the physics joint
  32283. */
  32284. type: number;
  32285. /**
  32286. * The data for the physics joint
  32287. */
  32288. jointData: PhysicsJointData;
  32289. private _physicsJoint;
  32290. protected _physicsPlugin: IPhysicsEnginePlugin;
  32291. /**
  32292. * Initializes the physics joint
  32293. * @param type The type of the physics joint
  32294. * @param jointData The data for the physics joint
  32295. */
  32296. constructor(
  32297. /**
  32298. * The type of the physics joint
  32299. */
  32300. type: number,
  32301. /**
  32302. * The data for the physics joint
  32303. */
  32304. jointData: PhysicsJointData);
  32305. /**
  32306. * Gets the physics joint
  32307. */
  32308. get physicsJoint(): any;
  32309. /**
  32310. * Sets the physics joint
  32311. */
  32312. set physicsJoint(newJoint: any);
  32313. /**
  32314. * Sets the physics plugin
  32315. */
  32316. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32317. /**
  32318. * Execute a function that is physics-plugin specific.
  32319. * @param {Function} func the function that will be executed.
  32320. * It accepts two parameters: the physics world and the physics joint
  32321. */
  32322. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32323. /**
  32324. * Distance-Joint type
  32325. */
  32326. static DistanceJoint: number;
  32327. /**
  32328. * Hinge-Joint type
  32329. */
  32330. static HingeJoint: number;
  32331. /**
  32332. * Ball-and-Socket joint type
  32333. */
  32334. static BallAndSocketJoint: number;
  32335. /**
  32336. * Wheel-Joint type
  32337. */
  32338. static WheelJoint: number;
  32339. /**
  32340. * Slider-Joint type
  32341. */
  32342. static SliderJoint: number;
  32343. /**
  32344. * Prismatic-Joint type
  32345. */
  32346. static PrismaticJoint: number;
  32347. /**
  32348. * Universal-Joint type
  32349. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32350. */
  32351. static UniversalJoint: number;
  32352. /**
  32353. * Hinge-Joint 2 type
  32354. */
  32355. static Hinge2Joint: number;
  32356. /**
  32357. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32358. */
  32359. static PointToPointJoint: number;
  32360. /**
  32361. * Spring-Joint type
  32362. */
  32363. static SpringJoint: number;
  32364. /**
  32365. * Lock-Joint type
  32366. */
  32367. static LockJoint: number;
  32368. }
  32369. /**
  32370. * A class representing a physics distance joint
  32371. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32372. */
  32373. export class DistanceJoint extends PhysicsJoint {
  32374. /**
  32375. *
  32376. * @param jointData The data for the Distance-Joint
  32377. */
  32378. constructor(jointData: DistanceJointData);
  32379. /**
  32380. * Update the predefined distance.
  32381. * @param maxDistance The maximum preferred distance
  32382. * @param minDistance The minimum preferred distance
  32383. */
  32384. updateDistance(maxDistance: number, minDistance?: number): void;
  32385. }
  32386. /**
  32387. * Represents a Motor-Enabled Joint
  32388. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32389. */
  32390. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32391. /**
  32392. * Initializes the Motor-Enabled Joint
  32393. * @param type The type of the joint
  32394. * @param jointData The physica joint data for the joint
  32395. */
  32396. constructor(type: number, jointData: PhysicsJointData);
  32397. /**
  32398. * Set the motor values.
  32399. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32400. * @param force the force to apply
  32401. * @param maxForce max force for this motor.
  32402. */
  32403. setMotor(force?: number, maxForce?: number): void;
  32404. /**
  32405. * Set the motor's limits.
  32406. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32407. * @param upperLimit The upper limit of the motor
  32408. * @param lowerLimit The lower limit of the motor
  32409. */
  32410. setLimit(upperLimit: number, lowerLimit?: number): void;
  32411. }
  32412. /**
  32413. * This class represents a single physics Hinge-Joint
  32414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32415. */
  32416. export class HingeJoint extends MotorEnabledJoint {
  32417. /**
  32418. * Initializes the Hinge-Joint
  32419. * @param jointData The joint data for the Hinge-Joint
  32420. */
  32421. constructor(jointData: PhysicsJointData);
  32422. /**
  32423. * Set the motor values.
  32424. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32425. * @param {number} force the force to apply
  32426. * @param {number} maxForce max force for this motor.
  32427. */
  32428. setMotor(force?: number, maxForce?: number): void;
  32429. /**
  32430. * Set the motor's limits.
  32431. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32432. * @param upperLimit The upper limit of the motor
  32433. * @param lowerLimit The lower limit of the motor
  32434. */
  32435. setLimit(upperLimit: number, lowerLimit?: number): void;
  32436. }
  32437. /**
  32438. * This class represents a dual hinge physics joint (same as wheel joint)
  32439. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32440. */
  32441. export class Hinge2Joint extends MotorEnabledJoint {
  32442. /**
  32443. * Initializes the Hinge2-Joint
  32444. * @param jointData The joint data for the Hinge2-Joint
  32445. */
  32446. constructor(jointData: PhysicsJointData);
  32447. /**
  32448. * Set the motor values.
  32449. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32450. * @param {number} targetSpeed the speed the motor is to reach
  32451. * @param {number} maxForce max force for this motor.
  32452. * @param {motorIndex} the motor's index, 0 or 1.
  32453. */
  32454. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32455. /**
  32456. * Set the motor limits.
  32457. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32458. * @param {number} upperLimit the upper limit
  32459. * @param {number} lowerLimit lower limit
  32460. * @param {motorIndex} the motor's index, 0 or 1.
  32461. */
  32462. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32463. }
  32464. /**
  32465. * Interface for a motor enabled joint
  32466. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32467. */
  32468. export interface IMotorEnabledJoint {
  32469. /**
  32470. * Physics joint
  32471. */
  32472. physicsJoint: any;
  32473. /**
  32474. * Sets the motor of the motor-enabled joint
  32475. * @param force The force of the motor
  32476. * @param maxForce The maximum force of the motor
  32477. * @param motorIndex The index of the motor
  32478. */
  32479. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32480. /**
  32481. * Sets the limit of the motor
  32482. * @param upperLimit The upper limit of the motor
  32483. * @param lowerLimit The lower limit of the motor
  32484. * @param motorIndex The index of the motor
  32485. */
  32486. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32487. }
  32488. /**
  32489. * Joint data for a Distance-Joint
  32490. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32491. */
  32492. export interface DistanceJointData extends PhysicsJointData {
  32493. /**
  32494. * Max distance the 2 joint objects can be apart
  32495. */
  32496. maxDistance: number;
  32497. }
  32498. /**
  32499. * Joint data from a spring joint
  32500. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32501. */
  32502. export interface SpringJointData extends PhysicsJointData {
  32503. /**
  32504. * Length of the spring
  32505. */
  32506. length: number;
  32507. /**
  32508. * Stiffness of the spring
  32509. */
  32510. stiffness: number;
  32511. /**
  32512. * Damping of the spring
  32513. */
  32514. damping: number;
  32515. /** this callback will be called when applying the force to the impostors. */
  32516. forceApplicationCallback: () => void;
  32517. }
  32518. }
  32519. declare module "babylonjs/Physics/physicsRaycastResult" {
  32520. import { Vector3 } from "babylonjs/Maths/math.vector";
  32521. /**
  32522. * Holds the data for the raycast result
  32523. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32524. */
  32525. export class PhysicsRaycastResult {
  32526. private _hasHit;
  32527. private _hitDistance;
  32528. private _hitNormalWorld;
  32529. private _hitPointWorld;
  32530. private _rayFromWorld;
  32531. private _rayToWorld;
  32532. /**
  32533. * Gets if there was a hit
  32534. */
  32535. get hasHit(): boolean;
  32536. /**
  32537. * Gets the distance from the hit
  32538. */
  32539. get hitDistance(): number;
  32540. /**
  32541. * Gets the hit normal/direction in the world
  32542. */
  32543. get hitNormalWorld(): Vector3;
  32544. /**
  32545. * Gets the hit point in the world
  32546. */
  32547. get hitPointWorld(): Vector3;
  32548. /**
  32549. * Gets the ray "start point" of the ray in the world
  32550. */
  32551. get rayFromWorld(): Vector3;
  32552. /**
  32553. * Gets the ray "end point" of the ray in the world
  32554. */
  32555. get rayToWorld(): Vector3;
  32556. /**
  32557. * Sets the hit data (normal & point in world space)
  32558. * @param hitNormalWorld defines the normal in world space
  32559. * @param hitPointWorld defines the point in world space
  32560. */
  32561. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32562. /**
  32563. * Sets the distance from the start point to the hit point
  32564. * @param distance
  32565. */
  32566. setHitDistance(distance: number): void;
  32567. /**
  32568. * Calculates the distance manually
  32569. */
  32570. calculateHitDistance(): void;
  32571. /**
  32572. * Resets all the values to default
  32573. * @param from The from point on world space
  32574. * @param to The to point on world space
  32575. */
  32576. reset(from?: Vector3, to?: Vector3): void;
  32577. }
  32578. /**
  32579. * Interface for the size containing width and height
  32580. */
  32581. interface IXYZ {
  32582. /**
  32583. * X
  32584. */
  32585. x: number;
  32586. /**
  32587. * Y
  32588. */
  32589. y: number;
  32590. /**
  32591. * Z
  32592. */
  32593. z: number;
  32594. }
  32595. }
  32596. declare module "babylonjs/Physics/IPhysicsEngine" {
  32597. import { Nullable } from "babylonjs/types";
  32598. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  32599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32600. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  32601. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  32602. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  32603. /**
  32604. * Interface used to describe a physics joint
  32605. */
  32606. export interface PhysicsImpostorJoint {
  32607. /** Defines the main impostor to which the joint is linked */
  32608. mainImpostor: PhysicsImpostor;
  32609. /** Defines the impostor that is connected to the main impostor using this joint */
  32610. connectedImpostor: PhysicsImpostor;
  32611. /** Defines the joint itself */
  32612. joint: PhysicsJoint;
  32613. }
  32614. /** @hidden */
  32615. export interface IPhysicsEnginePlugin {
  32616. world: any;
  32617. name: string;
  32618. setGravity(gravity: Vector3): void;
  32619. setTimeStep(timeStep: number): void;
  32620. getTimeStep(): number;
  32621. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32622. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32623. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32624. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32625. removePhysicsBody(impostor: PhysicsImpostor): void;
  32626. generateJoint(joint: PhysicsImpostorJoint): void;
  32627. removeJoint(joint: PhysicsImpostorJoint): void;
  32628. isSupported(): boolean;
  32629. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32630. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32631. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32632. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32633. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32634. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32635. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32636. getBodyMass(impostor: PhysicsImpostor): number;
  32637. getBodyFriction(impostor: PhysicsImpostor): number;
  32638. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32639. getBodyRestitution(impostor: PhysicsImpostor): number;
  32640. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32641. getBodyPressure?(impostor: PhysicsImpostor): number;
  32642. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32643. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32644. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32645. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32646. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32647. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32648. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32649. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32650. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32651. sleepBody(impostor: PhysicsImpostor): void;
  32652. wakeUpBody(impostor: PhysicsImpostor): void;
  32653. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32654. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32655. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32656. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32657. getRadius(impostor: PhysicsImpostor): number;
  32658. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32659. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32660. dispose(): void;
  32661. }
  32662. /**
  32663. * Interface used to define a physics engine
  32664. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32665. */
  32666. export interface IPhysicsEngine {
  32667. /**
  32668. * Gets the gravity vector used by the simulation
  32669. */
  32670. gravity: Vector3;
  32671. /**
  32672. * Sets the gravity vector used by the simulation
  32673. * @param gravity defines the gravity vector to use
  32674. */
  32675. setGravity(gravity: Vector3): void;
  32676. /**
  32677. * Set the time step of the physics engine.
  32678. * Default is 1/60.
  32679. * To slow it down, enter 1/600 for example.
  32680. * To speed it up, 1/30
  32681. * @param newTimeStep the new timestep to apply to this world.
  32682. */
  32683. setTimeStep(newTimeStep: number): void;
  32684. /**
  32685. * Get the time step of the physics engine.
  32686. * @returns the current time step
  32687. */
  32688. getTimeStep(): number;
  32689. /**
  32690. * Set the sub time step of the physics engine.
  32691. * Default is 0 meaning there is no sub steps
  32692. * To increase physics resolution precision, set a small value (like 1 ms)
  32693. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32694. */
  32695. setSubTimeStep(subTimeStep: number): void;
  32696. /**
  32697. * Get the sub time step of the physics engine.
  32698. * @returns the current sub time step
  32699. */
  32700. getSubTimeStep(): number;
  32701. /**
  32702. * Release all resources
  32703. */
  32704. dispose(): void;
  32705. /**
  32706. * Gets the name of the current physics plugin
  32707. * @returns the name of the plugin
  32708. */
  32709. getPhysicsPluginName(): string;
  32710. /**
  32711. * Adding a new impostor for the impostor tracking.
  32712. * This will be done by the impostor itself.
  32713. * @param impostor the impostor to add
  32714. */
  32715. addImpostor(impostor: PhysicsImpostor): void;
  32716. /**
  32717. * Remove an impostor from the engine.
  32718. * This impostor and its mesh will not longer be updated by the physics engine.
  32719. * @param impostor the impostor to remove
  32720. */
  32721. removeImpostor(impostor: PhysicsImpostor): void;
  32722. /**
  32723. * Add a joint to the physics engine
  32724. * @param mainImpostor defines the main impostor to which the joint is added.
  32725. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32726. * @param joint defines the joint that will connect both impostors.
  32727. */
  32728. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32729. /**
  32730. * Removes a joint from the simulation
  32731. * @param mainImpostor defines the impostor used with the joint
  32732. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32733. * @param joint defines the joint to remove
  32734. */
  32735. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32736. /**
  32737. * Gets the current plugin used to run the simulation
  32738. * @returns current plugin
  32739. */
  32740. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32741. /**
  32742. * Gets the list of physic impostors
  32743. * @returns an array of PhysicsImpostor
  32744. */
  32745. getImpostors(): Array<PhysicsImpostor>;
  32746. /**
  32747. * Gets the impostor for a physics enabled object
  32748. * @param object defines the object impersonated by the impostor
  32749. * @returns the PhysicsImpostor or null if not found
  32750. */
  32751. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32752. /**
  32753. * Gets the impostor for a physics body object
  32754. * @param body defines physics body used by the impostor
  32755. * @returns the PhysicsImpostor or null if not found
  32756. */
  32757. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32758. /**
  32759. * Does a raycast in the physics world
  32760. * @param from when should the ray start?
  32761. * @param to when should the ray end?
  32762. * @returns PhysicsRaycastResult
  32763. */
  32764. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32765. /**
  32766. * Called by the scene. No need to call it.
  32767. * @param delta defines the timespam between frames
  32768. */
  32769. _step(delta: number): void;
  32770. }
  32771. }
  32772. declare module "babylonjs/Physics/physicsImpostor" {
  32773. import { Nullable, IndicesArray } from "babylonjs/types";
  32774. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  32775. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32777. import { Scene } from "babylonjs/scene";
  32778. import { Bone } from "babylonjs/Bones/bone";
  32779. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32780. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  32781. import { Space } from "babylonjs/Maths/math.axis";
  32782. /**
  32783. * The interface for the physics imposter parameters
  32784. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32785. */
  32786. export interface PhysicsImpostorParameters {
  32787. /**
  32788. * The mass of the physics imposter
  32789. */
  32790. mass: number;
  32791. /**
  32792. * The friction of the physics imposter
  32793. */
  32794. friction?: number;
  32795. /**
  32796. * The coefficient of restitution of the physics imposter
  32797. */
  32798. restitution?: number;
  32799. /**
  32800. * The native options of the physics imposter
  32801. */
  32802. nativeOptions?: any;
  32803. /**
  32804. * Specifies if the parent should be ignored
  32805. */
  32806. ignoreParent?: boolean;
  32807. /**
  32808. * Specifies if bi-directional transformations should be disabled
  32809. */
  32810. disableBidirectionalTransformation?: boolean;
  32811. /**
  32812. * The pressure inside the physics imposter, soft object only
  32813. */
  32814. pressure?: number;
  32815. /**
  32816. * The stiffness the physics imposter, soft object only
  32817. */
  32818. stiffness?: number;
  32819. /**
  32820. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32821. */
  32822. velocityIterations?: number;
  32823. /**
  32824. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32825. */
  32826. positionIterations?: number;
  32827. /**
  32828. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32829. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32830. * Add to fix multiple points
  32831. */
  32832. fixedPoints?: number;
  32833. /**
  32834. * The collision margin around a soft object
  32835. */
  32836. margin?: number;
  32837. /**
  32838. * The collision margin around a soft object
  32839. */
  32840. damping?: number;
  32841. /**
  32842. * The path for a rope based on an extrusion
  32843. */
  32844. path?: any;
  32845. /**
  32846. * The shape of an extrusion used for a rope based on an extrusion
  32847. */
  32848. shape?: any;
  32849. }
  32850. /**
  32851. * Interface for a physics-enabled object
  32852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32853. */
  32854. export interface IPhysicsEnabledObject {
  32855. /**
  32856. * The position of the physics-enabled object
  32857. */
  32858. position: Vector3;
  32859. /**
  32860. * The rotation of the physics-enabled object
  32861. */
  32862. rotationQuaternion: Nullable<Quaternion>;
  32863. /**
  32864. * The scale of the physics-enabled object
  32865. */
  32866. scaling: Vector3;
  32867. /**
  32868. * The rotation of the physics-enabled object
  32869. */
  32870. rotation?: Vector3;
  32871. /**
  32872. * The parent of the physics-enabled object
  32873. */
  32874. parent?: any;
  32875. /**
  32876. * The bounding info of the physics-enabled object
  32877. * @returns The bounding info of the physics-enabled object
  32878. */
  32879. getBoundingInfo(): BoundingInfo;
  32880. /**
  32881. * Computes the world matrix
  32882. * @param force Specifies if the world matrix should be computed by force
  32883. * @returns A world matrix
  32884. */
  32885. computeWorldMatrix(force: boolean): Matrix;
  32886. /**
  32887. * Gets the world matrix
  32888. * @returns A world matrix
  32889. */
  32890. getWorldMatrix?(): Matrix;
  32891. /**
  32892. * Gets the child meshes
  32893. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32894. * @returns An array of abstract meshes
  32895. */
  32896. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32897. /**
  32898. * Gets the vertex data
  32899. * @param kind The type of vertex data
  32900. * @returns A nullable array of numbers, or a float32 array
  32901. */
  32902. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32903. /**
  32904. * Gets the indices from the mesh
  32905. * @returns A nullable array of index arrays
  32906. */
  32907. getIndices?(): Nullable<IndicesArray>;
  32908. /**
  32909. * Gets the scene from the mesh
  32910. * @returns the indices array or null
  32911. */
  32912. getScene?(): Scene;
  32913. /**
  32914. * Gets the absolute position from the mesh
  32915. * @returns the absolute position
  32916. */
  32917. getAbsolutePosition(): Vector3;
  32918. /**
  32919. * Gets the absolute pivot point from the mesh
  32920. * @returns the absolute pivot point
  32921. */
  32922. getAbsolutePivotPoint(): Vector3;
  32923. /**
  32924. * Rotates the mesh
  32925. * @param axis The axis of rotation
  32926. * @param amount The amount of rotation
  32927. * @param space The space of the rotation
  32928. * @returns The rotation transform node
  32929. */
  32930. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32931. /**
  32932. * Translates the mesh
  32933. * @param axis The axis of translation
  32934. * @param distance The distance of translation
  32935. * @param space The space of the translation
  32936. * @returns The transform node
  32937. */
  32938. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32939. /**
  32940. * Sets the absolute position of the mesh
  32941. * @param absolutePosition The absolute position of the mesh
  32942. * @returns The transform node
  32943. */
  32944. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32945. /**
  32946. * Gets the class name of the mesh
  32947. * @returns The class name
  32948. */
  32949. getClassName(): string;
  32950. }
  32951. /**
  32952. * Represents a physics imposter
  32953. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32954. */
  32955. export class PhysicsImpostor {
  32956. /**
  32957. * The physics-enabled object used as the physics imposter
  32958. */
  32959. object: IPhysicsEnabledObject;
  32960. /**
  32961. * The type of the physics imposter
  32962. */
  32963. type: number;
  32964. private _options;
  32965. private _scene?;
  32966. /**
  32967. * The default object size of the imposter
  32968. */
  32969. static DEFAULT_OBJECT_SIZE: Vector3;
  32970. /**
  32971. * The identity quaternion of the imposter
  32972. */
  32973. static IDENTITY_QUATERNION: Quaternion;
  32974. /** @hidden */
  32975. _pluginData: any;
  32976. private _physicsEngine;
  32977. private _physicsBody;
  32978. private _bodyUpdateRequired;
  32979. private _onBeforePhysicsStepCallbacks;
  32980. private _onAfterPhysicsStepCallbacks;
  32981. /** @hidden */
  32982. _onPhysicsCollideCallbacks: Array<{
  32983. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32984. otherImpostors: Array<PhysicsImpostor>;
  32985. }>;
  32986. private _deltaPosition;
  32987. private _deltaRotation;
  32988. private _deltaRotationConjugated;
  32989. /** @hidden */
  32990. _isFromLine: boolean;
  32991. private _parent;
  32992. private _isDisposed;
  32993. private static _tmpVecs;
  32994. private static _tmpQuat;
  32995. /**
  32996. * Specifies if the physics imposter is disposed
  32997. */
  32998. get isDisposed(): boolean;
  32999. /**
  33000. * Gets the mass of the physics imposter
  33001. */
  33002. get mass(): number;
  33003. set mass(value: number);
  33004. /**
  33005. * Gets the coefficient of friction
  33006. */
  33007. get friction(): number;
  33008. /**
  33009. * Sets the coefficient of friction
  33010. */
  33011. set friction(value: number);
  33012. /**
  33013. * Gets the coefficient of restitution
  33014. */
  33015. get restitution(): number;
  33016. /**
  33017. * Sets the coefficient of restitution
  33018. */
  33019. set restitution(value: number);
  33020. /**
  33021. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33022. */
  33023. get pressure(): number;
  33024. /**
  33025. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33026. */
  33027. set pressure(value: number);
  33028. /**
  33029. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33030. */
  33031. get stiffness(): number;
  33032. /**
  33033. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33034. */
  33035. set stiffness(value: number);
  33036. /**
  33037. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33038. */
  33039. get velocityIterations(): number;
  33040. /**
  33041. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33042. */
  33043. set velocityIterations(value: number);
  33044. /**
  33045. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33046. */
  33047. get positionIterations(): number;
  33048. /**
  33049. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33050. */
  33051. set positionIterations(value: number);
  33052. /**
  33053. * The unique id of the physics imposter
  33054. * set by the physics engine when adding this impostor to the array
  33055. */
  33056. uniqueId: number;
  33057. /**
  33058. * @hidden
  33059. */
  33060. soft: boolean;
  33061. /**
  33062. * @hidden
  33063. */
  33064. segments: number;
  33065. private _joints;
  33066. /**
  33067. * Initializes the physics imposter
  33068. * @param object The physics-enabled object used as the physics imposter
  33069. * @param type The type of the physics imposter
  33070. * @param _options The options for the physics imposter
  33071. * @param _scene The Babylon scene
  33072. */
  33073. constructor(
  33074. /**
  33075. * The physics-enabled object used as the physics imposter
  33076. */
  33077. object: IPhysicsEnabledObject,
  33078. /**
  33079. * The type of the physics imposter
  33080. */
  33081. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33082. /**
  33083. * This function will completly initialize this impostor.
  33084. * It will create a new body - but only if this mesh has no parent.
  33085. * If it has, this impostor will not be used other than to define the impostor
  33086. * of the child mesh.
  33087. * @hidden
  33088. */
  33089. _init(): void;
  33090. private _getPhysicsParent;
  33091. /**
  33092. * Should a new body be generated.
  33093. * @returns boolean specifying if body initialization is required
  33094. */
  33095. isBodyInitRequired(): boolean;
  33096. /**
  33097. * Sets the updated scaling
  33098. * @param updated Specifies if the scaling is updated
  33099. */
  33100. setScalingUpdated(): void;
  33101. /**
  33102. * Force a regeneration of this or the parent's impostor's body.
  33103. * Use under cautious - This will remove all joints already implemented.
  33104. */
  33105. forceUpdate(): void;
  33106. /**
  33107. * Gets the body that holds this impostor. Either its own, or its parent.
  33108. */
  33109. get physicsBody(): any;
  33110. /**
  33111. * Get the parent of the physics imposter
  33112. * @returns Physics imposter or null
  33113. */
  33114. get parent(): Nullable<PhysicsImpostor>;
  33115. /**
  33116. * Sets the parent of the physics imposter
  33117. */
  33118. set parent(value: Nullable<PhysicsImpostor>);
  33119. /**
  33120. * Set the physics body. Used mainly by the physics engine/plugin
  33121. */
  33122. set physicsBody(physicsBody: any);
  33123. /**
  33124. * Resets the update flags
  33125. */
  33126. resetUpdateFlags(): void;
  33127. /**
  33128. * Gets the object extend size
  33129. * @returns the object extend size
  33130. */
  33131. getObjectExtendSize(): Vector3;
  33132. /**
  33133. * Gets the object center
  33134. * @returns The object center
  33135. */
  33136. getObjectCenter(): Vector3;
  33137. /**
  33138. * Get a specific parameter from the options parameters
  33139. * @param paramName The object parameter name
  33140. * @returns The object parameter
  33141. */
  33142. getParam(paramName: string): any;
  33143. /**
  33144. * Sets a specific parameter in the options given to the physics plugin
  33145. * @param paramName The parameter name
  33146. * @param value The value of the parameter
  33147. */
  33148. setParam(paramName: string, value: number): void;
  33149. /**
  33150. * Specifically change the body's mass option. Won't recreate the physics body object
  33151. * @param mass The mass of the physics imposter
  33152. */
  33153. setMass(mass: number): void;
  33154. /**
  33155. * Gets the linear velocity
  33156. * @returns linear velocity or null
  33157. */
  33158. getLinearVelocity(): Nullable<Vector3>;
  33159. /**
  33160. * Sets the linear velocity
  33161. * @param velocity linear velocity or null
  33162. */
  33163. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33164. /**
  33165. * Gets the angular velocity
  33166. * @returns angular velocity or null
  33167. */
  33168. getAngularVelocity(): Nullable<Vector3>;
  33169. /**
  33170. * Sets the angular velocity
  33171. * @param velocity The velocity or null
  33172. */
  33173. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33174. /**
  33175. * Execute a function with the physics plugin native code
  33176. * Provide a function the will have two variables - the world object and the physics body object
  33177. * @param func The function to execute with the physics plugin native code
  33178. */
  33179. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33180. /**
  33181. * Register a function that will be executed before the physics world is stepping forward
  33182. * @param func The function to execute before the physics world is stepped forward
  33183. */
  33184. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33185. /**
  33186. * Unregister a function that will be executed before the physics world is stepping forward
  33187. * @param func The function to execute before the physics world is stepped forward
  33188. */
  33189. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33190. /**
  33191. * Register a function that will be executed after the physics step
  33192. * @param func The function to execute after physics step
  33193. */
  33194. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33195. /**
  33196. * Unregisters a function that will be executed after the physics step
  33197. * @param func The function to execute after physics step
  33198. */
  33199. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33200. /**
  33201. * register a function that will be executed when this impostor collides against a different body
  33202. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33203. * @param func Callback that is executed on collision
  33204. */
  33205. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33206. /**
  33207. * Unregisters the physics imposter on contact
  33208. * @param collideAgainst The physics object to collide against
  33209. * @param func Callback to execute on collision
  33210. */
  33211. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33212. private _tmpQuat;
  33213. private _tmpQuat2;
  33214. /**
  33215. * Get the parent rotation
  33216. * @returns The parent rotation
  33217. */
  33218. getParentsRotation(): Quaternion;
  33219. /**
  33220. * this function is executed by the physics engine.
  33221. */
  33222. beforeStep: () => void;
  33223. /**
  33224. * this function is executed by the physics engine
  33225. */
  33226. afterStep: () => void;
  33227. /**
  33228. * Legacy collision detection event support
  33229. */
  33230. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33231. /**
  33232. * event and body object due to cannon's event-based architecture.
  33233. */
  33234. onCollide: (e: {
  33235. body: any;
  33236. point: Nullable<Vector3>;
  33237. }) => void;
  33238. /**
  33239. * Apply a force
  33240. * @param force The force to apply
  33241. * @param contactPoint The contact point for the force
  33242. * @returns The physics imposter
  33243. */
  33244. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33245. /**
  33246. * Apply an impulse
  33247. * @param force The impulse force
  33248. * @param contactPoint The contact point for the impulse force
  33249. * @returns The physics imposter
  33250. */
  33251. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33252. /**
  33253. * A help function to create a joint
  33254. * @param otherImpostor A physics imposter used to create a joint
  33255. * @param jointType The type of joint
  33256. * @param jointData The data for the joint
  33257. * @returns The physics imposter
  33258. */
  33259. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33260. /**
  33261. * Add a joint to this impostor with a different impostor
  33262. * @param otherImpostor A physics imposter used to add a joint
  33263. * @param joint The joint to add
  33264. * @returns The physics imposter
  33265. */
  33266. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33267. /**
  33268. * Add an anchor to a cloth impostor
  33269. * @param otherImpostor rigid impostor to anchor to
  33270. * @param width ratio across width from 0 to 1
  33271. * @param height ratio up height from 0 to 1
  33272. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  33273. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33274. * @returns impostor the soft imposter
  33275. */
  33276. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33277. /**
  33278. * Add a hook to a rope impostor
  33279. * @param otherImpostor rigid impostor to anchor to
  33280. * @param length ratio across rope from 0 to 1
  33281. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  33282. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33283. * @returns impostor the rope imposter
  33284. */
  33285. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33286. /**
  33287. * Will keep this body still, in a sleep mode.
  33288. * @returns the physics imposter
  33289. */
  33290. sleep(): PhysicsImpostor;
  33291. /**
  33292. * Wake the body up.
  33293. * @returns The physics imposter
  33294. */
  33295. wakeUp(): PhysicsImpostor;
  33296. /**
  33297. * Clones the physics imposter
  33298. * @param newObject The physics imposter clones to this physics-enabled object
  33299. * @returns A nullable physics imposter
  33300. */
  33301. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33302. /**
  33303. * Disposes the physics imposter
  33304. */
  33305. dispose(): void;
  33306. /**
  33307. * Sets the delta position
  33308. * @param position The delta position amount
  33309. */
  33310. setDeltaPosition(position: Vector3): void;
  33311. /**
  33312. * Sets the delta rotation
  33313. * @param rotation The delta rotation amount
  33314. */
  33315. setDeltaRotation(rotation: Quaternion): void;
  33316. /**
  33317. * Gets the box size of the physics imposter and stores the result in the input parameter
  33318. * @param result Stores the box size
  33319. * @returns The physics imposter
  33320. */
  33321. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33322. /**
  33323. * Gets the radius of the physics imposter
  33324. * @returns Radius of the physics imposter
  33325. */
  33326. getRadius(): number;
  33327. /**
  33328. * Sync a bone with this impostor
  33329. * @param bone The bone to sync to the impostor.
  33330. * @param boneMesh The mesh that the bone is influencing.
  33331. * @param jointPivot The pivot of the joint / bone in local space.
  33332. * @param distToJoint Optional distance from the impostor to the joint.
  33333. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33334. */
  33335. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33336. /**
  33337. * Sync impostor to a bone
  33338. * @param bone The bone that the impostor will be synced to.
  33339. * @param boneMesh The mesh that the bone is influencing.
  33340. * @param jointPivot The pivot of the joint / bone in local space.
  33341. * @param distToJoint Optional distance from the impostor to the joint.
  33342. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33343. * @param boneAxis Optional vector3 axis the bone is aligned with
  33344. */
  33345. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33346. /**
  33347. * No-Imposter type
  33348. */
  33349. static NoImpostor: number;
  33350. /**
  33351. * Sphere-Imposter type
  33352. */
  33353. static SphereImpostor: number;
  33354. /**
  33355. * Box-Imposter type
  33356. */
  33357. static BoxImpostor: number;
  33358. /**
  33359. * Plane-Imposter type
  33360. */
  33361. static PlaneImpostor: number;
  33362. /**
  33363. * Mesh-imposter type
  33364. */
  33365. static MeshImpostor: number;
  33366. /**
  33367. * Capsule-Impostor type (Ammo.js plugin only)
  33368. */
  33369. static CapsuleImpostor: number;
  33370. /**
  33371. * Cylinder-Imposter type
  33372. */
  33373. static CylinderImpostor: number;
  33374. /**
  33375. * Particle-Imposter type
  33376. */
  33377. static ParticleImpostor: number;
  33378. /**
  33379. * Heightmap-Imposter type
  33380. */
  33381. static HeightmapImpostor: number;
  33382. /**
  33383. * ConvexHull-Impostor type (Ammo.js plugin only)
  33384. */
  33385. static ConvexHullImpostor: number;
  33386. /**
  33387. * Custom-Imposter type (Ammo.js plugin only)
  33388. */
  33389. static CustomImpostor: number;
  33390. /**
  33391. * Rope-Imposter type
  33392. */
  33393. static RopeImpostor: number;
  33394. /**
  33395. * Cloth-Imposter type
  33396. */
  33397. static ClothImpostor: number;
  33398. /**
  33399. * Softbody-Imposter type
  33400. */
  33401. static SoftbodyImpostor: number;
  33402. }
  33403. }
  33404. declare module "babylonjs/Meshes/mesh" {
  33405. import { Observable } from "babylonjs/Misc/observable";
  33406. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33407. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  33408. import { Camera } from "babylonjs/Cameras/camera";
  33409. import { Scene } from "babylonjs/scene";
  33410. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  33411. import { Color4 } from "babylonjs/Maths/math.color";
  33412. import { Engine } from "babylonjs/Engines/engine";
  33413. import { Node } from "babylonjs/node";
  33414. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  33415. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33416. import { Buffer } from "babylonjs/Meshes/buffer";
  33417. import { Geometry } from "babylonjs/Meshes/geometry";
  33418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33419. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33420. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  33421. import { Effect } from "babylonjs/Materials/effect";
  33422. import { Material } from "babylonjs/Materials/material";
  33423. import { Skeleton } from "babylonjs/Bones/skeleton";
  33424. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33425. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  33426. import { Path3D } from "babylonjs/Maths/math.path";
  33427. import { Plane } from "babylonjs/Maths/math.plane";
  33428. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33429. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  33430. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  33431. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  33432. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  33433. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33434. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  33435. /**
  33436. * @hidden
  33437. **/
  33438. export class _CreationDataStorage {
  33439. closePath?: boolean;
  33440. closeArray?: boolean;
  33441. idx: number[];
  33442. dashSize: number;
  33443. gapSize: number;
  33444. path3D: Path3D;
  33445. pathArray: Vector3[][];
  33446. arc: number;
  33447. radius: number;
  33448. cap: number;
  33449. tessellation: number;
  33450. }
  33451. /**
  33452. * @hidden
  33453. **/
  33454. class _InstanceDataStorage {
  33455. visibleInstances: any;
  33456. batchCache: _InstancesBatch;
  33457. instancesBufferSize: number;
  33458. instancesBuffer: Nullable<Buffer>;
  33459. instancesData: Float32Array;
  33460. overridenInstanceCount: number;
  33461. isFrozen: boolean;
  33462. previousBatch: Nullable<_InstancesBatch>;
  33463. hardwareInstancedRendering: boolean;
  33464. sideOrientation: number;
  33465. manualUpdate: boolean;
  33466. previousRenderId: number;
  33467. }
  33468. /**
  33469. * @hidden
  33470. **/
  33471. export class _InstancesBatch {
  33472. mustReturn: boolean;
  33473. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  33474. renderSelf: boolean[];
  33475. hardwareInstancedRendering: boolean[];
  33476. }
  33477. /**
  33478. * @hidden
  33479. **/
  33480. class _ThinInstanceDataStorage {
  33481. instancesCount: number;
  33482. matrixBuffer: Nullable<Buffer>;
  33483. matrixBufferSize: number;
  33484. matrixData: Nullable<Float32Array>;
  33485. boundingVectors: Array<Vector3>;
  33486. worldMatrices: Nullable<Matrix[]>;
  33487. }
  33488. /**
  33489. * Class used to represent renderable models
  33490. */
  33491. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33492. /**
  33493. * Mesh side orientation : usually the external or front surface
  33494. */
  33495. static readonly FRONTSIDE: number;
  33496. /**
  33497. * Mesh side orientation : usually the internal or back surface
  33498. */
  33499. static readonly BACKSIDE: number;
  33500. /**
  33501. * Mesh side orientation : both internal and external or front and back surfaces
  33502. */
  33503. static readonly DOUBLESIDE: number;
  33504. /**
  33505. * Mesh side orientation : by default, `FRONTSIDE`
  33506. */
  33507. static readonly DEFAULTSIDE: number;
  33508. /**
  33509. * Mesh cap setting : no cap
  33510. */
  33511. static readonly NO_CAP: number;
  33512. /**
  33513. * Mesh cap setting : one cap at the beginning of the mesh
  33514. */
  33515. static readonly CAP_START: number;
  33516. /**
  33517. * Mesh cap setting : one cap at the end of the mesh
  33518. */
  33519. static readonly CAP_END: number;
  33520. /**
  33521. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33522. */
  33523. static readonly CAP_ALL: number;
  33524. /**
  33525. * Mesh pattern setting : no flip or rotate
  33526. */
  33527. static readonly NO_FLIP: number;
  33528. /**
  33529. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33530. */
  33531. static readonly FLIP_TILE: number;
  33532. /**
  33533. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33534. */
  33535. static readonly ROTATE_TILE: number;
  33536. /**
  33537. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33538. */
  33539. static readonly FLIP_ROW: number;
  33540. /**
  33541. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33542. */
  33543. static readonly ROTATE_ROW: number;
  33544. /**
  33545. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33546. */
  33547. static readonly FLIP_N_ROTATE_TILE: number;
  33548. /**
  33549. * Mesh pattern setting : rotate pattern and rotate
  33550. */
  33551. static readonly FLIP_N_ROTATE_ROW: number;
  33552. /**
  33553. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33554. */
  33555. static readonly CENTER: number;
  33556. /**
  33557. * Mesh tile positioning : part tiles on left
  33558. */
  33559. static readonly LEFT: number;
  33560. /**
  33561. * Mesh tile positioning : part tiles on right
  33562. */
  33563. static readonly RIGHT: number;
  33564. /**
  33565. * Mesh tile positioning : part tiles on top
  33566. */
  33567. static readonly TOP: number;
  33568. /**
  33569. * Mesh tile positioning : part tiles on bottom
  33570. */
  33571. static readonly BOTTOM: number;
  33572. /**
  33573. * Gets the default side orientation.
  33574. * @param orientation the orientation to value to attempt to get
  33575. * @returns the default orientation
  33576. * @hidden
  33577. */
  33578. static _GetDefaultSideOrientation(orientation?: number): number;
  33579. private _internalMeshDataInfo;
  33580. get computeBonesUsingShaders(): boolean;
  33581. set computeBonesUsingShaders(value: boolean);
  33582. /**
  33583. * An event triggered before rendering the mesh
  33584. */
  33585. get onBeforeRenderObservable(): Observable<Mesh>;
  33586. /**
  33587. * An event triggered before binding the mesh
  33588. */
  33589. get onBeforeBindObservable(): Observable<Mesh>;
  33590. /**
  33591. * An event triggered after rendering the mesh
  33592. */
  33593. get onAfterRenderObservable(): Observable<Mesh>;
  33594. /**
  33595. * An event triggered before drawing the mesh
  33596. */
  33597. get onBeforeDrawObservable(): Observable<Mesh>;
  33598. private _onBeforeDrawObserver;
  33599. /**
  33600. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33601. */
  33602. set onBeforeDraw(callback: () => void);
  33603. get hasInstances(): boolean;
  33604. get hasThinInstances(): boolean;
  33605. /**
  33606. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33607. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33608. */
  33609. delayLoadState: number;
  33610. /**
  33611. * Gets the list of instances created from this mesh
  33612. * it is not supposed to be modified manually.
  33613. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33614. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33615. */
  33616. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  33617. /**
  33618. * Gets the file containing delay loading data for this mesh
  33619. */
  33620. delayLoadingFile: string;
  33621. /** @hidden */
  33622. _binaryInfo: any;
  33623. /**
  33624. * User defined function used to change how LOD level selection is done
  33625. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33626. */
  33627. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33628. /**
  33629. * Gets or sets the morph target manager
  33630. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33631. */
  33632. get morphTargetManager(): Nullable<MorphTargetManager>;
  33633. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33634. /** @hidden */
  33635. _creationDataStorage: Nullable<_CreationDataStorage>;
  33636. /** @hidden */
  33637. _geometry: Nullable<Geometry>;
  33638. /** @hidden */
  33639. _delayInfo: Array<string>;
  33640. /** @hidden */
  33641. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33642. /** @hidden */
  33643. _instanceDataStorage: _InstanceDataStorage;
  33644. /** @hidden */
  33645. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33646. private _effectiveMaterial;
  33647. /** @hidden */
  33648. _shouldGenerateFlatShading: boolean;
  33649. /** @hidden */
  33650. _originalBuilderSideOrientation: number;
  33651. /**
  33652. * Use this property to change the original side orientation defined at construction time
  33653. */
  33654. overrideMaterialSideOrientation: Nullable<number>;
  33655. /**
  33656. * Gets the source mesh (the one used to clone this one from)
  33657. */
  33658. get source(): Nullable<Mesh>;
  33659. /**
  33660. * Gets the list of clones of this mesh
  33661. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33662. * Note that useClonedMeshMap=true is the default setting
  33663. */
  33664. get cloneMeshMap(): Nullable<{
  33665. [id: string]: Mesh | undefined;
  33666. }>;
  33667. /**
  33668. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33669. */
  33670. get isUnIndexed(): boolean;
  33671. set isUnIndexed(value: boolean);
  33672. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33673. get worldMatrixInstancedBuffer(): Float32Array;
  33674. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33675. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33676. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33677. /**
  33678. * @constructor
  33679. * @param name The value used by scene.getMeshByName() to do a lookup.
  33680. * @param scene The scene to add this mesh to.
  33681. * @param parent The parent of this mesh, if it has one
  33682. * @param source An optional Mesh from which geometry is shared, cloned.
  33683. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33684. * When false, achieved by calling a clone(), also passing False.
  33685. * This will make creation of children, recursive.
  33686. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33687. */
  33688. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33689. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33690. doNotInstantiate: boolean;
  33691. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33692. /**
  33693. * Gets the class name
  33694. * @returns the string "Mesh".
  33695. */
  33696. getClassName(): string;
  33697. /** @hidden */
  33698. get _isMesh(): boolean;
  33699. /**
  33700. * Returns a description of this mesh
  33701. * @param fullDetails define if full details about this mesh must be used
  33702. * @returns a descriptive string representing this mesh
  33703. */
  33704. toString(fullDetails?: boolean): string;
  33705. /** @hidden */
  33706. _unBindEffect(): void;
  33707. /**
  33708. * Gets a boolean indicating if this mesh has LOD
  33709. */
  33710. get hasLODLevels(): boolean;
  33711. /**
  33712. * Gets the list of MeshLODLevel associated with the current mesh
  33713. * @returns an array of MeshLODLevel
  33714. */
  33715. getLODLevels(): MeshLODLevel[];
  33716. private _sortLODLevels;
  33717. /**
  33718. * Add a mesh as LOD level triggered at the given distance.
  33719. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33720. * @param distance The distance from the center of the object to show this level
  33721. * @param mesh The mesh to be added as LOD level (can be null)
  33722. * @return This mesh (for chaining)
  33723. */
  33724. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33725. /**
  33726. * Returns the LOD level mesh at the passed distance or null if not found.
  33727. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33728. * @param distance The distance from the center of the object to show this level
  33729. * @returns a Mesh or `null`
  33730. */
  33731. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33732. /**
  33733. * Remove a mesh from the LOD array
  33734. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33735. * @param mesh defines the mesh to be removed
  33736. * @return This mesh (for chaining)
  33737. */
  33738. removeLODLevel(mesh: Mesh): Mesh;
  33739. /**
  33740. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33741. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33742. * @param camera defines the camera to use to compute distance
  33743. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33744. * @return This mesh (for chaining)
  33745. */
  33746. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33747. /**
  33748. * Gets the mesh internal Geometry object
  33749. */
  33750. get geometry(): Nullable<Geometry>;
  33751. /**
  33752. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33753. * @returns the total number of vertices
  33754. */
  33755. getTotalVertices(): number;
  33756. /**
  33757. * Returns the content of an associated vertex buffer
  33758. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33759. * - VertexBuffer.PositionKind
  33760. * - VertexBuffer.UVKind
  33761. * - VertexBuffer.UV2Kind
  33762. * - VertexBuffer.UV3Kind
  33763. * - VertexBuffer.UV4Kind
  33764. * - VertexBuffer.UV5Kind
  33765. * - VertexBuffer.UV6Kind
  33766. * - VertexBuffer.ColorKind
  33767. * - VertexBuffer.MatricesIndicesKind
  33768. * - VertexBuffer.MatricesIndicesExtraKind
  33769. * - VertexBuffer.MatricesWeightsKind
  33770. * - VertexBuffer.MatricesWeightsExtraKind
  33771. * @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
  33772. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33773. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33774. */
  33775. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33776. /**
  33777. * Returns the mesh VertexBuffer object from the requested `kind`
  33778. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33779. * - VertexBuffer.PositionKind
  33780. * - VertexBuffer.NormalKind
  33781. * - VertexBuffer.UVKind
  33782. * - VertexBuffer.UV2Kind
  33783. * - VertexBuffer.UV3Kind
  33784. * - VertexBuffer.UV4Kind
  33785. * - VertexBuffer.UV5Kind
  33786. * - VertexBuffer.UV6Kind
  33787. * - VertexBuffer.ColorKind
  33788. * - VertexBuffer.MatricesIndicesKind
  33789. * - VertexBuffer.MatricesIndicesExtraKind
  33790. * - VertexBuffer.MatricesWeightsKind
  33791. * - VertexBuffer.MatricesWeightsExtraKind
  33792. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33793. */
  33794. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33795. /**
  33796. * Tests if a specific vertex buffer is associated with this mesh
  33797. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33798. * - VertexBuffer.PositionKind
  33799. * - VertexBuffer.NormalKind
  33800. * - VertexBuffer.UVKind
  33801. * - VertexBuffer.UV2Kind
  33802. * - VertexBuffer.UV3Kind
  33803. * - VertexBuffer.UV4Kind
  33804. * - VertexBuffer.UV5Kind
  33805. * - VertexBuffer.UV6Kind
  33806. * - VertexBuffer.ColorKind
  33807. * - VertexBuffer.MatricesIndicesKind
  33808. * - VertexBuffer.MatricesIndicesExtraKind
  33809. * - VertexBuffer.MatricesWeightsKind
  33810. * - VertexBuffer.MatricesWeightsExtraKind
  33811. * @returns a boolean
  33812. */
  33813. isVerticesDataPresent(kind: string): boolean;
  33814. /**
  33815. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33816. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33817. * - VertexBuffer.PositionKind
  33818. * - VertexBuffer.UVKind
  33819. * - VertexBuffer.UV2Kind
  33820. * - VertexBuffer.UV3Kind
  33821. * - VertexBuffer.UV4Kind
  33822. * - VertexBuffer.UV5Kind
  33823. * - VertexBuffer.UV6Kind
  33824. * - VertexBuffer.ColorKind
  33825. * - VertexBuffer.MatricesIndicesKind
  33826. * - VertexBuffer.MatricesIndicesExtraKind
  33827. * - VertexBuffer.MatricesWeightsKind
  33828. * - VertexBuffer.MatricesWeightsExtraKind
  33829. * @returns a boolean
  33830. */
  33831. isVertexBufferUpdatable(kind: string): boolean;
  33832. /**
  33833. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33834. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33835. * - VertexBuffer.PositionKind
  33836. * - VertexBuffer.NormalKind
  33837. * - VertexBuffer.UVKind
  33838. * - VertexBuffer.UV2Kind
  33839. * - VertexBuffer.UV3Kind
  33840. * - VertexBuffer.UV4Kind
  33841. * - VertexBuffer.UV5Kind
  33842. * - VertexBuffer.UV6Kind
  33843. * - VertexBuffer.ColorKind
  33844. * - VertexBuffer.MatricesIndicesKind
  33845. * - VertexBuffer.MatricesIndicesExtraKind
  33846. * - VertexBuffer.MatricesWeightsKind
  33847. * - VertexBuffer.MatricesWeightsExtraKind
  33848. * @returns an array of strings
  33849. */
  33850. getVerticesDataKinds(): string[];
  33851. /**
  33852. * Returns a positive integer : the total number of indices in this mesh geometry.
  33853. * @returns the numner of indices or zero if the mesh has no geometry.
  33854. */
  33855. getTotalIndices(): number;
  33856. /**
  33857. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33858. * @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.
  33859. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33860. * @returns the indices array or an empty array if the mesh has no geometry
  33861. */
  33862. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33863. get isBlocked(): boolean;
  33864. /**
  33865. * Determine if the current mesh is ready to be rendered
  33866. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33867. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33868. * @returns true if all associated assets are ready (material, textures, shaders)
  33869. */
  33870. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33871. /**
  33872. * 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.
  33873. */
  33874. get areNormalsFrozen(): boolean;
  33875. /**
  33876. * 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.
  33877. * @returns the current mesh
  33878. */
  33879. freezeNormals(): Mesh;
  33880. /**
  33881. * 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
  33882. * @returns the current mesh
  33883. */
  33884. unfreezeNormals(): Mesh;
  33885. /**
  33886. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33887. */
  33888. set overridenInstanceCount(count: number);
  33889. /** @hidden */
  33890. _preActivate(): Mesh;
  33891. /** @hidden */
  33892. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33893. /** @hidden */
  33894. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33895. protected _afterComputeWorldMatrix(): void;
  33896. /** @hidden */
  33897. _postActivate(): void;
  33898. /**
  33899. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33900. * This means the mesh underlying bounding box and sphere are recomputed.
  33901. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33902. * @returns the current mesh
  33903. */
  33904. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33905. /** @hidden */
  33906. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33907. /**
  33908. * This function will subdivide the mesh into multiple submeshes
  33909. * @param count defines the expected number of submeshes
  33910. */
  33911. subdivide(count: number): void;
  33912. /**
  33913. * Copy a FloatArray into a specific associated vertex buffer
  33914. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33915. * - VertexBuffer.PositionKind
  33916. * - VertexBuffer.UVKind
  33917. * - VertexBuffer.UV2Kind
  33918. * - VertexBuffer.UV3Kind
  33919. * - VertexBuffer.UV4Kind
  33920. * - VertexBuffer.UV5Kind
  33921. * - VertexBuffer.UV6Kind
  33922. * - VertexBuffer.ColorKind
  33923. * - VertexBuffer.MatricesIndicesKind
  33924. * - VertexBuffer.MatricesIndicesExtraKind
  33925. * - VertexBuffer.MatricesWeightsKind
  33926. * - VertexBuffer.MatricesWeightsExtraKind
  33927. * @param data defines the data source
  33928. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33929. * @param stride defines the data stride size (can be null)
  33930. * @returns the current mesh
  33931. */
  33932. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33933. /**
  33934. * Delete a vertex buffer associated with this mesh
  33935. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33936. * - VertexBuffer.PositionKind
  33937. * - VertexBuffer.UVKind
  33938. * - VertexBuffer.UV2Kind
  33939. * - VertexBuffer.UV3Kind
  33940. * - VertexBuffer.UV4Kind
  33941. * - VertexBuffer.UV5Kind
  33942. * - VertexBuffer.UV6Kind
  33943. * - VertexBuffer.ColorKind
  33944. * - VertexBuffer.MatricesIndicesKind
  33945. * - VertexBuffer.MatricesIndicesExtraKind
  33946. * - VertexBuffer.MatricesWeightsKind
  33947. * - VertexBuffer.MatricesWeightsExtraKind
  33948. */
  33949. removeVerticesData(kind: string): void;
  33950. /**
  33951. * Flags an associated vertex buffer as updatable
  33952. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33953. * - VertexBuffer.PositionKind
  33954. * - VertexBuffer.UVKind
  33955. * - VertexBuffer.UV2Kind
  33956. * - VertexBuffer.UV3Kind
  33957. * - VertexBuffer.UV4Kind
  33958. * - VertexBuffer.UV5Kind
  33959. * - VertexBuffer.UV6Kind
  33960. * - VertexBuffer.ColorKind
  33961. * - VertexBuffer.MatricesIndicesKind
  33962. * - VertexBuffer.MatricesIndicesExtraKind
  33963. * - VertexBuffer.MatricesWeightsKind
  33964. * - VertexBuffer.MatricesWeightsExtraKind
  33965. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33966. */
  33967. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33968. /**
  33969. * Sets the mesh global Vertex Buffer
  33970. * @param buffer defines the buffer to use
  33971. * @returns the current mesh
  33972. */
  33973. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33974. /**
  33975. * Update a specific associated vertex buffer
  33976. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33977. * - VertexBuffer.PositionKind
  33978. * - VertexBuffer.UVKind
  33979. * - VertexBuffer.UV2Kind
  33980. * - VertexBuffer.UV3Kind
  33981. * - VertexBuffer.UV4Kind
  33982. * - VertexBuffer.UV5Kind
  33983. * - VertexBuffer.UV6Kind
  33984. * - VertexBuffer.ColorKind
  33985. * - VertexBuffer.MatricesIndicesKind
  33986. * - VertexBuffer.MatricesIndicesExtraKind
  33987. * - VertexBuffer.MatricesWeightsKind
  33988. * - VertexBuffer.MatricesWeightsExtraKind
  33989. * @param data defines the data source
  33990. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33991. * @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)
  33992. * @returns the current mesh
  33993. */
  33994. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33995. /**
  33996. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33997. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33998. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33999. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34000. * @returns the current mesh
  34001. */
  34002. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34003. /**
  34004. * Creates a un-shared specific occurence of the geometry for the mesh.
  34005. * @returns the current mesh
  34006. */
  34007. makeGeometryUnique(): Mesh;
  34008. /**
  34009. * Set the index buffer of this mesh
  34010. * @param indices defines the source data
  34011. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34012. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34013. * @returns the current mesh
  34014. */
  34015. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34016. /**
  34017. * Update the current index buffer
  34018. * @param indices defines the source data
  34019. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34020. * @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)
  34021. * @returns the current mesh
  34022. */
  34023. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34024. /**
  34025. * Invert the geometry to move from a right handed system to a left handed one.
  34026. * @returns the current mesh
  34027. */
  34028. toLeftHanded(): Mesh;
  34029. /** @hidden */
  34030. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34031. /** @hidden */
  34032. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34033. /**
  34034. * Registers for this mesh a javascript function called just before the rendering process
  34035. * @param func defines the function to call before rendering this mesh
  34036. * @returns the current mesh
  34037. */
  34038. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34039. /**
  34040. * Disposes a previously registered javascript function called before the rendering
  34041. * @param func defines the function to remove
  34042. * @returns the current mesh
  34043. */
  34044. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34045. /**
  34046. * Registers for this mesh a javascript function called just after the rendering is complete
  34047. * @param func defines the function to call after rendering this mesh
  34048. * @returns the current mesh
  34049. */
  34050. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34051. /**
  34052. * Disposes a previously registered javascript function called after the rendering.
  34053. * @param func defines the function to remove
  34054. * @returns the current mesh
  34055. */
  34056. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34057. /** @hidden */
  34058. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34059. /** @hidden */
  34060. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34061. /** @hidden */
  34062. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34063. /** @hidden */
  34064. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34065. /** @hidden */
  34066. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34067. /** @hidden */
  34068. _rebuild(): void;
  34069. /** @hidden */
  34070. _freeze(): void;
  34071. /** @hidden */
  34072. _unFreeze(): void;
  34073. /**
  34074. * 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
  34075. * @param subMesh defines the subMesh to render
  34076. * @param enableAlphaMode defines if alpha mode can be changed
  34077. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34078. * @returns the current mesh
  34079. */
  34080. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34081. private _onBeforeDraw;
  34082. /**
  34083. * Renormalize the mesh and patch it up if there are no weights
  34084. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34085. * However in the case of zero weights then we set just a single influence to 1.
  34086. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34087. */
  34088. cleanMatrixWeights(): void;
  34089. private normalizeSkinFourWeights;
  34090. private normalizeSkinWeightsAndExtra;
  34091. /**
  34092. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34093. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34094. * the user know there was an issue with importing the mesh
  34095. * @returns a validation object with skinned, valid and report string
  34096. */
  34097. validateSkinning(): {
  34098. skinned: boolean;
  34099. valid: boolean;
  34100. report: string;
  34101. };
  34102. /** @hidden */
  34103. _checkDelayState(): Mesh;
  34104. private _queueLoad;
  34105. /**
  34106. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34107. * A mesh is in the frustum if its bounding box intersects the frustum
  34108. * @param frustumPlanes defines the frustum to test
  34109. * @returns true if the mesh is in the frustum planes
  34110. */
  34111. isInFrustum(frustumPlanes: Plane[]): boolean;
  34112. /**
  34113. * Sets the mesh material by the material or multiMaterial `id` property
  34114. * @param id is a string identifying the material or the multiMaterial
  34115. * @returns the current mesh
  34116. */
  34117. setMaterialByID(id: string): Mesh;
  34118. /**
  34119. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34120. * @returns an array of IAnimatable
  34121. */
  34122. getAnimatables(): IAnimatable[];
  34123. /**
  34124. * Modifies the mesh geometry according to the passed transformation matrix.
  34125. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34126. * The mesh normals are modified using the same transformation.
  34127. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34128. * @param transform defines the transform matrix to use
  34129. * @see https://doc.babylonjs.com/resources/baking_transformations
  34130. * @returns the current mesh
  34131. */
  34132. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34133. /**
  34134. * Modifies the mesh geometry according to its own current World Matrix.
  34135. * The mesh World Matrix is then reset.
  34136. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34137. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34138. * @see https://doc.babylonjs.com/resources/baking_transformations
  34139. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34140. * @returns the current mesh
  34141. */
  34142. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34143. /** @hidden */
  34144. get _positions(): Nullable<Vector3[]>;
  34145. /** @hidden */
  34146. _resetPointsArrayCache(): Mesh;
  34147. /** @hidden */
  34148. _generatePointsArray(): boolean;
  34149. /**
  34150. * Returns a new Mesh object generated from the current mesh properties.
  34151. * This method must not get confused with createInstance()
  34152. * @param name is a string, the name given to the new mesh
  34153. * @param newParent can be any Node object (default `null`)
  34154. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34155. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34156. * @returns a new mesh
  34157. */
  34158. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34159. /**
  34160. * Releases resources associated with this mesh.
  34161. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34162. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34163. */
  34164. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34165. /** @hidden */
  34166. _disposeInstanceSpecificData(): void;
  34167. /** @hidden */
  34168. _disposeThinInstanceSpecificData(): void;
  34169. /**
  34170. * Modifies the mesh geometry according to a displacement map.
  34171. * 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.
  34172. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34173. * @param url is a string, the URL from the image file is to be downloaded.
  34174. * @param minHeight is the lower limit of the displacement.
  34175. * @param maxHeight is the upper limit of the displacement.
  34176. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  34177. * @param uvOffset is an optional vector2 used to offset UV.
  34178. * @param uvScale is an optional vector2 used to scale UV.
  34179. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  34180. * @returns the Mesh.
  34181. */
  34182. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34183. /**
  34184. * Modifies the mesh geometry according to a displacementMap buffer.
  34185. * 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.
  34186. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34187. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34188. * @param heightMapWidth is the width of the buffer image.
  34189. * @param heightMapHeight is the height of the buffer image.
  34190. * @param minHeight is the lower limit of the displacement.
  34191. * @param maxHeight is the upper limit of the displacement.
  34192. * @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.
  34193. * @param uvOffset is an optional vector2 used to offset UV.
  34194. * @param uvScale is an optional vector2 used to scale UV.
  34195. * @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.
  34196. * @returns the Mesh.
  34197. */
  34198. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34199. /**
  34200. * Modify the mesh to get a flat shading rendering.
  34201. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34202. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34203. * @returns current mesh
  34204. */
  34205. convertToFlatShadedMesh(): Mesh;
  34206. /**
  34207. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34208. * In other words, more vertices, no more indices and a single bigger VBO.
  34209. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34210. * @returns current mesh
  34211. */
  34212. convertToUnIndexedMesh(): Mesh;
  34213. /**
  34214. * Inverses facet orientations.
  34215. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34216. * @param flipNormals will also inverts the normals
  34217. * @returns current mesh
  34218. */
  34219. flipFaces(flipNormals?: boolean): Mesh;
  34220. /**
  34221. * Increase the number of facets and hence vertices in a mesh
  34222. * Vertex normals are interpolated from existing vertex normals
  34223. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34224. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34225. */
  34226. increaseVertices(numberPerEdge: number): void;
  34227. /**
  34228. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34229. * This will undo any application of covertToFlatShadedMesh
  34230. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34231. */
  34232. forceSharedVertices(): void;
  34233. /** @hidden */
  34234. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34235. /** @hidden */
  34236. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34237. /**
  34238. * Creates a new InstancedMesh object from the mesh model.
  34239. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34240. * @param name defines the name of the new instance
  34241. * @returns a new InstancedMesh
  34242. */
  34243. createInstance(name: string): InstancedMesh;
  34244. /**
  34245. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34246. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34247. * @returns the current mesh
  34248. */
  34249. synchronizeInstances(): Mesh;
  34250. /**
  34251. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34252. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34253. * This should be used together with the simplification to avoid disappearing triangles.
  34254. * @param successCallback an optional success callback to be called after the optimization finished.
  34255. * @returns the current mesh
  34256. */
  34257. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34258. /**
  34259. * Serialize current mesh
  34260. * @param serializationObject defines the object which will receive the serialization data
  34261. */
  34262. serialize(serializationObject: any): void;
  34263. /** @hidden */
  34264. _syncGeometryWithMorphTargetManager(): void;
  34265. /** @hidden */
  34266. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34267. /**
  34268. * Returns a new Mesh object parsed from the source provided.
  34269. * @param parsedMesh is the source
  34270. * @param scene defines the hosting scene
  34271. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34272. * @returns a new Mesh
  34273. */
  34274. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34275. /**
  34276. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34277. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34278. * @param name defines the name of the mesh to create
  34279. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34280. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34281. * @param closePath creates a seam between the first and the last points of each path of the path array
  34282. * @param offset is taken in account only if the `pathArray` is containing a single path
  34283. * @param scene defines the hosting scene
  34284. * @param updatable defines if the mesh must be flagged as updatable
  34285. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34286. * @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)
  34287. * @returns a new Mesh
  34288. */
  34289. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34290. /**
  34291. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34292. * @param name defines the name of the mesh to create
  34293. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34294. * @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
  34295. * @param scene defines the hosting scene
  34296. * @param updatable defines if the mesh must be flagged as updatable
  34297. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34298. * @returns a new Mesh
  34299. */
  34300. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34301. /**
  34302. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34303. * @param name defines the name of the mesh to create
  34304. * @param size sets the size (float) of each box side (default 1)
  34305. * @param scene defines the hosting scene
  34306. * @param updatable defines if the mesh must be flagged as updatable
  34307. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34308. * @returns a new Mesh
  34309. */
  34310. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34311. /**
  34312. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34313. * @param name defines the name of the mesh to create
  34314. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34315. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34316. * @param scene defines the hosting scene
  34317. * @param updatable defines if the mesh must be flagged as updatable
  34318. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34319. * @returns a new Mesh
  34320. */
  34321. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34322. /**
  34323. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34324. * @param name defines the name of the mesh to create
  34325. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34326. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34327. * @param scene defines the hosting scene
  34328. * @returns a new Mesh
  34329. */
  34330. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34331. /**
  34332. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34333. * @param name defines the name of the mesh to create
  34334. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34335. * @param diameterTop set the top cap diameter (floats, default 1)
  34336. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34337. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34338. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34339. * @param scene defines the hosting scene
  34340. * @param updatable defines if the mesh must be flagged as updatable
  34341. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34342. * @returns a new Mesh
  34343. */
  34344. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34345. /**
  34346. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34347. * @param name defines the name of the mesh to create
  34348. * @param diameter sets the diameter size (float) of the torus (default 1)
  34349. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34350. * @param tessellation sets the number of torus sides (postive integer, default 16)
  34351. * @param scene defines the hosting scene
  34352. * @param updatable defines if the mesh must be flagged as updatable
  34353. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34354. * @returns a new Mesh
  34355. */
  34356. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34357. /**
  34358. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34359. * @param name defines the name of the mesh to create
  34360. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34361. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34362. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34363. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34364. * @param p the number of windings on X axis (positive integers, default 2)
  34365. * @param q the number of windings on Y axis (positive integers, default 3)
  34366. * @param scene defines the hosting scene
  34367. * @param updatable defines if the mesh must be flagged as updatable
  34368. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34369. * @returns a new Mesh
  34370. */
  34371. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34372. /**
  34373. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34374. * @param name defines the name of the mesh to create
  34375. * @param points is an array successive Vector3
  34376. * @param scene defines the hosting scene
  34377. * @param updatable defines if the mesh must be flagged as updatable
  34378. * @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).
  34379. * @returns a new Mesh
  34380. */
  34381. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34382. /**
  34383. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34384. * @param name defines the name of the mesh to create
  34385. * @param points is an array successive Vector3
  34386. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34387. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34388. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34389. * @param scene defines the hosting scene
  34390. * @param updatable defines if the mesh must be flagged as updatable
  34391. * @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)
  34392. * @returns a new Mesh
  34393. */
  34394. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34395. /**
  34396. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34397. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34398. * 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.
  34399. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34400. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34401. * Remember you can only change the shape positions, not their number when updating a polygon.
  34402. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34403. * @param name defines the name of the mesh to create
  34404. * @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
  34405. * @param scene defines the hosting scene
  34406. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34407. * @param updatable defines if the mesh must be flagged as updatable
  34408. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34409. * @param earcutInjection can be used to inject your own earcut reference
  34410. * @returns a new Mesh
  34411. */
  34412. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34413. /**
  34414. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34415. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34416. * @param name defines the name of the mesh to create
  34417. * @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
  34418. * @param depth defines the height of extrusion
  34419. * @param scene defines the hosting scene
  34420. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34421. * @param updatable defines if the mesh must be flagged as updatable
  34422. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34423. * @param earcutInjection can be used to inject your own earcut reference
  34424. * @returns a new Mesh
  34425. */
  34426. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34427. /**
  34428. * Creates an extruded shape mesh.
  34429. * 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
  34430. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34431. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34432. * @param name defines the name of the mesh to create
  34433. * @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
  34434. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34435. * @param scale is the value to scale the shape
  34436. * @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
  34437. * @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
  34438. * @param scene defines the hosting scene
  34439. * @param updatable defines if the mesh must be flagged as updatable
  34440. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34441. * @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)
  34442. * @returns a new Mesh
  34443. */
  34444. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34445. /**
  34446. * Creates an custom extruded shape mesh.
  34447. * The custom extrusion is a parametric shape.
  34448. * It has no predefined shape. Its final shape will depend on the input parameters.
  34449. * Please consider using the same method from the MeshBuilder class instead
  34450. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34451. * @param name defines the name of the mesh to create
  34452. * @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
  34453. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34454. * @param scaleFunction is a custom Javascript function called on each path point
  34455. * @param rotationFunction is a custom Javascript function called on each path point
  34456. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34457. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34458. * @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
  34459. * @param scene defines the hosting scene
  34460. * @param updatable defines if the mesh must be flagged as updatable
  34461. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34462. * @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)
  34463. * @returns a new Mesh
  34464. */
  34465. 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;
  34466. /**
  34467. * Creates lathe mesh.
  34468. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34469. * Please consider using the same method from the MeshBuilder class instead
  34470. * @param name defines the name of the mesh to create
  34471. * @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
  34472. * @param radius is the radius value of the lathe
  34473. * @param tessellation is the side number of the lathe.
  34474. * @param scene defines the hosting scene
  34475. * @param updatable defines if the mesh must be flagged as updatable
  34476. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34477. * @returns a new Mesh
  34478. */
  34479. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34480. /**
  34481. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34482. * @param name defines the name of the mesh to create
  34483. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34484. * @param scene defines the hosting scene
  34485. * @param updatable defines if the mesh must be flagged as updatable
  34486. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34487. * @returns a new Mesh
  34488. */
  34489. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34490. /**
  34491. * Creates a ground mesh.
  34492. * Please consider using the same method from the MeshBuilder class instead
  34493. * @param name defines the name of the mesh to create
  34494. * @param width set the width of the ground
  34495. * @param height set the height of the ground
  34496. * @param subdivisions sets the number of subdivisions per side
  34497. * @param scene defines the hosting scene
  34498. * @param updatable defines if the mesh must be flagged as updatable
  34499. * @returns a new Mesh
  34500. */
  34501. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34502. /**
  34503. * Creates a tiled ground mesh.
  34504. * Please consider using the same method from the MeshBuilder class instead
  34505. * @param name defines the name of the mesh to create
  34506. * @param xmin set the ground minimum X coordinate
  34507. * @param zmin set the ground minimum Y coordinate
  34508. * @param xmax set the ground maximum X coordinate
  34509. * @param zmax set the ground maximum Z coordinate
  34510. * @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
  34511. * @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
  34512. * @param scene defines the hosting scene
  34513. * @param updatable defines if the mesh must be flagged as updatable
  34514. * @returns a new Mesh
  34515. */
  34516. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34517. w: number;
  34518. h: number;
  34519. }, precision: {
  34520. w: number;
  34521. h: number;
  34522. }, scene: Scene, updatable?: boolean): Mesh;
  34523. /**
  34524. * Creates a ground mesh from a height map.
  34525. * Please consider using the same method from the MeshBuilder class instead
  34526. * @see https://doc.babylonjs.com/babylon101/height_map
  34527. * @param name defines the name of the mesh to create
  34528. * @param url sets the URL of the height map image resource
  34529. * @param width set the ground width size
  34530. * @param height set the ground height size
  34531. * @param subdivisions sets the number of subdivision per side
  34532. * @param minHeight is the minimum altitude on the ground
  34533. * @param maxHeight is the maximum altitude on the ground
  34534. * @param scene defines the hosting scene
  34535. * @param updatable defines if the mesh must be flagged as updatable
  34536. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34537. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34538. * @returns a new Mesh
  34539. */
  34540. 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;
  34541. /**
  34542. * Creates a tube mesh.
  34543. * The tube is a parametric shape.
  34544. * It has no predefined shape. Its final shape will depend on the input parameters.
  34545. * Please consider using the same method from the MeshBuilder class instead
  34546. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34547. * @param name defines the name of the mesh to create
  34548. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34549. * @param radius sets the tube radius size
  34550. * @param tessellation is the number of sides on the tubular surface
  34551. * @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
  34552. * @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
  34553. * @param scene defines the hosting scene
  34554. * @param updatable defines if the mesh must be flagged as updatable
  34555. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34556. * @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)
  34557. * @returns a new Mesh
  34558. */
  34559. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34560. (i: number, distance: number): number;
  34561. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34562. /**
  34563. * Creates a polyhedron mesh.
  34564. * Please consider using the same method from the MeshBuilder class instead.
  34565. * * 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
  34566. * * The parameter `size` (positive float, default 1) sets the polygon size
  34567. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34568. * * 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`
  34569. * * 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
  34570. * * 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)`)
  34571. * * 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
  34572. * * 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
  34573. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34574. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34576. * @param name defines the name of the mesh to create
  34577. * @param options defines the options used to create the mesh
  34578. * @param scene defines the hosting scene
  34579. * @returns a new Mesh
  34580. */
  34581. static CreatePolyhedron(name: string, options: {
  34582. type?: number;
  34583. size?: number;
  34584. sizeX?: number;
  34585. sizeY?: number;
  34586. sizeZ?: number;
  34587. custom?: any;
  34588. faceUV?: Vector4[];
  34589. faceColors?: Color4[];
  34590. updatable?: boolean;
  34591. sideOrientation?: number;
  34592. }, scene: Scene): Mesh;
  34593. /**
  34594. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34595. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34596. * * 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`)
  34597. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34598. * * 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
  34599. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34600. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34602. * @param name defines the name of the mesh
  34603. * @param options defines the options used to create the mesh
  34604. * @param scene defines the hosting scene
  34605. * @returns a new Mesh
  34606. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34607. */
  34608. static CreateIcoSphere(name: string, options: {
  34609. radius?: number;
  34610. flat?: boolean;
  34611. subdivisions?: number;
  34612. sideOrientation?: number;
  34613. updatable?: boolean;
  34614. }, scene: Scene): Mesh;
  34615. /**
  34616. * Creates a decal mesh.
  34617. * Please consider using the same method from the MeshBuilder class instead.
  34618. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34619. * @param name defines the name of the mesh
  34620. * @param sourceMesh defines the mesh receiving the decal
  34621. * @param position sets the position of the decal in world coordinates
  34622. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34623. * @param size sets the decal scaling
  34624. * @param angle sets the angle to rotate the decal
  34625. * @returns a new Mesh
  34626. */
  34627. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34628. /** Creates a Capsule Mesh
  34629. * @param name defines the name of the mesh.
  34630. * @param options the constructors options used to shape the mesh.
  34631. * @param scene defines the scene the mesh is scoped to.
  34632. * @returns the capsule mesh
  34633. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34634. */
  34635. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34636. /**
  34637. * Prepare internal position array for software CPU skinning
  34638. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34639. */
  34640. setPositionsForCPUSkinning(): Float32Array;
  34641. /**
  34642. * Prepare internal normal array for software CPU skinning
  34643. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34644. */
  34645. setNormalsForCPUSkinning(): Float32Array;
  34646. /**
  34647. * Updates the vertex buffer by applying transformation from the bones
  34648. * @param skeleton defines the skeleton to apply to current mesh
  34649. * @returns the current mesh
  34650. */
  34651. applySkeleton(skeleton: Skeleton): Mesh;
  34652. /**
  34653. * 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
  34654. * @param meshes defines the list of meshes to scan
  34655. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34656. */
  34657. static MinMax(meshes: AbstractMesh[]): {
  34658. min: Vector3;
  34659. max: Vector3;
  34660. };
  34661. /**
  34662. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34663. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34664. * @returns a vector3
  34665. */
  34666. static Center(meshesOrMinMaxVector: {
  34667. min: Vector3;
  34668. max: Vector3;
  34669. } | AbstractMesh[]): Vector3;
  34670. /**
  34671. * Merge the array of meshes into a single mesh for performance reasons.
  34672. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34673. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34674. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34675. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34676. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34677. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34678. * @returns a new mesh
  34679. */
  34680. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34681. /** @hidden */
  34682. addInstance(instance: InstancedMesh): void;
  34683. /** @hidden */
  34684. removeInstance(instance: InstancedMesh): void;
  34685. }
  34686. }
  34687. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  34688. import { Vector3 } from "babylonjs/Maths/math.vector";
  34689. import { Mesh } from "babylonjs/Meshes/mesh";
  34690. /**
  34691. * The options Interface for creating a Capsule Mesh
  34692. */
  34693. export interface ICreateCapsuleOptions {
  34694. /** The Orientation of the capsule. Default : Vector3.Up() */
  34695. orientation?: Vector3;
  34696. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34697. subdivisions: number;
  34698. /** Number of cylindrical segments on the capsule. */
  34699. tessellation: number;
  34700. /** Height or Length of the capsule. */
  34701. height: number;
  34702. /** Radius of the capsule. */
  34703. radius: number;
  34704. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34705. capSubdivisions: number;
  34706. /** Overwrite for the top radius. */
  34707. radiusTop?: number;
  34708. /** Overwrite for the bottom radius. */
  34709. radiusBottom?: number;
  34710. /** Overwrite for the top capSubdivisions. */
  34711. topCapSubdivisions?: number;
  34712. /** Overwrite for the bottom capSubdivisions. */
  34713. bottomCapSubdivisions?: number;
  34714. }
  34715. /**
  34716. * Class containing static functions to help procedurally build meshes
  34717. */
  34718. export class CapsuleBuilder {
  34719. /**
  34720. * Creates a capsule or a pill mesh
  34721. * @param name defines the name of the mesh
  34722. * @param options The constructors options.
  34723. * @param scene The scene the mesh is scoped to.
  34724. * @returns Capsule Mesh
  34725. */
  34726. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  34727. }
  34728. }
  34729. declare module "babylonjs/Meshes/mesh.vertexData" {
  34730. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  34731. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  34732. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  34733. import { Geometry } from "babylonjs/Meshes/geometry";
  34734. import { Mesh } from "babylonjs/Meshes/mesh";
  34735. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  34736. /**
  34737. * Define an interface for all classes that will get and set the data on vertices
  34738. */
  34739. export interface IGetSetVerticesData {
  34740. /**
  34741. * Gets a boolean indicating if specific vertex data is present
  34742. * @param kind defines the vertex data kind to use
  34743. * @returns true is data kind is present
  34744. */
  34745. isVerticesDataPresent(kind: string): boolean;
  34746. /**
  34747. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34748. * @param kind defines the data kind (Position, normal, etc...)
  34749. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34750. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34751. * @returns a float array containing vertex data
  34752. */
  34753. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34754. /**
  34755. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34756. * @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.
  34757. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34758. * @returns the indices array or an empty array if the mesh has no geometry
  34759. */
  34760. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34761. /**
  34762. * Set specific vertex data
  34763. * @param kind defines the data kind (Position, normal, etc...)
  34764. * @param data defines the vertex data to use
  34765. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34766. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34767. */
  34768. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34769. /**
  34770. * Update a specific associated vertex buffer
  34771. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34772. * - VertexBuffer.PositionKind
  34773. * - VertexBuffer.UVKind
  34774. * - VertexBuffer.UV2Kind
  34775. * - VertexBuffer.UV3Kind
  34776. * - VertexBuffer.UV4Kind
  34777. * - VertexBuffer.UV5Kind
  34778. * - VertexBuffer.UV6Kind
  34779. * - VertexBuffer.ColorKind
  34780. * - VertexBuffer.MatricesIndicesKind
  34781. * - VertexBuffer.MatricesIndicesExtraKind
  34782. * - VertexBuffer.MatricesWeightsKind
  34783. * - VertexBuffer.MatricesWeightsExtraKind
  34784. * @param data defines the data source
  34785. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34786. * @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)
  34787. */
  34788. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34789. /**
  34790. * Creates a new index buffer
  34791. * @param indices defines the indices to store in the index buffer
  34792. * @param totalVertices defines the total number of vertices (could be null)
  34793. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34794. */
  34795. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34796. }
  34797. /**
  34798. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34799. */
  34800. export class VertexData {
  34801. /**
  34802. * Mesh side orientation : usually the external or front surface
  34803. */
  34804. static readonly FRONTSIDE: number;
  34805. /**
  34806. * Mesh side orientation : usually the internal or back surface
  34807. */
  34808. static readonly BACKSIDE: number;
  34809. /**
  34810. * Mesh side orientation : both internal and external or front and back surfaces
  34811. */
  34812. static readonly DOUBLESIDE: number;
  34813. /**
  34814. * Mesh side orientation : by default, `FRONTSIDE`
  34815. */
  34816. static readonly DEFAULTSIDE: number;
  34817. /**
  34818. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34819. */
  34820. positions: Nullable<FloatArray>;
  34821. /**
  34822. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34823. */
  34824. normals: Nullable<FloatArray>;
  34825. /**
  34826. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34827. */
  34828. tangents: Nullable<FloatArray>;
  34829. /**
  34830. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34831. */
  34832. uvs: Nullable<FloatArray>;
  34833. /**
  34834. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34835. */
  34836. uvs2: Nullable<FloatArray>;
  34837. /**
  34838. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34839. */
  34840. uvs3: Nullable<FloatArray>;
  34841. /**
  34842. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34843. */
  34844. uvs4: Nullable<FloatArray>;
  34845. /**
  34846. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34847. */
  34848. uvs5: Nullable<FloatArray>;
  34849. /**
  34850. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34851. */
  34852. uvs6: Nullable<FloatArray>;
  34853. /**
  34854. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  34855. */
  34856. colors: Nullable<FloatArray>;
  34857. /**
  34858. * 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).
  34859. */
  34860. matricesIndices: Nullable<FloatArray>;
  34861. /**
  34862. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  34863. */
  34864. matricesWeights: Nullable<FloatArray>;
  34865. /**
  34866. * An array extending the number of possible indices
  34867. */
  34868. matricesIndicesExtra: Nullable<FloatArray>;
  34869. /**
  34870. * An array extending the number of possible weights when the number of indices is extended
  34871. */
  34872. matricesWeightsExtra: Nullable<FloatArray>;
  34873. /**
  34874. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  34875. */
  34876. indices: Nullable<IndicesArray>;
  34877. /**
  34878. * Uses the passed data array to set the set the values for the specified kind of data
  34879. * @param data a linear array of floating numbers
  34880. * @param kind the type of data that is being set, eg positions, colors etc
  34881. */
  34882. set(data: FloatArray, kind: string): void;
  34883. /**
  34884. * Associates the vertexData to the passed Mesh.
  34885. * Sets it as updatable or not (default `false`)
  34886. * @param mesh the mesh the vertexData is applied to
  34887. * @param updatable when used and having the value true allows new data to update the vertexData
  34888. * @returns the VertexData
  34889. */
  34890. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  34891. /**
  34892. * Associates the vertexData to the passed Geometry.
  34893. * Sets it as updatable or not (default `false`)
  34894. * @param geometry the geometry the vertexData is applied to
  34895. * @param updatable when used and having the value true allows new data to update the vertexData
  34896. * @returns VertexData
  34897. */
  34898. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  34899. /**
  34900. * Updates the associated mesh
  34901. * @param mesh the mesh to be updated
  34902. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34903. * @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
  34904. * @returns VertexData
  34905. */
  34906. updateMesh(mesh: Mesh): VertexData;
  34907. /**
  34908. * Updates the associated geometry
  34909. * @param geometry the geometry to be updated
  34910. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34911. * @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
  34912. * @returns VertexData.
  34913. */
  34914. updateGeometry(geometry: Geometry): VertexData;
  34915. private _applyTo;
  34916. private _update;
  34917. /**
  34918. * Transforms each position and each normal of the vertexData according to the passed Matrix
  34919. * @param matrix the transforming matrix
  34920. * @returns the VertexData
  34921. */
  34922. transform(matrix: Matrix): VertexData;
  34923. /**
  34924. * Merges the passed VertexData into the current one
  34925. * @param other the VertexData to be merged into the current one
  34926. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  34927. * @returns the modified VertexData
  34928. */
  34929. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  34930. private _mergeElement;
  34931. private _validate;
  34932. /**
  34933. * Serializes the VertexData
  34934. * @returns a serialized object
  34935. */
  34936. serialize(): any;
  34937. /**
  34938. * Extracts the vertexData from a mesh
  34939. * @param mesh the mesh from which to extract the VertexData
  34940. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  34941. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34942. * @returns the object VertexData associated to the passed mesh
  34943. */
  34944. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34945. /**
  34946. * Extracts the vertexData from the geometry
  34947. * @param geometry the geometry from which to extract the VertexData
  34948. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  34949. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34950. * @returns the object VertexData associated to the passed mesh
  34951. */
  34952. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34953. private static _ExtractFrom;
  34954. /**
  34955. * Creates the VertexData for a Ribbon
  34956. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  34957. * * pathArray array of paths, each of which an array of successive Vector3
  34958. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  34959. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  34960. * * 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
  34961. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34962. * * 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)
  34963. * * 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)
  34964. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  34965. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  34966. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  34967. * @returns the VertexData of the ribbon
  34968. */
  34969. static CreateRibbon(options: {
  34970. pathArray: Vector3[][];
  34971. closeArray?: boolean;
  34972. closePath?: boolean;
  34973. offset?: number;
  34974. sideOrientation?: number;
  34975. frontUVs?: Vector4;
  34976. backUVs?: Vector4;
  34977. invertUV?: boolean;
  34978. uvs?: Vector2[];
  34979. colors?: Color4[];
  34980. }): VertexData;
  34981. /**
  34982. * Creates the VertexData for a box
  34983. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34984. * * size sets the width, height and depth of the box to the value of size, optional default 1
  34985. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  34986. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  34987. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  34988. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34989. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34990. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34991. * * 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)
  34992. * * 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)
  34993. * @returns the VertexData of the box
  34994. */
  34995. static CreateBox(options: {
  34996. size?: number;
  34997. width?: number;
  34998. height?: number;
  34999. depth?: number;
  35000. faceUV?: Vector4[];
  35001. faceColors?: Color4[];
  35002. sideOrientation?: number;
  35003. frontUVs?: Vector4;
  35004. backUVs?: Vector4;
  35005. }): VertexData;
  35006. /**
  35007. * Creates the VertexData for a tiled box
  35008. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35009. * * faceTiles sets the pattern, tile size and number of tiles for a face
  35010. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  35011. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  35012. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35013. * @returns the VertexData of the box
  35014. */
  35015. static CreateTiledBox(options: {
  35016. pattern?: number;
  35017. width?: number;
  35018. height?: number;
  35019. depth?: number;
  35020. tileSize?: number;
  35021. tileWidth?: number;
  35022. tileHeight?: number;
  35023. alignHorizontal?: number;
  35024. alignVertical?: number;
  35025. faceUV?: Vector4[];
  35026. faceColors?: Color4[];
  35027. sideOrientation?: number;
  35028. }): VertexData;
  35029. /**
  35030. * Creates the VertexData for a tiled plane
  35031. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35032. * * pattern a limited pattern arrangement depending on the number
  35033. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  35034. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  35035. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  35036. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35037. * * 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)
  35038. * * 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)
  35039. * @returns the VertexData of the tiled plane
  35040. */
  35041. static CreateTiledPlane(options: {
  35042. pattern?: number;
  35043. tileSize?: number;
  35044. tileWidth?: number;
  35045. tileHeight?: number;
  35046. size?: number;
  35047. width?: number;
  35048. height?: number;
  35049. alignHorizontal?: number;
  35050. alignVertical?: number;
  35051. sideOrientation?: number;
  35052. frontUVs?: Vector4;
  35053. backUVs?: Vector4;
  35054. }): VertexData;
  35055. /**
  35056. * Creates the VertexData for an ellipsoid, defaults to a sphere
  35057. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35058. * * segments sets the number of horizontal strips optional, default 32
  35059. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  35060. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  35061. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  35062. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  35063. * * 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
  35064. * * 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
  35065. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35066. * * 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)
  35067. * * 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)
  35068. * @returns the VertexData of the ellipsoid
  35069. */
  35070. static CreateSphere(options: {
  35071. segments?: number;
  35072. diameter?: number;
  35073. diameterX?: number;
  35074. diameterY?: number;
  35075. diameterZ?: number;
  35076. arc?: number;
  35077. slice?: number;
  35078. sideOrientation?: number;
  35079. frontUVs?: Vector4;
  35080. backUVs?: Vector4;
  35081. }): VertexData;
  35082. /**
  35083. * Creates the VertexData for a cylinder, cone or prism
  35084. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35085. * * height sets the height (y direction) of the cylinder, optional, default 2
  35086. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  35087. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  35088. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  35089. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35090. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  35091. * * 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
  35092. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35093. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35094. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  35095. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  35096. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35097. * * 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)
  35098. * * 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)
  35099. * @returns the VertexData of the cylinder, cone or prism
  35100. */
  35101. static CreateCylinder(options: {
  35102. height?: number;
  35103. diameterTop?: number;
  35104. diameterBottom?: number;
  35105. diameter?: number;
  35106. tessellation?: number;
  35107. subdivisions?: number;
  35108. arc?: number;
  35109. faceColors?: Color4[];
  35110. faceUV?: Vector4[];
  35111. hasRings?: boolean;
  35112. enclose?: boolean;
  35113. sideOrientation?: number;
  35114. frontUVs?: Vector4;
  35115. backUVs?: Vector4;
  35116. }): VertexData;
  35117. /**
  35118. * Creates the VertexData for a torus
  35119. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35120. * * diameter the diameter of the torus, optional default 1
  35121. * * thickness the diameter of the tube forming the torus, optional default 0.5
  35122. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35123. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35124. * * 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)
  35125. * * 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)
  35126. * @returns the VertexData of the torus
  35127. */
  35128. static CreateTorus(options: {
  35129. diameter?: number;
  35130. thickness?: number;
  35131. tessellation?: number;
  35132. sideOrientation?: number;
  35133. frontUVs?: Vector4;
  35134. backUVs?: Vector4;
  35135. }): VertexData;
  35136. /**
  35137. * Creates the VertexData of the LineSystem
  35138. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  35139. * - lines an array of lines, each line being an array of successive Vector3
  35140. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  35141. * @returns the VertexData of the LineSystem
  35142. */
  35143. static CreateLineSystem(options: {
  35144. lines: Vector3[][];
  35145. colors?: Nullable<Color4[][]>;
  35146. }): VertexData;
  35147. /**
  35148. * Create the VertexData for a DashedLines
  35149. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  35150. * - points an array successive Vector3
  35151. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  35152. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  35153. * - dashNb the intended total number of dashes, optional, default 200
  35154. * @returns the VertexData for the DashedLines
  35155. */
  35156. static CreateDashedLines(options: {
  35157. points: Vector3[];
  35158. dashSize?: number;
  35159. gapSize?: number;
  35160. dashNb?: number;
  35161. }): VertexData;
  35162. /**
  35163. * Creates the VertexData for a Ground
  35164. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35165. * - width the width (x direction) of the ground, optional, default 1
  35166. * - height the height (z direction) of the ground, optional, default 1
  35167. * - subdivisions the number of subdivisions per side, optional, default 1
  35168. * @returns the VertexData of the Ground
  35169. */
  35170. static CreateGround(options: {
  35171. width?: number;
  35172. height?: number;
  35173. subdivisions?: number;
  35174. subdivisionsX?: number;
  35175. subdivisionsY?: number;
  35176. }): VertexData;
  35177. /**
  35178. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  35179. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35180. * * xmin the ground minimum X coordinate, optional, default -1
  35181. * * zmin the ground minimum Z coordinate, optional, default -1
  35182. * * xmax the ground maximum X coordinate, optional, default 1
  35183. * * zmax the ground maximum Z coordinate, optional, default 1
  35184. * * 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}
  35185. * * 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}
  35186. * @returns the VertexData of the TiledGround
  35187. */
  35188. static CreateTiledGround(options: {
  35189. xmin: number;
  35190. zmin: number;
  35191. xmax: number;
  35192. zmax: number;
  35193. subdivisions?: {
  35194. w: number;
  35195. h: number;
  35196. };
  35197. precision?: {
  35198. w: number;
  35199. h: number;
  35200. };
  35201. }): VertexData;
  35202. /**
  35203. * Creates the VertexData of the Ground designed from a heightmap
  35204. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  35205. * * width the width (x direction) of the ground
  35206. * * height the height (z direction) of the ground
  35207. * * subdivisions the number of subdivisions per side
  35208. * * minHeight the minimum altitude on the ground, optional, default 0
  35209. * * maxHeight the maximum altitude on the ground, optional default 1
  35210. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  35211. * * buffer the array holding the image color data
  35212. * * bufferWidth the width of image
  35213. * * bufferHeight the height of image
  35214. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  35215. * @returns the VertexData of the Ground designed from a heightmap
  35216. */
  35217. static CreateGroundFromHeightMap(options: {
  35218. width: number;
  35219. height: number;
  35220. subdivisions: number;
  35221. minHeight: number;
  35222. maxHeight: number;
  35223. colorFilter: Color3;
  35224. buffer: Uint8Array;
  35225. bufferWidth: number;
  35226. bufferHeight: number;
  35227. alphaFilter: number;
  35228. }): VertexData;
  35229. /**
  35230. * Creates the VertexData for a Plane
  35231. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  35232. * * size sets the width and height of the plane to the value of size, optional default 1
  35233. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  35234. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  35235. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35236. * * 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)
  35237. * * 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)
  35238. * @returns the VertexData of the box
  35239. */
  35240. static CreatePlane(options: {
  35241. size?: number;
  35242. width?: number;
  35243. height?: number;
  35244. sideOrientation?: number;
  35245. frontUVs?: Vector4;
  35246. backUVs?: Vector4;
  35247. }): VertexData;
  35248. /**
  35249. * Creates the VertexData of the Disc or regular Polygon
  35250. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  35251. * * radius the radius of the disc, optional default 0.5
  35252. * * tessellation the number of polygon sides, optional, default 64
  35253. * * 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
  35254. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35255. * * 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)
  35256. * * 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)
  35257. * @returns the VertexData of the box
  35258. */
  35259. static CreateDisc(options: {
  35260. radius?: number;
  35261. tessellation?: number;
  35262. arc?: number;
  35263. sideOrientation?: number;
  35264. frontUVs?: Vector4;
  35265. backUVs?: Vector4;
  35266. }): VertexData;
  35267. /**
  35268. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  35269. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  35270. * @param polygon a mesh built from polygonTriangulation.build()
  35271. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35272. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35273. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35274. * @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)
  35275. * @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)
  35276. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  35277. * @returns the VertexData of the Polygon
  35278. */
  35279. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  35280. /**
  35281. * Creates the VertexData of the IcoSphere
  35282. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  35283. * * radius the radius of the IcoSphere, optional default 1
  35284. * * radiusX allows stretching in the x direction, optional, default radius
  35285. * * radiusY allows stretching in the y direction, optional, default radius
  35286. * * radiusZ allows stretching in the z direction, optional, default radius
  35287. * * flat when true creates a flat shaded mesh, optional, default true
  35288. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35289. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35290. * * 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)
  35291. * * 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)
  35292. * @returns the VertexData of the IcoSphere
  35293. */
  35294. static CreateIcoSphere(options: {
  35295. radius?: number;
  35296. radiusX?: number;
  35297. radiusY?: number;
  35298. radiusZ?: number;
  35299. flat?: boolean;
  35300. subdivisions?: number;
  35301. sideOrientation?: number;
  35302. frontUVs?: Vector4;
  35303. backUVs?: Vector4;
  35304. }): VertexData;
  35305. /**
  35306. * Creates the VertexData for a Polyhedron
  35307. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  35308. * * type provided types are:
  35309. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  35310. * * 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)
  35311. * * size the size of the IcoSphere, optional default 1
  35312. * * sizeX allows stretching in the x direction, optional, default size
  35313. * * sizeY allows stretching in the y direction, optional, default size
  35314. * * sizeZ allows stretching in the z direction, optional, default size
  35315. * * 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
  35316. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35317. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35318. * * flat when true creates a flat shaded mesh, optional, default true
  35319. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35320. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35321. * * 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)
  35322. * * 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)
  35323. * @returns the VertexData of the Polyhedron
  35324. */
  35325. static CreatePolyhedron(options: {
  35326. type?: number;
  35327. size?: number;
  35328. sizeX?: number;
  35329. sizeY?: number;
  35330. sizeZ?: number;
  35331. custom?: any;
  35332. faceUV?: Vector4[];
  35333. faceColors?: Color4[];
  35334. flat?: boolean;
  35335. sideOrientation?: number;
  35336. frontUVs?: Vector4;
  35337. backUVs?: Vector4;
  35338. }): VertexData;
  35339. /**
  35340. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  35341. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  35342. * @returns the VertexData of the Capsule
  35343. */
  35344. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  35345. /**
  35346. * Creates the VertexData for a TorusKnot
  35347. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  35348. * * radius the radius of the torus knot, optional, default 2
  35349. * * tube the thickness of the tube, optional, default 0.5
  35350. * * radialSegments the number of sides on each tube segments, optional, default 32
  35351. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  35352. * * p the number of windings around the z axis, optional, default 2
  35353. * * q the number of windings around the x axis, optional, default 3
  35354. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35355. * * 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)
  35356. * * 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)
  35357. * @returns the VertexData of the Torus Knot
  35358. */
  35359. static CreateTorusKnot(options: {
  35360. radius?: number;
  35361. tube?: number;
  35362. radialSegments?: number;
  35363. tubularSegments?: number;
  35364. p?: number;
  35365. q?: number;
  35366. sideOrientation?: number;
  35367. frontUVs?: Vector4;
  35368. backUVs?: Vector4;
  35369. }): VertexData;
  35370. /**
  35371. * Compute normals for given positions and indices
  35372. * @param positions an array of vertex positions, [...., x, y, z, ......]
  35373. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  35374. * @param normals an array of vertex normals, [...., x, y, z, ......]
  35375. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  35376. * * facetNormals : optional array of facet normals (vector3)
  35377. * * facetPositions : optional array of facet positions (vector3)
  35378. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  35379. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  35380. * * bInfo : optional bounding info, required for facetPartitioning computation
  35381. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  35382. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  35383. * * useRightHandedSystem: optional boolean to for right handed system computation
  35384. * * depthSort : optional boolean to enable the facet depth sort computation
  35385. * * distanceTo : optional Vector3 to compute the facet depth from this location
  35386. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  35387. */
  35388. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  35389. facetNormals?: any;
  35390. facetPositions?: any;
  35391. facetPartitioning?: any;
  35392. ratio?: number;
  35393. bInfo?: any;
  35394. bbSize?: Vector3;
  35395. subDiv?: any;
  35396. useRightHandedSystem?: boolean;
  35397. depthSort?: boolean;
  35398. distanceTo?: Vector3;
  35399. depthSortedFacets?: any;
  35400. }): void;
  35401. /** @hidden */
  35402. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  35403. /**
  35404. * Applies VertexData created from the imported parameters to the geometry
  35405. * @param parsedVertexData the parsed data from an imported file
  35406. * @param geometry the geometry to apply the VertexData to
  35407. */
  35408. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  35409. }
  35410. }
  35411. declare module "babylonjs/Meshes/Builders/discBuilder" {
  35412. import { Nullable } from "babylonjs/types";
  35413. import { Scene } from "babylonjs/scene";
  35414. import { Vector4 } from "babylonjs/Maths/math.vector";
  35415. import { Mesh } from "babylonjs/Meshes/mesh";
  35416. /**
  35417. * Class containing static functions to help procedurally build meshes
  35418. */
  35419. export class DiscBuilder {
  35420. /**
  35421. * Creates a plane polygonal mesh. By default, this is a disc
  35422. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35423. * * 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
  35424. * * 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
  35425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35426. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35428. * @param name defines the name of the mesh
  35429. * @param options defines the options used to create the mesh
  35430. * @param scene defines the hosting scene
  35431. * @returns the plane polygonal mesh
  35432. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35433. */
  35434. static CreateDisc(name: string, options: {
  35435. radius?: number;
  35436. tessellation?: number;
  35437. arc?: number;
  35438. updatable?: boolean;
  35439. sideOrientation?: number;
  35440. frontUVs?: Vector4;
  35441. backUVs?: Vector4;
  35442. }, scene?: Nullable<Scene>): Mesh;
  35443. }
  35444. }
  35445. declare module "babylonjs/Particles/solidParticleSystem" {
  35446. import { Nullable } from "babylonjs/types";
  35447. import { Mesh } from "babylonjs/Meshes/mesh";
  35448. import { Scene, IDisposable } from "babylonjs/scene";
  35449. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  35450. import { Material } from "babylonjs/Materials/material";
  35451. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35452. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35453. /**
  35454. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35455. *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.
  35456. * The SPS is also a particle system. It provides some methods to manage the particles.
  35457. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35458. *
  35459. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35460. */
  35461. export class SolidParticleSystem implements IDisposable {
  35462. /**
  35463. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35464. * Example : var p = SPS.particles[i];
  35465. */
  35466. particles: SolidParticle[];
  35467. /**
  35468. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35469. */
  35470. nbParticles: number;
  35471. /**
  35472. * If the particles must ever face the camera (default false). Useful for planar particles.
  35473. */
  35474. billboard: boolean;
  35475. /**
  35476. * Recompute normals when adding a shape
  35477. */
  35478. recomputeNormals: boolean;
  35479. /**
  35480. * This a counter ofr your own usage. It's not set by any SPS functions.
  35481. */
  35482. counter: number;
  35483. /**
  35484. * The SPS name. This name is also given to the underlying mesh.
  35485. */
  35486. name: string;
  35487. /**
  35488. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  35489. */
  35490. mesh: Mesh;
  35491. /**
  35492. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35493. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35494. */
  35495. vars: any;
  35496. /**
  35497. * This array is populated when the SPS is set as 'pickable'.
  35498. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35499. * Each element of this array is an object `{idx: int, faceId: int}`.
  35500. * `idx` is the picked particle index in the `SPS.particles` array
  35501. * `faceId` is the picked face index counted within this particle.
  35502. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35503. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35504. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35505. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35506. */
  35507. pickedParticles: {
  35508. idx: number;
  35509. faceId: number;
  35510. }[];
  35511. /**
  35512. * This array is populated when the SPS is set as 'pickable'
  35513. * Each key of this array is a submesh index.
  35514. * Each element of this array is a second array defined like this :
  35515. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35516. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35517. * `idx` is the picked particle index in the `SPS.particles` array
  35518. * `faceId` is the picked face index counted within this particle.
  35519. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35520. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35521. */
  35522. pickedBySubMesh: {
  35523. idx: number;
  35524. faceId: number;
  35525. }[][];
  35526. /**
  35527. * This array is populated when `enableDepthSort` is set to true.
  35528. * Each element of this array is an instance of the class DepthSortedParticle.
  35529. */
  35530. depthSortedParticles: DepthSortedParticle[];
  35531. /**
  35532. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35533. * @hidden
  35534. */
  35535. _bSphereOnly: boolean;
  35536. /**
  35537. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35538. * @hidden
  35539. */
  35540. _bSphereRadiusFactor: number;
  35541. private _scene;
  35542. private _positions;
  35543. private _indices;
  35544. private _normals;
  35545. private _colors;
  35546. private _uvs;
  35547. private _indices32;
  35548. private _positions32;
  35549. private _normals32;
  35550. private _fixedNormal32;
  35551. private _colors32;
  35552. private _uvs32;
  35553. private _index;
  35554. private _updatable;
  35555. private _pickable;
  35556. private _isVisibilityBoxLocked;
  35557. private _alwaysVisible;
  35558. private _depthSort;
  35559. private _expandable;
  35560. private _shapeCounter;
  35561. private _copy;
  35562. private _color;
  35563. private _computeParticleColor;
  35564. private _computeParticleTexture;
  35565. private _computeParticleRotation;
  35566. private _computeParticleVertex;
  35567. private _computeBoundingBox;
  35568. private _depthSortParticles;
  35569. private _camera;
  35570. private _mustUnrotateFixedNormals;
  35571. private _particlesIntersect;
  35572. private _needs32Bits;
  35573. private _isNotBuilt;
  35574. private _lastParticleId;
  35575. private _idxOfId;
  35576. private _multimaterialEnabled;
  35577. private _useModelMaterial;
  35578. private _indicesByMaterial;
  35579. private _materialIndexes;
  35580. private _depthSortFunction;
  35581. private _materialSortFunction;
  35582. private _materials;
  35583. private _multimaterial;
  35584. private _materialIndexesById;
  35585. private _defaultMaterial;
  35586. private _autoUpdateSubMeshes;
  35587. private _tmpVertex;
  35588. /**
  35589. * Creates a SPS (Solid Particle System) object.
  35590. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35591. * @param scene (Scene) is the scene in which the SPS is added.
  35592. * @param options defines the options of the sps e.g.
  35593. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35594. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35595. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35596. * * 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.
  35597. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35598. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35599. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35600. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35601. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35602. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35603. */
  35604. constructor(name: string, scene: Scene, options?: {
  35605. updatable?: boolean;
  35606. isPickable?: boolean;
  35607. enableDepthSort?: boolean;
  35608. particleIntersection?: boolean;
  35609. boundingSphereOnly?: boolean;
  35610. bSphereRadiusFactor?: number;
  35611. expandable?: boolean;
  35612. useModelMaterial?: boolean;
  35613. enableMultiMaterial?: boolean;
  35614. });
  35615. /**
  35616. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35617. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35618. * @returns the created mesh
  35619. */
  35620. buildMesh(): Mesh;
  35621. /**
  35622. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35623. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35624. * Thus the particles generated from `digest()` have their property `position` set yet.
  35625. * @param mesh ( Mesh ) is the mesh to be digested
  35626. * @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
  35627. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35628. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35629. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35630. * @returns the current SPS
  35631. */
  35632. digest(mesh: Mesh, options?: {
  35633. facetNb?: number;
  35634. number?: number;
  35635. delta?: number;
  35636. storage?: [];
  35637. }): SolidParticleSystem;
  35638. /**
  35639. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35640. * @hidden
  35641. */
  35642. private _unrotateFixedNormals;
  35643. /**
  35644. * Resets the temporary working copy particle
  35645. * @hidden
  35646. */
  35647. private _resetCopy;
  35648. /**
  35649. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35650. * @param p the current index in the positions array to be updated
  35651. * @param ind the current index in the indices array
  35652. * @param shape a Vector3 array, the shape geometry
  35653. * @param positions the positions array to be updated
  35654. * @param meshInd the shape indices array
  35655. * @param indices the indices array to be updated
  35656. * @param meshUV the shape uv array
  35657. * @param uvs the uv array to be updated
  35658. * @param meshCol the shape color array
  35659. * @param colors the color array to be updated
  35660. * @param meshNor the shape normals array
  35661. * @param normals the normals array to be updated
  35662. * @param idx the particle index
  35663. * @param idxInShape the particle index in its shape
  35664. * @param options the addShape() method passed options
  35665. * @model the particle model
  35666. * @hidden
  35667. */
  35668. private _meshBuilder;
  35669. /**
  35670. * Returns a shape Vector3 array from positions float array
  35671. * @param positions float array
  35672. * @returns a vector3 array
  35673. * @hidden
  35674. */
  35675. private _posToShape;
  35676. /**
  35677. * Returns a shapeUV array from a float uvs (array deep copy)
  35678. * @param uvs as a float array
  35679. * @returns a shapeUV array
  35680. * @hidden
  35681. */
  35682. private _uvsToShapeUV;
  35683. /**
  35684. * Adds a new particle object in the particles array
  35685. * @param idx particle index in particles array
  35686. * @param id particle id
  35687. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35688. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35689. * @param model particle ModelShape object
  35690. * @param shapeId model shape identifier
  35691. * @param idxInShape index of the particle in the current model
  35692. * @param bInfo model bounding info object
  35693. * @param storage target storage array, if any
  35694. * @hidden
  35695. */
  35696. private _addParticle;
  35697. /**
  35698. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35699. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35700. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35701. * @param nb (positive integer) the number of particles to be created from this model
  35702. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35703. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35704. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35705. * @returns the number of shapes in the system
  35706. */
  35707. addShape(mesh: Mesh, nb: number, options?: {
  35708. positionFunction?: any;
  35709. vertexFunction?: any;
  35710. storage?: [];
  35711. }): number;
  35712. /**
  35713. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35714. * @hidden
  35715. */
  35716. private _rebuildParticle;
  35717. /**
  35718. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35719. * @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.
  35720. * @returns the SPS.
  35721. */
  35722. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35723. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35724. * Returns an array with the removed particles.
  35725. * 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.
  35726. * The SPS can't be empty so at least one particle needs to remain in place.
  35727. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35728. * @param start index of the first particle to remove
  35729. * @param end index of the last particle to remove (included)
  35730. * @returns an array populated with the removed particles
  35731. */
  35732. removeParticles(start: number, end: number): SolidParticle[];
  35733. /**
  35734. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35735. * @param solidParticleArray an array populated with Solid Particles objects
  35736. * @returns the SPS
  35737. */
  35738. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35739. /**
  35740. * Creates a new particle and modifies the SPS mesh geometry :
  35741. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35742. * - calls _addParticle() to populate the particle array
  35743. * factorized code from addShape() and insertParticlesFromArray()
  35744. * @param idx particle index in the particles array
  35745. * @param i particle index in its shape
  35746. * @param modelShape particle ModelShape object
  35747. * @param shape shape vertex array
  35748. * @param meshInd shape indices array
  35749. * @param meshUV shape uv array
  35750. * @param meshCol shape color array
  35751. * @param meshNor shape normals array
  35752. * @param bbInfo shape bounding info
  35753. * @param storage target particle storage
  35754. * @options addShape() passed options
  35755. * @hidden
  35756. */
  35757. private _insertNewParticle;
  35758. /**
  35759. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35760. * This method calls `updateParticle()` for each particle of the SPS.
  35761. * For an animated SPS, it is usually called within the render loop.
  35762. * 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.
  35763. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35764. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35765. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35766. * @returns the SPS.
  35767. */
  35768. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35769. /**
  35770. * Disposes the SPS.
  35771. */
  35772. dispose(): void;
  35773. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35774. * idx is the particle index in the SPS
  35775. * faceId is the picked face index counted within this particle.
  35776. * Returns null if the pickInfo can't identify a picked particle.
  35777. * @param pickingInfo (PickingInfo object)
  35778. * @returns {idx: number, faceId: number} or null
  35779. */
  35780. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35781. idx: number;
  35782. faceId: number;
  35783. }>;
  35784. /**
  35785. * Returns a SolidParticle object from its identifier : particle.id
  35786. * @param id (integer) the particle Id
  35787. * @returns the searched particle or null if not found in the SPS.
  35788. */
  35789. getParticleById(id: number): Nullable<SolidParticle>;
  35790. /**
  35791. * Returns a new array populated with the particles having the passed shapeId.
  35792. * @param shapeId (integer) the shape identifier
  35793. * @returns a new solid particle array
  35794. */
  35795. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35796. /**
  35797. * Populates the passed array "ref" with the particles having the passed shapeId.
  35798. * @param shapeId the shape identifier
  35799. * @returns the SPS
  35800. * @param ref
  35801. */
  35802. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35803. /**
  35804. * Computes the required SubMeshes according the materials assigned to the particles.
  35805. * @returns the solid particle system.
  35806. * Does nothing if called before the SPS mesh is built.
  35807. */
  35808. computeSubMeshes(): SolidParticleSystem;
  35809. /**
  35810. * Sorts the solid particles by material when MultiMaterial is enabled.
  35811. * Updates the indices32 array.
  35812. * Updates the indicesByMaterial array.
  35813. * Updates the mesh indices array.
  35814. * @returns the SPS
  35815. * @hidden
  35816. */
  35817. private _sortParticlesByMaterial;
  35818. /**
  35819. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35820. * @hidden
  35821. */
  35822. private _setMaterialIndexesById;
  35823. /**
  35824. * Returns an array with unique values of Materials from the passed array
  35825. * @param array the material array to be checked and filtered
  35826. * @hidden
  35827. */
  35828. private _filterUniqueMaterialId;
  35829. /**
  35830. * Sets a new Standard Material as _defaultMaterial if not already set.
  35831. * @hidden
  35832. */
  35833. private _setDefaultMaterial;
  35834. /**
  35835. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35836. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35837. * @returns the SPS.
  35838. */
  35839. refreshVisibleSize(): SolidParticleSystem;
  35840. /**
  35841. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35842. * @param size the size (float) of the visibility box
  35843. * note : this doesn't lock the SPS mesh bounding box.
  35844. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35845. */
  35846. setVisibilityBox(size: number): void;
  35847. /**
  35848. * Gets whether the SPS as always visible or not
  35849. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35850. */
  35851. get isAlwaysVisible(): boolean;
  35852. /**
  35853. * Sets the SPS as always visible or not
  35854. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35855. */
  35856. set isAlwaysVisible(val: boolean);
  35857. /**
  35858. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35859. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35860. */
  35861. set isVisibilityBoxLocked(val: boolean);
  35862. /**
  35863. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35864. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35865. */
  35866. get isVisibilityBoxLocked(): boolean;
  35867. /**
  35868. * Tells to `setParticles()` to compute the particle rotations or not.
  35869. * Default value : true. The SPS is faster when it's set to false.
  35870. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35871. */
  35872. set computeParticleRotation(val: boolean);
  35873. /**
  35874. * Tells to `setParticles()` to compute the particle colors or not.
  35875. * Default value : true. The SPS is faster when it's set to false.
  35876. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35877. */
  35878. set computeParticleColor(val: boolean);
  35879. set computeParticleTexture(val: boolean);
  35880. /**
  35881. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35882. * Default value : false. The SPS is faster when it's set to false.
  35883. * Note : the particle custom vertex positions aren't stored values.
  35884. */
  35885. set computeParticleVertex(val: boolean);
  35886. /**
  35887. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35888. */
  35889. set computeBoundingBox(val: boolean);
  35890. /**
  35891. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35892. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35893. * Default : `true`
  35894. */
  35895. set depthSortParticles(val: boolean);
  35896. /**
  35897. * Gets if `setParticles()` computes the particle rotations or not.
  35898. * Default value : true. The SPS is faster when it's set to false.
  35899. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35900. */
  35901. get computeParticleRotation(): boolean;
  35902. /**
  35903. * Gets if `setParticles()` computes the particle colors or not.
  35904. * Default value : true. The SPS is faster when it's set to false.
  35905. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35906. */
  35907. get computeParticleColor(): boolean;
  35908. /**
  35909. * Gets if `setParticles()` computes the particle textures or not.
  35910. * Default value : true. The SPS is faster when it's set to false.
  35911. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35912. */
  35913. get computeParticleTexture(): boolean;
  35914. /**
  35915. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35916. * Default value : false. The SPS is faster when it's set to false.
  35917. * Note : the particle custom vertex positions aren't stored values.
  35918. */
  35919. get computeParticleVertex(): boolean;
  35920. /**
  35921. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35922. */
  35923. get computeBoundingBox(): boolean;
  35924. /**
  35925. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35926. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35927. * Default : `true`
  35928. */
  35929. get depthSortParticles(): boolean;
  35930. /**
  35931. * Gets if the SPS is created as expandable at construction time.
  35932. * Default : `false`
  35933. */
  35934. get expandable(): boolean;
  35935. /**
  35936. * Gets if the SPS supports the Multi Materials
  35937. */
  35938. get multimaterialEnabled(): boolean;
  35939. /**
  35940. * Gets if the SPS uses the model materials for its own multimaterial.
  35941. */
  35942. get useModelMaterial(): boolean;
  35943. /**
  35944. * The SPS used material array.
  35945. */
  35946. get materials(): Material[];
  35947. /**
  35948. * Sets the SPS MultiMaterial from the passed materials.
  35949. * Note : the passed array is internally copied and not used then by reference.
  35950. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35951. */
  35952. setMultiMaterial(materials: Material[]): void;
  35953. /**
  35954. * The SPS computed multimaterial object
  35955. */
  35956. get multimaterial(): MultiMaterial;
  35957. set multimaterial(mm: MultiMaterial);
  35958. /**
  35959. * If the subMeshes must be updated on the next call to setParticles()
  35960. */
  35961. get autoUpdateSubMeshes(): boolean;
  35962. set autoUpdateSubMeshes(val: boolean);
  35963. /**
  35964. * This function does nothing. It may be overwritten to set all the particle first values.
  35965. * The SPS doesn't call this function, you may have to call it by your own.
  35966. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35967. */
  35968. initParticles(): void;
  35969. /**
  35970. * This function does nothing. It may be overwritten to recycle a particle.
  35971. * The SPS doesn't call this function, you may have to call it by your own.
  35972. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35973. * @param particle The particle to recycle
  35974. * @returns the recycled particle
  35975. */
  35976. recycleParticle(particle: SolidParticle): SolidParticle;
  35977. /**
  35978. * Updates a particle : this function should be overwritten by the user.
  35979. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35980. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35981. * @example : just set a particle position or velocity and recycle conditions
  35982. * @param particle The particle to update
  35983. * @returns the updated particle
  35984. */
  35985. updateParticle(particle: SolidParticle): SolidParticle;
  35986. /**
  35987. * Updates a vertex of a particle : it can be overwritten by the user.
  35988. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35989. * @param particle the current particle
  35990. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35991. * @param pt the index of the current vertex in the particle shape
  35992. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35993. * @example : just set a vertex particle position or color
  35994. * @returns the sps
  35995. */
  35996. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35997. /**
  35998. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35999. * This does nothing and may be overwritten by the user.
  36000. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36001. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36002. * @param update the boolean update value actually passed to setParticles()
  36003. */
  36004. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36005. /**
  36006. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  36007. * This will be passed three parameters.
  36008. * This does nothing and may be overwritten by the user.
  36009. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36010. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36011. * @param update the boolean update value actually passed to setParticles()
  36012. */
  36013. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36014. }
  36015. }
  36016. declare module "babylonjs/Particles/solidParticle" {
  36017. import { Nullable } from "babylonjs/types";
  36018. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  36019. import { Color4 } from "babylonjs/Maths/math.color";
  36020. import { Mesh } from "babylonjs/Meshes/mesh";
  36021. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36022. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  36023. import { Plane } from "babylonjs/Maths/math.plane";
  36024. import { Material } from "babylonjs/Materials/material";
  36025. /**
  36026. * Represents one particle of a solid particle system.
  36027. */
  36028. export class SolidParticle {
  36029. /**
  36030. * particle global index
  36031. */
  36032. idx: number;
  36033. /**
  36034. * particle identifier
  36035. */
  36036. id: number;
  36037. /**
  36038. * The color of the particle
  36039. */
  36040. color: Nullable<Color4>;
  36041. /**
  36042. * The world space position of the particle.
  36043. */
  36044. position: Vector3;
  36045. /**
  36046. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36047. */
  36048. rotation: Vector3;
  36049. /**
  36050. * The world space rotation quaternion of the particle.
  36051. */
  36052. rotationQuaternion: Nullable<Quaternion>;
  36053. /**
  36054. * The scaling of the particle.
  36055. */
  36056. scaling: Vector3;
  36057. /**
  36058. * The uvs of the particle.
  36059. */
  36060. uvs: Vector4;
  36061. /**
  36062. * The current speed of the particle.
  36063. */
  36064. velocity: Vector3;
  36065. /**
  36066. * The pivot point in the particle local space.
  36067. */
  36068. pivot: Vector3;
  36069. /**
  36070. * Must the particle be translated from its pivot point in its local space ?
  36071. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36072. * Default : false
  36073. */
  36074. translateFromPivot: boolean;
  36075. /**
  36076. * Is the particle active or not ?
  36077. */
  36078. alive: boolean;
  36079. /**
  36080. * Is the particle visible or not ?
  36081. */
  36082. isVisible: boolean;
  36083. /**
  36084. * Index of this particle in the global "positions" array (Internal use)
  36085. * @hidden
  36086. */
  36087. _pos: number;
  36088. /**
  36089. * @hidden Index of this particle in the global "indices" array (Internal use)
  36090. */
  36091. _ind: number;
  36092. /**
  36093. * @hidden ModelShape of this particle (Internal use)
  36094. */
  36095. _model: ModelShape;
  36096. /**
  36097. * ModelShape id of this particle
  36098. */
  36099. shapeId: number;
  36100. /**
  36101. * Index of the particle in its shape id
  36102. */
  36103. idxInShape: number;
  36104. /**
  36105. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36106. */
  36107. _modelBoundingInfo: BoundingInfo;
  36108. /**
  36109. * @hidden Particle BoundingInfo object (Internal use)
  36110. */
  36111. _boundingInfo: BoundingInfo;
  36112. /**
  36113. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36114. */
  36115. _sps: SolidParticleSystem;
  36116. /**
  36117. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36118. */
  36119. _stillInvisible: boolean;
  36120. /**
  36121. * @hidden Last computed particle rotation matrix
  36122. */
  36123. _rotationMatrix: number[];
  36124. /**
  36125. * Parent particle Id, if any.
  36126. * Default null.
  36127. */
  36128. parentId: Nullable<number>;
  36129. /**
  36130. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36131. */
  36132. materialIndex: Nullable<number>;
  36133. /**
  36134. * Custom object or properties.
  36135. */
  36136. props: Nullable<any>;
  36137. /**
  36138. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36139. * The possible values are :
  36140. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36141. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36142. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36143. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36144. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36145. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36146. * */
  36147. cullingStrategy: number;
  36148. /**
  36149. * @hidden Internal global position in the SPS.
  36150. */
  36151. _globalPosition: Vector3;
  36152. /**
  36153. * Creates a Solid Particle object.
  36154. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36155. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36156. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36157. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36158. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36159. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36160. * @param shapeId (integer) is the model shape identifier in the SPS.
  36161. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36162. * @param sps defines the sps it is associated to
  36163. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36164. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36165. */
  36166. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36167. /**
  36168. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36169. * @param target the particle target
  36170. * @returns the current particle
  36171. */
  36172. copyToRef(target: SolidParticle): SolidParticle;
  36173. /**
  36174. * Legacy support, changed scale to scaling
  36175. */
  36176. get scale(): Vector3;
  36177. /**
  36178. * Legacy support, changed scale to scaling
  36179. */
  36180. set scale(scale: Vector3);
  36181. /**
  36182. * Legacy support, changed quaternion to rotationQuaternion
  36183. */
  36184. get quaternion(): Nullable<Quaternion>;
  36185. /**
  36186. * Legacy support, changed quaternion to rotationQuaternion
  36187. */
  36188. set quaternion(q: Nullable<Quaternion>);
  36189. /**
  36190. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36191. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36192. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36193. * @returns true if it intersects
  36194. */
  36195. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36196. /**
  36197. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36198. * A particle is in the frustum if its bounding box intersects the frustum
  36199. * @param frustumPlanes defines the frustum to test
  36200. * @returns true if the particle is in the frustum planes
  36201. */
  36202. isInFrustum(frustumPlanes: Plane[]): boolean;
  36203. /**
  36204. * get the rotation matrix of the particle
  36205. * @hidden
  36206. */
  36207. getRotationMatrix(m: Matrix): void;
  36208. }
  36209. /**
  36210. * Represents the shape of the model used by one particle of a solid particle system.
  36211. * SPS internal tool, don't use it manually.
  36212. */
  36213. export class ModelShape {
  36214. /**
  36215. * The shape id
  36216. * @hidden
  36217. */
  36218. shapeID: number;
  36219. /**
  36220. * flat array of model positions (internal use)
  36221. * @hidden
  36222. */
  36223. _shape: Vector3[];
  36224. /**
  36225. * flat array of model UVs (internal use)
  36226. * @hidden
  36227. */
  36228. _shapeUV: number[];
  36229. /**
  36230. * color array of the model
  36231. * @hidden
  36232. */
  36233. _shapeColors: number[];
  36234. /**
  36235. * indices array of the model
  36236. * @hidden
  36237. */
  36238. _indices: number[];
  36239. /**
  36240. * normals array of the model
  36241. * @hidden
  36242. */
  36243. _normals: number[];
  36244. /**
  36245. * length of the shape in the model indices array (internal use)
  36246. * @hidden
  36247. */
  36248. _indicesLength: number;
  36249. /**
  36250. * Custom position function (internal use)
  36251. * @hidden
  36252. */
  36253. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36254. /**
  36255. * Custom vertex function (internal use)
  36256. * @hidden
  36257. */
  36258. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36259. /**
  36260. * Model material (internal use)
  36261. * @hidden
  36262. */
  36263. _material: Nullable<Material>;
  36264. /**
  36265. * 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.
  36266. * SPS internal tool, don't use it manually.
  36267. * @hidden
  36268. */
  36269. 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>);
  36270. }
  36271. /**
  36272. * Represents a Depth Sorted Particle in the solid particle system.
  36273. * @hidden
  36274. */
  36275. export class DepthSortedParticle {
  36276. /**
  36277. * Particle index
  36278. */
  36279. idx: number;
  36280. /**
  36281. * Index of the particle in the "indices" array
  36282. */
  36283. ind: number;
  36284. /**
  36285. * Length of the particle shape in the "indices" array
  36286. */
  36287. indicesLength: number;
  36288. /**
  36289. * Squared distance from the particle to the camera
  36290. */
  36291. sqDistance: number;
  36292. /**
  36293. * Material index when used with MultiMaterials
  36294. */
  36295. materialIndex: number;
  36296. /**
  36297. * Creates a new sorted particle
  36298. * @param materialIndex
  36299. */
  36300. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36301. }
  36302. /**
  36303. * Represents a solid particle vertex
  36304. */
  36305. export class SolidParticleVertex {
  36306. /**
  36307. * Vertex position
  36308. */
  36309. position: Vector3;
  36310. /**
  36311. * Vertex color
  36312. */
  36313. color: Color4;
  36314. /**
  36315. * Vertex UV
  36316. */
  36317. uv: Vector2;
  36318. /**
  36319. * Creates a new solid particle vertex
  36320. */
  36321. constructor();
  36322. /** Vertex x coordinate */
  36323. get x(): number;
  36324. set x(val: number);
  36325. /** Vertex y coordinate */
  36326. get y(): number;
  36327. set y(val: number);
  36328. /** Vertex z coordinate */
  36329. get z(): number;
  36330. set z(val: number);
  36331. }
  36332. }
  36333. declare module "babylonjs/Collisions/meshCollisionData" {
  36334. import { Collider } from "babylonjs/Collisions/collider";
  36335. import { Vector3 } from "babylonjs/Maths/math.vector";
  36336. import { Nullable } from "babylonjs/types";
  36337. import { Observer } from "babylonjs/Misc/observable";
  36338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36339. /**
  36340. * @hidden
  36341. */
  36342. export class _MeshCollisionData {
  36343. _checkCollisions: boolean;
  36344. _collisionMask: number;
  36345. _collisionGroup: number;
  36346. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36347. _collider: Nullable<Collider>;
  36348. _oldPositionForCollisions: Vector3;
  36349. _diffPositionForCollisions: Vector3;
  36350. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36351. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36352. _collisionResponse: boolean;
  36353. }
  36354. }
  36355. declare module "babylonjs/Meshes/abstractMesh" {
  36356. import { Observable } from "babylonjs/Misc/observable";
  36357. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  36358. import { Camera } from "babylonjs/Cameras/camera";
  36359. import { Scene, IDisposable } from "babylonjs/scene";
  36360. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36361. import { Node } from "babylonjs/node";
  36362. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  36363. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36364. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36365. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36366. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36367. import { Material } from "babylonjs/Materials/material";
  36368. import { Light } from "babylonjs/Lights/light";
  36369. import { Skeleton } from "babylonjs/Bones/skeleton";
  36370. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  36371. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  36372. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36373. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  36374. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  36375. import { Plane } from "babylonjs/Maths/math.plane";
  36376. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36377. import { Ray } from "babylonjs/Culling/ray";
  36378. import { Collider } from "babylonjs/Collisions/collider";
  36379. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36380. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  36381. import { IEdgesRendererOptions } from "babylonjs/Rendering/edgesRenderer";
  36382. /** @hidden */
  36383. class _FacetDataStorage {
  36384. facetPositions: Vector3[];
  36385. facetNormals: Vector3[];
  36386. facetPartitioning: number[][];
  36387. facetNb: number;
  36388. partitioningSubdivisions: number;
  36389. partitioningBBoxRatio: number;
  36390. facetDataEnabled: boolean;
  36391. facetParameters: any;
  36392. bbSize: Vector3;
  36393. subDiv: {
  36394. max: number;
  36395. X: number;
  36396. Y: number;
  36397. Z: number;
  36398. };
  36399. facetDepthSort: boolean;
  36400. facetDepthSortEnabled: boolean;
  36401. depthSortedIndices: IndicesArray;
  36402. depthSortedFacets: {
  36403. ind: number;
  36404. sqDistance: number;
  36405. }[];
  36406. facetDepthSortFunction: (f1: {
  36407. ind: number;
  36408. sqDistance: number;
  36409. }, f2: {
  36410. ind: number;
  36411. sqDistance: number;
  36412. }) => number;
  36413. facetDepthSortFrom: Vector3;
  36414. facetDepthSortOrigin: Vector3;
  36415. invertedMatrix: Matrix;
  36416. }
  36417. /**
  36418. * @hidden
  36419. **/
  36420. class _InternalAbstractMeshDataInfo {
  36421. _hasVertexAlpha: boolean;
  36422. _useVertexColors: boolean;
  36423. _numBoneInfluencers: number;
  36424. _applyFog: boolean;
  36425. _receiveShadows: boolean;
  36426. _facetData: _FacetDataStorage;
  36427. _visibility: number;
  36428. _skeleton: Nullable<Skeleton>;
  36429. _layerMask: number;
  36430. _computeBonesUsingShaders: boolean;
  36431. _isActive: boolean;
  36432. _onlyForInstances: boolean;
  36433. _isActiveIntermediate: boolean;
  36434. _onlyForInstancesIntermediate: boolean;
  36435. _actAsRegularMesh: boolean;
  36436. _currentLOD: Nullable<AbstractMesh>;
  36437. }
  36438. /**
  36439. * Class used to store all common mesh properties
  36440. */
  36441. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36442. /** No occlusion */
  36443. static OCCLUSION_TYPE_NONE: number;
  36444. /** Occlusion set to optimisitic */
  36445. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36446. /** Occlusion set to strict */
  36447. static OCCLUSION_TYPE_STRICT: number;
  36448. /** Use an accurante occlusion algorithm */
  36449. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36450. /** Use a conservative occlusion algorithm */
  36451. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36452. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36453. * Test order :
  36454. * Is the bounding sphere outside the frustum ?
  36455. * If not, are the bounding box vertices outside the frustum ?
  36456. * It not, then the cullable object is in the frustum.
  36457. */
  36458. static readonly CULLINGSTRATEGY_STANDARD: number;
  36459. /** Culling strategy : Bounding Sphere Only.
  36460. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36461. * It's also less accurate than the standard because some not visible objects can still be selected.
  36462. * Test : is the bounding sphere outside the frustum ?
  36463. * If not, then the cullable object is in the frustum.
  36464. */
  36465. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36466. /** Culling strategy : Optimistic Inclusion.
  36467. * This in an inclusion test first, then the standard exclusion test.
  36468. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36469. * 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.
  36470. * Anyway, it's as accurate as the standard strategy.
  36471. * Test :
  36472. * Is the cullable object bounding sphere center in the frustum ?
  36473. * If not, apply the default culling strategy.
  36474. */
  36475. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36476. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36477. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36478. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36479. * 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.
  36480. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36481. * Test :
  36482. * Is the cullable object bounding sphere center in the frustum ?
  36483. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36484. */
  36485. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36486. /**
  36487. * No billboard
  36488. */
  36489. static get BILLBOARDMODE_NONE(): number;
  36490. /** Billboard on X axis */
  36491. static get BILLBOARDMODE_X(): number;
  36492. /** Billboard on Y axis */
  36493. static get BILLBOARDMODE_Y(): number;
  36494. /** Billboard on Z axis */
  36495. static get BILLBOARDMODE_Z(): number;
  36496. /** Billboard on all axes */
  36497. static get BILLBOARDMODE_ALL(): number;
  36498. /** Billboard on using position instead of orientation */
  36499. static get BILLBOARDMODE_USE_POSITION(): number;
  36500. /** @hidden */
  36501. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36502. /**
  36503. * The culling strategy to use to check whether the mesh must be rendered or not.
  36504. * This value can be changed at any time and will be used on the next render mesh selection.
  36505. * The possible values are :
  36506. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36507. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36508. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36509. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36510. * Please read each static variable documentation to get details about the culling process.
  36511. * */
  36512. cullingStrategy: number;
  36513. /**
  36514. * Gets the number of facets in the mesh
  36515. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36516. */
  36517. get facetNb(): number;
  36518. /**
  36519. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  36520. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36521. */
  36522. get partitioningSubdivisions(): number;
  36523. set partitioningSubdivisions(nb: number);
  36524. /**
  36525. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  36526. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  36527. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36528. */
  36529. get partitioningBBoxRatio(): number;
  36530. set partitioningBBoxRatio(ratio: number);
  36531. /**
  36532. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36533. * Works only for updatable meshes.
  36534. * Doesn't work with multi-materials
  36535. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36536. */
  36537. get mustDepthSortFacets(): boolean;
  36538. set mustDepthSortFacets(sort: boolean);
  36539. /**
  36540. * The location (Vector3) where the facet depth sort must be computed from.
  36541. * By default, the active camera position.
  36542. * Used only when facet depth sort is enabled
  36543. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36544. */
  36545. get facetDepthSortFrom(): Vector3;
  36546. set facetDepthSortFrom(location: Vector3);
  36547. /**
  36548. * gets a boolean indicating if facetData is enabled
  36549. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36550. */
  36551. get isFacetDataEnabled(): boolean;
  36552. /** @hidden */
  36553. _updateNonUniformScalingState(value: boolean): boolean;
  36554. /**
  36555. * An event triggered when this mesh collides with another one
  36556. */
  36557. onCollideObservable: Observable<AbstractMesh>;
  36558. /** Set a function to call when this mesh collides with another one */
  36559. set onCollide(callback: () => void);
  36560. /**
  36561. * An event triggered when the collision's position changes
  36562. */
  36563. onCollisionPositionChangeObservable: Observable<Vector3>;
  36564. /** Set a function to call when the collision's position changes */
  36565. set onCollisionPositionChange(callback: () => void);
  36566. /**
  36567. * An event triggered when material is changed
  36568. */
  36569. onMaterialChangedObservable: Observable<AbstractMesh>;
  36570. /**
  36571. * Gets or sets the orientation for POV movement & rotation
  36572. */
  36573. definedFacingForward: boolean;
  36574. /** @hidden */
  36575. _occlusionQuery: Nullable<WebGLQuery>;
  36576. /** @hidden */
  36577. _renderingGroup: Nullable<RenderingGroup>;
  36578. /**
  36579. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36580. */
  36581. get visibility(): number;
  36582. /**
  36583. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36584. */
  36585. set visibility(value: number);
  36586. /** Gets or sets the alpha index used to sort transparent meshes
  36587. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36588. */
  36589. alphaIndex: number;
  36590. /**
  36591. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36592. */
  36593. isVisible: boolean;
  36594. /**
  36595. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36596. */
  36597. isPickable: boolean;
  36598. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36599. showSubMeshesBoundingBox: boolean;
  36600. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36601. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36602. */
  36603. isBlocker: boolean;
  36604. /**
  36605. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36606. */
  36607. enablePointerMoveEvents: boolean;
  36608. private _renderingGroupId;
  36609. /**
  36610. * Specifies the rendering group id for this mesh (0 by default)
  36611. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36612. */
  36613. get renderingGroupId(): number;
  36614. set renderingGroupId(value: number);
  36615. private _material;
  36616. /** Gets or sets current material */
  36617. get material(): Nullable<Material>;
  36618. set material(value: Nullable<Material>);
  36619. /**
  36620. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36621. * @see https://doc.babylonjs.com/babylon101/shadows
  36622. */
  36623. get receiveShadows(): boolean;
  36624. set receiveShadows(value: boolean);
  36625. /** Defines color to use when rendering outline */
  36626. outlineColor: Color3;
  36627. /** Define width to use when rendering outline */
  36628. outlineWidth: number;
  36629. /** Defines color to use when rendering overlay */
  36630. overlayColor: Color3;
  36631. /** Defines alpha to use when rendering overlay */
  36632. overlayAlpha: number;
  36633. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36634. get hasVertexAlpha(): boolean;
  36635. set hasVertexAlpha(value: boolean);
  36636. /** 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) */
  36637. get useVertexColors(): boolean;
  36638. set useVertexColors(value: boolean);
  36639. /**
  36640. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36641. */
  36642. get computeBonesUsingShaders(): boolean;
  36643. set computeBonesUsingShaders(value: boolean);
  36644. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36645. get numBoneInfluencers(): number;
  36646. set numBoneInfluencers(value: number);
  36647. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36648. get applyFog(): boolean;
  36649. set applyFog(value: boolean);
  36650. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36651. useOctreeForRenderingSelection: boolean;
  36652. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36653. useOctreeForPicking: boolean;
  36654. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36655. useOctreeForCollisions: boolean;
  36656. /**
  36657. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36658. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36659. */
  36660. get layerMask(): number;
  36661. set layerMask(value: number);
  36662. /**
  36663. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36664. */
  36665. alwaysSelectAsActiveMesh: boolean;
  36666. /**
  36667. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36668. */
  36669. doNotSyncBoundingInfo: boolean;
  36670. /**
  36671. * Gets or sets the current action manager
  36672. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36673. */
  36674. actionManager: Nullable<AbstractActionManager>;
  36675. private _meshCollisionData;
  36676. /**
  36677. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36678. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36679. */
  36680. ellipsoid: Vector3;
  36681. /**
  36682. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36683. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36684. */
  36685. ellipsoidOffset: Vector3;
  36686. /**
  36687. * Gets or sets a collision mask used to mask collisions (default is -1).
  36688. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36689. */
  36690. get collisionMask(): number;
  36691. set collisionMask(mask: number);
  36692. /**
  36693. * Gets or sets a collision response flag (default is true).
  36694. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36695. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36696. * to respond to the collision.
  36697. */
  36698. get collisionResponse(): boolean;
  36699. set collisionResponse(response: boolean);
  36700. /**
  36701. * Gets or sets the current collision group mask (-1 by default).
  36702. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36703. */
  36704. get collisionGroup(): number;
  36705. set collisionGroup(mask: number);
  36706. /**
  36707. * Gets or sets current surrounding meshes (null by default).
  36708. *
  36709. * By default collision detection is tested against every mesh in the scene.
  36710. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36711. * meshes will be tested for the collision.
  36712. *
  36713. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36714. */
  36715. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36716. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36717. /**
  36718. * Defines edge width used when edgesRenderer is enabled
  36719. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36720. */
  36721. edgesWidth: number;
  36722. /**
  36723. * Defines edge color used when edgesRenderer is enabled
  36724. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36725. */
  36726. edgesColor: Color4;
  36727. /** @hidden */
  36728. _edgesRenderer: Nullable<IEdgesRenderer>;
  36729. /** @hidden */
  36730. _masterMesh: Nullable<AbstractMesh>;
  36731. /** @hidden */
  36732. _boundingInfo: Nullable<BoundingInfo>;
  36733. /** @hidden */
  36734. _renderId: number;
  36735. /**
  36736. * Gets or sets the list of subMeshes
  36737. * @see https://doc.babylonjs.com/how_to/multi_materials
  36738. */
  36739. subMeshes: SubMesh[];
  36740. /** @hidden */
  36741. _intersectionsInProgress: AbstractMesh[];
  36742. /** @hidden */
  36743. _unIndexed: boolean;
  36744. /** @hidden */
  36745. _lightSources: Light[];
  36746. /** Gets the list of lights affecting that mesh */
  36747. get lightSources(): Light[];
  36748. /** @hidden */
  36749. get _positions(): Nullable<Vector3[]>;
  36750. /** @hidden */
  36751. _waitingData: {
  36752. lods: Nullable<any>;
  36753. actions: Nullable<any>;
  36754. freezeWorldMatrix: Nullable<boolean>;
  36755. };
  36756. /** @hidden */
  36757. _bonesTransformMatrices: Nullable<Float32Array>;
  36758. /** @hidden */
  36759. _transformMatrixTexture: Nullable<RawTexture>;
  36760. /**
  36761. * Gets or sets a skeleton to apply skining transformations
  36762. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36763. */
  36764. set skeleton(value: Nullable<Skeleton>);
  36765. get skeleton(): Nullable<Skeleton>;
  36766. /**
  36767. * An event triggered when the mesh is rebuilt.
  36768. */
  36769. onRebuildObservable: Observable<AbstractMesh>;
  36770. /**
  36771. * Creates a new AbstractMesh
  36772. * @param name defines the name of the mesh
  36773. * @param scene defines the hosting scene
  36774. */
  36775. constructor(name: string, scene?: Nullable<Scene>);
  36776. /**
  36777. * Returns the string "AbstractMesh"
  36778. * @returns "AbstractMesh"
  36779. */
  36780. getClassName(): string;
  36781. /**
  36782. * Gets a string representation of the current mesh
  36783. * @param fullDetails defines a boolean indicating if full details must be included
  36784. * @returns a string representation of the current mesh
  36785. */
  36786. toString(fullDetails?: boolean): string;
  36787. /**
  36788. * @hidden
  36789. */
  36790. protected _getEffectiveParent(): Nullable<Node>;
  36791. /** @hidden */
  36792. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36793. /** @hidden */
  36794. _rebuild(): void;
  36795. /** @hidden */
  36796. _resyncLightSources(): void;
  36797. /** @hidden */
  36798. _resyncLightSource(light: Light): void;
  36799. /** @hidden */
  36800. _unBindEffect(): void;
  36801. /** @hidden */
  36802. _removeLightSource(light: Light, dispose: boolean): void;
  36803. private _markSubMeshesAsDirty;
  36804. /** @hidden */
  36805. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36806. /** @hidden */
  36807. _markSubMeshesAsAttributesDirty(): void;
  36808. /** @hidden */
  36809. _markSubMeshesAsMiscDirty(): void;
  36810. /**
  36811. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36812. */
  36813. get scaling(): Vector3;
  36814. set scaling(newScaling: Vector3);
  36815. /**
  36816. * Returns true if the mesh is blocked. Implemented by child classes
  36817. */
  36818. get isBlocked(): boolean;
  36819. /**
  36820. * Returns the mesh itself by default. Implemented by child classes
  36821. * @param camera defines the camera to use to pick the right LOD level
  36822. * @returns the currentAbstractMesh
  36823. */
  36824. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36825. /**
  36826. * Returns 0 by default. Implemented by child classes
  36827. * @returns an integer
  36828. */
  36829. getTotalVertices(): number;
  36830. /**
  36831. * Returns a positive integer : the total number of indices in this mesh geometry.
  36832. * @returns the numner of indices or zero if the mesh has no geometry.
  36833. */
  36834. getTotalIndices(): number;
  36835. /**
  36836. * Returns null by default. Implemented by child classes
  36837. * @returns null
  36838. */
  36839. getIndices(): Nullable<IndicesArray>;
  36840. /**
  36841. * Returns the array of the requested vertex data kind. Implemented by child classes
  36842. * @param kind defines the vertex data kind to use
  36843. * @returns null
  36844. */
  36845. getVerticesData(kind: string): Nullable<FloatArray>;
  36846. /**
  36847. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36848. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36849. * Note that a new underlying VertexBuffer object is created each call.
  36850. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36851. * @param kind defines vertex data kind:
  36852. * * VertexBuffer.PositionKind
  36853. * * VertexBuffer.UVKind
  36854. * * VertexBuffer.UV2Kind
  36855. * * VertexBuffer.UV3Kind
  36856. * * VertexBuffer.UV4Kind
  36857. * * VertexBuffer.UV5Kind
  36858. * * VertexBuffer.UV6Kind
  36859. * * VertexBuffer.ColorKind
  36860. * * VertexBuffer.MatricesIndicesKind
  36861. * * VertexBuffer.MatricesIndicesExtraKind
  36862. * * VertexBuffer.MatricesWeightsKind
  36863. * * VertexBuffer.MatricesWeightsExtraKind
  36864. * @param data defines the data source
  36865. * @param updatable defines if the data must be flagged as updatable (or static)
  36866. * @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
  36867. * @returns the current mesh
  36868. */
  36869. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36870. /**
  36871. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36872. * If the mesh has no geometry, it is simply returned as it is.
  36873. * @param kind defines vertex data kind:
  36874. * * VertexBuffer.PositionKind
  36875. * * VertexBuffer.UVKind
  36876. * * VertexBuffer.UV2Kind
  36877. * * VertexBuffer.UV3Kind
  36878. * * VertexBuffer.UV4Kind
  36879. * * VertexBuffer.UV5Kind
  36880. * * VertexBuffer.UV6Kind
  36881. * * VertexBuffer.ColorKind
  36882. * * VertexBuffer.MatricesIndicesKind
  36883. * * VertexBuffer.MatricesIndicesExtraKind
  36884. * * VertexBuffer.MatricesWeightsKind
  36885. * * VertexBuffer.MatricesWeightsExtraKind
  36886. * @param data defines the data source
  36887. * @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
  36888. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36889. * @returns the current mesh
  36890. */
  36891. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36892. /**
  36893. * Sets the mesh indices,
  36894. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36895. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36896. * @param totalVertices Defines the total number of vertices
  36897. * @returns the current mesh
  36898. */
  36899. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36900. /**
  36901. * Gets a boolean indicating if specific vertex data is present
  36902. * @param kind defines the vertex data kind to use
  36903. * @returns true is data kind is present
  36904. */
  36905. isVerticesDataPresent(kind: string): boolean;
  36906. /**
  36907. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36908. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36909. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36910. * @returns a BoundingInfo
  36911. */
  36912. getBoundingInfo(): BoundingInfo;
  36913. /**
  36914. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36915. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36916. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36917. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36918. * @returns the current mesh
  36919. */
  36920. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36921. /**
  36922. * Overwrite the current bounding info
  36923. * @param boundingInfo defines the new bounding info
  36924. * @returns the current mesh
  36925. */
  36926. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36927. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36928. get useBones(): boolean;
  36929. /** @hidden */
  36930. _preActivate(): void;
  36931. /** @hidden */
  36932. _preActivateForIntermediateRendering(renderId: number): void;
  36933. /** @hidden */
  36934. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36935. /** @hidden */
  36936. _postActivate(): void;
  36937. /** @hidden */
  36938. _freeze(): void;
  36939. /** @hidden */
  36940. _unFreeze(): void;
  36941. /**
  36942. * Gets the current world matrix
  36943. * @returns a Matrix
  36944. */
  36945. getWorldMatrix(): Matrix;
  36946. /** @hidden */
  36947. _getWorldMatrixDeterminant(): number;
  36948. /**
  36949. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36950. */
  36951. get isAnInstance(): boolean;
  36952. /**
  36953. * Gets a boolean indicating if this mesh has instances
  36954. */
  36955. get hasInstances(): boolean;
  36956. /**
  36957. * Gets a boolean indicating if this mesh has thin instances
  36958. */
  36959. get hasThinInstances(): boolean;
  36960. /**
  36961. * Perform relative position change from the point of view of behind the front of the mesh.
  36962. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36963. * Supports definition of mesh facing forward or backward
  36964. * @param amountRight defines the distance on the right axis
  36965. * @param amountUp defines the distance on the up axis
  36966. * @param amountForward defines the distance on the forward axis
  36967. * @returns the current mesh
  36968. */
  36969. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  36970. /**
  36971. * Calculate relative position change from the point of view of behind the front of the mesh.
  36972. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36973. * Supports definition of mesh facing forward or backward
  36974. * @param amountRight defines the distance on the right axis
  36975. * @param amountUp defines the distance on the up axis
  36976. * @param amountForward defines the distance on the forward axis
  36977. * @returns the new displacement vector
  36978. */
  36979. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  36980. /**
  36981. * Perform relative rotation change from the point of view of behind the front of the mesh.
  36982. * Supports definition of mesh facing forward or backward
  36983. * @param flipBack defines the flip
  36984. * @param twirlClockwise defines the twirl
  36985. * @param tiltRight defines the tilt
  36986. * @returns the current mesh
  36987. */
  36988. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  36989. /**
  36990. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  36991. * Supports definition of mesh facing forward or backward.
  36992. * @param flipBack defines the flip
  36993. * @param twirlClockwise defines the twirl
  36994. * @param tiltRight defines the tilt
  36995. * @returns the new rotation vector
  36996. */
  36997. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  36998. /**
  36999. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  37000. * This means the mesh underlying bounding box and sphere are recomputed.
  37001. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  37002. * @returns the current mesh
  37003. */
  37004. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  37005. /** @hidden */
  37006. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  37007. /** @hidden */
  37008. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  37009. /** @hidden */
  37010. _updateBoundingInfo(): AbstractMesh;
  37011. /** @hidden */
  37012. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  37013. /** @hidden */
  37014. protected _afterComputeWorldMatrix(): void;
  37015. /** @hidden */
  37016. get _effectiveMesh(): AbstractMesh;
  37017. /**
  37018. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37019. * A mesh is in the frustum if its bounding box intersects the frustum
  37020. * @param frustumPlanes defines the frustum to test
  37021. * @returns true if the mesh is in the frustum planes
  37022. */
  37023. isInFrustum(frustumPlanes: Plane[]): boolean;
  37024. /**
  37025. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37026. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37027. * @param frustumPlanes defines the frustum to test
  37028. * @returns true if the mesh is completely in the frustum planes
  37029. */
  37030. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37031. /**
  37032. * True if the mesh intersects another mesh or a SolidParticle object
  37033. * @param mesh defines a target mesh or SolidParticle to test
  37034. * @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)
  37035. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37036. * @returns true if there is an intersection
  37037. */
  37038. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37039. /**
  37040. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37041. * @param point defines the point to test
  37042. * @returns true if there is an intersection
  37043. */
  37044. intersectsPoint(point: Vector3): boolean;
  37045. /**
  37046. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37047. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37048. */
  37049. get checkCollisions(): boolean;
  37050. set checkCollisions(collisionEnabled: boolean);
  37051. /**
  37052. * Gets Collider object used to compute collisions (not physics)
  37053. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37054. */
  37055. get collider(): Nullable<Collider>;
  37056. /**
  37057. * Move the mesh using collision engine
  37058. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37059. * @param displacement defines the requested displacement vector
  37060. * @returns the current mesh
  37061. */
  37062. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37063. private _onCollisionPositionChange;
  37064. /** @hidden */
  37065. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37066. /** @hidden */
  37067. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37068. /** @hidden */
  37069. _checkCollision(collider: Collider): AbstractMesh;
  37070. /** @hidden */
  37071. _generatePointsArray(): boolean;
  37072. /**
  37073. * Checks if the passed Ray intersects with the mesh
  37074. * @param ray defines the ray to use
  37075. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37076. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37077. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37078. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37079. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  37080. * @returns the picking info
  37081. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37082. */
  37083. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  37084. /**
  37085. * Clones the current mesh
  37086. * @param name defines the mesh name
  37087. * @param newParent defines the new mesh parent
  37088. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37089. * @returns the new mesh
  37090. */
  37091. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37092. /**
  37093. * Disposes all the submeshes of the current meshnp
  37094. * @returns the current mesh
  37095. */
  37096. releaseSubMeshes(): AbstractMesh;
  37097. /**
  37098. * Releases resources associated with this abstract mesh.
  37099. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37100. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37101. */
  37102. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37103. /**
  37104. * Adds the passed mesh as a child to the current mesh
  37105. * @param mesh defines the child mesh
  37106. * @returns the current mesh
  37107. */
  37108. addChild(mesh: AbstractMesh): AbstractMesh;
  37109. /**
  37110. * Removes the passed mesh from the current mesh children list
  37111. * @param mesh defines the child mesh
  37112. * @returns the current mesh
  37113. */
  37114. removeChild(mesh: AbstractMesh): AbstractMesh;
  37115. /** @hidden */
  37116. private _initFacetData;
  37117. /**
  37118. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37119. * This method can be called within the render loop.
  37120. * 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
  37121. * @returns the current mesh
  37122. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37123. */
  37124. updateFacetData(): AbstractMesh;
  37125. /**
  37126. * Returns the facetLocalNormals array.
  37127. * The normals are expressed in the mesh local spac
  37128. * @returns an array of Vector3
  37129. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37130. */
  37131. getFacetLocalNormals(): Vector3[];
  37132. /**
  37133. * Returns the facetLocalPositions array.
  37134. * The facet positions are expressed in the mesh local space
  37135. * @returns an array of Vector3
  37136. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37137. */
  37138. getFacetLocalPositions(): Vector3[];
  37139. /**
  37140. * Returns the facetLocalPartioning array
  37141. * @returns an array of array of numbers
  37142. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37143. */
  37144. getFacetLocalPartitioning(): number[][];
  37145. /**
  37146. * Returns the i-th facet position in the world system.
  37147. * This method allocates a new Vector3 per call
  37148. * @param i defines the facet index
  37149. * @returns a new Vector3
  37150. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37151. */
  37152. getFacetPosition(i: number): Vector3;
  37153. /**
  37154. * Sets the reference Vector3 with the i-th facet position in the world system
  37155. * @param i defines the facet index
  37156. * @param ref defines the target vector
  37157. * @returns the current mesh
  37158. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37159. */
  37160. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37161. /**
  37162. * Returns the i-th facet normal in the world system.
  37163. * This method allocates a new Vector3 per call
  37164. * @param i defines the facet index
  37165. * @returns a new Vector3
  37166. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37167. */
  37168. getFacetNormal(i: number): Vector3;
  37169. /**
  37170. * Sets the reference Vector3 with the i-th facet normal in the world system
  37171. * @param i defines the facet index
  37172. * @param ref defines the target vector
  37173. * @returns the current mesh
  37174. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37175. */
  37176. getFacetNormalToRef(i: number, ref: Vector3): this;
  37177. /**
  37178. * 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)
  37179. * @param x defines x coordinate
  37180. * @param y defines y coordinate
  37181. * @param z defines z coordinate
  37182. * @returns the array of facet indexes
  37183. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37184. */
  37185. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37186. /**
  37187. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37188. * @param projected sets as the (x,y,z) world projection on the facet
  37189. * @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
  37190. * @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
  37191. * @param x defines x coordinate
  37192. * @param y defines y coordinate
  37193. * @param z defines z coordinate
  37194. * @returns the face index if found (or null instead)
  37195. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37196. */
  37197. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37198. /**
  37199. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37200. * @param projected sets as the (x,y,z) local projection on the facet
  37201. * @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
  37202. * @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
  37203. * @param x defines x coordinate
  37204. * @param y defines y coordinate
  37205. * @param z defines z coordinate
  37206. * @returns the face index if found (or null instead)
  37207. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37208. */
  37209. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37210. /**
  37211. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37212. * @returns the parameters
  37213. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37214. */
  37215. getFacetDataParameters(): any;
  37216. /**
  37217. * Disables the feature FacetData and frees the related memory
  37218. * @returns the current mesh
  37219. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37220. */
  37221. disableFacetData(): AbstractMesh;
  37222. /**
  37223. * Updates the AbstractMesh indices array
  37224. * @param indices defines the data source
  37225. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37226. * @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)
  37227. * @returns the current mesh
  37228. */
  37229. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37230. /**
  37231. * Creates new normals data for the mesh
  37232. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37233. * @returns the current mesh
  37234. */
  37235. createNormals(updatable: boolean): AbstractMesh;
  37236. /**
  37237. * Align the mesh with a normal
  37238. * @param normal defines the normal to use
  37239. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37240. * @returns the current mesh
  37241. */
  37242. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37243. /** @hidden */
  37244. _checkOcclusionQuery(): boolean;
  37245. /**
  37246. * Disables the mesh edge rendering mode
  37247. * @returns the currentAbstractMesh
  37248. */
  37249. disableEdgesRendering(): AbstractMesh;
  37250. /**
  37251. * Enables the edge rendering mode on the mesh.
  37252. * This mode makes the mesh edges visible
  37253. * @param epsilon defines the maximal distance between two angles to detect a face
  37254. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37255. * @param options options to the edge renderer
  37256. * @returns the currentAbstractMesh
  37257. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37258. */
  37259. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  37260. /**
  37261. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37262. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37263. */
  37264. getConnectedParticleSystems(): IParticleSystem[];
  37265. }
  37266. }
  37267. declare module "babylonjs/Actions/actionEvent" {
  37268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37269. import { Nullable } from "babylonjs/types";
  37270. import { Sprite } from "babylonjs/Sprites/sprite";
  37271. import { Scene } from "babylonjs/scene";
  37272. import { Vector2 } from "babylonjs/Maths/math.vector";
  37273. /**
  37274. * Interface used to define ActionEvent
  37275. */
  37276. export interface IActionEvent {
  37277. /** The mesh or sprite that triggered the action */
  37278. source: any;
  37279. /** The X mouse cursor position at the time of the event */
  37280. pointerX: number;
  37281. /** The Y mouse cursor position at the time of the event */
  37282. pointerY: number;
  37283. /** The mesh that is currently pointed at (can be null) */
  37284. meshUnderPointer: Nullable<AbstractMesh>;
  37285. /** the original (browser) event that triggered the ActionEvent */
  37286. sourceEvent?: any;
  37287. /** additional data for the event */
  37288. additionalData?: any;
  37289. }
  37290. /**
  37291. * ActionEvent is the event being sent when an action is triggered.
  37292. */
  37293. export class ActionEvent implements IActionEvent {
  37294. /** The mesh or sprite that triggered the action */
  37295. source: any;
  37296. /** The X mouse cursor position at the time of the event */
  37297. pointerX: number;
  37298. /** The Y mouse cursor position at the time of the event */
  37299. pointerY: number;
  37300. /** The mesh that is currently pointed at (can be null) */
  37301. meshUnderPointer: Nullable<AbstractMesh>;
  37302. /** the original (browser) event that triggered the ActionEvent */
  37303. sourceEvent?: any;
  37304. /** additional data for the event */
  37305. additionalData?: any;
  37306. /**
  37307. * Creates a new ActionEvent
  37308. * @param source The mesh or sprite that triggered the action
  37309. * @param pointerX The X mouse cursor position at the time of the event
  37310. * @param pointerY The Y mouse cursor position at the time of the event
  37311. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37312. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37313. * @param additionalData additional data for the event
  37314. */
  37315. constructor(
  37316. /** The mesh or sprite that triggered the action */
  37317. source: any,
  37318. /** The X mouse cursor position at the time of the event */
  37319. pointerX: number,
  37320. /** The Y mouse cursor position at the time of the event */
  37321. pointerY: number,
  37322. /** The mesh that is currently pointed at (can be null) */
  37323. meshUnderPointer: Nullable<AbstractMesh>,
  37324. /** the original (browser) event that triggered the ActionEvent */
  37325. sourceEvent?: any,
  37326. /** additional data for the event */
  37327. additionalData?: any);
  37328. /**
  37329. * Helper function to auto-create an ActionEvent from a source mesh.
  37330. * @param source The source mesh that triggered the event
  37331. * @param evt The original (browser) event
  37332. * @param additionalData additional data for the event
  37333. * @returns the new ActionEvent
  37334. */
  37335. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37336. /**
  37337. * Helper function to auto-create an ActionEvent from a source sprite
  37338. * @param source The source sprite that triggered the event
  37339. * @param scene Scene associated with the sprite
  37340. * @param evt The original (browser) event
  37341. * @param additionalData additional data for the event
  37342. * @returns the new ActionEvent
  37343. */
  37344. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37345. /**
  37346. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37347. * @param scene the scene where the event occurred
  37348. * @param evt The original (browser) event
  37349. * @returns the new ActionEvent
  37350. */
  37351. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37352. /**
  37353. * Helper function to auto-create an ActionEvent from a primitive
  37354. * @param prim defines the target primitive
  37355. * @param pointerPos defines the pointer position
  37356. * @param evt The original (browser) event
  37357. * @param additionalData additional data for the event
  37358. * @returns the new ActionEvent
  37359. */
  37360. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37361. }
  37362. }
  37363. declare module "babylonjs/Actions/abstractActionManager" {
  37364. import { IDisposable } from "babylonjs/scene";
  37365. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  37366. import { IAction } from "babylonjs/Actions/action";
  37367. import { Nullable } from "babylonjs/types";
  37368. /**
  37369. * Abstract class used to decouple action Manager from scene and meshes.
  37370. * Do not instantiate.
  37371. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37372. */
  37373. export abstract class AbstractActionManager implements IDisposable {
  37374. /** Gets the list of active triggers */
  37375. static Triggers: {
  37376. [key: string]: number;
  37377. };
  37378. /** Gets the cursor to use when hovering items */
  37379. hoverCursor: string;
  37380. /** Gets the list of actions */
  37381. actions: IAction[];
  37382. /**
  37383. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37384. */
  37385. isRecursive: boolean;
  37386. /**
  37387. * Releases all associated resources
  37388. */
  37389. abstract dispose(): void;
  37390. /**
  37391. * Does this action manager has pointer triggers
  37392. */
  37393. abstract get hasPointerTriggers(): boolean;
  37394. /**
  37395. * Does this action manager has pick triggers
  37396. */
  37397. abstract get hasPickTriggers(): boolean;
  37398. /**
  37399. * Process a specific trigger
  37400. * @param trigger defines the trigger to process
  37401. * @param evt defines the event details to be processed
  37402. */
  37403. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37404. /**
  37405. * Does this action manager handles actions of any of the given triggers
  37406. * @param triggers defines the triggers to be tested
  37407. * @return a boolean indicating whether one (or more) of the triggers is handled
  37408. */
  37409. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37410. /**
  37411. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37412. * speed.
  37413. * @param triggerA defines the trigger to be tested
  37414. * @param triggerB defines the trigger to be tested
  37415. * @return a boolean indicating whether one (or more) of the triggers is handled
  37416. */
  37417. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37418. /**
  37419. * Does this action manager handles actions of a given trigger
  37420. * @param trigger defines the trigger to be tested
  37421. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37422. * @return whether the trigger is handled
  37423. */
  37424. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37425. /**
  37426. * Serialize this manager to a JSON object
  37427. * @param name defines the property name to store this manager
  37428. * @returns a JSON representation of this manager
  37429. */
  37430. abstract serialize(name: string): any;
  37431. /**
  37432. * Registers an action to this action manager
  37433. * @param action defines the action to be registered
  37434. * @return the action amended (prepared) after registration
  37435. */
  37436. abstract registerAction(action: IAction): Nullable<IAction>;
  37437. /**
  37438. * Unregisters an action to this action manager
  37439. * @param action defines the action to be unregistered
  37440. * @return a boolean indicating whether the action has been unregistered
  37441. */
  37442. abstract unregisterAction(action: IAction): Boolean;
  37443. /**
  37444. * Does exist one action manager with at least one trigger
  37445. **/
  37446. static get HasTriggers(): boolean;
  37447. /**
  37448. * Does exist one action manager with at least one pick trigger
  37449. **/
  37450. static get HasPickTriggers(): boolean;
  37451. /**
  37452. * Does exist one action manager that handles actions of a given trigger
  37453. * @param trigger defines the trigger to be tested
  37454. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  37455. **/
  37456. static HasSpecificTrigger(trigger: number): boolean;
  37457. }
  37458. }
  37459. declare module "babylonjs/node" {
  37460. import { Scene } from "babylonjs/scene";
  37461. import { Nullable } from "babylonjs/types";
  37462. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  37463. import { Engine } from "babylonjs/Engines/engine";
  37464. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  37465. import { Observable } from "babylonjs/Misc/observable";
  37466. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37467. import { IInspectable } from "babylonjs/Misc/iInspectable";
  37468. import { Animatable } from "babylonjs/Animations/animatable";
  37469. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  37470. import { Animation } from "babylonjs/Animations/animation";
  37471. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37473. /**
  37474. * Defines how a node can be built from a string name.
  37475. */
  37476. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37477. /**
  37478. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37479. */
  37480. export class Node implements IBehaviorAware<Node> {
  37481. /** @hidden */
  37482. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37483. private static _NodeConstructors;
  37484. /**
  37485. * Add a new node constructor
  37486. * @param type defines the type name of the node to construct
  37487. * @param constructorFunc defines the constructor function
  37488. */
  37489. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37490. /**
  37491. * Returns a node constructor based on type name
  37492. * @param type defines the type name
  37493. * @param name defines the new node name
  37494. * @param scene defines the hosting scene
  37495. * @param options defines optional options to transmit to constructors
  37496. * @returns the new constructor or null
  37497. */
  37498. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37499. /**
  37500. * Gets or sets the name of the node
  37501. */
  37502. name: string;
  37503. /**
  37504. * Gets or sets the id of the node
  37505. */
  37506. id: string;
  37507. /**
  37508. * Gets or sets the unique id of the node
  37509. */
  37510. uniqueId: number;
  37511. /**
  37512. * Gets or sets a string used to store user defined state for the node
  37513. */
  37514. state: string;
  37515. /**
  37516. * Gets or sets an object used to store user defined information for the node
  37517. */
  37518. metadata: any;
  37519. /**
  37520. * For internal use only. Please do not use.
  37521. */
  37522. reservedDataStore: any;
  37523. /**
  37524. * List of inspectable custom properties (used by the Inspector)
  37525. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37526. */
  37527. inspectableCustomProperties: IInspectable[];
  37528. private _doNotSerialize;
  37529. /**
  37530. * Gets or sets a boolean used to define if the node must be serialized
  37531. */
  37532. get doNotSerialize(): boolean;
  37533. set doNotSerialize(value: boolean);
  37534. /** @hidden */
  37535. _isDisposed: boolean;
  37536. /**
  37537. * Gets a list of Animations associated with the node
  37538. */
  37539. animations: import("babylonjs/Animations/animation").Animation[];
  37540. protected _ranges: {
  37541. [name: string]: Nullable<AnimationRange>;
  37542. };
  37543. /**
  37544. * Callback raised when the node is ready to be used
  37545. */
  37546. onReady: Nullable<(node: Node) => void>;
  37547. private _isEnabled;
  37548. private _isParentEnabled;
  37549. private _isReady;
  37550. /** @hidden */
  37551. _currentRenderId: number;
  37552. private _parentUpdateId;
  37553. /** @hidden */
  37554. _childUpdateId: number;
  37555. /** @hidden */
  37556. _waitingParentId: Nullable<string>;
  37557. /** @hidden */
  37558. _scene: Scene;
  37559. /** @hidden */
  37560. _cache: any;
  37561. private _parentNode;
  37562. private _children;
  37563. /** @hidden */
  37564. _worldMatrix: Matrix;
  37565. /** @hidden */
  37566. _worldMatrixDeterminant: number;
  37567. /** @hidden */
  37568. _worldMatrixDeterminantIsDirty: boolean;
  37569. /** @hidden */
  37570. private _sceneRootNodesIndex;
  37571. /**
  37572. * Gets a boolean indicating if the node has been disposed
  37573. * @returns true if the node was disposed
  37574. */
  37575. isDisposed(): boolean;
  37576. /**
  37577. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37578. * @see https://doc.babylonjs.com/how_to/parenting
  37579. */
  37580. set parent(parent: Nullable<Node>);
  37581. get parent(): Nullable<Node>;
  37582. /** @hidden */
  37583. _addToSceneRootNodes(): void;
  37584. /** @hidden */
  37585. _removeFromSceneRootNodes(): void;
  37586. private _animationPropertiesOverride;
  37587. /**
  37588. * Gets or sets the animation properties override
  37589. */
  37590. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37591. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37592. /**
  37593. * Gets a string identifying the name of the class
  37594. * @returns "Node" string
  37595. */
  37596. getClassName(): string;
  37597. /** @hidden */
  37598. readonly _isNode: boolean;
  37599. /**
  37600. * An event triggered when the mesh is disposed
  37601. */
  37602. onDisposeObservable: Observable<Node>;
  37603. private _onDisposeObserver;
  37604. /**
  37605. * Sets a callback that will be raised when the node will be disposed
  37606. */
  37607. set onDispose(callback: () => void);
  37608. /**
  37609. * Creates a new Node
  37610. * @param name the name and id to be given to this node
  37611. * @param scene the scene this node will be added to
  37612. */
  37613. constructor(name: string, scene?: Nullable<Scene>);
  37614. /**
  37615. * Gets the scene of the node
  37616. * @returns a scene
  37617. */
  37618. getScene(): Scene;
  37619. /**
  37620. * Gets the engine of the node
  37621. * @returns a Engine
  37622. */
  37623. getEngine(): Engine;
  37624. private _behaviors;
  37625. /**
  37626. * Attach a behavior to the node
  37627. * @see https://doc.babylonjs.com/features/behaviour
  37628. * @param behavior defines the behavior to attach
  37629. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37630. * @returns the current Node
  37631. */
  37632. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37633. /**
  37634. * Remove an attached behavior
  37635. * @see https://doc.babylonjs.com/features/behaviour
  37636. * @param behavior defines the behavior to attach
  37637. * @returns the current Node
  37638. */
  37639. removeBehavior(behavior: Behavior<Node>): Node;
  37640. /**
  37641. * Gets the list of attached behaviors
  37642. * @see https://doc.babylonjs.com/features/behaviour
  37643. */
  37644. get behaviors(): Behavior<Node>[];
  37645. /**
  37646. * Gets an attached behavior by name
  37647. * @param name defines the name of the behavior to look for
  37648. * @see https://doc.babylonjs.com/features/behaviour
  37649. * @returns null if behavior was not found else the requested behavior
  37650. */
  37651. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37652. /**
  37653. * Returns the latest update of the World matrix
  37654. * @returns a Matrix
  37655. */
  37656. getWorldMatrix(): Matrix;
  37657. /** @hidden */
  37658. _getWorldMatrixDeterminant(): number;
  37659. /**
  37660. * Returns directly the latest state of the mesh World matrix.
  37661. * A Matrix is returned.
  37662. */
  37663. get worldMatrixFromCache(): Matrix;
  37664. /** @hidden */
  37665. _initCache(): void;
  37666. /** @hidden */
  37667. updateCache(force?: boolean): void;
  37668. /** @hidden */
  37669. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37670. /** @hidden */
  37671. _updateCache(ignoreParentClass?: boolean): void;
  37672. /** @hidden */
  37673. _isSynchronized(): boolean;
  37674. /** @hidden */
  37675. _markSyncedWithParent(): void;
  37676. /** @hidden */
  37677. isSynchronizedWithParent(): boolean;
  37678. /** @hidden */
  37679. isSynchronized(): boolean;
  37680. /**
  37681. * Is this node ready to be used/rendered
  37682. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37683. * @return true if the node is ready
  37684. */
  37685. isReady(completeCheck?: boolean): boolean;
  37686. /**
  37687. * Is this node enabled?
  37688. * 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
  37689. * @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
  37690. * @return whether this node (and its parent) is enabled
  37691. */
  37692. isEnabled(checkAncestors?: boolean): boolean;
  37693. /** @hidden */
  37694. protected _syncParentEnabledState(): void;
  37695. /**
  37696. * Set the enabled state of this node
  37697. * @param value defines the new enabled state
  37698. */
  37699. setEnabled(value: boolean): void;
  37700. /**
  37701. * Is this node a descendant of the given node?
  37702. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37703. * @param ancestor defines the parent node to inspect
  37704. * @returns a boolean indicating if this node is a descendant of the given node
  37705. */
  37706. isDescendantOf(ancestor: Node): boolean;
  37707. /** @hidden */
  37708. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37709. /**
  37710. * Will return all nodes that have this node as ascendant
  37711. * @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
  37712. * @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
  37713. * @return all children nodes of all types
  37714. */
  37715. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37716. /**
  37717. * Get all child-meshes of this node
  37718. * @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)
  37719. * @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
  37720. * @returns an array of AbstractMesh
  37721. */
  37722. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37723. /**
  37724. * Get all direct children of this node
  37725. * @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
  37726. * @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)
  37727. * @returns an array of Node
  37728. */
  37729. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37730. /** @hidden */
  37731. _setReady(state: boolean): void;
  37732. /**
  37733. * Get an animation by name
  37734. * @param name defines the name of the animation to look for
  37735. * @returns null if not found else the requested animation
  37736. */
  37737. getAnimationByName(name: string): Nullable<Animation>;
  37738. /**
  37739. * Creates an animation range for this node
  37740. * @param name defines the name of the range
  37741. * @param from defines the starting key
  37742. * @param to defines the end key
  37743. */
  37744. createAnimationRange(name: string, from: number, to: number): void;
  37745. /**
  37746. * Delete a specific animation range
  37747. * @param name defines the name of the range to delete
  37748. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37749. */
  37750. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37751. /**
  37752. * Get an animation range by name
  37753. * @param name defines the name of the animation range to look for
  37754. * @returns null if not found else the requested animation range
  37755. */
  37756. getAnimationRange(name: string): Nullable<AnimationRange>;
  37757. /**
  37758. * Gets the list of all animation ranges defined on this node
  37759. * @returns an array
  37760. */
  37761. getAnimationRanges(): Nullable<AnimationRange>[];
  37762. /**
  37763. * Will start the animation sequence
  37764. * @param name defines the range frames for animation sequence
  37765. * @param loop defines if the animation should loop (false by default)
  37766. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37767. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37768. * @returns the object created for this animation. If range does not exist, it will return null
  37769. */
  37770. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37771. /**
  37772. * Serialize animation ranges into a JSON compatible object
  37773. * @returns serialization object
  37774. */
  37775. serializeAnimationRanges(): any;
  37776. /**
  37777. * Computes the world matrix of the node
  37778. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37779. * @returns the world matrix
  37780. */
  37781. computeWorldMatrix(force?: boolean): Matrix;
  37782. /**
  37783. * Releases resources associated with this node.
  37784. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37785. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37786. */
  37787. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37788. /**
  37789. * Parse animation range data from a serialization object and store them into a given node
  37790. * @param node defines where to store the animation ranges
  37791. * @param parsedNode defines the serialization object to read data from
  37792. * @param scene defines the hosting scene
  37793. */
  37794. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37795. /**
  37796. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37797. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37798. * @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
  37799. * @returns the new bounding vectors
  37800. */
  37801. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37802. min: Vector3;
  37803. max: Vector3;
  37804. };
  37805. }
  37806. }
  37807. declare module "babylonjs/Animations/animation" {
  37808. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  37809. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  37810. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  37811. import { Nullable } from "babylonjs/types";
  37812. import { Scene } from "babylonjs/scene";
  37813. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  37814. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37815. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  37816. import { Node } from "babylonjs/node";
  37817. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  37818. import { Size } from "babylonjs/Maths/math.size";
  37819. import { Animatable } from "babylonjs/Animations/animatable";
  37820. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  37821. /**
  37822. * @hidden
  37823. */
  37824. export class _IAnimationState {
  37825. key: number;
  37826. repeatCount: number;
  37827. workValue?: any;
  37828. loopMode?: number;
  37829. offsetValue?: any;
  37830. highLimitValue?: any;
  37831. }
  37832. /**
  37833. * Class used to store any kind of animation
  37834. */
  37835. export class Animation {
  37836. /**Name of the animation */
  37837. name: string;
  37838. /**Property to animate */
  37839. targetProperty: string;
  37840. /**The frames per second of the animation */
  37841. framePerSecond: number;
  37842. /**The data type of the animation */
  37843. dataType: number;
  37844. /**The loop mode of the animation */
  37845. loopMode?: number | undefined;
  37846. /**Specifies if blending should be enabled */
  37847. enableBlending?: boolean | undefined;
  37848. /**
  37849. * Use matrix interpolation instead of using direct key value when animating matrices
  37850. */
  37851. static AllowMatricesInterpolation: boolean;
  37852. /**
  37853. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37854. */
  37855. static AllowMatrixDecomposeForInterpolation: boolean;
  37856. /** Define the Url to load snippets */
  37857. static SnippetUrl: string;
  37858. /** Snippet ID if the animation was created from the snippet server */
  37859. snippetId: string;
  37860. /**
  37861. * Stores the key frames of the animation
  37862. */
  37863. private _keys;
  37864. /**
  37865. * Stores the easing function of the animation
  37866. */
  37867. private _easingFunction;
  37868. /**
  37869. * @hidden Internal use only
  37870. */
  37871. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  37872. /**
  37873. * The set of event that will be linked to this animation
  37874. */
  37875. private _events;
  37876. /**
  37877. * Stores an array of target property paths
  37878. */
  37879. targetPropertyPath: string[];
  37880. /**
  37881. * Stores the blending speed of the animation
  37882. */
  37883. blendingSpeed: number;
  37884. /**
  37885. * Stores the animation ranges for the animation
  37886. */
  37887. private _ranges;
  37888. /**
  37889. * @hidden Internal use
  37890. */
  37891. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37892. /**
  37893. * Sets up an animation
  37894. * @param property The property to animate
  37895. * @param animationType The animation type to apply
  37896. * @param framePerSecond The frames per second of the animation
  37897. * @param easingFunction The easing function used in the animation
  37898. * @returns The created animation
  37899. */
  37900. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37901. /**
  37902. * Create and start an animation on a node
  37903. * @param name defines the name of the global animation that will be run on all nodes
  37904. * @param node defines the root node where the animation will take place
  37905. * @param targetProperty defines property to animate
  37906. * @param framePerSecond defines the number of frame per second yo use
  37907. * @param totalFrame defines the number of frames in total
  37908. * @param from defines the initial value
  37909. * @param to defines the final value
  37910. * @param loopMode defines which loop mode you want to use (off by default)
  37911. * @param easingFunction defines the easing function to use (linear by default)
  37912. * @param onAnimationEnd defines the callback to call when animation end
  37913. * @returns the animatable created for this animation
  37914. */
  37915. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37916. /**
  37917. * Create and start an animation on a node and its descendants
  37918. * @param name defines the name of the global animation that will be run on all nodes
  37919. * @param node defines the root node where the animation will take place
  37920. * @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
  37921. * @param targetProperty defines property to animate
  37922. * @param framePerSecond defines the number of frame per second to use
  37923. * @param totalFrame defines the number of frames in total
  37924. * @param from defines the initial value
  37925. * @param to defines the final value
  37926. * @param loopMode defines which loop mode you want to use (off by default)
  37927. * @param easingFunction defines the easing function to use (linear by default)
  37928. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37929. * @returns the list of animatables created for all nodes
  37930. * @example https://www.babylonjs-playground.com/#MH0VLI
  37931. */
  37932. 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[]>;
  37933. /**
  37934. * Creates a new animation, merges it with the existing animations and starts it
  37935. * @param name Name of the animation
  37936. * @param node Node which contains the scene that begins the animations
  37937. * @param targetProperty Specifies which property to animate
  37938. * @param framePerSecond The frames per second of the animation
  37939. * @param totalFrame The total number of frames
  37940. * @param from The frame at the beginning of the animation
  37941. * @param to The frame at the end of the animation
  37942. * @param loopMode Specifies the loop mode of the animation
  37943. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37944. * @param onAnimationEnd Callback to run once the animation is complete
  37945. * @returns Nullable animation
  37946. */
  37947. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37948. /**
  37949. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37950. * @param sourceAnimation defines the Animation containing keyframes to convert
  37951. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37952. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37953. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37954. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37955. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37956. */
  37957. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37958. /**
  37959. * Transition property of an host to the target Value
  37960. * @param property The property to transition
  37961. * @param targetValue The target Value of the property
  37962. * @param host The object where the property to animate belongs
  37963. * @param scene Scene used to run the animation
  37964. * @param frameRate Framerate (in frame/s) to use
  37965. * @param transition The transition type we want to use
  37966. * @param duration The duration of the animation, in milliseconds
  37967. * @param onAnimationEnd Callback trigger at the end of the animation
  37968. * @returns Nullable animation
  37969. */
  37970. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  37971. /**
  37972. * Return the array of runtime animations currently using this animation
  37973. */
  37974. get runtimeAnimations(): RuntimeAnimation[];
  37975. /**
  37976. * Specifies if any of the runtime animations are currently running
  37977. */
  37978. get hasRunningRuntimeAnimations(): boolean;
  37979. /**
  37980. * Initializes the animation
  37981. * @param name Name of the animation
  37982. * @param targetProperty Property to animate
  37983. * @param framePerSecond The frames per second of the animation
  37984. * @param dataType The data type of the animation
  37985. * @param loopMode The loop mode of the animation
  37986. * @param enableBlending Specifies if blending should be enabled
  37987. */
  37988. constructor(
  37989. /**Name of the animation */
  37990. name: string,
  37991. /**Property to animate */
  37992. targetProperty: string,
  37993. /**The frames per second of the animation */
  37994. framePerSecond: number,
  37995. /**The data type of the animation */
  37996. dataType: number,
  37997. /**The loop mode of the animation */
  37998. loopMode?: number | undefined,
  37999. /**Specifies if blending should be enabled */
  38000. enableBlending?: boolean | undefined);
  38001. /**
  38002. * Converts the animation to a string
  38003. * @param fullDetails support for multiple levels of logging within scene loading
  38004. * @returns String form of the animation
  38005. */
  38006. toString(fullDetails?: boolean): string;
  38007. /**
  38008. * Add an event to this animation
  38009. * @param event Event to add
  38010. */
  38011. addEvent(event: AnimationEvent): void;
  38012. /**
  38013. * Remove all events found at the given frame
  38014. * @param frame The frame to remove events from
  38015. */
  38016. removeEvents(frame: number): void;
  38017. /**
  38018. * Retrieves all the events from the animation
  38019. * @returns Events from the animation
  38020. */
  38021. getEvents(): AnimationEvent[];
  38022. /**
  38023. * Creates an animation range
  38024. * @param name Name of the animation range
  38025. * @param from Starting frame of the animation range
  38026. * @param to Ending frame of the animation
  38027. */
  38028. createRange(name: string, from: number, to: number): void;
  38029. /**
  38030. * Deletes an animation range by name
  38031. * @param name Name of the animation range to delete
  38032. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38033. */
  38034. deleteRange(name: string, deleteFrames?: boolean): void;
  38035. /**
  38036. * Gets the animation range by name, or null if not defined
  38037. * @param name Name of the animation range
  38038. * @returns Nullable animation range
  38039. */
  38040. getRange(name: string): Nullable<AnimationRange>;
  38041. /**
  38042. * Gets the key frames from the animation
  38043. * @returns The key frames of the animation
  38044. */
  38045. getKeys(): Array<IAnimationKey>;
  38046. /**
  38047. * Gets the highest frame rate of the animation
  38048. * @returns Highest frame rate of the animation
  38049. */
  38050. getHighestFrame(): number;
  38051. /**
  38052. * Gets the easing function of the animation
  38053. * @returns Easing function of the animation
  38054. */
  38055. getEasingFunction(): IEasingFunction;
  38056. /**
  38057. * Sets the easing function of the animation
  38058. * @param easingFunction A custom mathematical formula for animation
  38059. */
  38060. setEasingFunction(easingFunction: EasingFunction): void;
  38061. /**
  38062. * Interpolates a scalar linearly
  38063. * @param startValue Start value of the animation curve
  38064. * @param endValue End value of the animation curve
  38065. * @param gradient Scalar amount to interpolate
  38066. * @returns Interpolated scalar value
  38067. */
  38068. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38069. /**
  38070. * Interpolates a scalar cubically
  38071. * @param startValue Start value of the animation curve
  38072. * @param outTangent End tangent of the animation
  38073. * @param endValue End value of the animation curve
  38074. * @param inTangent Start tangent of the animation curve
  38075. * @param gradient Scalar amount to interpolate
  38076. * @returns Interpolated scalar value
  38077. */
  38078. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38079. /**
  38080. * Interpolates a quaternion using a spherical linear interpolation
  38081. * @param startValue Start value of the animation curve
  38082. * @param endValue End value of the animation curve
  38083. * @param gradient Scalar amount to interpolate
  38084. * @returns Interpolated quaternion value
  38085. */
  38086. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38087. /**
  38088. * Interpolates a quaternion cubically
  38089. * @param startValue Start value of the animation curve
  38090. * @param outTangent End tangent of the animation curve
  38091. * @param endValue End value of the animation curve
  38092. * @param inTangent Start tangent of the animation curve
  38093. * @param gradient Scalar amount to interpolate
  38094. * @returns Interpolated quaternion value
  38095. */
  38096. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38097. /**
  38098. * Interpolates a Vector3 linearl
  38099. * @param startValue Start value of the animation curve
  38100. * @param endValue End value of the animation curve
  38101. * @param gradient Scalar amount to interpolate
  38102. * @returns Interpolated scalar value
  38103. */
  38104. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38105. /**
  38106. * Interpolates a Vector3 cubically
  38107. * @param startValue Start value of the animation curve
  38108. * @param outTangent End tangent of the animation
  38109. * @param endValue End value of the animation curve
  38110. * @param inTangent Start tangent of the animation curve
  38111. * @param gradient Scalar amount to interpolate
  38112. * @returns InterpolatedVector3 value
  38113. */
  38114. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38115. /**
  38116. * Interpolates a Vector2 linearly
  38117. * @param startValue Start value of the animation curve
  38118. * @param endValue End value of the animation curve
  38119. * @param gradient Scalar amount to interpolate
  38120. * @returns Interpolated Vector2 value
  38121. */
  38122. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38123. /**
  38124. * Interpolates a Vector2 cubically
  38125. * @param startValue Start value of the animation curve
  38126. * @param outTangent End tangent of the animation
  38127. * @param endValue End value of the animation curve
  38128. * @param inTangent Start tangent of the animation curve
  38129. * @param gradient Scalar amount to interpolate
  38130. * @returns Interpolated Vector2 value
  38131. */
  38132. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38133. /**
  38134. * Interpolates a size linearly
  38135. * @param startValue Start value of the animation curve
  38136. * @param endValue End value of the animation curve
  38137. * @param gradient Scalar amount to interpolate
  38138. * @returns Interpolated Size value
  38139. */
  38140. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38141. /**
  38142. * Interpolates a Color3 linearly
  38143. * @param startValue Start value of the animation curve
  38144. * @param endValue End value of the animation curve
  38145. * @param gradient Scalar amount to interpolate
  38146. * @returns Interpolated Color3 value
  38147. */
  38148. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38149. /**
  38150. * Interpolates a Color4 linearly
  38151. * @param startValue Start value of the animation curve
  38152. * @param endValue End value of the animation curve
  38153. * @param gradient Scalar amount to interpolate
  38154. * @returns Interpolated Color3 value
  38155. */
  38156. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38157. /**
  38158. * @hidden Internal use only
  38159. */
  38160. _getKeyValue(value: any): any;
  38161. /**
  38162. * @hidden Internal use only
  38163. */
  38164. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38165. /**
  38166. * Defines the function to use to interpolate matrices
  38167. * @param startValue defines the start matrix
  38168. * @param endValue defines the end matrix
  38169. * @param gradient defines the gradient between both matrices
  38170. * @param result defines an optional target matrix where to store the interpolation
  38171. * @returns the interpolated matrix
  38172. */
  38173. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  38174. /**
  38175. * Makes a copy of the animation
  38176. * @returns Cloned animation
  38177. */
  38178. clone(): Animation;
  38179. /**
  38180. * Sets the key frames of the animation
  38181. * @param values The animation key frames to set
  38182. */
  38183. setKeys(values: Array<IAnimationKey>): void;
  38184. /**
  38185. * Serializes the animation to an object
  38186. * @returns Serialized object
  38187. */
  38188. serialize(): any;
  38189. /**
  38190. * Float animation type
  38191. */
  38192. static readonly ANIMATIONTYPE_FLOAT: number;
  38193. /**
  38194. * Vector3 animation type
  38195. */
  38196. static readonly ANIMATIONTYPE_VECTOR3: number;
  38197. /**
  38198. * Quaternion animation type
  38199. */
  38200. static readonly ANIMATIONTYPE_QUATERNION: number;
  38201. /**
  38202. * Matrix animation type
  38203. */
  38204. static readonly ANIMATIONTYPE_MATRIX: number;
  38205. /**
  38206. * Color3 animation type
  38207. */
  38208. static readonly ANIMATIONTYPE_COLOR3: number;
  38209. /**
  38210. * Color3 animation type
  38211. */
  38212. static readonly ANIMATIONTYPE_COLOR4: number;
  38213. /**
  38214. * Vector2 animation type
  38215. */
  38216. static readonly ANIMATIONTYPE_VECTOR2: number;
  38217. /**
  38218. * Size animation type
  38219. */
  38220. static readonly ANIMATIONTYPE_SIZE: number;
  38221. /**
  38222. * Relative Loop Mode
  38223. */
  38224. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38225. /**
  38226. * Cycle Loop Mode
  38227. */
  38228. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38229. /**
  38230. * Constant Loop Mode
  38231. */
  38232. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38233. /** @hidden */
  38234. static _UniversalLerp(left: any, right: any, amount: number): any;
  38235. /**
  38236. * Parses an animation object and creates an animation
  38237. * @param parsedAnimation Parsed animation object
  38238. * @returns Animation object
  38239. */
  38240. static Parse(parsedAnimation: any): Animation;
  38241. /**
  38242. * Appends the serialized animations from the source animations
  38243. * @param source Source containing the animations
  38244. * @param destination Target to store the animations
  38245. */
  38246. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38247. /**
  38248. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38249. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38250. * @param url defines the url to load from
  38251. * @returns a promise that will resolve to the new animation or an array of animations
  38252. */
  38253. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38254. /**
  38255. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38256. * @param snippetId defines the snippet to load
  38257. * @returns a promise that will resolve to the new animation or a new array of animations
  38258. */
  38259. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38260. }
  38261. }
  38262. declare module "babylonjs/Animations/animatable.interface" {
  38263. import { Nullable } from "babylonjs/types";
  38264. import { Animation } from "babylonjs/Animations/animation";
  38265. /**
  38266. * Interface containing an array of animations
  38267. */
  38268. export interface IAnimatable {
  38269. /**
  38270. * Array of animations
  38271. */
  38272. animations: Nullable<Array<Animation>>;
  38273. }
  38274. }
  38275. declare module "babylonjs/Misc/decorators" {
  38276. import { Nullable } from "babylonjs/types";
  38277. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38278. import { Scene } from "babylonjs/scene";
  38279. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  38280. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38281. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38282. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38283. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38284. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38285. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38286. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38287. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38288. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38289. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38290. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38291. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38292. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38293. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38294. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38295. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38296. /**
  38297. * Decorator used to define property that can be serialized as reference to a camera
  38298. * @param sourceName defines the name of the property to decorate
  38299. */
  38300. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38301. /**
  38302. * Class used to help serialization objects
  38303. */
  38304. export class SerializationHelper {
  38305. /** @hidden */
  38306. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38307. /** @hidden */
  38308. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38309. /** @hidden */
  38310. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38311. /** @hidden */
  38312. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38313. /**
  38314. * Appends the serialized animations from the source animations
  38315. * @param source Source containing the animations
  38316. * @param destination Target to store the animations
  38317. */
  38318. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38319. /**
  38320. * Static function used to serialized a specific entity
  38321. * @param entity defines the entity to serialize
  38322. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38323. * @returns a JSON compatible object representing the serialization of the entity
  38324. */
  38325. static Serialize<T>(entity: T, serializationObject?: any): any;
  38326. /**
  38327. * Creates a new entity from a serialization data object
  38328. * @param creationFunction defines a function used to instanciated the new entity
  38329. * @param source defines the source serialization data
  38330. * @param scene defines the hosting scene
  38331. * @param rootUrl defines the root url for resources
  38332. * @returns a new entity
  38333. */
  38334. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38335. /**
  38336. * Clones an object
  38337. * @param creationFunction defines the function used to instanciate the new object
  38338. * @param source defines the source object
  38339. * @returns the cloned object
  38340. */
  38341. static Clone<T>(creationFunction: () => T, source: T): T;
  38342. /**
  38343. * Instanciates a new object based on a source one (some data will be shared between both object)
  38344. * @param creationFunction defines the function used to instanciate the new object
  38345. * @param source defines the source object
  38346. * @returns the new object
  38347. */
  38348. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38349. }
  38350. }
  38351. declare module "babylonjs/Cameras/camera" {
  38352. import { SmartArray } from "babylonjs/Misc/smartArray";
  38353. import { Observable } from "babylonjs/Misc/observable";
  38354. import { Nullable } from "babylonjs/types";
  38355. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38356. import { Scene } from "babylonjs/scene";
  38357. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38358. import { Node } from "babylonjs/node";
  38359. import { Mesh } from "babylonjs/Meshes/mesh";
  38360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38361. import { ICullable } from "babylonjs/Culling/boundingInfo";
  38362. import { Viewport } from "babylonjs/Maths/math.viewport";
  38363. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38364. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38365. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38366. import { Ray } from "babylonjs/Culling/ray";
  38367. /**
  38368. * This is the base class of all the camera used in the application.
  38369. * @see https://doc.babylonjs.com/features/cameras
  38370. */
  38371. export class Camera extends Node {
  38372. /** @hidden */
  38373. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  38374. /**
  38375. * This is the default projection mode used by the cameras.
  38376. * It helps recreating a feeling of perspective and better appreciate depth.
  38377. * This is the best way to simulate real life cameras.
  38378. */
  38379. static readonly PERSPECTIVE_CAMERA: number;
  38380. /**
  38381. * This helps creating camera with an orthographic mode.
  38382. * 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.
  38383. */
  38384. static readonly ORTHOGRAPHIC_CAMERA: number;
  38385. /**
  38386. * This is the default FOV mode for perspective cameras.
  38387. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  38388. */
  38389. static readonly FOVMODE_VERTICAL_FIXED: number;
  38390. /**
  38391. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  38392. */
  38393. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  38394. /**
  38395. * This specifies ther is no need for a camera rig.
  38396. * Basically only one eye is rendered corresponding to the camera.
  38397. */
  38398. static readonly RIG_MODE_NONE: number;
  38399. /**
  38400. * Simulates a camera Rig with one blue eye and one red eye.
  38401. * This can be use with 3d blue and red glasses.
  38402. */
  38403. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  38404. /**
  38405. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  38406. */
  38407. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  38408. /**
  38409. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  38410. */
  38411. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  38412. /**
  38413. * Defines that both eyes of the camera will be rendered over under each other.
  38414. */
  38415. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  38416. /**
  38417. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  38418. */
  38419. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  38420. /**
  38421. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  38422. */
  38423. static readonly RIG_MODE_VR: number;
  38424. /**
  38425. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  38426. */
  38427. static readonly RIG_MODE_WEBVR: number;
  38428. /**
  38429. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  38430. */
  38431. static readonly RIG_MODE_CUSTOM: number;
  38432. /**
  38433. * Defines if by default attaching controls should prevent the default javascript event to continue.
  38434. */
  38435. static ForceAttachControlToAlwaysPreventDefault: boolean;
  38436. /**
  38437. * Define the input manager associated with the camera.
  38438. */
  38439. inputs: CameraInputsManager<Camera>;
  38440. /** @hidden */
  38441. _position: Vector3;
  38442. /**
  38443. * Define the current local position of the camera in the scene
  38444. */
  38445. get position(): Vector3;
  38446. set position(newPosition: Vector3);
  38447. protected _upVector: Vector3;
  38448. /**
  38449. * The vector the camera should consider as up.
  38450. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  38451. */
  38452. set upVector(vec: Vector3);
  38453. get upVector(): Vector3;
  38454. /**
  38455. * Define the current limit on the left side for an orthographic camera
  38456. * In scene unit
  38457. */
  38458. orthoLeft: Nullable<number>;
  38459. /**
  38460. * Define the current limit on the right side for an orthographic camera
  38461. * In scene unit
  38462. */
  38463. orthoRight: Nullable<number>;
  38464. /**
  38465. * Define the current limit on the bottom side for an orthographic camera
  38466. * In scene unit
  38467. */
  38468. orthoBottom: Nullable<number>;
  38469. /**
  38470. * Define the current limit on the top side for an orthographic camera
  38471. * In scene unit
  38472. */
  38473. orthoTop: Nullable<number>;
  38474. /**
  38475. * Field Of View is set in Radians. (default is 0.8)
  38476. */
  38477. fov: number;
  38478. /**
  38479. * Define the minimum distance the camera can see from.
  38480. * This is important to note that the depth buffer are not infinite and the closer it starts
  38481. * the more your scene might encounter depth fighting issue.
  38482. */
  38483. minZ: number;
  38484. /**
  38485. * Define the maximum distance the camera can see to.
  38486. * This is important to note that the depth buffer are not infinite and the further it end
  38487. * the more your scene might encounter depth fighting issue.
  38488. */
  38489. maxZ: number;
  38490. /**
  38491. * Define the default inertia of the camera.
  38492. * This helps giving a smooth feeling to the camera movement.
  38493. */
  38494. inertia: number;
  38495. /**
  38496. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  38497. */
  38498. mode: number;
  38499. /**
  38500. * Define whether the camera is intermediate.
  38501. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  38502. */
  38503. isIntermediate: boolean;
  38504. /**
  38505. * Define the viewport of the camera.
  38506. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  38507. */
  38508. viewport: Viewport;
  38509. /**
  38510. * Restricts the camera to viewing objects with the same layerMask.
  38511. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  38512. */
  38513. layerMask: number;
  38514. /**
  38515. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  38516. */
  38517. fovMode: number;
  38518. /**
  38519. * Rig mode of the camera.
  38520. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  38521. * This is normally controlled byt the camera themselves as internal use.
  38522. */
  38523. cameraRigMode: number;
  38524. /**
  38525. * Defines the distance between both "eyes" in case of a RIG
  38526. */
  38527. interaxialDistance: number;
  38528. /**
  38529. * Defines if stereoscopic rendering is done side by side or over under.
  38530. */
  38531. isStereoscopicSideBySide: boolean;
  38532. /**
  38533. * 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
  38534. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  38535. * else in the scene. (Eg. security camera)
  38536. *
  38537. * 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)
  38538. */
  38539. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  38540. /**
  38541. * When set, the camera will render to this render target instead of the default canvas
  38542. *
  38543. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  38544. */
  38545. outputRenderTarget: Nullable<RenderTargetTexture>;
  38546. /**
  38547. * Observable triggered when the camera view matrix has changed.
  38548. */
  38549. onViewMatrixChangedObservable: Observable<Camera>;
  38550. /**
  38551. * Observable triggered when the camera Projection matrix has changed.
  38552. */
  38553. onProjectionMatrixChangedObservable: Observable<Camera>;
  38554. /**
  38555. * Observable triggered when the inputs have been processed.
  38556. */
  38557. onAfterCheckInputsObservable: Observable<Camera>;
  38558. /**
  38559. * Observable triggered when reset has been called and applied to the camera.
  38560. */
  38561. onRestoreStateObservable: Observable<Camera>;
  38562. /**
  38563. * Is this camera a part of a rig system?
  38564. */
  38565. isRigCamera: boolean;
  38566. /**
  38567. * If isRigCamera set to true this will be set with the parent camera.
  38568. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  38569. */
  38570. rigParent?: Camera;
  38571. /** @hidden */
  38572. _cameraRigParams: any;
  38573. /** @hidden */
  38574. _rigCameras: Camera[];
  38575. /** @hidden */
  38576. _rigPostProcess: Nullable<PostProcess>;
  38577. protected _webvrViewMatrix: Matrix;
  38578. /** @hidden */
  38579. _skipRendering: boolean;
  38580. /** @hidden */
  38581. _projectionMatrix: Matrix;
  38582. /** @hidden */
  38583. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  38584. /** @hidden */
  38585. _activeMeshes: SmartArray<AbstractMesh>;
  38586. protected _globalPosition: Vector3;
  38587. /** @hidden */
  38588. _computedViewMatrix: Matrix;
  38589. private _doNotComputeProjectionMatrix;
  38590. private _transformMatrix;
  38591. private _frustumPlanes;
  38592. private _refreshFrustumPlanes;
  38593. private _storedFov;
  38594. private _stateStored;
  38595. /**
  38596. * Instantiates a new camera object.
  38597. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  38598. * @see https://doc.babylonjs.com/features/cameras
  38599. * @param name Defines the name of the camera in the scene
  38600. * @param position Defines the position of the camera
  38601. * @param scene Defines the scene the camera belongs too
  38602. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  38603. */
  38604. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38605. /**
  38606. * Store current camera state (fov, position, etc..)
  38607. * @returns the camera
  38608. */
  38609. storeState(): Camera;
  38610. /**
  38611. * Restores the camera state values if it has been stored. You must call storeState() first
  38612. */
  38613. protected _restoreStateValues(): boolean;
  38614. /**
  38615. * Restored camera state. You must call storeState() first.
  38616. * @returns true if restored and false otherwise
  38617. */
  38618. restoreState(): boolean;
  38619. /**
  38620. * Gets the class name of the camera.
  38621. * @returns the class name
  38622. */
  38623. getClassName(): string;
  38624. /** @hidden */
  38625. readonly _isCamera: boolean;
  38626. /**
  38627. * Gets a string representation of the camera useful for debug purpose.
  38628. * @param fullDetails Defines that a more verboe level of logging is required
  38629. * @returns the string representation
  38630. */
  38631. toString(fullDetails?: boolean): string;
  38632. /**
  38633. * Gets the current world space position of the camera.
  38634. */
  38635. get globalPosition(): Vector3;
  38636. /**
  38637. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38638. * @returns the active meshe list
  38639. */
  38640. getActiveMeshes(): SmartArray<AbstractMesh>;
  38641. /**
  38642. * Check whether a mesh is part of the current active mesh list of the camera
  38643. * @param mesh Defines the mesh to check
  38644. * @returns true if active, false otherwise
  38645. */
  38646. isActiveMesh(mesh: Mesh): boolean;
  38647. /**
  38648. * Is this camera ready to be used/rendered
  38649. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38650. * @return true if the camera is ready
  38651. */
  38652. isReady(completeCheck?: boolean): boolean;
  38653. /** @hidden */
  38654. _initCache(): void;
  38655. /** @hidden */
  38656. _updateCache(ignoreParentClass?: boolean): void;
  38657. /** @hidden */
  38658. _isSynchronized(): boolean;
  38659. /** @hidden */
  38660. _isSynchronizedViewMatrix(): boolean;
  38661. /** @hidden */
  38662. _isSynchronizedProjectionMatrix(): boolean;
  38663. /**
  38664. * Attach the input controls to a specific dom element to get the input from.
  38665. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38666. */
  38667. attachControl(noPreventDefault?: boolean): void;
  38668. /**
  38669. * Attach the input controls to a specific dom element to get the input from.
  38670. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  38671. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38672. * BACK COMPAT SIGNATURE ONLY.
  38673. */
  38674. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38675. /**
  38676. * Detach the current controls from the specified dom element.
  38677. */
  38678. detachControl(): void;
  38679. /**
  38680. * Detach the current controls from the specified dom element.
  38681. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  38682. */
  38683. detachControl(ignored: any): void;
  38684. /**
  38685. * Update the camera state according to the different inputs gathered during the frame.
  38686. */
  38687. update(): void;
  38688. /** @hidden */
  38689. _checkInputs(): void;
  38690. /** @hidden */
  38691. get rigCameras(): Camera[];
  38692. /**
  38693. * Gets the post process used by the rig cameras
  38694. */
  38695. get rigPostProcess(): Nullable<PostProcess>;
  38696. /**
  38697. * Internal, gets the first post proces.
  38698. * @returns the first post process to be run on this camera.
  38699. */
  38700. _getFirstPostProcess(): Nullable<PostProcess>;
  38701. private _cascadePostProcessesToRigCams;
  38702. /**
  38703. * Attach a post process to the camera.
  38704. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38705. * @param postProcess The post process to attach to the camera
  38706. * @param insertAt The position of the post process in case several of them are in use in the scene
  38707. * @returns the position the post process has been inserted at
  38708. */
  38709. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38710. /**
  38711. * Detach a post process to the camera.
  38712. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38713. * @param postProcess The post process to detach from the camera
  38714. */
  38715. detachPostProcess(postProcess: PostProcess): void;
  38716. /**
  38717. * Gets the current world matrix of the camera
  38718. */
  38719. getWorldMatrix(): Matrix;
  38720. /** @hidden */
  38721. _getViewMatrix(): Matrix;
  38722. /**
  38723. * Gets the current view matrix of the camera.
  38724. * @param force forces the camera to recompute the matrix without looking at the cached state
  38725. * @returns the view matrix
  38726. */
  38727. getViewMatrix(force?: boolean): Matrix;
  38728. /**
  38729. * Freeze the projection matrix.
  38730. * It will prevent the cache check of the camera projection compute and can speed up perf
  38731. * if no parameter of the camera are meant to change
  38732. * @param projection Defines manually a projection if necessary
  38733. */
  38734. freezeProjectionMatrix(projection?: Matrix): void;
  38735. /**
  38736. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38737. */
  38738. unfreezeProjectionMatrix(): void;
  38739. /**
  38740. * Gets the current projection matrix of the camera.
  38741. * @param force forces the camera to recompute the matrix without looking at the cached state
  38742. * @returns the projection matrix
  38743. */
  38744. getProjectionMatrix(force?: boolean): Matrix;
  38745. /**
  38746. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38747. * @returns a Matrix
  38748. */
  38749. getTransformationMatrix(): Matrix;
  38750. private _updateFrustumPlanes;
  38751. /**
  38752. * Checks if a cullable object (mesh...) is in the camera frustum
  38753. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38754. * @param target The object to check
  38755. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38756. * @returns true if the object is in frustum otherwise false
  38757. */
  38758. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38759. /**
  38760. * Checks if a cullable object (mesh...) is in the camera frustum
  38761. * Unlike isInFrustum this cheks the full bounding box
  38762. * @param target The object to check
  38763. * @returns true if the object is in frustum otherwise false
  38764. */
  38765. isCompletelyInFrustum(target: ICullable): boolean;
  38766. /**
  38767. * Gets a ray in the forward direction from the camera.
  38768. * @param length Defines the length of the ray to create
  38769. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38770. * @param origin Defines the start point of the ray which defaults to the camera position
  38771. * @returns the forward ray
  38772. */
  38773. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38774. /**
  38775. * Gets a ray in the forward direction from the camera.
  38776. * @param refRay the ray to (re)use when setting the values
  38777. * @param length Defines the length of the ray to create
  38778. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38779. * @param origin Defines the start point of the ray which defaults to the camera position
  38780. * @returns the forward ray
  38781. */
  38782. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38783. /**
  38784. * Releases resources associated with this node.
  38785. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38786. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38787. */
  38788. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38789. /** @hidden */
  38790. _isLeftCamera: boolean;
  38791. /**
  38792. * Gets the left camera of a rig setup in case of Rigged Camera
  38793. */
  38794. get isLeftCamera(): boolean;
  38795. /** @hidden */
  38796. _isRightCamera: boolean;
  38797. /**
  38798. * Gets the right camera of a rig setup in case of Rigged Camera
  38799. */
  38800. get isRightCamera(): boolean;
  38801. /**
  38802. * Gets the left camera of a rig setup in case of Rigged Camera
  38803. */
  38804. get leftCamera(): Nullable<FreeCamera>;
  38805. /**
  38806. * Gets the right camera of a rig setup in case of Rigged Camera
  38807. */
  38808. get rightCamera(): Nullable<FreeCamera>;
  38809. /**
  38810. * Gets the left camera target of a rig setup in case of Rigged Camera
  38811. * @returns the target position
  38812. */
  38813. getLeftTarget(): Nullable<Vector3>;
  38814. /**
  38815. * Gets the right camera target of a rig setup in case of Rigged Camera
  38816. * @returns the target position
  38817. */
  38818. getRightTarget(): Nullable<Vector3>;
  38819. /**
  38820. * @hidden
  38821. */
  38822. setCameraRigMode(mode: number, rigParams: any): void;
  38823. /** @hidden */
  38824. static _setStereoscopicRigMode(camera: Camera): void;
  38825. /** @hidden */
  38826. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38827. /** @hidden */
  38828. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38829. /** @hidden */
  38830. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38831. /** @hidden */
  38832. _getVRProjectionMatrix(): Matrix;
  38833. protected _updateCameraRotationMatrix(): void;
  38834. protected _updateWebVRCameraRotationMatrix(): void;
  38835. /**
  38836. * This function MUST be overwritten by the different WebVR cameras available.
  38837. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38838. * @hidden
  38839. */
  38840. _getWebVRProjectionMatrix(): Matrix;
  38841. /**
  38842. * This function MUST be overwritten by the different WebVR cameras available.
  38843. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38844. * @hidden
  38845. */
  38846. _getWebVRViewMatrix(): Matrix;
  38847. /** @hidden */
  38848. setCameraRigParameter(name: string, value: any): void;
  38849. /**
  38850. * needs to be overridden by children so sub has required properties to be copied
  38851. * @hidden
  38852. */
  38853. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38854. /**
  38855. * May need to be overridden by children
  38856. * @hidden
  38857. */
  38858. _updateRigCameras(): void;
  38859. /** @hidden */
  38860. _setupInputs(): void;
  38861. /**
  38862. * Serialiaze the camera setup to a json represention
  38863. * @returns the JSON representation
  38864. */
  38865. serialize(): any;
  38866. /**
  38867. * Clones the current camera.
  38868. * @param name The cloned camera name
  38869. * @returns the cloned camera
  38870. */
  38871. clone(name: string): Camera;
  38872. /**
  38873. * Gets the direction of the camera relative to a given local axis.
  38874. * @param localAxis Defines the reference axis to provide a relative direction.
  38875. * @return the direction
  38876. */
  38877. getDirection(localAxis: Vector3): Vector3;
  38878. /**
  38879. * Returns the current camera absolute rotation
  38880. */
  38881. get absoluteRotation(): Quaternion;
  38882. /**
  38883. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38884. * @param localAxis Defines the reference axis to provide a relative direction.
  38885. * @param result Defines the vector to store the result in
  38886. */
  38887. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38888. /**
  38889. * Gets a camera constructor for a given camera type
  38890. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38891. * @param name The name of the camera the result will be able to instantiate
  38892. * @param scene The scene the result will construct the camera in
  38893. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38894. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38895. * @returns a factory method to construc the camera
  38896. */
  38897. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38898. /**
  38899. * Compute the world matrix of the camera.
  38900. * @returns the camera world matrix
  38901. */
  38902. computeWorldMatrix(): Matrix;
  38903. /**
  38904. * Parse a JSON and creates the camera from the parsed information
  38905. * @param parsedCamera The JSON to parse
  38906. * @param scene The scene to instantiate the camera in
  38907. * @returns the newly constructed camera
  38908. */
  38909. static Parse(parsedCamera: any, scene: Scene): Camera;
  38910. }
  38911. }
  38912. declare module "babylonjs/PostProcesses/postProcessManager" {
  38913. import { Nullable } from "babylonjs/types";
  38914. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38915. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38916. import { Scene } from "babylonjs/scene";
  38917. /**
  38918. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38919. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38920. */
  38921. export class PostProcessManager {
  38922. private _scene;
  38923. private _indexBuffer;
  38924. private _vertexBuffers;
  38925. /**
  38926. * Creates a new instance PostProcess
  38927. * @param scene The scene that the post process is associated with.
  38928. */
  38929. constructor(scene: Scene);
  38930. private _prepareBuffers;
  38931. private _buildIndexBuffer;
  38932. /**
  38933. * Rebuilds the vertex buffers of the manager.
  38934. * @hidden
  38935. */
  38936. _rebuild(): void;
  38937. /**
  38938. * Prepares a frame to be run through a post process.
  38939. * @param sourceTexture The input texture to the post procesess. (default: null)
  38940. * @param postProcesses An array of post processes to be run. (default: null)
  38941. * @returns True if the post processes were able to be run.
  38942. * @hidden
  38943. */
  38944. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  38945. /**
  38946. * Manually render a set of post processes to a texture.
  38947. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  38948. * @param postProcesses An array of post processes to be run.
  38949. * @param targetTexture The target texture to render to.
  38950. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  38951. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  38952. * @param lodLevel defines which lod of the texture to render to
  38953. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  38954. */
  38955. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  38956. /**
  38957. * Finalize the result of the output of the postprocesses.
  38958. * @param doNotPresent If true the result will not be displayed to the screen.
  38959. * @param targetTexture The target texture to render to.
  38960. * @param faceIndex The index of the face to bind the target texture to.
  38961. * @param postProcesses The array of post processes to render.
  38962. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  38963. * @hidden
  38964. */
  38965. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  38966. /**
  38967. * Disposes of the post process manager.
  38968. */
  38969. dispose(): void;
  38970. }
  38971. }
  38972. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  38973. import { Observable } from "babylonjs/Misc/observable";
  38974. import { SmartArray } from "babylonjs/Misc/smartArray";
  38975. import { Nullable, Immutable } from "babylonjs/types";
  38976. import { Camera } from "babylonjs/Cameras/camera";
  38977. import { Scene } from "babylonjs/scene";
  38978. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  38979. import { Color4 } from "babylonjs/Maths/math.color";
  38980. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  38981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38982. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38983. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38984. import { Texture } from "babylonjs/Materials/Textures/texture";
  38985. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38986. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  38987. import "babylonjs/Engines/Extensions/engine.renderTarget";
  38988. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  38989. import { Engine } from "babylonjs/Engines/engine";
  38990. /**
  38991. * This Helps creating a texture that will be created from a camera in your scene.
  38992. * It is basically a dynamic texture that could be used to create special effects for instance.
  38993. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  38994. */
  38995. export class RenderTargetTexture extends Texture {
  38996. /**
  38997. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  38998. */
  38999. static readonly REFRESHRATE_RENDER_ONCE: number;
  39000. /**
  39001. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  39002. */
  39003. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  39004. /**
  39005. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  39006. * the central point of your effect and can save a lot of performances.
  39007. */
  39008. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  39009. /**
  39010. * Use this predicate to dynamically define the list of mesh you want to render.
  39011. * If set, the renderList property will be overwritten.
  39012. */
  39013. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  39014. private _renderList;
  39015. /**
  39016. * Use this list to define the list of mesh you want to render.
  39017. */
  39018. get renderList(): Nullable<Array<AbstractMesh>>;
  39019. set renderList(value: Nullable<Array<AbstractMesh>>);
  39020. /**
  39021. * Use this function to overload the renderList array at rendering time.
  39022. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  39023. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  39024. * the cube (if the RTT is a cube, else layerOrFace=0).
  39025. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  39026. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  39027. * hold dummy elements!
  39028. */
  39029. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  39030. private _hookArray;
  39031. /**
  39032. * Define if particles should be rendered in your texture.
  39033. */
  39034. renderParticles: boolean;
  39035. /**
  39036. * Define if sprites should be rendered in your texture.
  39037. */
  39038. renderSprites: boolean;
  39039. /**
  39040. * Define the camera used to render the texture.
  39041. */
  39042. activeCamera: Nullable<Camera>;
  39043. /**
  39044. * Override the mesh isReady function with your own one.
  39045. */
  39046. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  39047. /**
  39048. * Override the render function of the texture with your own one.
  39049. */
  39050. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  39051. /**
  39052. * Define if camera post processes should be use while rendering the texture.
  39053. */
  39054. useCameraPostProcesses: boolean;
  39055. /**
  39056. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  39057. */
  39058. ignoreCameraViewport: boolean;
  39059. private _postProcessManager;
  39060. private _postProcesses;
  39061. private _resizeObserver;
  39062. /**
  39063. * An event triggered when the texture is unbind.
  39064. */
  39065. onBeforeBindObservable: Observable<RenderTargetTexture>;
  39066. /**
  39067. * An event triggered when the texture is unbind.
  39068. */
  39069. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  39070. private _onAfterUnbindObserver;
  39071. /**
  39072. * Set a after unbind callback in the texture.
  39073. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  39074. */
  39075. set onAfterUnbind(callback: () => void);
  39076. /**
  39077. * An event triggered before rendering the texture
  39078. */
  39079. onBeforeRenderObservable: Observable<number>;
  39080. private _onBeforeRenderObserver;
  39081. /**
  39082. * Set a before render callback in the texture.
  39083. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  39084. */
  39085. set onBeforeRender(callback: (faceIndex: number) => void);
  39086. /**
  39087. * An event triggered after rendering the texture
  39088. */
  39089. onAfterRenderObservable: Observable<number>;
  39090. private _onAfterRenderObserver;
  39091. /**
  39092. * Set a after render callback in the texture.
  39093. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  39094. */
  39095. set onAfterRender(callback: (faceIndex: number) => void);
  39096. /**
  39097. * An event triggered after the texture clear
  39098. */
  39099. onClearObservable: Observable<Engine>;
  39100. private _onClearObserver;
  39101. /**
  39102. * Set a clear callback in the texture.
  39103. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  39104. */
  39105. set onClear(callback: (Engine: Engine) => void);
  39106. /**
  39107. * An event triggered when the texture is resized.
  39108. */
  39109. onResizeObservable: Observable<RenderTargetTexture>;
  39110. /**
  39111. * Define the clear color of the Render Target if it should be different from the scene.
  39112. */
  39113. clearColor: Color4;
  39114. protected _size: number | {
  39115. width: number;
  39116. height: number;
  39117. layers?: number;
  39118. };
  39119. protected _initialSizeParameter: number | {
  39120. width: number;
  39121. height: number;
  39122. } | {
  39123. ratio: number;
  39124. };
  39125. protected _sizeRatio: Nullable<number>;
  39126. /** @hidden */
  39127. _generateMipMaps: boolean;
  39128. protected _renderingManager: RenderingManager;
  39129. /** @hidden */
  39130. _waitingRenderList?: string[];
  39131. protected _doNotChangeAspectRatio: boolean;
  39132. protected _currentRefreshId: number;
  39133. protected _refreshRate: number;
  39134. protected _textureMatrix: Matrix;
  39135. protected _samples: number;
  39136. protected _renderTargetOptions: RenderTargetCreationOptions;
  39137. /**
  39138. * Gets render target creation options that were used.
  39139. */
  39140. get renderTargetOptions(): RenderTargetCreationOptions;
  39141. protected _onRatioRescale(): void;
  39142. /**
  39143. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  39144. * It must define where the camera used to render the texture is set
  39145. */
  39146. boundingBoxPosition: Vector3;
  39147. private _boundingBoxSize;
  39148. /**
  39149. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  39150. * When defined, the cubemap will switch to local mode
  39151. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  39152. * @example https://www.babylonjs-playground.com/#RNASML
  39153. */
  39154. set boundingBoxSize(value: Vector3);
  39155. get boundingBoxSize(): Vector3;
  39156. /**
  39157. * In case the RTT has been created with a depth texture, get the associated
  39158. * depth texture.
  39159. * Otherwise, return null.
  39160. */
  39161. get depthStencilTexture(): Nullable<InternalTexture>;
  39162. /**
  39163. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  39164. * or used a shadow, depth texture...
  39165. * @param name The friendly name of the texture
  39166. * @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)
  39167. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  39168. * @param generateMipMaps True if mip maps need to be generated after render.
  39169. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  39170. * @param type The type of the buffer in the RTT (int, half float, float...)
  39171. * @param isCube True if a cube texture needs to be created
  39172. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  39173. * @param generateDepthBuffer True to generate a depth buffer
  39174. * @param generateStencilBuffer True to generate a stencil buffer
  39175. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  39176. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  39177. * @param delayAllocation if the texture allocation should be delayed (default: false)
  39178. */
  39179. constructor(name: string, size: number | {
  39180. width: number;
  39181. height: number;
  39182. layers?: number;
  39183. } | {
  39184. ratio: number;
  39185. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  39186. /**
  39187. * Creates a depth stencil texture.
  39188. * This is only available in WebGL 2 or with the depth texture extension available.
  39189. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  39190. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  39191. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  39192. */
  39193. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  39194. private _processSizeParameter;
  39195. /**
  39196. * Define the number of samples to use in case of MSAA.
  39197. * It defaults to one meaning no MSAA has been enabled.
  39198. */
  39199. get samples(): number;
  39200. set samples(value: number);
  39201. /**
  39202. * Resets the refresh counter of the texture and start bak from scratch.
  39203. * Could be useful to regenerate the texture if it is setup to render only once.
  39204. */
  39205. resetRefreshCounter(): void;
  39206. /**
  39207. * Define the refresh rate of the texture or the rendering frequency.
  39208. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  39209. */
  39210. get refreshRate(): number;
  39211. set refreshRate(value: number);
  39212. /**
  39213. * Adds a post process to the render target rendering passes.
  39214. * @param postProcess define the post process to add
  39215. */
  39216. addPostProcess(postProcess: PostProcess): void;
  39217. /**
  39218. * Clear all the post processes attached to the render target
  39219. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  39220. */
  39221. clearPostProcesses(dispose?: boolean): void;
  39222. /**
  39223. * Remove one of the post process from the list of attached post processes to the texture
  39224. * @param postProcess define the post process to remove from the list
  39225. */
  39226. removePostProcess(postProcess: PostProcess): void;
  39227. /** @hidden */
  39228. _shouldRender(): boolean;
  39229. /**
  39230. * Gets the actual render size of the texture.
  39231. * @returns the width of the render size
  39232. */
  39233. getRenderSize(): number;
  39234. /**
  39235. * Gets the actual render width of the texture.
  39236. * @returns the width of the render size
  39237. */
  39238. getRenderWidth(): number;
  39239. /**
  39240. * Gets the actual render height of the texture.
  39241. * @returns the height of the render size
  39242. */
  39243. getRenderHeight(): number;
  39244. /**
  39245. * Gets the actual number of layers of the texture.
  39246. * @returns the number of layers
  39247. */
  39248. getRenderLayers(): number;
  39249. /**
  39250. * Get if the texture can be rescaled or not.
  39251. */
  39252. get canRescale(): boolean;
  39253. /**
  39254. * Resize the texture using a ratio.
  39255. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  39256. */
  39257. scale(ratio: number): void;
  39258. /**
  39259. * Get the texture reflection matrix used to rotate/transform the reflection.
  39260. * @returns the reflection matrix
  39261. */
  39262. getReflectionTextureMatrix(): Matrix;
  39263. /**
  39264. * Resize the texture to a new desired size.
  39265. * Be carrefull as it will recreate all the data in the new texture.
  39266. * @param size Define the new size. It can be:
  39267. * - a number for squared texture,
  39268. * - an object containing { width: number, height: number }
  39269. * - or an object containing a ratio { ratio: number }
  39270. */
  39271. resize(size: number | {
  39272. width: number;
  39273. height: number;
  39274. } | {
  39275. ratio: number;
  39276. }): void;
  39277. private _defaultRenderListPrepared;
  39278. /**
  39279. * Renders all the objects from the render list into the texture.
  39280. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  39281. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  39282. */
  39283. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  39284. private _bestReflectionRenderTargetDimension;
  39285. private _prepareRenderingManager;
  39286. /**
  39287. * @hidden
  39288. * @param faceIndex face index to bind to if this is a cubetexture
  39289. * @param layer defines the index of the texture to bind in the array
  39290. */
  39291. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  39292. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  39293. private renderToTarget;
  39294. /**
  39295. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  39296. * This allowed control for front to back rendering or reversly depending of the special needs.
  39297. *
  39298. * @param renderingGroupId The rendering group id corresponding to its index
  39299. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  39300. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  39301. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  39302. */
  39303. 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;
  39304. /**
  39305. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  39306. *
  39307. * @param renderingGroupId The rendering group id corresponding to its index
  39308. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  39309. */
  39310. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  39311. /**
  39312. * Clones the texture.
  39313. * @returns the cloned texture
  39314. */
  39315. clone(): RenderTargetTexture;
  39316. /**
  39317. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  39318. * @returns The JSON representation of the texture
  39319. */
  39320. serialize(): any;
  39321. /**
  39322. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  39323. */
  39324. disposeFramebufferObjects(): void;
  39325. /**
  39326. * Dispose the texture and release its associated resources.
  39327. */
  39328. dispose(): void;
  39329. /** @hidden */
  39330. _rebuild(): void;
  39331. /**
  39332. * Clear the info related to rendering groups preventing retention point in material dispose.
  39333. */
  39334. freeRenderingGroups(): void;
  39335. /**
  39336. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  39337. * @returns the view count
  39338. */
  39339. getViewCount(): number;
  39340. }
  39341. }
  39342. declare module "babylonjs/Materials/effect" {
  39343. import { Observable } from "babylonjs/Misc/observable";
  39344. import { Nullable } from "babylonjs/types";
  39345. import { IDisposable } from "babylonjs/scene";
  39346. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  39347. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  39348. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  39349. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  39350. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  39351. import { Engine } from "babylonjs/Engines/engine";
  39352. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39353. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  39354. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39355. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39356. /**
  39357. * Options to be used when creating an effect.
  39358. */
  39359. export interface IEffectCreationOptions {
  39360. /**
  39361. * Atrributes that will be used in the shader.
  39362. */
  39363. attributes: string[];
  39364. /**
  39365. * Uniform varible names that will be set in the shader.
  39366. */
  39367. uniformsNames: string[];
  39368. /**
  39369. * Uniform buffer variable names that will be set in the shader.
  39370. */
  39371. uniformBuffersNames: string[];
  39372. /**
  39373. * Sampler texture variable names that will be set in the shader.
  39374. */
  39375. samplers: string[];
  39376. /**
  39377. * Define statements that will be set in the shader.
  39378. */
  39379. defines: any;
  39380. /**
  39381. * Possible fallbacks for this effect to improve performance when needed.
  39382. */
  39383. fallbacks: Nullable<IEffectFallbacks>;
  39384. /**
  39385. * Callback that will be called when the shader is compiled.
  39386. */
  39387. onCompiled: Nullable<(effect: Effect) => void>;
  39388. /**
  39389. * Callback that will be called if an error occurs during shader compilation.
  39390. */
  39391. onError: Nullable<(effect: Effect, errors: string) => void>;
  39392. /**
  39393. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39394. */
  39395. indexParameters?: any;
  39396. /**
  39397. * Max number of lights that can be used in the shader.
  39398. */
  39399. maxSimultaneousLights?: number;
  39400. /**
  39401. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  39402. */
  39403. transformFeedbackVaryings?: Nullable<string[]>;
  39404. /**
  39405. * 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
  39406. */
  39407. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  39408. /**
  39409. * Is this effect rendering to several color attachments ?
  39410. */
  39411. multiTarget?: boolean;
  39412. }
  39413. /**
  39414. * Effect containing vertex and fragment shader that can be executed on an object.
  39415. */
  39416. export class Effect implements IDisposable {
  39417. /**
  39418. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39419. */
  39420. static ShadersRepository: string;
  39421. /**
  39422. * Enable logging of the shader code when a compilation error occurs
  39423. */
  39424. static LogShaderCodeOnCompilationError: boolean;
  39425. /**
  39426. * Name of the effect.
  39427. */
  39428. name: any;
  39429. /**
  39430. * String container all the define statements that should be set on the shader.
  39431. */
  39432. defines: string;
  39433. /**
  39434. * Callback that will be called when the shader is compiled.
  39435. */
  39436. onCompiled: Nullable<(effect: Effect) => void>;
  39437. /**
  39438. * Callback that will be called if an error occurs during shader compilation.
  39439. */
  39440. onError: Nullable<(effect: Effect, errors: string) => void>;
  39441. /**
  39442. * Callback that will be called when effect is bound.
  39443. */
  39444. onBind: Nullable<(effect: Effect) => void>;
  39445. /**
  39446. * Unique ID of the effect.
  39447. */
  39448. uniqueId: number;
  39449. /**
  39450. * Observable that will be called when the shader is compiled.
  39451. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  39452. */
  39453. onCompileObservable: Observable<Effect>;
  39454. /**
  39455. * Observable that will be called if an error occurs during shader compilation.
  39456. */
  39457. onErrorObservable: Observable<Effect>;
  39458. /** @hidden */
  39459. _onBindObservable: Nullable<Observable<Effect>>;
  39460. /**
  39461. * @hidden
  39462. * Specifies if the effect was previously ready
  39463. */
  39464. _wasPreviouslyReady: boolean;
  39465. /**
  39466. * Observable that will be called when effect is bound.
  39467. */
  39468. get onBindObservable(): Observable<Effect>;
  39469. /** @hidden */
  39470. _bonesComputationForcedToCPU: boolean;
  39471. /** @hidden */
  39472. _multiTarget: boolean;
  39473. private static _uniqueIdSeed;
  39474. private _engine;
  39475. private _uniformBuffersNames;
  39476. private _uniformBuffersNamesList;
  39477. private _uniformsNames;
  39478. private _samplerList;
  39479. private _samplers;
  39480. private _isReady;
  39481. private _compilationError;
  39482. private _allFallbacksProcessed;
  39483. private _attributesNames;
  39484. private _attributes;
  39485. private _attributeLocationByName;
  39486. private _uniforms;
  39487. /**
  39488. * Key for the effect.
  39489. * @hidden
  39490. */
  39491. _key: string;
  39492. private _indexParameters;
  39493. private _fallbacks;
  39494. private _vertexSourceCode;
  39495. private _fragmentSourceCode;
  39496. private _vertexSourceCodeOverride;
  39497. private _fragmentSourceCodeOverride;
  39498. private _transformFeedbackVaryings;
  39499. private _rawVertexSourceCode;
  39500. private _rawFragmentSourceCode;
  39501. /**
  39502. * Compiled shader to webGL program.
  39503. * @hidden
  39504. */
  39505. _pipelineContext: Nullable<IPipelineContext>;
  39506. private _valueCache;
  39507. private static _baseCache;
  39508. /**
  39509. * Instantiates an effect.
  39510. * An effect can be used to create/manage/execute vertex and fragment shaders.
  39511. * @param baseName Name of the effect.
  39512. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  39513. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  39514. * @param samplers List of sampler variables that will be passed to the shader.
  39515. * @param engine Engine to be used to render the effect
  39516. * @param defines Define statements to be added to the shader.
  39517. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  39518. * @param onCompiled Callback that will be called when the shader is compiled.
  39519. * @param onError Callback that will be called if an error occurs during shader compilation.
  39520. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39521. */
  39522. 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);
  39523. private _useFinalCode;
  39524. /**
  39525. * Unique key for this effect
  39526. */
  39527. get key(): string;
  39528. /**
  39529. * If the effect has been compiled and prepared.
  39530. * @returns if the effect is compiled and prepared.
  39531. */
  39532. isReady(): boolean;
  39533. private _isReadyInternal;
  39534. /**
  39535. * The engine the effect was initialized with.
  39536. * @returns the engine.
  39537. */
  39538. getEngine(): Engine;
  39539. /**
  39540. * The pipeline context for this effect
  39541. * @returns the associated pipeline context
  39542. */
  39543. getPipelineContext(): Nullable<IPipelineContext>;
  39544. /**
  39545. * The set of names of attribute variables for the shader.
  39546. * @returns An array of attribute names.
  39547. */
  39548. getAttributesNames(): string[];
  39549. /**
  39550. * Returns the attribute at the given index.
  39551. * @param index The index of the attribute.
  39552. * @returns The location of the attribute.
  39553. */
  39554. getAttributeLocation(index: number): number;
  39555. /**
  39556. * Returns the attribute based on the name of the variable.
  39557. * @param name of the attribute to look up.
  39558. * @returns the attribute location.
  39559. */
  39560. getAttributeLocationByName(name: string): number;
  39561. /**
  39562. * The number of attributes.
  39563. * @returns the numnber of attributes.
  39564. */
  39565. getAttributesCount(): number;
  39566. /**
  39567. * Gets the index of a uniform variable.
  39568. * @param uniformName of the uniform to look up.
  39569. * @returns the index.
  39570. */
  39571. getUniformIndex(uniformName: string): number;
  39572. /**
  39573. * Returns the attribute based on the name of the variable.
  39574. * @param uniformName of the uniform to look up.
  39575. * @returns the location of the uniform.
  39576. */
  39577. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39578. /**
  39579. * Returns an array of sampler variable names
  39580. * @returns The array of sampler variable names.
  39581. */
  39582. getSamplers(): string[];
  39583. /**
  39584. * Returns an array of uniform variable names
  39585. * @returns The array of uniform variable names.
  39586. */
  39587. getUniformNames(): string[];
  39588. /**
  39589. * Returns an array of uniform buffer variable names
  39590. * @returns The array of uniform buffer variable names.
  39591. */
  39592. getUniformBuffersNames(): string[];
  39593. /**
  39594. * Returns the index parameters used to create the effect
  39595. * @returns The index parameters object
  39596. */
  39597. getIndexParameters(): any;
  39598. /**
  39599. * The error from the last compilation.
  39600. * @returns the error string.
  39601. */
  39602. getCompilationError(): string;
  39603. /**
  39604. * Gets a boolean indicating that all fallbacks were used during compilation
  39605. * @returns true if all fallbacks were used
  39606. */
  39607. allFallbacksProcessed(): boolean;
  39608. /**
  39609. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  39610. * @param func The callback to be used.
  39611. */
  39612. executeWhenCompiled(func: (effect: Effect) => void): void;
  39613. private _checkIsReady;
  39614. private _loadShader;
  39615. /**
  39616. * Gets the vertex shader source code of this effect
  39617. */
  39618. get vertexSourceCode(): string;
  39619. /**
  39620. * Gets the fragment shader source code of this effect
  39621. */
  39622. get fragmentSourceCode(): string;
  39623. /**
  39624. * Gets the vertex shader source code before it has been processed by the preprocessor
  39625. */
  39626. get rawVertexSourceCode(): string;
  39627. /**
  39628. * Gets the fragment shader source code before it has been processed by the preprocessor
  39629. */
  39630. get rawFragmentSourceCode(): string;
  39631. /**
  39632. * Recompiles the webGL program
  39633. * @param vertexSourceCode The source code for the vertex shader.
  39634. * @param fragmentSourceCode The source code for the fragment shader.
  39635. * @param onCompiled Callback called when completed.
  39636. * @param onError Callback called on error.
  39637. * @hidden
  39638. */
  39639. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39640. /**
  39641. * Prepares the effect
  39642. * @hidden
  39643. */
  39644. _prepareEffect(): void;
  39645. private _getShaderCodeAndErrorLine;
  39646. private _processCompilationErrors;
  39647. /**
  39648. * Checks if the effect is supported. (Must be called after compilation)
  39649. */
  39650. get isSupported(): boolean;
  39651. /**
  39652. * Binds a texture to the engine to be used as output of the shader.
  39653. * @param channel Name of the output variable.
  39654. * @param texture Texture to bind.
  39655. * @hidden
  39656. */
  39657. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39658. /**
  39659. * Sets a texture on the engine to be used in the shader.
  39660. * @param channel Name of the sampler variable.
  39661. * @param texture Texture to set.
  39662. */
  39663. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39664. /**
  39665. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39666. * @param channel Name of the sampler variable.
  39667. * @param texture Texture to set.
  39668. */
  39669. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39670. /**
  39671. * Sets an array of textures on the engine to be used in the shader.
  39672. * @param channel Name of the variable.
  39673. * @param textures Textures to set.
  39674. */
  39675. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39676. /**
  39677. * 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)
  39678. * @param channel Name of the sampler variable.
  39679. * @param postProcess Post process to get the input texture from.
  39680. */
  39681. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39682. /**
  39683. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39684. * 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)
  39685. * @param channel Name of the sampler variable.
  39686. * @param postProcess Post process to get the output texture from.
  39687. */
  39688. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39689. /** @hidden */
  39690. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  39691. /** @hidden */
  39692. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  39693. /** @hidden */
  39694. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  39695. /** @hidden */
  39696. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  39697. /**
  39698. * Binds a buffer to a uniform.
  39699. * @param buffer Buffer to bind.
  39700. * @param name Name of the uniform variable to bind to.
  39701. */
  39702. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39703. /**
  39704. * Binds block to a uniform.
  39705. * @param blockName Name of the block to bind.
  39706. * @param index Index to bind.
  39707. */
  39708. bindUniformBlock(blockName: string, index: number): void;
  39709. /**
  39710. * Sets an interger value on a uniform variable.
  39711. * @param uniformName Name of the variable.
  39712. * @param value Value to be set.
  39713. * @returns this effect.
  39714. */
  39715. setInt(uniformName: string, value: number): Effect;
  39716. /**
  39717. * Sets an int array on a uniform variable.
  39718. * @param uniformName Name of the variable.
  39719. * @param array array to be set.
  39720. * @returns this effect.
  39721. */
  39722. setIntArray(uniformName: string, array: Int32Array): Effect;
  39723. /**
  39724. * 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)
  39725. * @param uniformName Name of the variable.
  39726. * @param array array to be set.
  39727. * @returns this effect.
  39728. */
  39729. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39730. /**
  39731. * 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)
  39732. * @param uniformName Name of the variable.
  39733. * @param array array to be set.
  39734. * @returns this effect.
  39735. */
  39736. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39737. /**
  39738. * 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)
  39739. * @param uniformName Name of the variable.
  39740. * @param array array to be set.
  39741. * @returns this effect.
  39742. */
  39743. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39744. /**
  39745. * Sets an float array on a uniform variable.
  39746. * @param uniformName Name of the variable.
  39747. * @param array array to be set.
  39748. * @returns this effect.
  39749. */
  39750. setFloatArray(uniformName: string, array: Float32Array): Effect;
  39751. /**
  39752. * 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)
  39753. * @param uniformName Name of the variable.
  39754. * @param array array to be set.
  39755. * @returns this effect.
  39756. */
  39757. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  39758. /**
  39759. * 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)
  39760. * @param uniformName Name of the variable.
  39761. * @param array array to be set.
  39762. * @returns this effect.
  39763. */
  39764. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  39765. /**
  39766. * 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)
  39767. * @param uniformName Name of the variable.
  39768. * @param array array to be set.
  39769. * @returns this effect.
  39770. */
  39771. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  39772. /**
  39773. * Sets an array on a uniform variable.
  39774. * @param uniformName Name of the variable.
  39775. * @param array array to be set.
  39776. * @returns this effect.
  39777. */
  39778. setArray(uniformName: string, array: number[]): Effect;
  39779. /**
  39780. * 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)
  39781. * @param uniformName Name of the variable.
  39782. * @param array array to be set.
  39783. * @returns this effect.
  39784. */
  39785. setArray2(uniformName: string, array: number[]): Effect;
  39786. /**
  39787. * 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)
  39788. * @param uniformName Name of the variable.
  39789. * @param array array to be set.
  39790. * @returns this effect.
  39791. */
  39792. setArray3(uniformName: string, array: number[]): Effect;
  39793. /**
  39794. * 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)
  39795. * @param uniformName Name of the variable.
  39796. * @param array array to be set.
  39797. * @returns this effect.
  39798. */
  39799. setArray4(uniformName: string, array: number[]): Effect;
  39800. /**
  39801. * Sets matrices on a uniform variable.
  39802. * @param uniformName Name of the variable.
  39803. * @param matrices matrices to be set.
  39804. * @returns this effect.
  39805. */
  39806. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39807. /**
  39808. * Sets matrix on a uniform variable.
  39809. * @param uniformName Name of the variable.
  39810. * @param matrix matrix to be set.
  39811. * @returns this effect.
  39812. */
  39813. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39814. /**
  39815. * 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)
  39816. * @param uniformName Name of the variable.
  39817. * @param matrix matrix to be set.
  39818. * @returns this effect.
  39819. */
  39820. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39821. /**
  39822. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39823. * @param uniformName Name of the variable.
  39824. * @param matrix matrix to be set.
  39825. * @returns this effect.
  39826. */
  39827. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39828. /**
  39829. * Sets a float on a uniform variable.
  39830. * @param uniformName Name of the variable.
  39831. * @param value value to be set.
  39832. * @returns this effect.
  39833. */
  39834. setFloat(uniformName: string, value: number): Effect;
  39835. /**
  39836. * Sets a boolean on a uniform variable.
  39837. * @param uniformName Name of the variable.
  39838. * @param bool value to be set.
  39839. * @returns this effect.
  39840. */
  39841. setBool(uniformName: string, bool: boolean): Effect;
  39842. /**
  39843. * Sets a Vector2 on a uniform variable.
  39844. * @param uniformName Name of the variable.
  39845. * @param vector2 vector2 to be set.
  39846. * @returns this effect.
  39847. */
  39848. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39849. /**
  39850. * Sets a float2 on a uniform variable.
  39851. * @param uniformName Name of the variable.
  39852. * @param x First float in float2.
  39853. * @param y Second float in float2.
  39854. * @returns this effect.
  39855. */
  39856. setFloat2(uniformName: string, x: number, y: number): Effect;
  39857. /**
  39858. * Sets a Vector3 on a uniform variable.
  39859. * @param uniformName Name of the variable.
  39860. * @param vector3 Value to be set.
  39861. * @returns this effect.
  39862. */
  39863. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39864. /**
  39865. * Sets a float3 on a uniform variable.
  39866. * @param uniformName Name of the variable.
  39867. * @param x First float in float3.
  39868. * @param y Second float in float3.
  39869. * @param z Third float in float3.
  39870. * @returns this effect.
  39871. */
  39872. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39873. /**
  39874. * Sets a Vector4 on a uniform variable.
  39875. * @param uniformName Name of the variable.
  39876. * @param vector4 Value to be set.
  39877. * @returns this effect.
  39878. */
  39879. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39880. /**
  39881. * Sets a float4 on a uniform variable.
  39882. * @param uniformName Name of the variable.
  39883. * @param x First float in float4.
  39884. * @param y Second float in float4.
  39885. * @param z Third float in float4.
  39886. * @param w Fourth float in float4.
  39887. * @returns this effect.
  39888. */
  39889. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39890. /**
  39891. * Sets a Color3 on a uniform variable.
  39892. * @param uniformName Name of the variable.
  39893. * @param color3 Value to be set.
  39894. * @returns this effect.
  39895. */
  39896. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39897. /**
  39898. * Sets a Color4 on a uniform variable.
  39899. * @param uniformName Name of the variable.
  39900. * @param color3 Value to be set.
  39901. * @param alpha Alpha value to be set.
  39902. * @returns this effect.
  39903. */
  39904. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39905. /**
  39906. * Sets a Color4 on a uniform variable
  39907. * @param uniformName defines the name of the variable
  39908. * @param color4 defines the value to be set
  39909. * @returns this effect.
  39910. */
  39911. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39912. /** Release all associated resources */
  39913. dispose(): void;
  39914. /**
  39915. * This function will add a new shader to the shader store
  39916. * @param name the name of the shader
  39917. * @param pixelShader optional pixel shader content
  39918. * @param vertexShader optional vertex shader content
  39919. */
  39920. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39921. /**
  39922. * Store of each shader (The can be looked up using effect.key)
  39923. */
  39924. static ShadersStore: {
  39925. [key: string]: string;
  39926. };
  39927. /**
  39928. * Store of each included file for a shader (The can be looked up using effect.key)
  39929. */
  39930. static IncludesShadersStore: {
  39931. [key: string]: string;
  39932. };
  39933. /**
  39934. * Resets the cache of effects.
  39935. */
  39936. static ResetCache(): void;
  39937. }
  39938. }
  39939. declare module "babylonjs/Engines/engineCapabilities" {
  39940. /**
  39941. * Interface used to describe the capabilities of the engine relatively to the current browser
  39942. */
  39943. export interface EngineCapabilities {
  39944. /** Maximum textures units per fragment shader */
  39945. maxTexturesImageUnits: number;
  39946. /** Maximum texture units per vertex shader */
  39947. maxVertexTextureImageUnits: number;
  39948. /** Maximum textures units in the entire pipeline */
  39949. maxCombinedTexturesImageUnits: number;
  39950. /** Maximum texture size */
  39951. maxTextureSize: number;
  39952. /** Maximum texture samples */
  39953. maxSamples?: number;
  39954. /** Maximum cube texture size */
  39955. maxCubemapTextureSize: number;
  39956. /** Maximum render texture size */
  39957. maxRenderTextureSize: number;
  39958. /** Maximum number of vertex attributes */
  39959. maxVertexAttribs: number;
  39960. /** Maximum number of varyings */
  39961. maxVaryingVectors: number;
  39962. /** Maximum number of uniforms per vertex shader */
  39963. maxVertexUniformVectors: number;
  39964. /** Maximum number of uniforms per fragment shader */
  39965. maxFragmentUniformVectors: number;
  39966. /** Defines if standard derivates (dx/dy) are supported */
  39967. standardDerivatives: boolean;
  39968. /** Defines if s3tc texture compression is supported */
  39969. s3tc?: WEBGL_compressed_texture_s3tc;
  39970. /** Defines if pvrtc texture compression is supported */
  39971. pvrtc: any;
  39972. /** Defines if etc1 texture compression is supported */
  39973. etc1: any;
  39974. /** Defines if etc2 texture compression is supported */
  39975. etc2: any;
  39976. /** Defines if astc texture compression is supported */
  39977. astc: any;
  39978. /** Defines if bptc texture compression is supported */
  39979. bptc: any;
  39980. /** Defines if float textures are supported */
  39981. textureFloat: boolean;
  39982. /** Defines if vertex array objects are supported */
  39983. vertexArrayObject: boolean;
  39984. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39985. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39986. /** Gets the maximum level of anisotropy supported */
  39987. maxAnisotropy: number;
  39988. /** Defines if instancing is supported */
  39989. instancedArrays: boolean;
  39990. /** Defines if 32 bits indices are supported */
  39991. uintIndices: boolean;
  39992. /** Defines if high precision shaders are supported */
  39993. highPrecisionShaderSupported: boolean;
  39994. /** Defines if depth reading in the fragment shader is supported */
  39995. fragmentDepthSupported: boolean;
  39996. /** Defines if float texture linear filtering is supported*/
  39997. textureFloatLinearFiltering: boolean;
  39998. /** Defines if rendering to float textures is supported */
  39999. textureFloatRender: boolean;
  40000. /** Defines if half float textures are supported*/
  40001. textureHalfFloat: boolean;
  40002. /** Defines if half float texture linear filtering is supported*/
  40003. textureHalfFloatLinearFiltering: boolean;
  40004. /** Defines if rendering to half float textures is supported */
  40005. textureHalfFloatRender: boolean;
  40006. /** Defines if textureLOD shader command is supported */
  40007. textureLOD: boolean;
  40008. /** Defines if draw buffers extension is supported */
  40009. drawBuffersExtension: boolean;
  40010. /** Defines if depth textures are supported */
  40011. depthTextureExtension: boolean;
  40012. /** Defines if float color buffer are supported */
  40013. colorBufferFloat: boolean;
  40014. /** Gets disjoint timer query extension (null if not supported) */
  40015. timerQuery?: EXT_disjoint_timer_query;
  40016. /** Defines if timestamp can be used with timer query */
  40017. canUseTimestampForTimerQuery: boolean;
  40018. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  40019. multiview?: any;
  40020. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  40021. oculusMultiview?: any;
  40022. /** Function used to let the system compiles shaders in background */
  40023. parallelShaderCompile?: {
  40024. COMPLETION_STATUS_KHR: number;
  40025. };
  40026. /** Max number of texture samples for MSAA */
  40027. maxMSAASamples: number;
  40028. /** Defines if the blend min max extension is supported */
  40029. blendMinMax: boolean;
  40030. }
  40031. }
  40032. declare module "babylonjs/States/depthCullingState" {
  40033. import { Nullable } from "babylonjs/types";
  40034. /**
  40035. * @hidden
  40036. **/
  40037. export class DepthCullingState {
  40038. private _isDepthTestDirty;
  40039. private _isDepthMaskDirty;
  40040. private _isDepthFuncDirty;
  40041. private _isCullFaceDirty;
  40042. private _isCullDirty;
  40043. private _isZOffsetDirty;
  40044. private _isFrontFaceDirty;
  40045. private _depthTest;
  40046. private _depthMask;
  40047. private _depthFunc;
  40048. private _cull;
  40049. private _cullFace;
  40050. private _zOffset;
  40051. private _frontFace;
  40052. /**
  40053. * Initializes the state.
  40054. */
  40055. constructor();
  40056. get isDirty(): boolean;
  40057. get zOffset(): number;
  40058. set zOffset(value: number);
  40059. get cullFace(): Nullable<number>;
  40060. set cullFace(value: Nullable<number>);
  40061. get cull(): Nullable<boolean>;
  40062. set cull(value: Nullable<boolean>);
  40063. get depthFunc(): Nullable<number>;
  40064. set depthFunc(value: Nullable<number>);
  40065. get depthMask(): boolean;
  40066. set depthMask(value: boolean);
  40067. get depthTest(): boolean;
  40068. set depthTest(value: boolean);
  40069. get frontFace(): Nullable<number>;
  40070. set frontFace(value: Nullable<number>);
  40071. reset(): void;
  40072. apply(gl: WebGLRenderingContext): void;
  40073. }
  40074. }
  40075. declare module "babylonjs/States/stencilState" {
  40076. /**
  40077. * @hidden
  40078. **/
  40079. export class StencilState {
  40080. /** 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 */
  40081. static readonly ALWAYS: number;
  40082. /** Passed to stencilOperation to specify that stencil value must be kept */
  40083. static readonly KEEP: number;
  40084. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40085. static readonly REPLACE: number;
  40086. private _isStencilTestDirty;
  40087. private _isStencilMaskDirty;
  40088. private _isStencilFuncDirty;
  40089. private _isStencilOpDirty;
  40090. private _stencilTest;
  40091. private _stencilMask;
  40092. private _stencilFunc;
  40093. private _stencilFuncRef;
  40094. private _stencilFuncMask;
  40095. private _stencilOpStencilFail;
  40096. private _stencilOpDepthFail;
  40097. private _stencilOpStencilDepthPass;
  40098. get isDirty(): boolean;
  40099. get stencilFunc(): number;
  40100. set stencilFunc(value: number);
  40101. get stencilFuncRef(): number;
  40102. set stencilFuncRef(value: number);
  40103. get stencilFuncMask(): number;
  40104. set stencilFuncMask(value: number);
  40105. get stencilOpStencilFail(): number;
  40106. set stencilOpStencilFail(value: number);
  40107. get stencilOpDepthFail(): number;
  40108. set stencilOpDepthFail(value: number);
  40109. get stencilOpStencilDepthPass(): number;
  40110. set stencilOpStencilDepthPass(value: number);
  40111. get stencilMask(): number;
  40112. set stencilMask(value: number);
  40113. get stencilTest(): boolean;
  40114. set stencilTest(value: boolean);
  40115. constructor();
  40116. reset(): void;
  40117. apply(gl: WebGLRenderingContext): void;
  40118. }
  40119. }
  40120. declare module "babylonjs/States/alphaCullingState" {
  40121. /**
  40122. * @hidden
  40123. **/
  40124. export class AlphaState {
  40125. private _isAlphaBlendDirty;
  40126. private _isBlendFunctionParametersDirty;
  40127. private _isBlendEquationParametersDirty;
  40128. private _isBlendConstantsDirty;
  40129. private _alphaBlend;
  40130. private _blendFunctionParameters;
  40131. private _blendEquationParameters;
  40132. private _blendConstants;
  40133. /**
  40134. * Initializes the state.
  40135. */
  40136. constructor();
  40137. get isDirty(): boolean;
  40138. get alphaBlend(): boolean;
  40139. set alphaBlend(value: boolean);
  40140. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  40141. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  40142. setAlphaEquationParameters(rgb: number, alpha: number): void;
  40143. reset(): void;
  40144. apply(gl: WebGLRenderingContext): void;
  40145. }
  40146. }
  40147. declare module "babylonjs/Engines/WebGL/webGLShaderProcessors" {
  40148. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  40149. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  40150. /** @hidden */
  40151. export class WebGLShaderProcessor implements IShaderProcessor {
  40152. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  40153. }
  40154. }
  40155. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  40156. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  40157. /** @hidden */
  40158. export class WebGL2ShaderProcessor implements IShaderProcessor {
  40159. attributeProcessor(attribute: string): string;
  40160. varyingProcessor(varying: string, isFragment: boolean): string;
  40161. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  40162. }
  40163. }
  40164. declare module "babylonjs/Engines/instancingAttributeInfo" {
  40165. /**
  40166. * Interface for attribute information associated with buffer instanciation
  40167. */
  40168. export interface InstancingAttributeInfo {
  40169. /**
  40170. * Name of the GLSL attribute
  40171. * if attribute index is not specified, this is used to retrieve the index from the effect
  40172. */
  40173. attributeName: string;
  40174. /**
  40175. * Index/offset of the attribute in the vertex shader
  40176. * if not specified, this will be computes from the name.
  40177. */
  40178. index?: number;
  40179. /**
  40180. * size of the attribute, 1, 2, 3 or 4
  40181. */
  40182. attributeSize: number;
  40183. /**
  40184. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  40185. */
  40186. offset: number;
  40187. /**
  40188. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  40189. * default to 1
  40190. */
  40191. divisor?: number;
  40192. /**
  40193. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  40194. * default is FLOAT
  40195. */
  40196. attributeType?: number;
  40197. /**
  40198. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  40199. */
  40200. normalized?: boolean;
  40201. }
  40202. }
  40203. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  40204. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40205. import { Nullable } from "babylonjs/types";
  40206. module "babylonjs/Engines/thinEngine" {
  40207. interface ThinEngine {
  40208. /**
  40209. * Update a video texture
  40210. * @param texture defines the texture to update
  40211. * @param video defines the video element to use
  40212. * @param invertY defines if data must be stored with Y axis inverted
  40213. */
  40214. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  40215. }
  40216. }
  40217. }
  40218. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  40219. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40220. import { Nullable } from "babylonjs/types";
  40221. module "babylonjs/Engines/thinEngine" {
  40222. interface ThinEngine {
  40223. /**
  40224. * Creates a dynamic texture
  40225. * @param width defines the width of the texture
  40226. * @param height defines the height of the texture
  40227. * @param generateMipMaps defines if the engine should generate the mip levels
  40228. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  40229. * @returns the dynamic texture inside an InternalTexture
  40230. */
  40231. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  40232. /**
  40233. * Update the content of a dynamic texture
  40234. * @param texture defines the texture to update
  40235. * @param source defines the source containing the data
  40236. * @param invertY defines if data must be stored with Y axis inverted
  40237. * @param premulAlpha defines if alpha is stored as premultiplied
  40238. * @param format defines the format of the data
  40239. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  40240. */
  40241. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  40242. }
  40243. }
  40244. }
  40245. declare module "babylonjs/Materials/Textures/videoTexture" {
  40246. import { Observable } from "babylonjs/Misc/observable";
  40247. import { Nullable } from "babylonjs/types";
  40248. import { Scene } from "babylonjs/scene";
  40249. import { Texture } from "babylonjs/Materials/Textures/texture";
  40250. import "babylonjs/Engines/Extensions/engine.videoTexture";
  40251. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  40252. /**
  40253. * Settings for finer control over video usage
  40254. */
  40255. export interface VideoTextureSettings {
  40256. /**
  40257. * Applies `autoplay` to video, if specified
  40258. */
  40259. autoPlay?: boolean;
  40260. /**
  40261. * Applies `muted` to video, if specified
  40262. */
  40263. muted?: boolean;
  40264. /**
  40265. * Applies `loop` to video, if specified
  40266. */
  40267. loop?: boolean;
  40268. /**
  40269. * Automatically updates internal texture from video at every frame in the render loop
  40270. */
  40271. autoUpdateTexture: boolean;
  40272. /**
  40273. * Image src displayed during the video loading or until the user interacts with the video.
  40274. */
  40275. poster?: string;
  40276. }
  40277. /**
  40278. * If you want to display a video in your scene, this is the special texture for that.
  40279. * This special texture works similar to other textures, with the exception of a few parameters.
  40280. * @see https://doc.babylonjs.com/how_to/video_texture
  40281. */
  40282. export class VideoTexture extends Texture {
  40283. /**
  40284. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  40285. */
  40286. readonly autoUpdateTexture: boolean;
  40287. /**
  40288. * The video instance used by the texture internally
  40289. */
  40290. readonly video: HTMLVideoElement;
  40291. private _onUserActionRequestedObservable;
  40292. /**
  40293. * Event triggerd when a dom action is required by the user to play the video.
  40294. * This happens due to recent changes in browser policies preventing video to auto start.
  40295. */
  40296. get onUserActionRequestedObservable(): Observable<Texture>;
  40297. private _generateMipMaps;
  40298. private _stillImageCaptured;
  40299. private _displayingPosterTexture;
  40300. private _settings;
  40301. private _createInternalTextureOnEvent;
  40302. private _frameId;
  40303. private _currentSrc;
  40304. /**
  40305. * Creates a video texture.
  40306. * If you want to display a video in your scene, this is the special texture for that.
  40307. * This special texture works similar to other textures, with the exception of a few parameters.
  40308. * @see https://doc.babylonjs.com/how_to/video_texture
  40309. * @param name optional name, will detect from video source, if not defined
  40310. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  40311. * @param scene is obviously the current scene.
  40312. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  40313. * @param invertY is false by default but can be used to invert video on Y axis
  40314. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  40315. * @param settings allows finer control over video usage
  40316. */
  40317. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  40318. private _getName;
  40319. private _getVideo;
  40320. private _createInternalTexture;
  40321. private reset;
  40322. /**
  40323. * @hidden Internal method to initiate `update`.
  40324. */
  40325. _rebuild(): void;
  40326. /**
  40327. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  40328. */
  40329. update(): void;
  40330. /**
  40331. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  40332. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  40333. */
  40334. updateTexture(isVisible: boolean): void;
  40335. protected _updateInternalTexture: () => void;
  40336. /**
  40337. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  40338. * @param url New url.
  40339. */
  40340. updateURL(url: string): void;
  40341. /**
  40342. * Clones the texture.
  40343. * @returns the cloned texture
  40344. */
  40345. clone(): VideoTexture;
  40346. /**
  40347. * Dispose the texture and release its associated resources.
  40348. */
  40349. dispose(): void;
  40350. /**
  40351. * Creates a video texture straight from a stream.
  40352. * @param scene Define the scene the texture should be created in
  40353. * @param stream Define the stream the texture should be created from
  40354. * @returns The created video texture as a promise
  40355. */
  40356. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  40357. /**
  40358. * Creates a video texture straight from your WebCam video feed.
  40359. * @param scene Define the scene the texture should be created in
  40360. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40361. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40362. * @returns The created video texture as a promise
  40363. */
  40364. static CreateFromWebCamAsync(scene: Scene, constraints: {
  40365. minWidth: number;
  40366. maxWidth: number;
  40367. minHeight: number;
  40368. maxHeight: number;
  40369. deviceId: string;
  40370. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  40371. /**
  40372. * Creates a video texture straight from your WebCam video feed.
  40373. * @param scene Define the scene the texture should be created in
  40374. * @param onReady Define a callback to triggered once the texture will be ready
  40375. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40376. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40377. */
  40378. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  40379. minWidth: number;
  40380. maxWidth: number;
  40381. minHeight: number;
  40382. maxHeight: number;
  40383. deviceId: string;
  40384. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  40385. }
  40386. }
  40387. declare module "babylonjs/Engines/thinEngine" {
  40388. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  40389. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  40390. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  40391. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40392. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  40393. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  40394. import { Observable } from "babylonjs/Misc/observable";
  40395. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  40396. import { StencilState } from "babylonjs/States/stencilState";
  40397. import { AlphaState } from "babylonjs/States/alphaCullingState";
  40398. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40399. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  40400. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  40401. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40402. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  40403. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  40404. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  40405. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  40406. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  40407. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40408. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  40409. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  40410. import { WebRequest } from "babylonjs/Misc/webRequest";
  40411. import { LoadFileError } from "babylonjs/Misc/fileTools";
  40412. /**
  40413. * Defines the interface used by objects working like Scene
  40414. * @hidden
  40415. */
  40416. export interface ISceneLike {
  40417. _addPendingData(data: any): void;
  40418. _removePendingData(data: any): void;
  40419. offlineProvider: IOfflineProvider;
  40420. }
  40421. /**
  40422. * Information about the current host
  40423. */
  40424. export interface HostInformation {
  40425. /**
  40426. * Defines if the current host is a mobile
  40427. */
  40428. isMobile: boolean;
  40429. }
  40430. /** Interface defining initialization parameters for Engine class */
  40431. export interface EngineOptions extends WebGLContextAttributes {
  40432. /**
  40433. * Defines if the engine should no exceed a specified device ratio
  40434. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  40435. */
  40436. limitDeviceRatio?: number;
  40437. /**
  40438. * Defines if webvr should be enabled automatically
  40439. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40440. */
  40441. autoEnableWebVR?: boolean;
  40442. /**
  40443. * Defines if webgl2 should be turned off even if supported
  40444. * @see https://doc.babylonjs.com/features/webgl2
  40445. */
  40446. disableWebGL2Support?: boolean;
  40447. /**
  40448. * Defines if webaudio should be initialized as well
  40449. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40450. */
  40451. audioEngine?: boolean;
  40452. /**
  40453. * Defines if animations should run using a deterministic lock step
  40454. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40455. */
  40456. deterministicLockstep?: boolean;
  40457. /** Defines the maximum steps to use with deterministic lock step mode */
  40458. lockstepMaxSteps?: number;
  40459. /** Defines the seconds between each deterministic lock step */
  40460. timeStep?: number;
  40461. /**
  40462. * Defines that engine should ignore context lost events
  40463. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  40464. */
  40465. doNotHandleContextLost?: boolean;
  40466. /**
  40467. * Defines that engine should ignore modifying touch action attribute and style
  40468. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  40469. */
  40470. doNotHandleTouchAction?: boolean;
  40471. /**
  40472. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  40473. */
  40474. useHighPrecisionFloats?: boolean;
  40475. /**
  40476. * Make the canvas XR Compatible for XR sessions
  40477. */
  40478. xrCompatible?: boolean;
  40479. /**
  40480. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  40481. */
  40482. useHighPrecisionMatrix?: boolean;
  40483. /**
  40484. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  40485. */
  40486. failIfMajorPerformanceCaveat?: boolean;
  40487. }
  40488. /**
  40489. * The base engine class (root of all engines)
  40490. */
  40491. export class ThinEngine {
  40492. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  40493. static ExceptionList: ({
  40494. key: string;
  40495. capture: string;
  40496. captureConstraint: number;
  40497. targets: string[];
  40498. } | {
  40499. key: string;
  40500. capture: null;
  40501. captureConstraint: null;
  40502. targets: string[];
  40503. })[];
  40504. /** @hidden */
  40505. static _TextureLoaders: IInternalTextureLoader[];
  40506. /**
  40507. * Returns the current npm package of the sdk
  40508. */
  40509. static get NpmPackage(): string;
  40510. /**
  40511. * Returns the current version of the framework
  40512. */
  40513. static get Version(): string;
  40514. /**
  40515. * Returns a string describing the current engine
  40516. */
  40517. get description(): string;
  40518. /**
  40519. * Gets or sets the epsilon value used by collision engine
  40520. */
  40521. static CollisionsEpsilon: number;
  40522. /**
  40523. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40524. */
  40525. static get ShadersRepository(): string;
  40526. static set ShadersRepository(value: string);
  40527. /** @hidden */
  40528. _shaderProcessor: IShaderProcessor;
  40529. /**
  40530. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  40531. */
  40532. forcePOTTextures: boolean;
  40533. /**
  40534. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  40535. */
  40536. isFullscreen: boolean;
  40537. /**
  40538. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  40539. */
  40540. cullBackFaces: boolean;
  40541. /**
  40542. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  40543. */
  40544. renderEvenInBackground: boolean;
  40545. /**
  40546. * Gets or sets a boolean indicating that cache can be kept between frames
  40547. */
  40548. preventCacheWipeBetweenFrames: boolean;
  40549. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  40550. validateShaderPrograms: boolean;
  40551. /**
  40552. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40553. * This can provide greater z depth for distant objects.
  40554. */
  40555. useReverseDepthBuffer: boolean;
  40556. /**
  40557. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40558. */
  40559. disableUniformBuffers: boolean;
  40560. /** @hidden */
  40561. _uniformBuffers: UniformBuffer[];
  40562. /**
  40563. * Gets a boolean indicating that the engine supports uniform buffers
  40564. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40565. */
  40566. get supportsUniformBuffers(): boolean;
  40567. /** @hidden */
  40568. _gl: WebGLRenderingContext;
  40569. /** @hidden */
  40570. _webGLVersion: number;
  40571. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40572. protected _windowIsBackground: boolean;
  40573. protected _creationOptions: EngineOptions;
  40574. protected _highPrecisionShadersAllowed: boolean;
  40575. /** @hidden */
  40576. get _shouldUseHighPrecisionShader(): boolean;
  40577. /**
  40578. * Gets a boolean indicating that only power of 2 textures are supported
  40579. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40580. */
  40581. get needPOTTextures(): boolean;
  40582. /** @hidden */
  40583. _badOS: boolean;
  40584. /** @hidden */
  40585. _badDesktopOS: boolean;
  40586. private _hardwareScalingLevel;
  40587. /** @hidden */
  40588. _caps: EngineCapabilities;
  40589. private _isStencilEnable;
  40590. private _glVersion;
  40591. private _glRenderer;
  40592. private _glVendor;
  40593. /** @hidden */
  40594. _videoTextureSupported: boolean;
  40595. protected _renderingQueueLaunched: boolean;
  40596. protected _activeRenderLoops: (() => void)[];
  40597. /**
  40598. * Observable signaled when a context lost event is raised
  40599. */
  40600. onContextLostObservable: Observable<ThinEngine>;
  40601. /**
  40602. * Observable signaled when a context restored event is raised
  40603. */
  40604. onContextRestoredObservable: Observable<ThinEngine>;
  40605. private _onContextLost;
  40606. private _onContextRestored;
  40607. protected _contextWasLost: boolean;
  40608. /** @hidden */
  40609. _doNotHandleContextLost: boolean;
  40610. /**
  40611. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40612. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40613. */
  40614. get doNotHandleContextLost(): boolean;
  40615. set doNotHandleContextLost(value: boolean);
  40616. /**
  40617. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40618. */
  40619. disableVertexArrayObjects: boolean;
  40620. /** @hidden */
  40621. protected _colorWrite: boolean;
  40622. /** @hidden */
  40623. protected _colorWriteChanged: boolean;
  40624. /** @hidden */
  40625. protected _depthCullingState: DepthCullingState;
  40626. /** @hidden */
  40627. protected _stencilState: StencilState;
  40628. /** @hidden */
  40629. _alphaState: AlphaState;
  40630. /** @hidden */
  40631. _alphaMode: number;
  40632. /** @hidden */
  40633. _alphaEquation: number;
  40634. /** @hidden */
  40635. _internalTexturesCache: InternalTexture[];
  40636. /** @hidden */
  40637. protected _activeChannel: number;
  40638. private _currentTextureChannel;
  40639. /** @hidden */
  40640. protected _boundTexturesCache: {
  40641. [key: string]: Nullable<InternalTexture>;
  40642. };
  40643. /** @hidden */
  40644. protected _currentEffect: Nullable<Effect>;
  40645. /** @hidden */
  40646. protected _currentProgram: Nullable<WebGLProgram>;
  40647. private _compiledEffects;
  40648. private _vertexAttribArraysEnabled;
  40649. /** @hidden */
  40650. protected _cachedViewport: Nullable<IViewportLike>;
  40651. private _cachedVertexArrayObject;
  40652. /** @hidden */
  40653. protected _cachedVertexBuffers: any;
  40654. /** @hidden */
  40655. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40656. /** @hidden */
  40657. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40658. /** @hidden */
  40659. _currentRenderTarget: Nullable<InternalTexture>;
  40660. private _uintIndicesCurrentlySet;
  40661. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40662. /** @hidden */
  40663. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40664. /** @hidden */
  40665. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40666. private _currentBufferPointers;
  40667. private _currentInstanceLocations;
  40668. private _currentInstanceBuffers;
  40669. private _textureUnits;
  40670. /** @hidden */
  40671. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40672. /** @hidden */
  40673. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40674. /** @hidden */
  40675. _boundRenderFunction: any;
  40676. private _vaoRecordInProgress;
  40677. private _mustWipeVertexAttributes;
  40678. private _emptyTexture;
  40679. private _emptyCubeTexture;
  40680. private _emptyTexture3D;
  40681. private _emptyTexture2DArray;
  40682. /** @hidden */
  40683. _frameHandler: number;
  40684. private _nextFreeTextureSlots;
  40685. private _maxSimultaneousTextures;
  40686. private _activeRequests;
  40687. /** @hidden */
  40688. _transformTextureUrl: Nullable<(url: string) => string>;
  40689. /**
  40690. * Gets information about the current host
  40691. */
  40692. hostInformation: HostInformation;
  40693. protected get _supportsHardwareTextureRescaling(): boolean;
  40694. private _framebufferDimensionsObject;
  40695. /**
  40696. * sets the object from which width and height will be taken from when getting render width and height
  40697. * Will fallback to the gl object
  40698. * @param dimensions the framebuffer width and height that will be used.
  40699. */
  40700. set framebufferDimensionsObject(dimensions: Nullable<{
  40701. framebufferWidth: number;
  40702. framebufferHeight: number;
  40703. }>);
  40704. /**
  40705. * Gets the current viewport
  40706. */
  40707. get currentViewport(): Nullable<IViewportLike>;
  40708. /**
  40709. * Gets the default empty texture
  40710. */
  40711. get emptyTexture(): InternalTexture;
  40712. /**
  40713. * Gets the default empty 3D texture
  40714. */
  40715. get emptyTexture3D(): InternalTexture;
  40716. /**
  40717. * Gets the default empty 2D array texture
  40718. */
  40719. get emptyTexture2DArray(): InternalTexture;
  40720. /**
  40721. * Gets the default empty cube texture
  40722. */
  40723. get emptyCubeTexture(): InternalTexture;
  40724. /**
  40725. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40726. */
  40727. readonly premultipliedAlpha: boolean;
  40728. /**
  40729. * Observable event triggered before each texture is initialized
  40730. */
  40731. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  40732. /**
  40733. * Creates a new engine
  40734. * @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
  40735. * @param antialias defines enable antialiasing (default: false)
  40736. * @param options defines further options to be sent to the getContext() function
  40737. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40738. */
  40739. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40740. private _rebuildInternalTextures;
  40741. private _rebuildEffects;
  40742. /**
  40743. * Gets a boolean indicating if all created effects are ready
  40744. * @returns true if all effects are ready
  40745. */
  40746. areAllEffectsReady(): boolean;
  40747. protected _rebuildBuffers(): void;
  40748. protected _initGLContext(): void;
  40749. /**
  40750. * Gets version of the current webGL context
  40751. */
  40752. get webGLVersion(): number;
  40753. /**
  40754. * Gets a string identifying the name of the class
  40755. * @returns "Engine" string
  40756. */
  40757. getClassName(): string;
  40758. /**
  40759. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40760. */
  40761. get isStencilEnable(): boolean;
  40762. /** @hidden */
  40763. _prepareWorkingCanvas(): void;
  40764. /**
  40765. * Reset the texture cache to empty state
  40766. */
  40767. resetTextureCache(): void;
  40768. /**
  40769. * Gets an object containing information about the current webGL context
  40770. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40771. */
  40772. getGlInfo(): {
  40773. vendor: string;
  40774. renderer: string;
  40775. version: string;
  40776. };
  40777. /**
  40778. * Defines the hardware scaling level.
  40779. * By default the hardware scaling level is computed from the window device ratio.
  40780. * 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.
  40781. * @param level defines the level to use
  40782. */
  40783. setHardwareScalingLevel(level: number): void;
  40784. /**
  40785. * Gets the current hardware scaling level.
  40786. * By default the hardware scaling level is computed from the window device ratio.
  40787. * 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.
  40788. * @returns a number indicating the current hardware scaling level
  40789. */
  40790. getHardwareScalingLevel(): number;
  40791. /**
  40792. * Gets the list of loaded textures
  40793. * @returns an array containing all loaded textures
  40794. */
  40795. getLoadedTexturesCache(): InternalTexture[];
  40796. /**
  40797. * Gets the object containing all engine capabilities
  40798. * @returns the EngineCapabilities object
  40799. */
  40800. getCaps(): EngineCapabilities;
  40801. /**
  40802. * stop executing a render loop function and remove it from the execution array
  40803. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40804. */
  40805. stopRenderLoop(renderFunction?: () => void): void;
  40806. /** @hidden */
  40807. _renderLoop(): void;
  40808. /**
  40809. * Gets the HTML canvas attached with the current webGL context
  40810. * @returns a HTML canvas
  40811. */
  40812. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40813. /**
  40814. * Gets host window
  40815. * @returns the host window object
  40816. */
  40817. getHostWindow(): Nullable<Window>;
  40818. /**
  40819. * Gets the current render width
  40820. * @param useScreen defines if screen size must be used (or the current render target if any)
  40821. * @returns a number defining the current render width
  40822. */
  40823. getRenderWidth(useScreen?: boolean): number;
  40824. /**
  40825. * Gets the current render height
  40826. * @param useScreen defines if screen size must be used (or the current render target if any)
  40827. * @returns a number defining the current render height
  40828. */
  40829. getRenderHeight(useScreen?: boolean): number;
  40830. /**
  40831. * Can be used to override the current requestAnimationFrame requester.
  40832. * @hidden
  40833. */
  40834. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40835. /**
  40836. * Register and execute a render loop. The engine can have more than one render function
  40837. * @param renderFunction defines the function to continuously execute
  40838. */
  40839. runRenderLoop(renderFunction: () => void): void;
  40840. /**
  40841. * Clear the current render buffer or the current render target (if any is set up)
  40842. * @param color defines the color to use
  40843. * @param backBuffer defines if the back buffer must be cleared
  40844. * @param depth defines if the depth buffer must be cleared
  40845. * @param stencil defines if the stencil buffer must be cleared
  40846. */
  40847. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40848. private _viewportCached;
  40849. /** @hidden */
  40850. _viewport(x: number, y: number, width: number, height: number): void;
  40851. /**
  40852. * Set the WebGL's viewport
  40853. * @param viewport defines the viewport element to be used
  40854. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40855. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40856. */
  40857. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40858. /**
  40859. * Begin a new frame
  40860. */
  40861. beginFrame(): void;
  40862. /**
  40863. * Enf the current frame
  40864. */
  40865. endFrame(): void;
  40866. /**
  40867. * Resize the view according to the canvas' size
  40868. */
  40869. resize(): void;
  40870. /**
  40871. * Force a specific size of the canvas
  40872. * @param width defines the new canvas' width
  40873. * @param height defines the new canvas' height
  40874. * @returns true if the size was changed
  40875. */
  40876. setSize(width: number, height: number): boolean;
  40877. /**
  40878. * Binds the frame buffer to the specified texture.
  40879. * @param texture The texture to render to or null for the default canvas
  40880. * @param faceIndex The face of the texture to render to in case of cube texture
  40881. * @param requiredWidth The width of the target to render to
  40882. * @param requiredHeight The height of the target to render to
  40883. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40884. * @param lodLevel defines the lod level to bind to the frame buffer
  40885. * @param layer defines the 2d array index to bind to frame buffer to
  40886. */
  40887. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40888. /** @hidden */
  40889. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40890. /**
  40891. * Unbind the current render target texture from the webGL context
  40892. * @param texture defines the render target texture to unbind
  40893. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40894. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40895. */
  40896. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40897. /**
  40898. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40899. */
  40900. flushFramebuffer(): void;
  40901. /**
  40902. * Unbind the current render target and bind the default framebuffer
  40903. */
  40904. restoreDefaultFramebuffer(): void;
  40905. /** @hidden */
  40906. protected _resetVertexBufferBinding(): void;
  40907. /**
  40908. * Creates a vertex buffer
  40909. * @param data the data for the vertex buffer
  40910. * @returns the new WebGL static buffer
  40911. */
  40912. createVertexBuffer(data: DataArray): DataBuffer;
  40913. private _createVertexBuffer;
  40914. /**
  40915. * Creates a dynamic vertex buffer
  40916. * @param data the data for the dynamic vertex buffer
  40917. * @returns the new WebGL dynamic buffer
  40918. */
  40919. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40920. protected _resetIndexBufferBinding(): void;
  40921. /**
  40922. * Creates a new index buffer
  40923. * @param indices defines the content of the index buffer
  40924. * @param updatable defines if the index buffer must be updatable
  40925. * @returns a new webGL buffer
  40926. */
  40927. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40928. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40929. /**
  40930. * Bind a webGL buffer to the webGL context
  40931. * @param buffer defines the buffer to bind
  40932. */
  40933. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40934. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40935. private bindBuffer;
  40936. /**
  40937. * update the bound buffer with the given data
  40938. * @param data defines the data to update
  40939. */
  40940. updateArrayBuffer(data: Float32Array): void;
  40941. private _vertexAttribPointer;
  40942. /** @hidden */
  40943. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40944. private _bindVertexBuffersAttributes;
  40945. /**
  40946. * Records a vertex array object
  40947. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40948. * @param vertexBuffers defines the list of vertex buffers to store
  40949. * @param indexBuffer defines the index buffer to store
  40950. * @param effect defines the effect to store
  40951. * @returns the new vertex array object
  40952. */
  40953. recordVertexArrayObject(vertexBuffers: {
  40954. [key: string]: VertexBuffer;
  40955. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  40956. /**
  40957. * Bind a specific vertex array object
  40958. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40959. * @param vertexArrayObject defines the vertex array object to bind
  40960. * @param indexBuffer defines the index buffer to bind
  40961. */
  40962. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40963. /**
  40964. * Bind webGl buffers directly to the webGL context
  40965. * @param vertexBuffer defines the vertex buffer to bind
  40966. * @param indexBuffer defines the index buffer to bind
  40967. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40968. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40969. * @param effect defines the effect associated with the vertex buffer
  40970. */
  40971. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40972. private _unbindVertexArrayObject;
  40973. /**
  40974. * Bind a list of vertex buffers to the webGL context
  40975. * @param vertexBuffers defines the list of vertex buffers to bind
  40976. * @param indexBuffer defines the index buffer to bind
  40977. * @param effect defines the effect associated with the vertex buffers
  40978. */
  40979. bindBuffers(vertexBuffers: {
  40980. [key: string]: Nullable<VertexBuffer>;
  40981. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  40982. /**
  40983. * Unbind all instance attributes
  40984. */
  40985. unbindInstanceAttributes(): void;
  40986. /**
  40987. * Release and free the memory of a vertex array object
  40988. * @param vao defines the vertex array object to delete
  40989. */
  40990. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40991. /** @hidden */
  40992. _releaseBuffer(buffer: DataBuffer): boolean;
  40993. protected _deleteBuffer(buffer: DataBuffer): void;
  40994. /**
  40995. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40996. * @param instancesBuffer defines the webGL buffer to update and bind
  40997. * @param data defines the data to store in the buffer
  40998. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40999. */
  41000. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  41001. /**
  41002. * Bind the content of a webGL buffer used with instantiation
  41003. * @param instancesBuffer defines the webGL buffer to bind
  41004. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  41005. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  41006. */
  41007. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  41008. /**
  41009. * Disable the instance attribute corresponding to the name in parameter
  41010. * @param name defines the name of the attribute to disable
  41011. */
  41012. disableInstanceAttributeByName(name: string): void;
  41013. /**
  41014. * Disable the instance attribute corresponding to the location in parameter
  41015. * @param attributeLocation defines the attribute location of the attribute to disable
  41016. */
  41017. disableInstanceAttribute(attributeLocation: number): void;
  41018. /**
  41019. * Disable the attribute corresponding to the location in parameter
  41020. * @param attributeLocation defines the attribute location of the attribute to disable
  41021. */
  41022. disableAttributeByIndex(attributeLocation: number): void;
  41023. /**
  41024. * Send a draw order
  41025. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  41026. * @param indexStart defines the starting index
  41027. * @param indexCount defines the number of index to draw
  41028. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41029. */
  41030. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41031. /**
  41032. * Draw a list of points
  41033. * @param verticesStart defines the index of first vertex to draw
  41034. * @param verticesCount defines the count of vertices to draw
  41035. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41036. */
  41037. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41038. /**
  41039. * Draw a list of unindexed primitives
  41040. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  41041. * @param verticesStart defines the index of first vertex to draw
  41042. * @param verticesCount defines the count of vertices to draw
  41043. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41044. */
  41045. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41046. /**
  41047. * Draw a list of indexed primitives
  41048. * @param fillMode defines the primitive to use
  41049. * @param indexStart defines the starting index
  41050. * @param indexCount defines the number of index to draw
  41051. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41052. */
  41053. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41054. /**
  41055. * Draw a list of unindexed primitives
  41056. * @param fillMode defines the primitive to use
  41057. * @param verticesStart defines the index of first vertex to draw
  41058. * @param verticesCount defines the count of vertices to draw
  41059. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41060. */
  41061. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41062. private _drawMode;
  41063. /** @hidden */
  41064. protected _reportDrawCall(): void;
  41065. /** @hidden */
  41066. _releaseEffect(effect: Effect): void;
  41067. /** @hidden */
  41068. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41069. /**
  41070. * Create a new effect (used to store vertex/fragment shaders)
  41071. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  41072. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  41073. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  41074. * @param samplers defines an array of string used to represent textures
  41075. * @param defines defines the string containing the defines to use to compile the shaders
  41076. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  41077. * @param onCompiled defines a function to call when the effect creation is successful
  41078. * @param onError defines a function to call when the effect creation has failed
  41079. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  41080. * @returns the new Effect
  41081. */
  41082. 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;
  41083. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  41084. private _compileShader;
  41085. private _compileRawShader;
  41086. /** @hidden */
  41087. _getShaderSource(shader: WebGLShader): Nullable<string>;
  41088. /**
  41089. * Directly creates a webGL program
  41090. * @param pipelineContext defines the pipeline context to attach to
  41091. * @param vertexCode defines the vertex shader code to use
  41092. * @param fragmentCode defines the fragment shader code to use
  41093. * @param context defines the webGL context to use (if not set, the current one will be used)
  41094. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  41095. * @returns the new webGL program
  41096. */
  41097. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41098. /**
  41099. * Creates a webGL program
  41100. * @param pipelineContext defines the pipeline context to attach to
  41101. * @param vertexCode defines the vertex shader code to use
  41102. * @param fragmentCode defines the fragment shader code to use
  41103. * @param defines defines the string containing the defines to use to compile the shaders
  41104. * @param context defines the webGL context to use (if not set, the current one will be used)
  41105. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  41106. * @returns the new webGL program
  41107. */
  41108. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41109. /**
  41110. * Creates a new pipeline context
  41111. * @returns the new pipeline
  41112. */
  41113. createPipelineContext(): IPipelineContext;
  41114. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41115. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  41116. /** @hidden */
  41117. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  41118. /** @hidden */
  41119. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  41120. /** @hidden */
  41121. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  41122. /**
  41123. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  41124. * @param pipelineContext defines the pipeline context to use
  41125. * @param uniformsNames defines the list of uniform names
  41126. * @returns an array of webGL uniform locations
  41127. */
  41128. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41129. /**
  41130. * Gets the lsit of active attributes for a given webGL program
  41131. * @param pipelineContext defines the pipeline context to use
  41132. * @param attributesNames defines the list of attribute names to get
  41133. * @returns an array of indices indicating the offset of each attribute
  41134. */
  41135. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41136. /**
  41137. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  41138. * @param effect defines the effect to activate
  41139. */
  41140. enableEffect(effect: Nullable<Effect>): void;
  41141. /**
  41142. * Set the value of an uniform to a number (int)
  41143. * @param uniform defines the webGL uniform location where to store the value
  41144. * @param value defines the int number to store
  41145. * @returns true if the value was set
  41146. */
  41147. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41148. /**
  41149. * Set the value of an uniform to an array of int32
  41150. * @param uniform defines the webGL uniform location where to store the value
  41151. * @param array defines the array of int32 to store
  41152. * @returns true if the value was set
  41153. */
  41154. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41155. /**
  41156. * Set the value of an uniform to an array of int32 (stored as vec2)
  41157. * @param uniform defines the webGL uniform location where to store the value
  41158. * @param array defines the array of int32 to store
  41159. * @returns true if the value was set
  41160. */
  41161. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41162. /**
  41163. * Set the value of an uniform to an array of int32 (stored as vec3)
  41164. * @param uniform defines the webGL uniform location where to store the value
  41165. * @param array defines the array of int32 to store
  41166. * @returns true if the value was set
  41167. */
  41168. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41169. /**
  41170. * Set the value of an uniform to an array of int32 (stored as vec4)
  41171. * @param uniform defines the webGL uniform location where to store the value
  41172. * @param array defines the array of int32 to store
  41173. * @returns true if the value was set
  41174. */
  41175. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41176. /**
  41177. * Set the value of an uniform to an array of number
  41178. * @param uniform defines the webGL uniform location where to store the value
  41179. * @param array defines the array of number to store
  41180. * @returns true if the value was set
  41181. */
  41182. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41183. /**
  41184. * Set the value of an uniform to an array of number (stored as vec2)
  41185. * @param uniform defines the webGL uniform location where to store the value
  41186. * @param array defines the array of number to store
  41187. * @returns true if the value was set
  41188. */
  41189. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41190. /**
  41191. * Set the value of an uniform to an array of number (stored as vec3)
  41192. * @param uniform defines the webGL uniform location where to store the value
  41193. * @param array defines the array of number to store
  41194. * @returns true if the value was set
  41195. */
  41196. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41197. /**
  41198. * Set the value of an uniform to an array of number (stored as vec4)
  41199. * @param uniform defines the webGL uniform location where to store the value
  41200. * @param array defines the array of number to store
  41201. * @returns true if the value was set
  41202. */
  41203. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41204. /**
  41205. * Set the value of an uniform to an array of float32 (stored as matrices)
  41206. * @param uniform defines the webGL uniform location where to store the value
  41207. * @param matrices defines the array of float32 to store
  41208. * @returns true if the value was set
  41209. */
  41210. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  41211. /**
  41212. * Set the value of an uniform to a matrix (3x3)
  41213. * @param uniform defines the webGL uniform location where to store the value
  41214. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  41215. * @returns true if the value was set
  41216. */
  41217. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41218. /**
  41219. * Set the value of an uniform to a matrix (2x2)
  41220. * @param uniform defines the webGL uniform location where to store the value
  41221. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  41222. * @returns true if the value was set
  41223. */
  41224. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41225. /**
  41226. * Set the value of an uniform to a number (float)
  41227. * @param uniform defines the webGL uniform location where to store the value
  41228. * @param value defines the float number to store
  41229. * @returns true if the value was transfered
  41230. */
  41231. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41232. /**
  41233. * Set the value of an uniform to a vec2
  41234. * @param uniform defines the webGL uniform location where to store the value
  41235. * @param x defines the 1st component of the value
  41236. * @param y defines the 2nd component of the value
  41237. * @returns true if the value was set
  41238. */
  41239. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  41240. /**
  41241. * Set the value of an uniform to a vec3
  41242. * @param uniform defines the webGL uniform location where to store the value
  41243. * @param x defines the 1st component of the value
  41244. * @param y defines the 2nd component of the value
  41245. * @param z defines the 3rd component of the value
  41246. * @returns true if the value was set
  41247. */
  41248. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  41249. /**
  41250. * Set the value of an uniform to a vec4
  41251. * @param uniform defines the webGL uniform location where to store the value
  41252. * @param x defines the 1st component of the value
  41253. * @param y defines the 2nd component of the value
  41254. * @param z defines the 3rd component of the value
  41255. * @param w defines the 4th component of the value
  41256. * @returns true if the value was set
  41257. */
  41258. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  41259. /**
  41260. * Apply all cached states (depth, culling, stencil and alpha)
  41261. */
  41262. applyStates(): void;
  41263. /**
  41264. * Enable or disable color writing
  41265. * @param enable defines the state to set
  41266. */
  41267. setColorWrite(enable: boolean): void;
  41268. /**
  41269. * Gets a boolean indicating if color writing is enabled
  41270. * @returns the current color writing state
  41271. */
  41272. getColorWrite(): boolean;
  41273. /**
  41274. * Gets the depth culling state manager
  41275. */
  41276. get depthCullingState(): DepthCullingState;
  41277. /**
  41278. * Gets the alpha state manager
  41279. */
  41280. get alphaState(): AlphaState;
  41281. /**
  41282. * Gets the stencil state manager
  41283. */
  41284. get stencilState(): StencilState;
  41285. /**
  41286. * Clears the list of texture accessible through engine.
  41287. * This can help preventing texture load conflict due to name collision.
  41288. */
  41289. clearInternalTexturesCache(): void;
  41290. /**
  41291. * Force the entire cache to be cleared
  41292. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  41293. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  41294. */
  41295. wipeCaches(bruteForce?: boolean): void;
  41296. /** @hidden */
  41297. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  41298. min: number;
  41299. mag: number;
  41300. };
  41301. /** @hidden */
  41302. _createTexture(): WebGLTexture;
  41303. /**
  41304. * Usually called from Texture.ts.
  41305. * Passed information to create a WebGLTexture
  41306. * @param url defines a value which contains one of the following:
  41307. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  41308. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  41309. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  41310. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  41311. * @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)
  41312. * @param scene needed for loading to the correct scene
  41313. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  41314. * @param onLoad optional callback to be called upon successful completion
  41315. * @param onError optional callback to be called upon failure
  41316. * @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
  41317. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  41318. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  41319. * @param forcedExtension defines the extension to use to pick the right loader
  41320. * @param mimeType defines an optional mime type
  41321. * @param loaderOptions options to be passed to the loader
  41322. * @returns a InternalTexture for assignment back into BABYLON.Texture
  41323. */
  41324. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  41325. /**
  41326. * Loads an image as an HTMLImageElement.
  41327. * @param input url string, ArrayBuffer, or Blob to load
  41328. * @param onLoad callback called when the image successfully loads
  41329. * @param onError callback called when the image fails to load
  41330. * @param offlineProvider offline provider for caching
  41331. * @param mimeType optional mime type
  41332. * @returns the HTMLImageElement of the loaded image
  41333. * @hidden
  41334. */
  41335. 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>;
  41336. /**
  41337. * @hidden
  41338. */
  41339. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41340. private _unpackFlipYCached;
  41341. /**
  41342. * In case you are sharing the context with other applications, it might
  41343. * be interested to not cache the unpack flip y state to ensure a consistent
  41344. * value would be set.
  41345. */
  41346. enableUnpackFlipYCached: boolean;
  41347. /** @hidden */
  41348. _unpackFlipY(value: boolean): void;
  41349. /** @hidden */
  41350. _getUnpackAlignement(): number;
  41351. private _getTextureTarget;
  41352. /**
  41353. * Update the sampling mode of a given texture
  41354. * @param samplingMode defines the required sampling mode
  41355. * @param texture defines the texture to update
  41356. * @param generateMipMaps defines whether to generate mipmaps for the texture
  41357. */
  41358. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  41359. /**
  41360. * Update the sampling mode of a given texture
  41361. * @param texture defines the texture to update
  41362. * @param wrapU defines the texture wrap mode of the u coordinates
  41363. * @param wrapV defines the texture wrap mode of the v coordinates
  41364. * @param wrapR defines the texture wrap mode of the r coordinates
  41365. */
  41366. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  41367. /** @hidden */
  41368. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  41369. width: number;
  41370. height: number;
  41371. layers?: number;
  41372. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  41373. /** @hidden */
  41374. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41375. /** @hidden */
  41376. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  41377. /**
  41378. * Update a portion of an internal texture
  41379. * @param texture defines the texture to update
  41380. * @param imageData defines the data to store into the texture
  41381. * @param xOffset defines the x coordinates of the update rectangle
  41382. * @param yOffset defines the y coordinates of the update rectangle
  41383. * @param width defines the width of the update rectangle
  41384. * @param height defines the height of the update rectangle
  41385. * @param faceIndex defines the face index if texture is a cube (0 by default)
  41386. * @param lod defines the lod level to update (0 by default)
  41387. */
  41388. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  41389. /** @hidden */
  41390. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41391. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  41392. private _prepareWebGLTexture;
  41393. /** @hidden */
  41394. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  41395. private _getDepthStencilBuffer;
  41396. /** @hidden */
  41397. _releaseFramebufferObjects(texture: InternalTexture): void;
  41398. /** @hidden */
  41399. _releaseTexture(texture: InternalTexture): void;
  41400. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  41401. protected _setProgram(program: WebGLProgram): void;
  41402. protected _boundUniforms: {
  41403. [key: number]: WebGLUniformLocation;
  41404. };
  41405. /**
  41406. * Binds an effect to the webGL context
  41407. * @param effect defines the effect to bind
  41408. */
  41409. bindSamplers(effect: Effect): void;
  41410. private _activateCurrentTexture;
  41411. /** @hidden */
  41412. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  41413. /** @hidden */
  41414. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  41415. /**
  41416. * Unbind all textures from the webGL context
  41417. */
  41418. unbindAllTextures(): void;
  41419. /**
  41420. * Sets a texture to the according uniform.
  41421. * @param channel The texture channel
  41422. * @param uniform The uniform to set
  41423. * @param texture The texture to apply
  41424. */
  41425. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>): void;
  41426. private _bindSamplerUniformToChannel;
  41427. private _getTextureWrapMode;
  41428. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  41429. /**
  41430. * Sets an array of texture to the webGL context
  41431. * @param channel defines the channel where the texture array must be set
  41432. * @param uniform defines the associated uniform location
  41433. * @param textures defines the array of textures to bind
  41434. */
  41435. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[]): void;
  41436. /** @hidden */
  41437. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  41438. private _setTextureParameterFloat;
  41439. private _setTextureParameterInteger;
  41440. /**
  41441. * Unbind all vertex attributes from the webGL context
  41442. */
  41443. unbindAllAttributes(): void;
  41444. /**
  41445. * 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
  41446. */
  41447. releaseEffects(): void;
  41448. /**
  41449. * Dispose and release all associated resources
  41450. */
  41451. dispose(): void;
  41452. /**
  41453. * Attach a new callback raised when context lost event is fired
  41454. * @param callback defines the callback to call
  41455. */
  41456. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41457. /**
  41458. * Attach a new callback raised when context restored event is fired
  41459. * @param callback defines the callback to call
  41460. */
  41461. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41462. /**
  41463. * Get the current error code of the webGL context
  41464. * @returns the error code
  41465. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41466. */
  41467. getError(): number;
  41468. private _canRenderToFloatFramebuffer;
  41469. private _canRenderToHalfFloatFramebuffer;
  41470. private _canRenderToFramebuffer;
  41471. /** @hidden */
  41472. _getWebGLTextureType(type: number): number;
  41473. /** @hidden */
  41474. _getInternalFormat(format: number): number;
  41475. /** @hidden */
  41476. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41477. /** @hidden */
  41478. _getRGBAMultiSampleBufferFormat(type: number): number;
  41479. /** @hidden */
  41480. _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;
  41481. /**
  41482. * Loads a file from a url
  41483. * @param url url to load
  41484. * @param onSuccess callback called when the file successfully loads
  41485. * @param onProgress callback called while file is loading (if the server supports this mode)
  41486. * @param offlineProvider defines the offline provider for caching
  41487. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41488. * @param onError callback called when the file fails to load
  41489. * @returns a file request object
  41490. * @hidden
  41491. */
  41492. 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;
  41493. /**
  41494. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41495. * @param x defines the x coordinate of the rectangle where pixels must be read
  41496. * @param y defines the y coordinate of the rectangle where pixels must be read
  41497. * @param width defines the width of the rectangle where pixels must be read
  41498. * @param height defines the height of the rectangle where pixels must be read
  41499. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41500. * @returns a Uint8Array containing RGBA colors
  41501. */
  41502. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  41503. private static _IsSupported;
  41504. private static _HasMajorPerformanceCaveat;
  41505. /**
  41506. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41507. */
  41508. static get IsSupported(): boolean;
  41509. /**
  41510. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41511. * @returns true if the engine can be created
  41512. * @ignorenaming
  41513. */
  41514. static isSupported(): boolean;
  41515. /**
  41516. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  41517. */
  41518. static get HasMajorPerformanceCaveat(): boolean;
  41519. /**
  41520. * Find the next highest power of two.
  41521. * @param x Number to start search from.
  41522. * @return Next highest power of two.
  41523. */
  41524. static CeilingPOT(x: number): number;
  41525. /**
  41526. * Find the next lowest power of two.
  41527. * @param x Number to start search from.
  41528. * @return Next lowest power of two.
  41529. */
  41530. static FloorPOT(x: number): number;
  41531. /**
  41532. * Find the nearest power of two.
  41533. * @param x Number to start search from.
  41534. * @return Next nearest power of two.
  41535. */
  41536. static NearestPOT(x: number): number;
  41537. /**
  41538. * Get the closest exponent of two
  41539. * @param value defines the value to approximate
  41540. * @param max defines the maximum value to return
  41541. * @param mode defines how to define the closest value
  41542. * @returns closest exponent of two of the given value
  41543. */
  41544. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41545. /**
  41546. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41547. * @param func - the function to be called
  41548. * @param requester - the object that will request the next frame. Falls back to window.
  41549. * @returns frame number
  41550. */
  41551. static QueueNewFrame(func: () => void, requester?: any): number;
  41552. /**
  41553. * Gets host document
  41554. * @returns the host document object
  41555. */
  41556. getHostDocument(): Nullable<Document>;
  41557. }
  41558. }
  41559. declare module "babylonjs/Materials/Textures/internalTexture" {
  41560. import { Observable } from "babylonjs/Misc/observable";
  41561. import { Nullable, int } from "babylonjs/types";
  41562. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  41563. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41564. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  41565. /**
  41566. * Defines the source of the internal texture
  41567. */
  41568. export enum InternalTextureSource {
  41569. /**
  41570. * The source of the texture data is unknown
  41571. */
  41572. Unknown = 0,
  41573. /**
  41574. * Texture data comes from an URL
  41575. */
  41576. Url = 1,
  41577. /**
  41578. * Texture data is only used for temporary storage
  41579. */
  41580. Temp = 2,
  41581. /**
  41582. * Texture data comes from raw data (ArrayBuffer)
  41583. */
  41584. Raw = 3,
  41585. /**
  41586. * Texture content is dynamic (video or dynamic texture)
  41587. */
  41588. Dynamic = 4,
  41589. /**
  41590. * Texture content is generated by rendering to it
  41591. */
  41592. RenderTarget = 5,
  41593. /**
  41594. * Texture content is part of a multi render target process
  41595. */
  41596. MultiRenderTarget = 6,
  41597. /**
  41598. * Texture data comes from a cube data file
  41599. */
  41600. Cube = 7,
  41601. /**
  41602. * Texture data comes from a raw cube data
  41603. */
  41604. CubeRaw = 8,
  41605. /**
  41606. * Texture data come from a prefiltered cube data file
  41607. */
  41608. CubePrefiltered = 9,
  41609. /**
  41610. * Texture content is raw 3D data
  41611. */
  41612. Raw3D = 10,
  41613. /**
  41614. * Texture content is raw 2D array data
  41615. */
  41616. Raw2DArray = 11,
  41617. /**
  41618. * Texture content is a depth texture
  41619. */
  41620. Depth = 12,
  41621. /**
  41622. * Texture data comes from a raw cube data encoded with RGBD
  41623. */
  41624. CubeRawRGBD = 13
  41625. }
  41626. /**
  41627. * Class used to store data associated with WebGL texture data for the engine
  41628. * This class should not be used directly
  41629. */
  41630. export class InternalTexture {
  41631. /** @hidden */
  41632. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41633. /**
  41634. * Defines if the texture is ready
  41635. */
  41636. isReady: boolean;
  41637. /**
  41638. * Defines if the texture is a cube texture
  41639. */
  41640. isCube: boolean;
  41641. /**
  41642. * Defines if the texture contains 3D data
  41643. */
  41644. is3D: boolean;
  41645. /**
  41646. * Defines if the texture contains 2D array data
  41647. */
  41648. is2DArray: boolean;
  41649. /**
  41650. * Defines if the texture contains multiview data
  41651. */
  41652. isMultiview: boolean;
  41653. /**
  41654. * Gets the URL used to load this texture
  41655. */
  41656. url: string;
  41657. /** @hidden */
  41658. _originalUrl: string;
  41659. /**
  41660. * Gets the sampling mode of the texture
  41661. */
  41662. samplingMode: number;
  41663. /**
  41664. * Gets a boolean indicating if the texture needs mipmaps generation
  41665. */
  41666. generateMipMaps: boolean;
  41667. /**
  41668. * Gets the number of samples used by the texture (WebGL2+ only)
  41669. */
  41670. samples: number;
  41671. /**
  41672. * Gets the type of the texture (int, float...)
  41673. */
  41674. type: number;
  41675. /**
  41676. * Gets the format of the texture (RGB, RGBA...)
  41677. */
  41678. format: number;
  41679. /**
  41680. * Observable called when the texture is loaded
  41681. */
  41682. onLoadedObservable: Observable<InternalTexture>;
  41683. /**
  41684. * Gets the width of the texture
  41685. */
  41686. width: number;
  41687. /**
  41688. * Gets the height of the texture
  41689. */
  41690. height: number;
  41691. /**
  41692. * Gets the depth of the texture
  41693. */
  41694. depth: number;
  41695. /**
  41696. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41697. */
  41698. baseWidth: number;
  41699. /**
  41700. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41701. */
  41702. baseHeight: number;
  41703. /**
  41704. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41705. */
  41706. baseDepth: number;
  41707. /**
  41708. * Gets a boolean indicating if the texture is inverted on Y axis
  41709. */
  41710. invertY: boolean;
  41711. /** @hidden */
  41712. _invertVScale: boolean;
  41713. /** @hidden */
  41714. _associatedChannel: number;
  41715. /** @hidden */
  41716. _source: InternalTextureSource;
  41717. /** @hidden */
  41718. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41719. /** @hidden */
  41720. _bufferView: Nullable<ArrayBufferView>;
  41721. /** @hidden */
  41722. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41723. /** @hidden */
  41724. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41725. /** @hidden */
  41726. _size: number;
  41727. /** @hidden */
  41728. _extension: string;
  41729. /** @hidden */
  41730. _files: Nullable<string[]>;
  41731. /** @hidden */
  41732. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41733. /** @hidden */
  41734. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41735. /** @hidden */
  41736. _framebuffer: Nullable<WebGLFramebuffer>;
  41737. /** @hidden */
  41738. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41739. /** @hidden */
  41740. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41741. /** @hidden */
  41742. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41743. /** @hidden */
  41744. _attachments: Nullable<number[]>;
  41745. /** @hidden */
  41746. _textureArray: Nullable<InternalTexture[]>;
  41747. /** @hidden */
  41748. _cachedCoordinatesMode: Nullable<number>;
  41749. /** @hidden */
  41750. _cachedWrapU: Nullable<number>;
  41751. /** @hidden */
  41752. _cachedWrapV: Nullable<number>;
  41753. /** @hidden */
  41754. _cachedWrapR: Nullable<number>;
  41755. /** @hidden */
  41756. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41757. /** @hidden */
  41758. _isDisabled: boolean;
  41759. /** @hidden */
  41760. _compression: Nullable<string>;
  41761. /** @hidden */
  41762. _generateStencilBuffer: boolean;
  41763. /** @hidden */
  41764. _generateDepthBuffer: boolean;
  41765. /** @hidden */
  41766. _comparisonFunction: number;
  41767. /** @hidden */
  41768. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41769. /** @hidden */
  41770. _lodGenerationScale: number;
  41771. /** @hidden */
  41772. _lodGenerationOffset: number;
  41773. /** @hidden */
  41774. _depthStencilTexture: Nullable<InternalTexture>;
  41775. /** @hidden */
  41776. _colorTextureArray: Nullable<WebGLTexture>;
  41777. /** @hidden */
  41778. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41779. /** @hidden */
  41780. _lodTextureHigh: Nullable<BaseTexture>;
  41781. /** @hidden */
  41782. _lodTextureMid: Nullable<BaseTexture>;
  41783. /** @hidden */
  41784. _lodTextureLow: Nullable<BaseTexture>;
  41785. /** @hidden */
  41786. _isRGBD: boolean;
  41787. /** @hidden */
  41788. _linearSpecularLOD: boolean;
  41789. /** @hidden */
  41790. _irradianceTexture: Nullable<BaseTexture>;
  41791. /** @hidden */
  41792. _webGLTexture: Nullable<WebGLTexture>;
  41793. /** @hidden */
  41794. _references: number;
  41795. /** @hidden */
  41796. _gammaSpace: Nullable<boolean>;
  41797. private _engine;
  41798. /**
  41799. * Gets the Engine the texture belongs to.
  41800. * @returns The babylon engine
  41801. */
  41802. getEngine(): ThinEngine;
  41803. /**
  41804. * Gets the data source type of the texture
  41805. */
  41806. get source(): InternalTextureSource;
  41807. /**
  41808. * Creates a new InternalTexture
  41809. * @param engine defines the engine to use
  41810. * @param source defines the type of data that will be used
  41811. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41812. */
  41813. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41814. /**
  41815. * Increments the number of references (ie. the number of Texture that point to it)
  41816. */
  41817. incrementReferences(): void;
  41818. /**
  41819. * Change the size of the texture (not the size of the content)
  41820. * @param width defines the new width
  41821. * @param height defines the new height
  41822. * @param depth defines the new depth (1 by default)
  41823. */
  41824. updateSize(width: int, height: int, depth?: int): void;
  41825. /** @hidden */
  41826. _rebuild(): void;
  41827. /** @hidden */
  41828. _swapAndDie(target: InternalTexture): void;
  41829. /**
  41830. * Dispose the current allocated resources
  41831. */
  41832. dispose(): void;
  41833. }
  41834. }
  41835. declare module "babylonjs/Loading/loadingScreen" {
  41836. /**
  41837. * Interface used to present a loading screen while loading a scene
  41838. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41839. */
  41840. export interface ILoadingScreen {
  41841. /**
  41842. * Function called to display the loading screen
  41843. */
  41844. displayLoadingUI: () => void;
  41845. /**
  41846. * Function called to hide the loading screen
  41847. */
  41848. hideLoadingUI: () => void;
  41849. /**
  41850. * Gets or sets the color to use for the background
  41851. */
  41852. loadingUIBackgroundColor: string;
  41853. /**
  41854. * Gets or sets the text to display while loading
  41855. */
  41856. loadingUIText: string;
  41857. }
  41858. /**
  41859. * Class used for the default loading screen
  41860. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41861. */
  41862. export class DefaultLoadingScreen implements ILoadingScreen {
  41863. private _renderingCanvas;
  41864. private _loadingText;
  41865. private _loadingDivBackgroundColor;
  41866. private _loadingDiv;
  41867. private _loadingTextDiv;
  41868. /** Gets or sets the logo url to use for the default loading screen */
  41869. static DefaultLogoUrl: string;
  41870. /** Gets or sets the spinner url to use for the default loading screen */
  41871. static DefaultSpinnerUrl: string;
  41872. /**
  41873. * Creates a new default loading screen
  41874. * @param _renderingCanvas defines the canvas used to render the scene
  41875. * @param _loadingText defines the default text to display
  41876. * @param _loadingDivBackgroundColor defines the default background color
  41877. */
  41878. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41879. /**
  41880. * Function called to display the loading screen
  41881. */
  41882. displayLoadingUI(): void;
  41883. /**
  41884. * Function called to hide the loading screen
  41885. */
  41886. hideLoadingUI(): void;
  41887. /**
  41888. * Gets or sets the text to display while loading
  41889. */
  41890. set loadingUIText(text: string);
  41891. get loadingUIText(): string;
  41892. /**
  41893. * Gets or sets the color to use for the background
  41894. */
  41895. get loadingUIBackgroundColor(): string;
  41896. set loadingUIBackgroundColor(color: string);
  41897. private _resizeLoadingUI;
  41898. }
  41899. }
  41900. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  41901. /**
  41902. * Interface for any object that can request an animation frame
  41903. */
  41904. export interface ICustomAnimationFrameRequester {
  41905. /**
  41906. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41907. */
  41908. renderFunction?: Function;
  41909. /**
  41910. * Called to request the next frame to render to
  41911. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41912. */
  41913. requestAnimationFrame: Function;
  41914. /**
  41915. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41916. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41917. */
  41918. requestID?: number;
  41919. }
  41920. }
  41921. declare module "babylonjs/Misc/performanceMonitor" {
  41922. /**
  41923. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41924. */
  41925. export class PerformanceMonitor {
  41926. private _enabled;
  41927. private _rollingFrameTime;
  41928. private _lastFrameTimeMs;
  41929. /**
  41930. * constructor
  41931. * @param frameSampleSize The number of samples required to saturate the sliding window
  41932. */
  41933. constructor(frameSampleSize?: number);
  41934. /**
  41935. * Samples current frame
  41936. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41937. */
  41938. sampleFrame(timeMs?: number): void;
  41939. /**
  41940. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41941. */
  41942. get averageFrameTime(): number;
  41943. /**
  41944. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41945. */
  41946. get averageFrameTimeVariance(): number;
  41947. /**
  41948. * Returns the frame time of the most recent frame
  41949. */
  41950. get instantaneousFrameTime(): number;
  41951. /**
  41952. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41953. */
  41954. get averageFPS(): number;
  41955. /**
  41956. * Returns the average framerate in frames per second using the most recent frame time
  41957. */
  41958. get instantaneousFPS(): number;
  41959. /**
  41960. * Returns true if enough samples have been taken to completely fill the sliding window
  41961. */
  41962. get isSaturated(): boolean;
  41963. /**
  41964. * Enables contributions to the sliding window sample set
  41965. */
  41966. enable(): void;
  41967. /**
  41968. * Disables contributions to the sliding window sample set
  41969. * Samples will not be interpolated over the disabled period
  41970. */
  41971. disable(): void;
  41972. /**
  41973. * Returns true if sampling is enabled
  41974. */
  41975. get isEnabled(): boolean;
  41976. /**
  41977. * Resets performance monitor
  41978. */
  41979. reset(): void;
  41980. }
  41981. /**
  41982. * RollingAverage
  41983. *
  41984. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41985. */
  41986. export class RollingAverage {
  41987. /**
  41988. * Current average
  41989. */
  41990. average: number;
  41991. /**
  41992. * Current variance
  41993. */
  41994. variance: number;
  41995. protected _samples: Array<number>;
  41996. protected _sampleCount: number;
  41997. protected _pos: number;
  41998. protected _m2: number;
  41999. /**
  42000. * constructor
  42001. * @param length The number of samples required to saturate the sliding window
  42002. */
  42003. constructor(length: number);
  42004. /**
  42005. * Adds a sample to the sample set
  42006. * @param v The sample value
  42007. */
  42008. add(v: number): void;
  42009. /**
  42010. * Returns previously added values or null if outside of history or outside the sliding window domain
  42011. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  42012. * @return Value previously recorded with add() or null if outside of range
  42013. */
  42014. history(i: number): number;
  42015. /**
  42016. * Returns true if enough samples have been taken to completely fill the sliding window
  42017. * @return true if sample-set saturated
  42018. */
  42019. isSaturated(): boolean;
  42020. /**
  42021. * Resets the rolling average (equivalent to 0 samples taken so far)
  42022. */
  42023. reset(): void;
  42024. /**
  42025. * Wraps a value around the sample range boundaries
  42026. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  42027. * @return Wrapped position in sample range
  42028. */
  42029. protected _wrapPosition(i: number): number;
  42030. }
  42031. }
  42032. declare module "babylonjs/Misc/perfCounter" {
  42033. /**
  42034. * This class is used to track a performance counter which is number based.
  42035. * The user has access to many properties which give statistics of different nature.
  42036. *
  42037. * The implementer can track two kinds of Performance Counter: time and count.
  42038. * 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.
  42039. * 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.
  42040. */
  42041. export class PerfCounter {
  42042. /**
  42043. * Gets or sets a global boolean to turn on and off all the counters
  42044. */
  42045. static Enabled: boolean;
  42046. /**
  42047. * Returns the smallest value ever
  42048. */
  42049. get min(): number;
  42050. /**
  42051. * Returns the biggest value ever
  42052. */
  42053. get max(): number;
  42054. /**
  42055. * Returns the average value since the performance counter is running
  42056. */
  42057. get average(): number;
  42058. /**
  42059. * Returns the average value of the last second the counter was monitored
  42060. */
  42061. get lastSecAverage(): number;
  42062. /**
  42063. * Returns the current value
  42064. */
  42065. get current(): number;
  42066. /**
  42067. * Gets the accumulated total
  42068. */
  42069. get total(): number;
  42070. /**
  42071. * Gets the total value count
  42072. */
  42073. get count(): number;
  42074. /**
  42075. * Creates a new counter
  42076. */
  42077. constructor();
  42078. /**
  42079. * Call this method to start monitoring a new frame.
  42080. * 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.
  42081. */
  42082. fetchNewFrame(): void;
  42083. /**
  42084. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  42085. * @param newCount the count value to add to the monitored count
  42086. * @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.
  42087. */
  42088. addCount(newCount: number, fetchResult: boolean): void;
  42089. /**
  42090. * Start monitoring this performance counter
  42091. */
  42092. beginMonitoring(): void;
  42093. /**
  42094. * Compute the time lapsed since the previous beginMonitoring() call.
  42095. * @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
  42096. */
  42097. endMonitoring(newFrame?: boolean): void;
  42098. private _fetchResult;
  42099. private _startMonitoringTime;
  42100. private _min;
  42101. private _max;
  42102. private _average;
  42103. private _current;
  42104. private _totalValueCount;
  42105. private _totalAccumulated;
  42106. private _lastSecAverage;
  42107. private _lastSecAccumulated;
  42108. private _lastSecTime;
  42109. private _lastSecValueCount;
  42110. }
  42111. }
  42112. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  42113. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42114. import { Nullable } from "babylonjs/types";
  42115. module "babylonjs/Engines/thinEngine" {
  42116. interface ThinEngine {
  42117. /** @hidden */
  42118. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  42119. }
  42120. }
  42121. }
  42122. declare module "babylonjs/Audio/analyser" {
  42123. import { Scene } from "babylonjs/scene";
  42124. /**
  42125. * Class used to work with sound analyzer using fast fourier transform (FFT)
  42126. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42127. */
  42128. export class Analyser {
  42129. /**
  42130. * Gets or sets the smoothing
  42131. * @ignorenaming
  42132. */
  42133. SMOOTHING: number;
  42134. /**
  42135. * Gets or sets the FFT table size
  42136. * @ignorenaming
  42137. */
  42138. FFT_SIZE: number;
  42139. /**
  42140. * Gets or sets the bar graph amplitude
  42141. * @ignorenaming
  42142. */
  42143. BARGRAPHAMPLITUDE: number;
  42144. /**
  42145. * Gets or sets the position of the debug canvas
  42146. * @ignorenaming
  42147. */
  42148. DEBUGCANVASPOS: {
  42149. x: number;
  42150. y: number;
  42151. };
  42152. /**
  42153. * Gets or sets the debug canvas size
  42154. * @ignorenaming
  42155. */
  42156. DEBUGCANVASSIZE: {
  42157. width: number;
  42158. height: number;
  42159. };
  42160. private _byteFreqs;
  42161. private _byteTime;
  42162. private _floatFreqs;
  42163. private _webAudioAnalyser;
  42164. private _debugCanvas;
  42165. private _debugCanvasContext;
  42166. private _scene;
  42167. private _registerFunc;
  42168. private _audioEngine;
  42169. /**
  42170. * Creates a new analyser
  42171. * @param scene defines hosting scene
  42172. */
  42173. constructor(scene: Scene);
  42174. /**
  42175. * Get the number of data values you will have to play with for the visualization
  42176. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  42177. * @returns a number
  42178. */
  42179. getFrequencyBinCount(): number;
  42180. /**
  42181. * Gets the current frequency data as a byte array
  42182. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42183. * @returns a Uint8Array
  42184. */
  42185. getByteFrequencyData(): Uint8Array;
  42186. /**
  42187. * Gets the current waveform as a byte array
  42188. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  42189. * @returns a Uint8Array
  42190. */
  42191. getByteTimeDomainData(): Uint8Array;
  42192. /**
  42193. * Gets the current frequency data as a float array
  42194. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42195. * @returns a Float32Array
  42196. */
  42197. getFloatFrequencyData(): Float32Array;
  42198. /**
  42199. * Renders the debug canvas
  42200. */
  42201. drawDebugCanvas(): void;
  42202. /**
  42203. * Stops rendering the debug canvas and removes it
  42204. */
  42205. stopDebugCanvas(): void;
  42206. /**
  42207. * Connects two audio nodes
  42208. * @param inputAudioNode defines first node to connect
  42209. * @param outputAudioNode defines second node to connect
  42210. */
  42211. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  42212. /**
  42213. * Releases all associated resources
  42214. */
  42215. dispose(): void;
  42216. }
  42217. }
  42218. declare module "babylonjs/Audio/Interfaces/IAudioEngine" {
  42219. import { Observable } from "babylonjs/Misc/observable";
  42220. import { IDisposable } from "babylonjs/scene";
  42221. import { Nullable } from "babylonjs/types";
  42222. import { Analyser } from "babylonjs/Audio/analyser";
  42223. /**
  42224. * This represents an audio engine and it is responsible
  42225. * to play, synchronize and analyse sounds throughout the application.
  42226. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42227. */
  42228. export interface IAudioEngine extends IDisposable {
  42229. /**
  42230. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  42231. */
  42232. readonly canUseWebAudio: boolean;
  42233. /**
  42234. * Gets the current AudioContext if available.
  42235. */
  42236. readonly audioContext: Nullable<AudioContext>;
  42237. /**
  42238. * The master gain node defines the global audio volume of your audio engine.
  42239. */
  42240. readonly masterGain: GainNode;
  42241. /**
  42242. * Gets whether or not mp3 are supported by your browser.
  42243. */
  42244. readonly isMP3supported: boolean;
  42245. /**
  42246. * Gets whether or not ogg are supported by your browser.
  42247. */
  42248. readonly isOGGsupported: boolean;
  42249. /**
  42250. * Defines if Babylon should emit a warning if WebAudio is not supported.
  42251. * @ignoreNaming
  42252. */
  42253. WarnedWebAudioUnsupported: boolean;
  42254. /**
  42255. * Defines if the audio engine relies on a custom unlocked button.
  42256. * In this case, the embedded button will not be displayed.
  42257. */
  42258. useCustomUnlockedButton: boolean;
  42259. /**
  42260. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  42261. */
  42262. readonly unlocked: boolean;
  42263. /**
  42264. * Event raised when audio has been unlocked on the browser.
  42265. */
  42266. onAudioUnlockedObservable: Observable<IAudioEngine>;
  42267. /**
  42268. * Event raised when audio has been locked on the browser.
  42269. */
  42270. onAudioLockedObservable: Observable<IAudioEngine>;
  42271. /**
  42272. * Flags the audio engine in Locked state.
  42273. * This happens due to new browser policies preventing audio to autoplay.
  42274. */
  42275. lock(): void;
  42276. /**
  42277. * Unlocks the audio engine once a user action has been done on the dom.
  42278. * This is helpful to resume play once browser policies have been satisfied.
  42279. */
  42280. unlock(): void;
  42281. /**
  42282. * Gets the global volume sets on the master gain.
  42283. * @returns the global volume if set or -1 otherwise
  42284. */
  42285. getGlobalVolume(): number;
  42286. /**
  42287. * Sets the global volume of your experience (sets on the master gain).
  42288. * @param newVolume Defines the new global volume of the application
  42289. */
  42290. setGlobalVolume(newVolume: number): void;
  42291. /**
  42292. * Connect the audio engine to an audio analyser allowing some amazing
  42293. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42294. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42295. * @param analyser The analyser to connect to the engine
  42296. */
  42297. connectToAnalyser(analyser: Analyser): void;
  42298. }
  42299. }
  42300. declare module "babylonjs/Engines/engine" {
  42301. import { Observable } from "babylonjs/Misc/observable";
  42302. import { Nullable } from "babylonjs/types";
  42303. import { Scene } from "babylonjs/scene";
  42304. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42305. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  42306. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  42307. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  42308. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42309. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  42310. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  42311. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  42312. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42313. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  42314. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42315. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  42316. import "babylonjs/Engines/Extensions/engine.alpha";
  42317. import "babylonjs/Engines/Extensions/engine.readTexture";
  42318. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  42319. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  42320. import { Material } from "babylonjs/Materials/material";
  42321. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42322. /**
  42323. * Defines the interface used by display changed events
  42324. */
  42325. export interface IDisplayChangedEventArgs {
  42326. /** Gets the vrDisplay object (if any) */
  42327. vrDisplay: Nullable<any>;
  42328. /** Gets a boolean indicating if webVR is supported */
  42329. vrSupported: boolean;
  42330. }
  42331. /**
  42332. * Defines the interface used by objects containing a viewport (like a camera)
  42333. */
  42334. interface IViewportOwnerLike {
  42335. /**
  42336. * Gets or sets the viewport
  42337. */
  42338. viewport: IViewportLike;
  42339. }
  42340. /**
  42341. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  42342. */
  42343. export class Engine extends ThinEngine {
  42344. /** Defines that alpha blending is disabled */
  42345. static readonly ALPHA_DISABLE: number;
  42346. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  42347. static readonly ALPHA_ADD: number;
  42348. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  42349. static readonly ALPHA_COMBINE: number;
  42350. /** Defines that alpha blending to DEST - SRC * DEST */
  42351. static readonly ALPHA_SUBTRACT: number;
  42352. /** Defines that alpha blending to SRC * DEST */
  42353. static readonly ALPHA_MULTIPLY: number;
  42354. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  42355. static readonly ALPHA_MAXIMIZED: number;
  42356. /** Defines that alpha blending to SRC + DEST */
  42357. static readonly ALPHA_ONEONE: number;
  42358. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  42359. static readonly ALPHA_PREMULTIPLIED: number;
  42360. /**
  42361. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  42362. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  42363. */
  42364. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  42365. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  42366. static readonly ALPHA_INTERPOLATE: number;
  42367. /**
  42368. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  42369. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  42370. */
  42371. static readonly ALPHA_SCREENMODE: number;
  42372. /** Defines that the ressource is not delayed*/
  42373. static readonly DELAYLOADSTATE_NONE: number;
  42374. /** Defines that the ressource was successfully delay loaded */
  42375. static readonly DELAYLOADSTATE_LOADED: number;
  42376. /** Defines that the ressource is currently delay loading */
  42377. static readonly DELAYLOADSTATE_LOADING: number;
  42378. /** Defines that the ressource is delayed and has not started loading */
  42379. static readonly DELAYLOADSTATE_NOTLOADED: number;
  42380. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  42381. static readonly NEVER: number;
  42382. /** 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 */
  42383. static readonly ALWAYS: number;
  42384. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  42385. static readonly LESS: number;
  42386. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  42387. static readonly EQUAL: number;
  42388. /** 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 */
  42389. static readonly LEQUAL: number;
  42390. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  42391. static readonly GREATER: number;
  42392. /** 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 */
  42393. static readonly GEQUAL: number;
  42394. /** 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 */
  42395. static readonly NOTEQUAL: number;
  42396. /** Passed to stencilOperation to specify that stencil value must be kept */
  42397. static readonly KEEP: number;
  42398. /** Passed to stencilOperation to specify that stencil value must be replaced */
  42399. static readonly REPLACE: number;
  42400. /** Passed to stencilOperation to specify that stencil value must be incremented */
  42401. static readonly INCR: number;
  42402. /** Passed to stencilOperation to specify that stencil value must be decremented */
  42403. static readonly DECR: number;
  42404. /** Passed to stencilOperation to specify that stencil value must be inverted */
  42405. static readonly INVERT: number;
  42406. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  42407. static readonly INCR_WRAP: number;
  42408. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  42409. static readonly DECR_WRAP: number;
  42410. /** Texture is not repeating outside of 0..1 UVs */
  42411. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  42412. /** Texture is repeating outside of 0..1 UVs */
  42413. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  42414. /** Texture is repeating and mirrored */
  42415. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  42416. /** ALPHA */
  42417. static readonly TEXTUREFORMAT_ALPHA: number;
  42418. /** LUMINANCE */
  42419. static readonly TEXTUREFORMAT_LUMINANCE: number;
  42420. /** LUMINANCE_ALPHA */
  42421. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  42422. /** RGB */
  42423. static readonly TEXTUREFORMAT_RGB: number;
  42424. /** RGBA */
  42425. static readonly TEXTUREFORMAT_RGBA: number;
  42426. /** RED */
  42427. static readonly TEXTUREFORMAT_RED: number;
  42428. /** RED (2nd reference) */
  42429. static readonly TEXTUREFORMAT_R: number;
  42430. /** RG */
  42431. static readonly TEXTUREFORMAT_RG: number;
  42432. /** RED_INTEGER */
  42433. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  42434. /** RED_INTEGER (2nd reference) */
  42435. static readonly TEXTUREFORMAT_R_INTEGER: number;
  42436. /** RG_INTEGER */
  42437. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  42438. /** RGB_INTEGER */
  42439. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  42440. /** RGBA_INTEGER */
  42441. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  42442. /** UNSIGNED_BYTE */
  42443. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  42444. /** UNSIGNED_BYTE (2nd reference) */
  42445. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  42446. /** FLOAT */
  42447. static readonly TEXTURETYPE_FLOAT: number;
  42448. /** HALF_FLOAT */
  42449. static readonly TEXTURETYPE_HALF_FLOAT: number;
  42450. /** BYTE */
  42451. static readonly TEXTURETYPE_BYTE: number;
  42452. /** SHORT */
  42453. static readonly TEXTURETYPE_SHORT: number;
  42454. /** UNSIGNED_SHORT */
  42455. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  42456. /** INT */
  42457. static readonly TEXTURETYPE_INT: number;
  42458. /** UNSIGNED_INT */
  42459. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42460. /** UNSIGNED_SHORT_4_4_4_4 */
  42461. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42462. /** UNSIGNED_SHORT_5_5_5_1 */
  42463. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42464. /** UNSIGNED_SHORT_5_6_5 */
  42465. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42466. /** UNSIGNED_INT_2_10_10_10_REV */
  42467. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42468. /** UNSIGNED_INT_24_8 */
  42469. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42470. /** UNSIGNED_INT_10F_11F_11F_REV */
  42471. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42472. /** UNSIGNED_INT_5_9_9_9_REV */
  42473. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42474. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42475. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42476. /** nearest is mag = nearest and min = nearest and mip = linear */
  42477. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42478. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42479. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42480. /** Trilinear is mag = linear and min = linear and mip = linear */
  42481. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42482. /** nearest is mag = nearest and min = nearest and mip = linear */
  42483. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42484. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42485. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42486. /** Trilinear is mag = linear and min = linear and mip = linear */
  42487. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42488. /** mag = nearest and min = nearest and mip = nearest */
  42489. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42490. /** mag = nearest and min = linear and mip = nearest */
  42491. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42492. /** mag = nearest and min = linear and mip = linear */
  42493. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42494. /** mag = nearest and min = linear and mip = none */
  42495. static readonly TEXTURE_NEAREST_LINEAR: number;
  42496. /** mag = nearest and min = nearest and mip = none */
  42497. static readonly TEXTURE_NEAREST_NEAREST: number;
  42498. /** mag = linear and min = nearest and mip = nearest */
  42499. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42500. /** mag = linear and min = nearest and mip = linear */
  42501. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42502. /** mag = linear and min = linear and mip = none */
  42503. static readonly TEXTURE_LINEAR_LINEAR: number;
  42504. /** mag = linear and min = nearest and mip = none */
  42505. static readonly TEXTURE_LINEAR_NEAREST: number;
  42506. /** Explicit coordinates mode */
  42507. static readonly TEXTURE_EXPLICIT_MODE: number;
  42508. /** Spherical coordinates mode */
  42509. static readonly TEXTURE_SPHERICAL_MODE: number;
  42510. /** Planar coordinates mode */
  42511. static readonly TEXTURE_PLANAR_MODE: number;
  42512. /** Cubic coordinates mode */
  42513. static readonly TEXTURE_CUBIC_MODE: number;
  42514. /** Projection coordinates mode */
  42515. static readonly TEXTURE_PROJECTION_MODE: number;
  42516. /** Skybox coordinates mode */
  42517. static readonly TEXTURE_SKYBOX_MODE: number;
  42518. /** Inverse Cubic coordinates mode */
  42519. static readonly TEXTURE_INVCUBIC_MODE: number;
  42520. /** Equirectangular coordinates mode */
  42521. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42522. /** Equirectangular Fixed coordinates mode */
  42523. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42524. /** Equirectangular Fixed Mirrored coordinates mode */
  42525. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42526. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42527. static readonly SCALEMODE_FLOOR: number;
  42528. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42529. static readonly SCALEMODE_NEAREST: number;
  42530. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42531. static readonly SCALEMODE_CEILING: number;
  42532. /**
  42533. * Returns the current npm package of the sdk
  42534. */
  42535. static get NpmPackage(): string;
  42536. /**
  42537. * Returns the current version of the framework
  42538. */
  42539. static get Version(): string;
  42540. /** Gets the list of created engines */
  42541. static get Instances(): Engine[];
  42542. /**
  42543. * Gets the latest created engine
  42544. */
  42545. static get LastCreatedEngine(): Nullable<Engine>;
  42546. /**
  42547. * Gets the latest created scene
  42548. */
  42549. static get LastCreatedScene(): Nullable<Scene>;
  42550. /**
  42551. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42552. * @param flag defines which part of the materials must be marked as dirty
  42553. * @param predicate defines a predicate used to filter which materials should be affected
  42554. */
  42555. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42556. /**
  42557. * Method called to create the default loading screen.
  42558. * This can be overriden in your own app.
  42559. * @param canvas The rendering canvas element
  42560. * @returns The loading screen
  42561. */
  42562. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42563. /**
  42564. * Method called to create the default rescale post process on each engine.
  42565. */
  42566. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42567. /**
  42568. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42569. **/
  42570. enableOfflineSupport: boolean;
  42571. /**
  42572. * 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)
  42573. **/
  42574. disableManifestCheck: boolean;
  42575. /**
  42576. * Gets the list of created scenes
  42577. */
  42578. scenes: Scene[];
  42579. /**
  42580. * Event raised when a new scene is created
  42581. */
  42582. onNewSceneAddedObservable: Observable<Scene>;
  42583. /**
  42584. * Gets the list of created postprocesses
  42585. */
  42586. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42587. /**
  42588. * Gets a boolean indicating if the pointer is currently locked
  42589. */
  42590. isPointerLock: boolean;
  42591. /**
  42592. * Observable event triggered each time the rendering canvas is resized
  42593. */
  42594. onResizeObservable: Observable<Engine>;
  42595. /**
  42596. * Observable event triggered each time the canvas loses focus
  42597. */
  42598. onCanvasBlurObservable: Observable<Engine>;
  42599. /**
  42600. * Observable event triggered each time the canvas gains focus
  42601. */
  42602. onCanvasFocusObservable: Observable<Engine>;
  42603. /**
  42604. * Observable event triggered each time the canvas receives pointerout event
  42605. */
  42606. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42607. /**
  42608. * Observable raised when the engine begins a new frame
  42609. */
  42610. onBeginFrameObservable: Observable<Engine>;
  42611. /**
  42612. * If set, will be used to request the next animation frame for the render loop
  42613. */
  42614. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42615. /**
  42616. * Observable raised when the engine ends the current frame
  42617. */
  42618. onEndFrameObservable: Observable<Engine>;
  42619. /**
  42620. * Observable raised when the engine is about to compile a shader
  42621. */
  42622. onBeforeShaderCompilationObservable: Observable<Engine>;
  42623. /**
  42624. * Observable raised when the engine has jsut compiled a shader
  42625. */
  42626. onAfterShaderCompilationObservable: Observable<Engine>;
  42627. /**
  42628. * Gets the audio engine
  42629. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42630. * @ignorenaming
  42631. */
  42632. static audioEngine: IAudioEngine;
  42633. /**
  42634. * Default AudioEngine factory responsible of creating the Audio Engine.
  42635. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42636. */
  42637. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42638. /**
  42639. * Default offline support factory responsible of creating a tool used to store data locally.
  42640. * By default, this will create a Database object if the workload has been embedded.
  42641. */
  42642. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42643. private _loadingScreen;
  42644. private _pointerLockRequested;
  42645. private _rescalePostProcess;
  42646. private _deterministicLockstep;
  42647. private _lockstepMaxSteps;
  42648. private _timeStep;
  42649. protected get _supportsHardwareTextureRescaling(): boolean;
  42650. private _fps;
  42651. private _deltaTime;
  42652. /** @hidden */
  42653. _drawCalls: PerfCounter;
  42654. /** 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 */
  42655. canvasTabIndex: number;
  42656. /**
  42657. * Turn this value on if you want to pause FPS computation when in background
  42658. */
  42659. disablePerformanceMonitorInBackground: boolean;
  42660. private _performanceMonitor;
  42661. /**
  42662. * Gets the performance monitor attached to this engine
  42663. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42664. */
  42665. get performanceMonitor(): PerformanceMonitor;
  42666. private _onFocus;
  42667. private _onBlur;
  42668. private _onCanvasPointerOut;
  42669. private _onCanvasBlur;
  42670. private _onCanvasFocus;
  42671. private _onFullscreenChange;
  42672. private _onPointerLockChange;
  42673. /**
  42674. * Gets the HTML element used to attach event listeners
  42675. * @returns a HTML element
  42676. */
  42677. getInputElement(): Nullable<HTMLElement>;
  42678. /**
  42679. * Creates a new engine
  42680. * @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
  42681. * @param antialias defines enable antialiasing (default: false)
  42682. * @param options defines further options to be sent to the getContext() function
  42683. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42684. */
  42685. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42686. /**
  42687. * Gets current aspect ratio
  42688. * @param viewportOwner defines the camera to use to get the aspect ratio
  42689. * @param useScreen defines if screen size must be used (or the current render target if any)
  42690. * @returns a number defining the aspect ratio
  42691. */
  42692. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42693. /**
  42694. * Gets current screen aspect ratio
  42695. * @returns a number defining the aspect ratio
  42696. */
  42697. getScreenAspectRatio(): number;
  42698. /**
  42699. * Gets the client rect of the HTML canvas attached with the current webGL context
  42700. * @returns a client rectanglee
  42701. */
  42702. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42703. /**
  42704. * Gets the client rect of the HTML element used for events
  42705. * @returns a client rectanglee
  42706. */
  42707. getInputElementClientRect(): Nullable<ClientRect>;
  42708. /**
  42709. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42710. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42711. * @returns true if engine is in deterministic lock step mode
  42712. */
  42713. isDeterministicLockStep(): boolean;
  42714. /**
  42715. * Gets the max steps when engine is running in deterministic lock step
  42716. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42717. * @returns the max steps
  42718. */
  42719. getLockstepMaxSteps(): number;
  42720. /**
  42721. * Returns the time in ms between steps when using deterministic lock step.
  42722. * @returns time step in (ms)
  42723. */
  42724. getTimeStep(): number;
  42725. /**
  42726. * Force the mipmap generation for the given render target texture
  42727. * @param texture defines the render target texture to use
  42728. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42729. */
  42730. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42731. /** States */
  42732. /**
  42733. * Set various states to the webGL context
  42734. * @param culling defines backface culling state
  42735. * @param zOffset defines the value to apply to zOffset (0 by default)
  42736. * @param force defines if states must be applied even if cache is up to date
  42737. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42738. */
  42739. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42740. /**
  42741. * Set the z offset to apply to current rendering
  42742. * @param value defines the offset to apply
  42743. */
  42744. setZOffset(value: number): void;
  42745. /**
  42746. * Gets the current value of the zOffset
  42747. * @returns the current zOffset state
  42748. */
  42749. getZOffset(): number;
  42750. /**
  42751. * Enable or disable depth buffering
  42752. * @param enable defines the state to set
  42753. */
  42754. setDepthBuffer(enable: boolean): void;
  42755. /**
  42756. * Gets a boolean indicating if depth writing is enabled
  42757. * @returns the current depth writing state
  42758. */
  42759. getDepthWrite(): boolean;
  42760. /**
  42761. * Enable or disable depth writing
  42762. * @param enable defines the state to set
  42763. */
  42764. setDepthWrite(enable: boolean): void;
  42765. /**
  42766. * Gets a boolean indicating if stencil buffer is enabled
  42767. * @returns the current stencil buffer state
  42768. */
  42769. getStencilBuffer(): boolean;
  42770. /**
  42771. * Enable or disable the stencil buffer
  42772. * @param enable defines if the stencil buffer must be enabled or disabled
  42773. */
  42774. setStencilBuffer(enable: boolean): void;
  42775. /**
  42776. * Gets the current stencil mask
  42777. * @returns a number defining the new stencil mask to use
  42778. */
  42779. getStencilMask(): number;
  42780. /**
  42781. * Sets the current stencil mask
  42782. * @param mask defines the new stencil mask to use
  42783. */
  42784. setStencilMask(mask: number): void;
  42785. /**
  42786. * Gets the current stencil function
  42787. * @returns a number defining the stencil function to use
  42788. */
  42789. getStencilFunction(): number;
  42790. /**
  42791. * Gets the current stencil reference value
  42792. * @returns a number defining the stencil reference value to use
  42793. */
  42794. getStencilFunctionReference(): number;
  42795. /**
  42796. * Gets the current stencil mask
  42797. * @returns a number defining the stencil mask to use
  42798. */
  42799. getStencilFunctionMask(): number;
  42800. /**
  42801. * Sets the current stencil function
  42802. * @param stencilFunc defines the new stencil function to use
  42803. */
  42804. setStencilFunction(stencilFunc: number): void;
  42805. /**
  42806. * Sets the current stencil reference
  42807. * @param reference defines the new stencil reference to use
  42808. */
  42809. setStencilFunctionReference(reference: number): void;
  42810. /**
  42811. * Sets the current stencil mask
  42812. * @param mask defines the new stencil mask to use
  42813. */
  42814. setStencilFunctionMask(mask: number): void;
  42815. /**
  42816. * Gets the current stencil operation when stencil fails
  42817. * @returns a number defining stencil operation to use when stencil fails
  42818. */
  42819. getStencilOperationFail(): number;
  42820. /**
  42821. * Gets the current stencil operation when depth fails
  42822. * @returns a number defining stencil operation to use when depth fails
  42823. */
  42824. getStencilOperationDepthFail(): number;
  42825. /**
  42826. * Gets the current stencil operation when stencil passes
  42827. * @returns a number defining stencil operation to use when stencil passes
  42828. */
  42829. getStencilOperationPass(): number;
  42830. /**
  42831. * Sets the stencil operation to use when stencil fails
  42832. * @param operation defines the stencil operation to use when stencil fails
  42833. */
  42834. setStencilOperationFail(operation: number): void;
  42835. /**
  42836. * Sets the stencil operation to use when depth fails
  42837. * @param operation defines the stencil operation to use when depth fails
  42838. */
  42839. setStencilOperationDepthFail(operation: number): void;
  42840. /**
  42841. * Sets the stencil operation to use when stencil passes
  42842. * @param operation defines the stencil operation to use when stencil passes
  42843. */
  42844. setStencilOperationPass(operation: number): void;
  42845. /**
  42846. * Sets a boolean indicating if the dithering state is enabled or disabled
  42847. * @param value defines the dithering state
  42848. */
  42849. setDitheringState(value: boolean): void;
  42850. /**
  42851. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42852. * @param value defines the rasterizer state
  42853. */
  42854. setRasterizerState(value: boolean): void;
  42855. /**
  42856. * Gets the current depth function
  42857. * @returns a number defining the depth function
  42858. */
  42859. getDepthFunction(): Nullable<number>;
  42860. /**
  42861. * Sets the current depth function
  42862. * @param depthFunc defines the function to use
  42863. */
  42864. setDepthFunction(depthFunc: number): void;
  42865. /**
  42866. * Sets the current depth function to GREATER
  42867. */
  42868. setDepthFunctionToGreater(): void;
  42869. /**
  42870. * Sets the current depth function to GEQUAL
  42871. */
  42872. setDepthFunctionToGreaterOrEqual(): void;
  42873. /**
  42874. * Sets the current depth function to LESS
  42875. */
  42876. setDepthFunctionToLess(): void;
  42877. /**
  42878. * Sets the current depth function to LEQUAL
  42879. */
  42880. setDepthFunctionToLessOrEqual(): void;
  42881. private _cachedStencilBuffer;
  42882. private _cachedStencilFunction;
  42883. private _cachedStencilMask;
  42884. private _cachedStencilOperationPass;
  42885. private _cachedStencilOperationFail;
  42886. private _cachedStencilOperationDepthFail;
  42887. private _cachedStencilReference;
  42888. /**
  42889. * Caches the the state of the stencil buffer
  42890. */
  42891. cacheStencilState(): void;
  42892. /**
  42893. * Restores the state of the stencil buffer
  42894. */
  42895. restoreStencilState(): void;
  42896. /**
  42897. * Directly set the WebGL Viewport
  42898. * @param x defines the x coordinate of the viewport (in screen space)
  42899. * @param y defines the y coordinate of the viewport (in screen space)
  42900. * @param width defines the width of the viewport (in screen space)
  42901. * @param height defines the height of the viewport (in screen space)
  42902. * @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
  42903. */
  42904. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42905. /**
  42906. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42907. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42908. * @param y defines the y-coordinate of the corner of the clear rectangle
  42909. * @param width defines the width of the clear rectangle
  42910. * @param height defines the height of the clear rectangle
  42911. * @param clearColor defines the clear color
  42912. */
  42913. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42914. /**
  42915. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42916. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42917. * @param y defines the y-coordinate of the corner of the clear rectangle
  42918. * @param width defines the width of the clear rectangle
  42919. * @param height defines the height of the clear rectangle
  42920. */
  42921. enableScissor(x: number, y: number, width: number, height: number): void;
  42922. /**
  42923. * Disable previously set scissor test rectangle
  42924. */
  42925. disableScissor(): void;
  42926. protected _reportDrawCall(): void;
  42927. /**
  42928. * Initializes a webVR display and starts listening to display change events
  42929. * The onVRDisplayChangedObservable will be notified upon these changes
  42930. * @returns The onVRDisplayChangedObservable
  42931. */
  42932. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42933. /** @hidden */
  42934. _prepareVRComponent(): void;
  42935. /** @hidden */
  42936. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42937. /** @hidden */
  42938. _submitVRFrame(): void;
  42939. /**
  42940. * Call this function to leave webVR mode
  42941. * Will do nothing if webVR is not supported or if there is no webVR device
  42942. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42943. */
  42944. disableVR(): void;
  42945. /**
  42946. * Gets a boolean indicating that the system is in VR mode and is presenting
  42947. * @returns true if VR mode is engaged
  42948. */
  42949. isVRPresenting(): boolean;
  42950. /** @hidden */
  42951. _requestVRFrame(): void;
  42952. /** @hidden */
  42953. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42954. /**
  42955. * Gets the source code of the vertex shader associated with a specific webGL program
  42956. * @param program defines the program to use
  42957. * @returns a string containing the source code of the vertex shader associated with the program
  42958. */
  42959. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42960. /**
  42961. * Gets the source code of the fragment shader associated with a specific webGL program
  42962. * @param program defines the program to use
  42963. * @returns a string containing the source code of the fragment shader associated with the program
  42964. */
  42965. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42966. /**
  42967. * Sets a depth stencil texture from a render target to the according uniform.
  42968. * @param channel The texture channel
  42969. * @param uniform The uniform to set
  42970. * @param texture The render target texture containing the depth stencil texture to apply
  42971. */
  42972. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  42973. /**
  42974. * Sets a texture to the webGL context from a postprocess
  42975. * @param channel defines the channel to use
  42976. * @param postProcess defines the source postprocess
  42977. */
  42978. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  42979. /**
  42980. * Binds the output of the passed in post process to the texture channel specified
  42981. * @param channel The channel the texture should be bound to
  42982. * @param postProcess The post process which's output should be bound
  42983. */
  42984. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  42985. protected _rebuildBuffers(): void;
  42986. /** @hidden */
  42987. _renderFrame(): void;
  42988. _renderLoop(): void;
  42989. /** @hidden */
  42990. _renderViews(): boolean;
  42991. /**
  42992. * Toggle full screen mode
  42993. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42994. */
  42995. switchFullscreen(requestPointerLock: boolean): void;
  42996. /**
  42997. * Enters full screen mode
  42998. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42999. */
  43000. enterFullscreen(requestPointerLock: boolean): void;
  43001. /**
  43002. * Exits full screen mode
  43003. */
  43004. exitFullscreen(): void;
  43005. /**
  43006. * Enters Pointerlock mode
  43007. */
  43008. enterPointerlock(): void;
  43009. /**
  43010. * Exits Pointerlock mode
  43011. */
  43012. exitPointerlock(): void;
  43013. /**
  43014. * Begin a new frame
  43015. */
  43016. beginFrame(): void;
  43017. /**
  43018. * Enf the current frame
  43019. */
  43020. endFrame(): void;
  43021. resize(): void;
  43022. /**
  43023. * Force a specific size of the canvas
  43024. * @param width defines the new canvas' width
  43025. * @param height defines the new canvas' height
  43026. * @returns true if the size was changed
  43027. */
  43028. setSize(width: number, height: number): boolean;
  43029. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  43030. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  43031. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  43032. _releaseTexture(texture: InternalTexture): void;
  43033. /**
  43034. * @hidden
  43035. * Rescales a texture
  43036. * @param source input texutre
  43037. * @param destination destination texture
  43038. * @param scene scene to use to render the resize
  43039. * @param internalFormat format to use when resizing
  43040. * @param onComplete callback to be called when resize has completed
  43041. */
  43042. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  43043. /**
  43044. * Gets the current framerate
  43045. * @returns a number representing the framerate
  43046. */
  43047. getFps(): number;
  43048. /**
  43049. * Gets the time spent between current and previous frame
  43050. * @returns a number representing the delta time in ms
  43051. */
  43052. getDeltaTime(): number;
  43053. private _measureFps;
  43054. /** @hidden */
  43055. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  43056. /**
  43057. * Updates the sample count of a render target texture
  43058. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43059. * @param texture defines the texture to update
  43060. * @param samples defines the sample count to set
  43061. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43062. */
  43063. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  43064. /**
  43065. * Updates a depth texture Comparison Mode and Function.
  43066. * If the comparison Function is equal to 0, the mode will be set to none.
  43067. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  43068. * @param texture The texture to set the comparison function for
  43069. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  43070. */
  43071. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  43072. /**
  43073. * Creates a webGL buffer to use with instanciation
  43074. * @param capacity defines the size of the buffer
  43075. * @returns the webGL buffer
  43076. */
  43077. createInstancesBuffer(capacity: number): DataBuffer;
  43078. /**
  43079. * Delete a webGL buffer used with instanciation
  43080. * @param buffer defines the webGL buffer to delete
  43081. */
  43082. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  43083. private _clientWaitAsync;
  43084. /** @hidden */
  43085. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  43086. dispose(): void;
  43087. private _disableTouchAction;
  43088. /**
  43089. * Display the loading screen
  43090. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43091. */
  43092. displayLoadingUI(): void;
  43093. /**
  43094. * Hide the loading screen
  43095. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43096. */
  43097. hideLoadingUI(): void;
  43098. /**
  43099. * Gets the current loading screen object
  43100. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43101. */
  43102. get loadingScreen(): ILoadingScreen;
  43103. /**
  43104. * Sets the current loading screen object
  43105. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43106. */
  43107. set loadingScreen(loadingScreen: ILoadingScreen);
  43108. /**
  43109. * Sets the current loading screen text
  43110. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43111. */
  43112. set loadingUIText(text: string);
  43113. /**
  43114. * Sets the current loading screen background color
  43115. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43116. */
  43117. set loadingUIBackgroundColor(color: string);
  43118. /** Pointerlock and fullscreen */
  43119. /**
  43120. * Ask the browser to promote the current element to pointerlock mode
  43121. * @param element defines the DOM element to promote
  43122. */
  43123. static _RequestPointerlock(element: HTMLElement): void;
  43124. /**
  43125. * Asks the browser to exit pointerlock mode
  43126. */
  43127. static _ExitPointerlock(): void;
  43128. /**
  43129. * Ask the browser to promote the current element to fullscreen rendering mode
  43130. * @param element defines the DOM element to promote
  43131. */
  43132. static _RequestFullscreen(element: HTMLElement): void;
  43133. /**
  43134. * Asks the browser to exit fullscreen mode
  43135. */
  43136. static _ExitFullscreen(): void;
  43137. }
  43138. }
  43139. declare module "babylonjs/Engines/engineStore" {
  43140. import { Nullable } from "babylonjs/types";
  43141. import { Engine } from "babylonjs/Engines/engine";
  43142. import { Scene } from "babylonjs/scene";
  43143. /**
  43144. * The engine store class is responsible to hold all the instances of Engine and Scene created
  43145. * during the life time of the application.
  43146. */
  43147. export class EngineStore {
  43148. /** Gets the list of created engines */
  43149. static Instances: import("babylonjs/Engines/engine").Engine[];
  43150. /** @hidden */
  43151. static _LastCreatedScene: Nullable<Scene>;
  43152. /**
  43153. * Gets the latest created engine
  43154. */
  43155. static get LastCreatedEngine(): Nullable<Engine>;
  43156. /**
  43157. * Gets the latest created scene
  43158. */
  43159. static get LastCreatedScene(): Nullable<Scene>;
  43160. /**
  43161. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43162. * @ignorenaming
  43163. */
  43164. static UseFallbackTexture: boolean;
  43165. /**
  43166. * Texture content used if a texture cannot loaded
  43167. * @ignorenaming
  43168. */
  43169. static FallbackTexture: string;
  43170. }
  43171. }
  43172. declare module "babylonjs/Misc/promise" {
  43173. /**
  43174. * Helper class that provides a small promise polyfill
  43175. */
  43176. export class PromisePolyfill {
  43177. /**
  43178. * Static function used to check if the polyfill is required
  43179. * If this is the case then the function will inject the polyfill to window.Promise
  43180. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  43181. */
  43182. static Apply(force?: boolean): void;
  43183. }
  43184. }
  43185. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  43186. /**
  43187. * Interface for screenshot methods with describe argument called `size` as object with options
  43188. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  43189. */
  43190. export interface IScreenshotSize {
  43191. /**
  43192. * number in pixels for canvas height
  43193. */
  43194. height?: number;
  43195. /**
  43196. * multiplier allowing render at a higher or lower resolution
  43197. * If value is defined then height and width will be ignored and taken from camera
  43198. */
  43199. precision?: number;
  43200. /**
  43201. * number in pixels for canvas width
  43202. */
  43203. width?: number;
  43204. }
  43205. }
  43206. declare module "babylonjs/Misc/tools" {
  43207. import { Nullable, float } from "babylonjs/types";
  43208. import { DomManagement } from "babylonjs/Misc/domManagement";
  43209. import { WebRequest } from "babylonjs/Misc/webRequest";
  43210. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43211. import { ReadFileError } from "babylonjs/Misc/fileTools";
  43212. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  43213. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  43214. import { Camera } from "babylonjs/Cameras/camera";
  43215. import { Engine } from "babylonjs/Engines/engine";
  43216. interface IColor4Like {
  43217. r: float;
  43218. g: float;
  43219. b: float;
  43220. a: float;
  43221. }
  43222. /**
  43223. * Class containing a set of static utilities functions
  43224. */
  43225. export class Tools {
  43226. /**
  43227. * Gets or sets the base URL to use to load assets
  43228. */
  43229. static get BaseUrl(): string;
  43230. static set BaseUrl(value: string);
  43231. /**
  43232. * Enable/Disable Custom HTTP Request Headers globally.
  43233. * default = false
  43234. * @see CustomRequestHeaders
  43235. */
  43236. static UseCustomRequestHeaders: boolean;
  43237. /**
  43238. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  43239. * i.e. when loading files, where the server/service expects an Authorization header
  43240. */
  43241. static CustomRequestHeaders: {
  43242. [key: string]: string;
  43243. };
  43244. /**
  43245. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  43246. */
  43247. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  43248. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  43249. /**
  43250. * Default behaviour for cors in the application.
  43251. * It can be a string if the expected behavior is identical in the entire app.
  43252. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  43253. */
  43254. static get CorsBehavior(): string | ((url: string | string[]) => string);
  43255. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  43256. /**
  43257. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43258. * @ignorenaming
  43259. */
  43260. static get UseFallbackTexture(): boolean;
  43261. static set UseFallbackTexture(value: boolean);
  43262. /**
  43263. * Use this object to register external classes like custom textures or material
  43264. * to allow the laoders to instantiate them
  43265. */
  43266. static get RegisteredExternalClasses(): {
  43267. [key: string]: Object;
  43268. };
  43269. static set RegisteredExternalClasses(classes: {
  43270. [key: string]: Object;
  43271. });
  43272. /**
  43273. * Texture content used if a texture cannot loaded
  43274. * @ignorenaming
  43275. */
  43276. static get fallbackTexture(): string;
  43277. static set fallbackTexture(value: string);
  43278. /**
  43279. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  43280. * @param u defines the coordinate on X axis
  43281. * @param v defines the coordinate on Y axis
  43282. * @param width defines the width of the source data
  43283. * @param height defines the height of the source data
  43284. * @param pixels defines the source byte array
  43285. * @param color defines the output color
  43286. */
  43287. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  43288. /**
  43289. * Interpolates between a and b via alpha
  43290. * @param a The lower value (returned when alpha = 0)
  43291. * @param b The upper value (returned when alpha = 1)
  43292. * @param alpha The interpolation-factor
  43293. * @return The mixed value
  43294. */
  43295. static Mix(a: number, b: number, alpha: number): number;
  43296. /**
  43297. * Tries to instantiate a new object from a given class name
  43298. * @param className defines the class name to instantiate
  43299. * @returns the new object or null if the system was not able to do the instantiation
  43300. */
  43301. static Instantiate(className: string): any;
  43302. /**
  43303. * Provides a slice function that will work even on IE
  43304. * @param data defines the array to slice
  43305. * @param start defines the start of the data (optional)
  43306. * @param end defines the end of the data (optional)
  43307. * @returns the new sliced array
  43308. */
  43309. static Slice<T>(data: T, start?: number, end?: number): T;
  43310. /**
  43311. * Provides a slice function that will work even on IE
  43312. * The difference between this and Slice is that this will force-convert to array
  43313. * @param data defines the array to slice
  43314. * @param start defines the start of the data (optional)
  43315. * @param end defines the end of the data (optional)
  43316. * @returns the new sliced array
  43317. */
  43318. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  43319. /**
  43320. * Polyfill for setImmediate
  43321. * @param action defines the action to execute after the current execution block
  43322. */
  43323. static SetImmediate(action: () => void): void;
  43324. /**
  43325. * Function indicating if a number is an exponent of 2
  43326. * @param value defines the value to test
  43327. * @returns true if the value is an exponent of 2
  43328. */
  43329. static IsExponentOfTwo(value: number): boolean;
  43330. private static _tmpFloatArray;
  43331. /**
  43332. * Returns the nearest 32-bit single precision float representation of a Number
  43333. * @param value A Number. If the parameter is of a different type, it will get converted
  43334. * to a number or to NaN if it cannot be converted
  43335. * @returns number
  43336. */
  43337. static FloatRound(value: number): number;
  43338. /**
  43339. * Extracts the filename from a path
  43340. * @param path defines the path to use
  43341. * @returns the filename
  43342. */
  43343. static GetFilename(path: string): string;
  43344. /**
  43345. * Extracts the "folder" part of a path (everything before the filename).
  43346. * @param uri The URI to extract the info from
  43347. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  43348. * @returns The "folder" part of the path
  43349. */
  43350. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  43351. /**
  43352. * Extracts text content from a DOM element hierarchy
  43353. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  43354. */
  43355. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  43356. /**
  43357. * Convert an angle in radians to degrees
  43358. * @param angle defines the angle to convert
  43359. * @returns the angle in degrees
  43360. */
  43361. static ToDegrees(angle: number): number;
  43362. /**
  43363. * Convert an angle in degrees to radians
  43364. * @param angle defines the angle to convert
  43365. * @returns the angle in radians
  43366. */
  43367. static ToRadians(angle: number): number;
  43368. /**
  43369. * Returns an array if obj is not an array
  43370. * @param obj defines the object to evaluate as an array
  43371. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  43372. * @returns either obj directly if obj is an array or a new array containing obj
  43373. */
  43374. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  43375. /**
  43376. * Gets the pointer prefix to use
  43377. * @param engine defines the engine we are finding the prefix for
  43378. * @returns "pointer" if touch is enabled. Else returns "mouse"
  43379. */
  43380. static GetPointerPrefix(engine: Engine): string;
  43381. /**
  43382. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  43383. * @param url define the url we are trying
  43384. * @param element define the dom element where to configure the cors policy
  43385. */
  43386. static SetCorsBehavior(url: string | string[], element: {
  43387. crossOrigin: string | null;
  43388. }): void;
  43389. /**
  43390. * Removes unwanted characters from an url
  43391. * @param url defines the url to clean
  43392. * @returns the cleaned url
  43393. */
  43394. static CleanUrl(url: string): string;
  43395. /**
  43396. * Gets or sets a function used to pre-process url before using them to load assets
  43397. */
  43398. static get PreprocessUrl(): (url: string) => string;
  43399. static set PreprocessUrl(processor: (url: string) => string);
  43400. /**
  43401. * Loads an image as an HTMLImageElement.
  43402. * @param input url string, ArrayBuffer, or Blob to load
  43403. * @param onLoad callback called when the image successfully loads
  43404. * @param onError callback called when the image fails to load
  43405. * @param offlineProvider offline provider for caching
  43406. * @param mimeType optional mime type
  43407. * @returns the HTMLImageElement of the loaded image
  43408. */
  43409. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  43410. /**
  43411. * Loads a file from a url
  43412. * @param url url string, ArrayBuffer, or Blob to load
  43413. * @param onSuccess callback called when the file successfully loads
  43414. * @param onProgress callback called while file is loading (if the server supports this mode)
  43415. * @param offlineProvider defines the offline provider for caching
  43416. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43417. * @param onError callback called when the file fails to load
  43418. * @returns a file request object
  43419. */
  43420. 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;
  43421. /**
  43422. * Loads a file from a url
  43423. * @param url the file url to load
  43424. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43425. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  43426. */
  43427. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  43428. /**
  43429. * Load a script (identified by an url). When the url returns, the
  43430. * content of this file is added into a new script element, attached to the DOM (body element)
  43431. * @param scriptUrl defines the url of the script to laod
  43432. * @param onSuccess defines the callback called when the script is loaded
  43433. * @param onError defines the callback to call if an error occurs
  43434. * @param scriptId defines the id of the script element
  43435. */
  43436. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  43437. /**
  43438. * Load an asynchronous script (identified by an url). When the url returns, the
  43439. * content of this file is added into a new script element, attached to the DOM (body element)
  43440. * @param scriptUrl defines the url of the script to laod
  43441. * @param scriptId defines the id of the script element
  43442. * @returns a promise request object
  43443. */
  43444. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  43445. /**
  43446. * Loads a file from a blob
  43447. * @param fileToLoad defines the blob to use
  43448. * @param callback defines the callback to call when data is loaded
  43449. * @param progressCallback defines the callback to call during loading process
  43450. * @returns a file request object
  43451. */
  43452. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43453. /**
  43454. * Reads a file from a File object
  43455. * @param file defines the file to load
  43456. * @param onSuccess defines the callback to call when data is loaded
  43457. * @param onProgress defines the callback to call during loading process
  43458. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43459. * @param onError defines the callback to call when an error occurs
  43460. * @returns a file request object
  43461. */
  43462. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43463. /**
  43464. * Creates a data url from a given string content
  43465. * @param content defines the content to convert
  43466. * @returns the new data url link
  43467. */
  43468. static FileAsURL(content: string): string;
  43469. /**
  43470. * Format the given number to a specific decimal format
  43471. * @param value defines the number to format
  43472. * @param decimals defines the number of decimals to use
  43473. * @returns the formatted string
  43474. */
  43475. static Format(value: number, decimals?: number): string;
  43476. /**
  43477. * Tries to copy an object by duplicating every property
  43478. * @param source defines the source object
  43479. * @param destination defines the target object
  43480. * @param doNotCopyList defines a list of properties to avoid
  43481. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43482. */
  43483. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43484. /**
  43485. * Gets a boolean indicating if the given object has no own property
  43486. * @param obj defines the object to test
  43487. * @returns true if object has no own property
  43488. */
  43489. static IsEmpty(obj: any): boolean;
  43490. /**
  43491. * Function used to register events at window level
  43492. * @param windowElement defines the Window object to use
  43493. * @param events defines the events to register
  43494. */
  43495. static RegisterTopRootEvents(windowElement: Window, events: {
  43496. name: string;
  43497. handler: Nullable<(e: FocusEvent) => any>;
  43498. }[]): void;
  43499. /**
  43500. * Function used to unregister events from window level
  43501. * @param windowElement defines the Window object to use
  43502. * @param events defines the events to unregister
  43503. */
  43504. static UnregisterTopRootEvents(windowElement: Window, events: {
  43505. name: string;
  43506. handler: Nullable<(e: FocusEvent) => any>;
  43507. }[]): void;
  43508. /**
  43509. * @ignore
  43510. */
  43511. static _ScreenshotCanvas: HTMLCanvasElement;
  43512. /**
  43513. * Dumps the current bound framebuffer
  43514. * @param width defines the rendering width
  43515. * @param height defines the rendering height
  43516. * @param engine defines the hosting engine
  43517. * @param successCallback defines the callback triggered once the data are available
  43518. * @param mimeType defines the mime type of the result
  43519. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43520. */
  43521. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43522. /**
  43523. * Converts the canvas data to blob.
  43524. * This acts as a polyfill for browsers not supporting the to blob function.
  43525. * @param canvas Defines the canvas to extract the data from
  43526. * @param successCallback Defines the callback triggered once the data are available
  43527. * @param mimeType Defines the mime type of the result
  43528. */
  43529. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43530. /**
  43531. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43532. * @param successCallback defines the callback triggered once the data are available
  43533. * @param mimeType defines the mime type of the result
  43534. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43535. */
  43536. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43537. /**
  43538. * Downloads a blob in the browser
  43539. * @param blob defines the blob to download
  43540. * @param fileName defines the name of the downloaded file
  43541. */
  43542. static Download(blob: Blob, fileName: string): void;
  43543. /**
  43544. * Will return the right value of the noPreventDefault variable
  43545. * Needed to keep backwards compatibility to the old API.
  43546. *
  43547. * @param args arguments passed to the attachControl function
  43548. * @returns the correct value for noPreventDefault
  43549. */
  43550. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43551. /**
  43552. * Captures a screenshot of the current rendering
  43553. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43554. * @param engine defines the rendering engine
  43555. * @param camera defines the source camera
  43556. * @param size This parameter can be set to a single number or to an object with the
  43557. * following (optional) properties: precision, width, height. If a single number is passed,
  43558. * it will be used for both width and height. If an object is passed, the screenshot size
  43559. * will be derived from the parameters. The precision property is a multiplier allowing
  43560. * rendering at a higher or lower resolution
  43561. * @param successCallback defines the callback receives a single parameter which contains the
  43562. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43563. * src parameter of an <img> to display it
  43564. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43565. * Check your browser for supported MIME types
  43566. */
  43567. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43568. /**
  43569. * Captures a screenshot of the current rendering
  43570. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43571. * @param engine defines the rendering engine
  43572. * @param camera defines the source camera
  43573. * @param size This parameter can be set to a single number or to an object with the
  43574. * following (optional) properties: precision, width, height. If a single number is passed,
  43575. * it will be used for both width and height. If an object is passed, the screenshot size
  43576. * will be derived from the parameters. The precision property is a multiplier allowing
  43577. * rendering at a higher or lower resolution
  43578. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43579. * Check your browser for supported MIME types
  43580. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43581. * to the src parameter of an <img> to display it
  43582. */
  43583. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43584. /**
  43585. * Generates an image screenshot from the specified camera.
  43586. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43587. * @param engine The engine to use for rendering
  43588. * @param camera The camera to use for rendering
  43589. * @param size This parameter can be set to a single number or to an object with the
  43590. * following (optional) properties: precision, width, height. If a single number is passed,
  43591. * it will be used for both width and height. If an object is passed, the screenshot size
  43592. * will be derived from the parameters. The precision property is a multiplier allowing
  43593. * rendering at a higher or lower resolution
  43594. * @param successCallback The callback receives a single parameter which contains the
  43595. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43596. * src parameter of an <img> to display it
  43597. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43598. * Check your browser for supported MIME types
  43599. * @param samples Texture samples (default: 1)
  43600. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43601. * @param fileName A name for for the downloaded file.
  43602. */
  43603. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43604. /**
  43605. * Generates an image screenshot from the specified camera.
  43606. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43607. * @param engine The engine to use for rendering
  43608. * @param camera The camera to use for rendering
  43609. * @param size This parameter can be set to a single number or to an object with the
  43610. * following (optional) properties: precision, width, height. If a single number is passed,
  43611. * it will be used for both width and height. If an object is passed, the screenshot size
  43612. * will be derived from the parameters. The precision property is a multiplier allowing
  43613. * rendering at a higher or lower resolution
  43614. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43615. * Check your browser for supported MIME types
  43616. * @param samples Texture samples (default: 1)
  43617. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43618. * @param fileName A name for for the downloaded file.
  43619. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43620. * to the src parameter of an <img> to display it
  43621. */
  43622. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43623. /**
  43624. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43625. * Be aware Math.random() could cause collisions, but:
  43626. * "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"
  43627. * @returns a pseudo random id
  43628. */
  43629. static RandomId(): string;
  43630. /**
  43631. * Test if the given uri is a base64 string
  43632. * @param uri The uri to test
  43633. * @return True if the uri is a base64 string or false otherwise
  43634. */
  43635. static IsBase64(uri: string): boolean;
  43636. /**
  43637. * Decode the given base64 uri.
  43638. * @param uri The uri to decode
  43639. * @return The decoded base64 data.
  43640. */
  43641. static DecodeBase64(uri: string): ArrayBuffer;
  43642. /**
  43643. * Gets the absolute url.
  43644. * @param url the input url
  43645. * @return the absolute url
  43646. */
  43647. static GetAbsoluteUrl(url: string): string;
  43648. /**
  43649. * No log
  43650. */
  43651. static readonly NoneLogLevel: number;
  43652. /**
  43653. * Only message logs
  43654. */
  43655. static readonly MessageLogLevel: number;
  43656. /**
  43657. * Only warning logs
  43658. */
  43659. static readonly WarningLogLevel: number;
  43660. /**
  43661. * Only error logs
  43662. */
  43663. static readonly ErrorLogLevel: number;
  43664. /**
  43665. * All logs
  43666. */
  43667. static readonly AllLogLevel: number;
  43668. /**
  43669. * Gets a value indicating the number of loading errors
  43670. * @ignorenaming
  43671. */
  43672. static get errorsCount(): number;
  43673. /**
  43674. * Callback called when a new log is added
  43675. */
  43676. static OnNewCacheEntry: (entry: string) => void;
  43677. /**
  43678. * Log a message to the console
  43679. * @param message defines the message to log
  43680. */
  43681. static Log(message: string): void;
  43682. /**
  43683. * Write a warning message to the console
  43684. * @param message defines the message to log
  43685. */
  43686. static Warn(message: string): void;
  43687. /**
  43688. * Write an error message to the console
  43689. * @param message defines the message to log
  43690. */
  43691. static Error(message: string): void;
  43692. /**
  43693. * Gets current log cache (list of logs)
  43694. */
  43695. static get LogCache(): string;
  43696. /**
  43697. * Clears the log cache
  43698. */
  43699. static ClearLogCache(): void;
  43700. /**
  43701. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43702. */
  43703. static set LogLevels(level: number);
  43704. /**
  43705. * Checks if the window object exists
  43706. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43707. */
  43708. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43709. /**
  43710. * No performance log
  43711. */
  43712. static readonly PerformanceNoneLogLevel: number;
  43713. /**
  43714. * Use user marks to log performance
  43715. */
  43716. static readonly PerformanceUserMarkLogLevel: number;
  43717. /**
  43718. * Log performance to the console
  43719. */
  43720. static readonly PerformanceConsoleLogLevel: number;
  43721. private static _performance;
  43722. /**
  43723. * Sets the current performance log level
  43724. */
  43725. static set PerformanceLogLevel(level: number);
  43726. private static _StartPerformanceCounterDisabled;
  43727. private static _EndPerformanceCounterDisabled;
  43728. private static _StartUserMark;
  43729. private static _EndUserMark;
  43730. private static _StartPerformanceConsole;
  43731. private static _EndPerformanceConsole;
  43732. /**
  43733. * Starts a performance counter
  43734. */
  43735. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43736. /**
  43737. * Ends a specific performance coutner
  43738. */
  43739. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43740. /**
  43741. * Gets either window.performance.now() if supported or Date.now() else
  43742. */
  43743. static get Now(): number;
  43744. /**
  43745. * This method will return the name of the class used to create the instance of the given object.
  43746. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43747. * @param object the object to get the class name from
  43748. * @param isType defines if the object is actually a type
  43749. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43750. */
  43751. static GetClassName(object: any, isType?: boolean): string;
  43752. /**
  43753. * Gets the first element of an array satisfying a given predicate
  43754. * @param array defines the array to browse
  43755. * @param predicate defines the predicate to use
  43756. * @returns null if not found or the element
  43757. */
  43758. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43759. /**
  43760. * This method will return the name of the full name of the class, including its owning module (if any).
  43761. * 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).
  43762. * @param object the object to get the class name from
  43763. * @param isType defines if the object is actually a type
  43764. * @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.
  43765. * @ignorenaming
  43766. */
  43767. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43768. /**
  43769. * Returns a promise that resolves after the given amount of time.
  43770. * @param delay Number of milliseconds to delay
  43771. * @returns Promise that resolves after the given amount of time
  43772. */
  43773. static DelayAsync(delay: number): Promise<void>;
  43774. /**
  43775. * Utility function to detect if the current user agent is Safari
  43776. * @returns whether or not the current user agent is safari
  43777. */
  43778. static IsSafari(): boolean;
  43779. }
  43780. /**
  43781. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43782. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43783. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43784. * @param name The name of the class, case should be preserved
  43785. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43786. */
  43787. export function className(name: string, module?: string): (target: Object) => void;
  43788. /**
  43789. * An implementation of a loop for asynchronous functions.
  43790. */
  43791. export class AsyncLoop {
  43792. /**
  43793. * Defines the number of iterations for the loop
  43794. */
  43795. iterations: number;
  43796. /**
  43797. * Defines the current index of the loop.
  43798. */
  43799. index: number;
  43800. private _done;
  43801. private _fn;
  43802. private _successCallback;
  43803. /**
  43804. * Constructor.
  43805. * @param iterations the number of iterations.
  43806. * @param func the function to run each iteration
  43807. * @param successCallback the callback that will be called upon succesful execution
  43808. * @param offset starting offset.
  43809. */
  43810. constructor(
  43811. /**
  43812. * Defines the number of iterations for the loop
  43813. */
  43814. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43815. /**
  43816. * Execute the next iteration. Must be called after the last iteration was finished.
  43817. */
  43818. executeNext(): void;
  43819. /**
  43820. * Break the loop and run the success callback.
  43821. */
  43822. breakLoop(): void;
  43823. /**
  43824. * Create and run an async loop.
  43825. * @param iterations the number of iterations.
  43826. * @param fn the function to run each iteration
  43827. * @param successCallback the callback that will be called upon succesful execution
  43828. * @param offset starting offset.
  43829. * @returns the created async loop object
  43830. */
  43831. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43832. /**
  43833. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43834. * @param iterations total number of iterations
  43835. * @param syncedIterations number of synchronous iterations in each async iteration.
  43836. * @param fn the function to call each iteration.
  43837. * @param callback a success call back that will be called when iterating stops.
  43838. * @param breakFunction a break condition (optional)
  43839. * @param timeout timeout settings for the setTimeout function. default - 0.
  43840. * @returns the created async loop object
  43841. */
  43842. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43843. }
  43844. }
  43845. declare module "babylonjs/Misc/stringDictionary" {
  43846. import { Nullable } from "babylonjs/types";
  43847. /**
  43848. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43849. * The underlying implementation relies on an associative array to ensure the best performances.
  43850. * The value can be anything including 'null' but except 'undefined'
  43851. */
  43852. export class StringDictionary<T> {
  43853. /**
  43854. * This will clear this dictionary and copy the content from the 'source' one.
  43855. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43856. * @param source the dictionary to take the content from and copy to this dictionary
  43857. */
  43858. copyFrom(source: StringDictionary<T>): void;
  43859. /**
  43860. * Get a value based from its key
  43861. * @param key the given key to get the matching value from
  43862. * @return the value if found, otherwise undefined is returned
  43863. */
  43864. get(key: string): T | undefined;
  43865. /**
  43866. * Get a value from its key or add it if it doesn't exist.
  43867. * This method will ensure you that a given key/data will be present in the dictionary.
  43868. * @param key the given key to get the matching value from
  43869. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43870. * The factory will only be invoked if there's no data for the given key.
  43871. * @return the value corresponding to the key.
  43872. */
  43873. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43874. /**
  43875. * Get a value from its key if present in the dictionary otherwise add it
  43876. * @param key the key to get the value from
  43877. * @param val if there's no such key/value pair in the dictionary add it with this value
  43878. * @return the value corresponding to the key
  43879. */
  43880. getOrAdd(key: string, val: T): T;
  43881. /**
  43882. * Check if there's a given key in the dictionary
  43883. * @param key the key to check for
  43884. * @return true if the key is present, false otherwise
  43885. */
  43886. contains(key: string): boolean;
  43887. /**
  43888. * Add a new key and its corresponding value
  43889. * @param key the key to add
  43890. * @param value the value corresponding to the key
  43891. * @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
  43892. */
  43893. add(key: string, value: T): boolean;
  43894. /**
  43895. * Update a specific value associated to a key
  43896. * @param key defines the key to use
  43897. * @param value defines the value to store
  43898. * @returns true if the value was updated (or false if the key was not found)
  43899. */
  43900. set(key: string, value: T): boolean;
  43901. /**
  43902. * Get the element of the given key and remove it from the dictionary
  43903. * @param key defines the key to search
  43904. * @returns the value associated with the key or null if not found
  43905. */
  43906. getAndRemove(key: string): Nullable<T>;
  43907. /**
  43908. * Remove a key/value from the dictionary.
  43909. * @param key the key to remove
  43910. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43911. */
  43912. remove(key: string): boolean;
  43913. /**
  43914. * Clear the whole content of the dictionary
  43915. */
  43916. clear(): void;
  43917. /**
  43918. * Gets the current count
  43919. */
  43920. get count(): number;
  43921. /**
  43922. * Execute a callback on each key/val of the dictionary.
  43923. * Note that you can remove any element in this dictionary in the callback implementation
  43924. * @param callback the callback to execute on a given key/value pair
  43925. */
  43926. forEach(callback: (key: string, val: T) => void): void;
  43927. /**
  43928. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43929. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43930. * Note that you can remove any element in this dictionary in the callback implementation
  43931. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43932. * @returns the first item
  43933. */
  43934. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43935. private _count;
  43936. private _data;
  43937. }
  43938. }
  43939. declare module "babylonjs/Collisions/collisionCoordinator" {
  43940. import { Nullable } from "babylonjs/types";
  43941. import { Scene } from "babylonjs/scene";
  43942. import { Vector3 } from "babylonjs/Maths/math.vector";
  43943. import { Collider } from "babylonjs/Collisions/collider";
  43944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43945. /** @hidden */
  43946. export interface ICollisionCoordinator {
  43947. createCollider(): Collider;
  43948. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43949. init(scene: Scene): void;
  43950. }
  43951. /** @hidden */
  43952. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43953. private _scene;
  43954. private _scaledPosition;
  43955. private _scaledVelocity;
  43956. private _finalPosition;
  43957. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43958. createCollider(): Collider;
  43959. init(scene: Scene): void;
  43960. private _collideWithWorld;
  43961. }
  43962. }
  43963. declare module "babylonjs/Inputs/scene.inputManager" {
  43964. import { Nullable } from "babylonjs/types";
  43965. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43966. import { Vector2 } from "babylonjs/Maths/math.vector";
  43967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43968. import { Scene } from "babylonjs/scene";
  43969. /**
  43970. * Class used to manage all inputs for the scene.
  43971. */
  43972. export class InputManager {
  43973. /** The distance in pixel that you have to move to prevent some events */
  43974. static DragMovementThreshold: number;
  43975. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43976. static LongPressDelay: number;
  43977. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43978. static DoubleClickDelay: number;
  43979. /** If you need to check double click without raising a single click at first click, enable this flag */
  43980. static ExclusiveDoubleClickMode: boolean;
  43981. /** 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. */
  43982. private _alreadyAttached;
  43983. private _alreadyAttachedTo;
  43984. private _wheelEventName;
  43985. private _onPointerMove;
  43986. private _onPointerDown;
  43987. private _onPointerUp;
  43988. private _initClickEvent;
  43989. private _initActionManager;
  43990. private _delayedSimpleClick;
  43991. private _delayedSimpleClickTimeout;
  43992. private _previousDelayedSimpleClickTimeout;
  43993. private _meshPickProceed;
  43994. private _previousButtonPressed;
  43995. private _currentPickResult;
  43996. private _previousPickResult;
  43997. private _totalPointersPressed;
  43998. private _doubleClickOccured;
  43999. private _pointerOverMesh;
  44000. private _pickedDownMesh;
  44001. private _pickedUpMesh;
  44002. private _pointerX;
  44003. private _pointerY;
  44004. private _unTranslatedPointerX;
  44005. private _unTranslatedPointerY;
  44006. private _startingPointerPosition;
  44007. private _previousStartingPointerPosition;
  44008. private _startingPointerTime;
  44009. private _previousStartingPointerTime;
  44010. private _pointerCaptures;
  44011. private _meshUnderPointerId;
  44012. private _onKeyDown;
  44013. private _onKeyUp;
  44014. private _keyboardIsAttached;
  44015. private _onCanvasFocusObserver;
  44016. private _onCanvasBlurObserver;
  44017. private _scene;
  44018. /**
  44019. * Creates a new InputManager
  44020. * @param scene defines the hosting scene
  44021. */
  44022. constructor(scene: Scene);
  44023. /**
  44024. * Gets the mesh that is currently under the pointer
  44025. */
  44026. get meshUnderPointer(): Nullable<AbstractMesh>;
  44027. /**
  44028. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  44029. * @param pointerId the pointer id to use
  44030. * @returns The mesh under this pointer id or null if not found
  44031. */
  44032. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  44033. /**
  44034. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  44035. */
  44036. get unTranslatedPointer(): Vector2;
  44037. /**
  44038. * Gets or sets the current on-screen X position of the pointer
  44039. */
  44040. get pointerX(): number;
  44041. set pointerX(value: number);
  44042. /**
  44043. * Gets or sets the current on-screen Y position of the pointer
  44044. */
  44045. get pointerY(): number;
  44046. set pointerY(value: number);
  44047. private _updatePointerPosition;
  44048. private _processPointerMove;
  44049. private _setRayOnPointerInfo;
  44050. private _checkPrePointerObservable;
  44051. /**
  44052. * Use this method to simulate a pointer move on a mesh
  44053. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44054. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44055. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44056. */
  44057. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  44058. /**
  44059. * Use this method to simulate a pointer down on a mesh
  44060. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44061. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44062. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44063. */
  44064. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  44065. private _processPointerDown;
  44066. /** @hidden */
  44067. _isPointerSwiping(): boolean;
  44068. /**
  44069. * Use this method to simulate a pointer up on a mesh
  44070. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44071. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44072. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44073. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  44074. */
  44075. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  44076. private _processPointerUp;
  44077. /**
  44078. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  44079. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  44080. * @returns true if the pointer was captured
  44081. */
  44082. isPointerCaptured(pointerId?: number): boolean;
  44083. /**
  44084. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  44085. * @param attachUp defines if you want to attach events to pointerup
  44086. * @param attachDown defines if you want to attach events to pointerdown
  44087. * @param attachMove defines if you want to attach events to pointermove
  44088. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  44089. */
  44090. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  44091. /**
  44092. * Detaches all event handlers
  44093. */
  44094. detachControl(): void;
  44095. /**
  44096. * Force the value of meshUnderPointer
  44097. * @param mesh defines the mesh to use
  44098. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  44099. */
  44100. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44101. /**
  44102. * Gets the mesh under the pointer
  44103. * @returns a Mesh or null if no mesh is under the pointer
  44104. */
  44105. getPointerOverMesh(): Nullable<AbstractMesh>;
  44106. }
  44107. }
  44108. declare module "babylonjs/Animations/animationGroup" {
  44109. import { Animatable } from "babylonjs/Animations/animatable";
  44110. import { Animation } from "babylonjs/Animations/animation";
  44111. import { Scene, IDisposable } from "babylonjs/scene";
  44112. import { Observable } from "babylonjs/Misc/observable";
  44113. import { Nullable } from "babylonjs/types";
  44114. import "babylonjs/Animations/animatable";
  44115. /**
  44116. * This class defines the direct association between an animation and a target
  44117. */
  44118. export class TargetedAnimation {
  44119. /**
  44120. * Animation to perform
  44121. */
  44122. animation: Animation;
  44123. /**
  44124. * Target to animate
  44125. */
  44126. target: any;
  44127. /**
  44128. * Returns the string "TargetedAnimation"
  44129. * @returns "TargetedAnimation"
  44130. */
  44131. getClassName(): string;
  44132. /**
  44133. * Serialize the object
  44134. * @returns the JSON object representing the current entity
  44135. */
  44136. serialize(): any;
  44137. }
  44138. /**
  44139. * Use this class to create coordinated animations on multiple targets
  44140. */
  44141. export class AnimationGroup implements IDisposable {
  44142. /** The name of the animation group */
  44143. name: string;
  44144. private _scene;
  44145. private _targetedAnimations;
  44146. private _animatables;
  44147. private _from;
  44148. private _to;
  44149. private _isStarted;
  44150. private _isPaused;
  44151. private _speedRatio;
  44152. private _loopAnimation;
  44153. private _isAdditive;
  44154. /**
  44155. * Gets or sets the unique id of the node
  44156. */
  44157. uniqueId: number;
  44158. /**
  44159. * This observable will notify when one animation have ended
  44160. */
  44161. onAnimationEndObservable: Observable<TargetedAnimation>;
  44162. /**
  44163. * Observer raised when one animation loops
  44164. */
  44165. onAnimationLoopObservable: Observable<TargetedAnimation>;
  44166. /**
  44167. * Observer raised when all animations have looped
  44168. */
  44169. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  44170. /**
  44171. * This observable will notify when all animations have ended.
  44172. */
  44173. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  44174. /**
  44175. * This observable will notify when all animations have paused.
  44176. */
  44177. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  44178. /**
  44179. * This observable will notify when all animations are playing.
  44180. */
  44181. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  44182. /**
  44183. * Gets the first frame
  44184. */
  44185. get from(): number;
  44186. /**
  44187. * Gets the last frame
  44188. */
  44189. get to(): number;
  44190. /**
  44191. * Define if the animations are started
  44192. */
  44193. get isStarted(): boolean;
  44194. /**
  44195. * Gets a value indicating that the current group is playing
  44196. */
  44197. get isPlaying(): boolean;
  44198. /**
  44199. * Gets or sets the speed ratio to use for all animations
  44200. */
  44201. get speedRatio(): number;
  44202. /**
  44203. * Gets or sets the speed ratio to use for all animations
  44204. */
  44205. set speedRatio(value: number);
  44206. /**
  44207. * Gets or sets if all animations should loop or not
  44208. */
  44209. get loopAnimation(): boolean;
  44210. set loopAnimation(value: boolean);
  44211. /**
  44212. * Gets or sets if all animations should be evaluated additively
  44213. */
  44214. get isAdditive(): boolean;
  44215. set isAdditive(value: boolean);
  44216. /**
  44217. * Gets the targeted animations for this animation group
  44218. */
  44219. get targetedAnimations(): Array<TargetedAnimation>;
  44220. /**
  44221. * returning the list of animatables controlled by this animation group.
  44222. */
  44223. get animatables(): Array<Animatable>;
  44224. /**
  44225. * Gets the list of target animations
  44226. */
  44227. get children(): TargetedAnimation[];
  44228. /**
  44229. * Instantiates a new Animation Group.
  44230. * This helps managing several animations at once.
  44231. * @see https://doc.babylonjs.com/how_to/group
  44232. * @param name Defines the name of the group
  44233. * @param scene Defines the scene the group belongs to
  44234. */
  44235. constructor(
  44236. /** The name of the animation group */
  44237. name: string, scene?: Nullable<Scene>);
  44238. /**
  44239. * Add an animation (with its target) in the group
  44240. * @param animation defines the animation we want to add
  44241. * @param target defines the target of the animation
  44242. * @returns the TargetedAnimation object
  44243. */
  44244. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  44245. /**
  44246. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  44247. * It can add constant keys at begin or end
  44248. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  44249. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  44250. * @returns the animation group
  44251. */
  44252. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  44253. private _animationLoopCount;
  44254. private _animationLoopFlags;
  44255. private _processLoop;
  44256. /**
  44257. * Start all animations on given targets
  44258. * @param loop defines if animations must loop
  44259. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  44260. * @param from defines the from key (optional)
  44261. * @param to defines the to key (optional)
  44262. * @param isAdditive defines the additive state for the resulting animatables (optional)
  44263. * @returns the current animation group
  44264. */
  44265. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  44266. /**
  44267. * Pause all animations
  44268. * @returns the animation group
  44269. */
  44270. pause(): AnimationGroup;
  44271. /**
  44272. * Play all animations to initial state
  44273. * This function will start() the animations if they were not started or will restart() them if they were paused
  44274. * @param loop defines if animations must loop
  44275. * @returns the animation group
  44276. */
  44277. play(loop?: boolean): AnimationGroup;
  44278. /**
  44279. * Reset all animations to initial state
  44280. * @returns the animation group
  44281. */
  44282. reset(): AnimationGroup;
  44283. /**
  44284. * Restart animations from key 0
  44285. * @returns the animation group
  44286. */
  44287. restart(): AnimationGroup;
  44288. /**
  44289. * Stop all animations
  44290. * @returns the animation group
  44291. */
  44292. stop(): AnimationGroup;
  44293. /**
  44294. * Set animation weight for all animatables
  44295. * @param weight defines the weight to use
  44296. * @return the animationGroup
  44297. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44298. */
  44299. setWeightForAllAnimatables(weight: number): AnimationGroup;
  44300. /**
  44301. * Synchronize and normalize all animatables with a source animatable
  44302. * @param root defines the root animatable to synchronize with
  44303. * @return the animationGroup
  44304. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44305. */
  44306. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  44307. /**
  44308. * Goes to a specific frame in this animation group
  44309. * @param frame the frame number to go to
  44310. * @return the animationGroup
  44311. */
  44312. goToFrame(frame: number): AnimationGroup;
  44313. /**
  44314. * Dispose all associated resources
  44315. */
  44316. dispose(): void;
  44317. private _checkAnimationGroupEnded;
  44318. /**
  44319. * Clone the current animation group and returns a copy
  44320. * @param newName defines the name of the new group
  44321. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  44322. * @returns the new aniamtion group
  44323. */
  44324. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  44325. /**
  44326. * Serializes the animationGroup to an object
  44327. * @returns Serialized object
  44328. */
  44329. serialize(): any;
  44330. /**
  44331. * Returns a new AnimationGroup object parsed from the source provided.
  44332. * @param parsedAnimationGroup defines the source
  44333. * @param scene defines the scene that will receive the animationGroup
  44334. * @returns a new AnimationGroup
  44335. */
  44336. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  44337. /**
  44338. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  44339. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  44340. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  44341. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  44342. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  44343. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  44344. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  44345. */
  44346. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  44347. /**
  44348. * Returns the string "AnimationGroup"
  44349. * @returns "AnimationGroup"
  44350. */
  44351. getClassName(): string;
  44352. /**
  44353. * Creates a detailled string about the object
  44354. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  44355. * @returns a string representing the object
  44356. */
  44357. toString(fullDetails?: boolean): string;
  44358. }
  44359. }
  44360. declare module "babylonjs/scene" {
  44361. import { Nullable } from "babylonjs/types";
  44362. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  44363. import { Observable } from "babylonjs/Misc/observable";
  44364. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44365. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  44366. import { Geometry } from "babylonjs/Meshes/geometry";
  44367. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44368. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44370. import { Mesh } from "babylonjs/Meshes/mesh";
  44371. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44372. import { Bone } from "babylonjs/Bones/bone";
  44373. import { Skeleton } from "babylonjs/Bones/skeleton";
  44374. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  44375. import { Camera } from "babylonjs/Cameras/camera";
  44376. import { AbstractScene } from "babylonjs/abstractScene";
  44377. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44378. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44379. import { Material } from "babylonjs/Materials/material";
  44380. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44381. import { Effect } from "babylonjs/Materials/effect";
  44382. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44383. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  44384. import { Light } from "babylonjs/Lights/light";
  44385. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  44386. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  44387. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  44388. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  44389. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  44390. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  44391. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  44392. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, PreActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  44393. import { Engine } from "babylonjs/Engines/engine";
  44394. import { Node } from "babylonjs/node";
  44395. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  44396. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  44397. import { WebRequest } from "babylonjs/Misc/webRequest";
  44398. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  44399. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  44400. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44401. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  44402. import { Plane } from "babylonjs/Maths/math.plane";
  44403. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  44404. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  44405. import { Ray } from "babylonjs/Culling/ray";
  44406. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  44407. import { Animation } from "babylonjs/Animations/animation";
  44408. import { Animatable } from "babylonjs/Animations/animatable";
  44409. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44410. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  44411. import { Collider } from "babylonjs/Collisions/collider";
  44412. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  44413. /**
  44414. * Define an interface for all classes that will hold resources
  44415. */
  44416. export interface IDisposable {
  44417. /**
  44418. * Releases all held resources
  44419. */
  44420. dispose(): void;
  44421. }
  44422. /** Interface defining initialization parameters for Scene class */
  44423. export interface SceneOptions {
  44424. /**
  44425. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  44426. * It will improve performance when the number of geometries becomes important.
  44427. */
  44428. useGeometryUniqueIdsMap?: boolean;
  44429. /**
  44430. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  44431. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  44432. */
  44433. useMaterialMeshMap?: boolean;
  44434. /**
  44435. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  44436. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  44437. */
  44438. useClonedMeshMap?: boolean;
  44439. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  44440. virtual?: boolean;
  44441. }
  44442. /**
  44443. * Represents a scene to be rendered by the engine.
  44444. * @see https://doc.babylonjs.com/features/scene
  44445. */
  44446. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  44447. /** The fog is deactivated */
  44448. static readonly FOGMODE_NONE: number;
  44449. /** The fog density is following an exponential function */
  44450. static readonly FOGMODE_EXP: number;
  44451. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  44452. static readonly FOGMODE_EXP2: number;
  44453. /** The fog density is following a linear function. */
  44454. static readonly FOGMODE_LINEAR: number;
  44455. /**
  44456. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  44457. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44458. */
  44459. static MinDeltaTime: number;
  44460. /**
  44461. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  44462. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44463. */
  44464. static MaxDeltaTime: number;
  44465. /**
  44466. * Factory used to create the default material.
  44467. * @param name The name of the material to create
  44468. * @param scene The scene to create the material for
  44469. * @returns The default material
  44470. */
  44471. static DefaultMaterialFactory(scene: Scene): Material;
  44472. /**
  44473. * Factory used to create the a collision coordinator.
  44474. * @returns The collision coordinator
  44475. */
  44476. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  44477. /** @hidden */
  44478. _inputManager: InputManager;
  44479. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  44480. cameraToUseForPointers: Nullable<Camera>;
  44481. /** @hidden */
  44482. readonly _isScene: boolean;
  44483. /** @hidden */
  44484. _blockEntityCollection: boolean;
  44485. /**
  44486. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  44487. */
  44488. autoClear: boolean;
  44489. /**
  44490. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  44491. */
  44492. autoClearDepthAndStencil: boolean;
  44493. /**
  44494. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  44495. */
  44496. clearColor: Color4;
  44497. /**
  44498. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  44499. */
  44500. ambientColor: Color3;
  44501. /**
  44502. * This is use to store the default BRDF lookup for PBR materials in your scene.
  44503. * It should only be one of the following (if not the default embedded one):
  44504. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  44505. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  44506. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  44507. * The material properties need to be setup according to the type of texture in use.
  44508. */
  44509. environmentBRDFTexture: BaseTexture;
  44510. /**
  44511. * Texture used in all pbr material as the reflection texture.
  44512. * As in the majority of the scene they are the same (exception for multi room and so on),
  44513. * this is easier to reference from here than from all the materials.
  44514. */
  44515. get environmentTexture(): Nullable<BaseTexture>;
  44516. /**
  44517. * Texture used in all pbr material as the reflection texture.
  44518. * As in the majority of the scene they are the same (exception for multi room and so on),
  44519. * this is easier to set here than in all the materials.
  44520. */
  44521. set environmentTexture(value: Nullable<BaseTexture>);
  44522. /** @hidden */
  44523. protected _environmentIntensity: number;
  44524. /**
  44525. * Intensity of the environment in all pbr material.
  44526. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44527. * As in the majority of the scene they are the same (exception for multi room and so on),
  44528. * this is easier to reference from here than from all the materials.
  44529. */
  44530. get environmentIntensity(): number;
  44531. /**
  44532. * Intensity of the environment in all pbr material.
  44533. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44534. * As in the majority of the scene they are the same (exception for multi room and so on),
  44535. * this is easier to set here than in all the materials.
  44536. */
  44537. set environmentIntensity(value: number);
  44538. /** @hidden */
  44539. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44540. /**
  44541. * Default image processing configuration used either in the rendering
  44542. * Forward main pass or through the imageProcessingPostProcess if present.
  44543. * As in the majority of the scene they are the same (exception for multi camera),
  44544. * this is easier to reference from here than from all the materials and post process.
  44545. *
  44546. * No setter as we it is a shared configuration, you can set the values instead.
  44547. */
  44548. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44549. private _forceWireframe;
  44550. /**
  44551. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  44552. */
  44553. set forceWireframe(value: boolean);
  44554. get forceWireframe(): boolean;
  44555. private _skipFrustumClipping;
  44556. /**
  44557. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  44558. */
  44559. set skipFrustumClipping(value: boolean);
  44560. get skipFrustumClipping(): boolean;
  44561. private _forcePointsCloud;
  44562. /**
  44563. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  44564. */
  44565. set forcePointsCloud(value: boolean);
  44566. get forcePointsCloud(): boolean;
  44567. /**
  44568. * Gets or sets the active clipplane 1
  44569. */
  44570. clipPlane: Nullable<Plane>;
  44571. /**
  44572. * Gets or sets the active clipplane 2
  44573. */
  44574. clipPlane2: Nullable<Plane>;
  44575. /**
  44576. * Gets or sets the active clipplane 3
  44577. */
  44578. clipPlane3: Nullable<Plane>;
  44579. /**
  44580. * Gets or sets the active clipplane 4
  44581. */
  44582. clipPlane4: Nullable<Plane>;
  44583. /**
  44584. * Gets or sets the active clipplane 5
  44585. */
  44586. clipPlane5: Nullable<Plane>;
  44587. /**
  44588. * Gets or sets the active clipplane 6
  44589. */
  44590. clipPlane6: Nullable<Plane>;
  44591. /**
  44592. * Gets or sets a boolean indicating if animations are enabled
  44593. */
  44594. animationsEnabled: boolean;
  44595. private _animationPropertiesOverride;
  44596. /**
  44597. * Gets or sets the animation properties override
  44598. */
  44599. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  44600. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  44601. /**
  44602. * Gets or sets a boolean indicating if a constant deltatime has to be used
  44603. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  44604. */
  44605. useConstantAnimationDeltaTime: boolean;
  44606. /**
  44607. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  44608. * Please note that it requires to run a ray cast through the scene on every frame
  44609. */
  44610. constantlyUpdateMeshUnderPointer: boolean;
  44611. /**
  44612. * Defines the HTML cursor to use when hovering over interactive elements
  44613. */
  44614. hoverCursor: string;
  44615. /**
  44616. * Defines the HTML default cursor to use (empty by default)
  44617. */
  44618. defaultCursor: string;
  44619. /**
  44620. * Defines whether cursors are handled by the scene.
  44621. */
  44622. doNotHandleCursors: boolean;
  44623. /**
  44624. * This is used to call preventDefault() on pointer down
  44625. * in order to block unwanted artifacts like system double clicks
  44626. */
  44627. preventDefaultOnPointerDown: boolean;
  44628. /**
  44629. * This is used to call preventDefault() on pointer up
  44630. * in order to block unwanted artifacts like system double clicks
  44631. */
  44632. preventDefaultOnPointerUp: boolean;
  44633. /**
  44634. * Gets or sets user defined metadata
  44635. */
  44636. metadata: any;
  44637. /**
  44638. * For internal use only. Please do not use.
  44639. */
  44640. reservedDataStore: any;
  44641. /**
  44642. * Gets the name of the plugin used to load this scene (null by default)
  44643. */
  44644. loadingPluginName: string;
  44645. /**
  44646. * Use this array to add regular expressions used to disable offline support for specific urls
  44647. */
  44648. disableOfflineSupportExceptionRules: RegExp[];
  44649. /**
  44650. * An event triggered when the scene is disposed.
  44651. */
  44652. onDisposeObservable: Observable<Scene>;
  44653. private _onDisposeObserver;
  44654. /** Sets a function to be executed when this scene is disposed. */
  44655. set onDispose(callback: () => void);
  44656. /**
  44657. * An event triggered before rendering the scene (right after animations and physics)
  44658. */
  44659. onBeforeRenderObservable: Observable<Scene>;
  44660. private _onBeforeRenderObserver;
  44661. /** Sets a function to be executed before rendering this scene */
  44662. set beforeRender(callback: Nullable<() => void>);
  44663. /**
  44664. * An event triggered after rendering the scene
  44665. */
  44666. onAfterRenderObservable: Observable<Scene>;
  44667. /**
  44668. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  44669. */
  44670. onAfterRenderCameraObservable: Observable<Camera>;
  44671. private _onAfterRenderObserver;
  44672. /** Sets a function to be executed after rendering this scene */
  44673. set afterRender(callback: Nullable<() => void>);
  44674. /**
  44675. * An event triggered before animating the scene
  44676. */
  44677. onBeforeAnimationsObservable: Observable<Scene>;
  44678. /**
  44679. * An event triggered after animations processing
  44680. */
  44681. onAfterAnimationsObservable: Observable<Scene>;
  44682. /**
  44683. * An event triggered before draw calls are ready to be sent
  44684. */
  44685. onBeforeDrawPhaseObservable: Observable<Scene>;
  44686. /**
  44687. * An event triggered after draw calls have been sent
  44688. */
  44689. onAfterDrawPhaseObservable: Observable<Scene>;
  44690. /**
  44691. * An event triggered when the scene is ready
  44692. */
  44693. onReadyObservable: Observable<Scene>;
  44694. /**
  44695. * An event triggered before rendering a camera
  44696. */
  44697. onBeforeCameraRenderObservable: Observable<Camera>;
  44698. private _onBeforeCameraRenderObserver;
  44699. /** Sets a function to be executed before rendering a camera*/
  44700. set beforeCameraRender(callback: () => void);
  44701. /**
  44702. * An event triggered after rendering a camera
  44703. */
  44704. onAfterCameraRenderObservable: Observable<Camera>;
  44705. private _onAfterCameraRenderObserver;
  44706. /** Sets a function to be executed after rendering a camera*/
  44707. set afterCameraRender(callback: () => void);
  44708. /**
  44709. * An event triggered when active meshes evaluation is about to start
  44710. */
  44711. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  44712. /**
  44713. * An event triggered when active meshes evaluation is done
  44714. */
  44715. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  44716. /**
  44717. * An event triggered when particles rendering is about to start
  44718. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44719. */
  44720. onBeforeParticlesRenderingObservable: Observable<Scene>;
  44721. /**
  44722. * An event triggered when particles rendering is done
  44723. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44724. */
  44725. onAfterParticlesRenderingObservable: Observable<Scene>;
  44726. /**
  44727. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  44728. */
  44729. onDataLoadedObservable: Observable<Scene>;
  44730. /**
  44731. * An event triggered when a camera is created
  44732. */
  44733. onNewCameraAddedObservable: Observable<Camera>;
  44734. /**
  44735. * An event triggered when a camera is removed
  44736. */
  44737. onCameraRemovedObservable: Observable<Camera>;
  44738. /**
  44739. * An event triggered when a light is created
  44740. */
  44741. onNewLightAddedObservable: Observable<Light>;
  44742. /**
  44743. * An event triggered when a light is removed
  44744. */
  44745. onLightRemovedObservable: Observable<Light>;
  44746. /**
  44747. * An event triggered when a geometry is created
  44748. */
  44749. onNewGeometryAddedObservable: Observable<Geometry>;
  44750. /**
  44751. * An event triggered when a geometry is removed
  44752. */
  44753. onGeometryRemovedObservable: Observable<Geometry>;
  44754. /**
  44755. * An event triggered when a transform node is created
  44756. */
  44757. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  44758. /**
  44759. * An event triggered when a transform node is removed
  44760. */
  44761. onTransformNodeRemovedObservable: Observable<TransformNode>;
  44762. /**
  44763. * An event triggered when a mesh is created
  44764. */
  44765. onNewMeshAddedObservable: Observable<AbstractMesh>;
  44766. /**
  44767. * An event triggered when a mesh is removed
  44768. */
  44769. onMeshRemovedObservable: Observable<AbstractMesh>;
  44770. /**
  44771. * An event triggered when a skeleton is created
  44772. */
  44773. onNewSkeletonAddedObservable: Observable<Skeleton>;
  44774. /**
  44775. * An event triggered when a skeleton is removed
  44776. */
  44777. onSkeletonRemovedObservable: Observable<Skeleton>;
  44778. /**
  44779. * An event triggered when a material is created
  44780. */
  44781. onNewMaterialAddedObservable: Observable<Material>;
  44782. /**
  44783. * An event triggered when a multi material is created
  44784. */
  44785. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  44786. /**
  44787. * An event triggered when a material is removed
  44788. */
  44789. onMaterialRemovedObservable: Observable<Material>;
  44790. /**
  44791. * An event triggered when a multi material is removed
  44792. */
  44793. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  44794. /**
  44795. * An event triggered when a texture is created
  44796. */
  44797. onNewTextureAddedObservable: Observable<BaseTexture>;
  44798. /**
  44799. * An event triggered when a texture is removed
  44800. */
  44801. onTextureRemovedObservable: Observable<BaseTexture>;
  44802. /**
  44803. * An event triggered when render targets are about to be rendered
  44804. * Can happen multiple times per frame.
  44805. */
  44806. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  44807. /**
  44808. * An event triggered when render targets were rendered.
  44809. * Can happen multiple times per frame.
  44810. */
  44811. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  44812. /**
  44813. * An event triggered before calculating deterministic simulation step
  44814. */
  44815. onBeforeStepObservable: Observable<Scene>;
  44816. /**
  44817. * An event triggered after calculating deterministic simulation step
  44818. */
  44819. onAfterStepObservable: Observable<Scene>;
  44820. /**
  44821. * An event triggered when the activeCamera property is updated
  44822. */
  44823. onActiveCameraChanged: Observable<Scene>;
  44824. /**
  44825. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  44826. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44827. * 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)
  44828. */
  44829. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44830. /**
  44831. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  44832. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44833. * 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)
  44834. */
  44835. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44836. /**
  44837. * This Observable will when a mesh has been imported into the scene.
  44838. */
  44839. onMeshImportedObservable: Observable<AbstractMesh>;
  44840. /**
  44841. * This Observable will when an animation file has been imported into the scene.
  44842. */
  44843. onAnimationFileImportedObservable: Observable<Scene>;
  44844. /**
  44845. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  44846. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  44847. */
  44848. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  44849. /** @hidden */
  44850. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  44851. /**
  44852. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  44853. */
  44854. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  44855. /**
  44856. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  44857. */
  44858. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  44859. /**
  44860. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  44861. */
  44862. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  44863. /** Callback called when a pointer move is detected */
  44864. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44865. /** Callback called when a pointer down is detected */
  44866. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44867. /** Callback called when a pointer up is detected */
  44868. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  44869. /** Callback called when a pointer pick is detected */
  44870. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  44871. /**
  44872. * 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).
  44873. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  44874. */
  44875. onPrePointerObservable: Observable<PointerInfoPre>;
  44876. /**
  44877. * Observable event triggered each time an input event is received from the rendering canvas
  44878. */
  44879. onPointerObservable: Observable<PointerInfo>;
  44880. /**
  44881. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  44882. */
  44883. get unTranslatedPointer(): Vector2;
  44884. /**
  44885. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  44886. */
  44887. static get DragMovementThreshold(): number;
  44888. static set DragMovementThreshold(value: number);
  44889. /**
  44890. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  44891. */
  44892. static get LongPressDelay(): number;
  44893. static set LongPressDelay(value: number);
  44894. /**
  44895. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  44896. */
  44897. static get DoubleClickDelay(): number;
  44898. static set DoubleClickDelay(value: number);
  44899. /** If you need to check double click without raising a single click at first click, enable this flag */
  44900. static get ExclusiveDoubleClickMode(): boolean;
  44901. static set ExclusiveDoubleClickMode(value: boolean);
  44902. /** @hidden */
  44903. _mirroredCameraPosition: Nullable<Vector3>;
  44904. /**
  44905. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  44906. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  44907. */
  44908. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  44909. /**
  44910. * Observable event triggered each time an keyboard event is received from the hosting window
  44911. */
  44912. onKeyboardObservable: Observable<KeyboardInfo>;
  44913. private _useRightHandedSystem;
  44914. /**
  44915. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  44916. */
  44917. set useRightHandedSystem(value: boolean);
  44918. get useRightHandedSystem(): boolean;
  44919. private _timeAccumulator;
  44920. private _currentStepId;
  44921. private _currentInternalStep;
  44922. /**
  44923. * Sets the step Id used by deterministic lock step
  44924. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44925. * @param newStepId defines the step Id
  44926. */
  44927. setStepId(newStepId: number): void;
  44928. /**
  44929. * Gets the step Id used by deterministic lock step
  44930. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44931. * @returns the step Id
  44932. */
  44933. getStepId(): number;
  44934. /**
  44935. * Gets the internal step used by deterministic lock step
  44936. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44937. * @returns the internal step
  44938. */
  44939. getInternalStep(): number;
  44940. private _fogEnabled;
  44941. /**
  44942. * Gets or sets a boolean indicating if fog is enabled on this scene
  44943. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44944. * (Default is true)
  44945. */
  44946. set fogEnabled(value: boolean);
  44947. get fogEnabled(): boolean;
  44948. private _fogMode;
  44949. /**
  44950. * Gets or sets the fog mode to use
  44951. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44952. * | mode | value |
  44953. * | --- | --- |
  44954. * | FOGMODE_NONE | 0 |
  44955. * | FOGMODE_EXP | 1 |
  44956. * | FOGMODE_EXP2 | 2 |
  44957. * | FOGMODE_LINEAR | 3 |
  44958. */
  44959. set fogMode(value: number);
  44960. get fogMode(): number;
  44961. /**
  44962. * Gets or sets the fog color to use
  44963. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44964. * (Default is Color3(0.2, 0.2, 0.3))
  44965. */
  44966. fogColor: Color3;
  44967. /**
  44968. * Gets or sets the fog density to use
  44969. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44970. * (Default is 0.1)
  44971. */
  44972. fogDensity: number;
  44973. /**
  44974. * Gets or sets the fog start distance to use
  44975. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44976. * (Default is 0)
  44977. */
  44978. fogStart: number;
  44979. /**
  44980. * Gets or sets the fog end distance to use
  44981. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44982. * (Default is 1000)
  44983. */
  44984. fogEnd: number;
  44985. /**
  44986. * Flag indicating that the frame buffer binding is handled by another component
  44987. */
  44988. prePass: boolean;
  44989. private _shadowsEnabled;
  44990. /**
  44991. * Gets or sets a boolean indicating if shadows are enabled on this scene
  44992. */
  44993. set shadowsEnabled(value: boolean);
  44994. get shadowsEnabled(): boolean;
  44995. private _lightsEnabled;
  44996. /**
  44997. * Gets or sets a boolean indicating if lights are enabled on this scene
  44998. */
  44999. set lightsEnabled(value: boolean);
  45000. get lightsEnabled(): boolean;
  45001. /** All of the active cameras added to this scene. */
  45002. activeCameras: Camera[];
  45003. /** @hidden */
  45004. _activeCamera: Nullable<Camera>;
  45005. /** Gets or sets the current active camera */
  45006. get activeCamera(): Nullable<Camera>;
  45007. set activeCamera(value: Nullable<Camera>);
  45008. private _defaultMaterial;
  45009. /** The default material used on meshes when no material is affected */
  45010. get defaultMaterial(): Material;
  45011. /** The default material used on meshes when no material is affected */
  45012. set defaultMaterial(value: Material);
  45013. private _texturesEnabled;
  45014. /**
  45015. * Gets or sets a boolean indicating if textures are enabled on this scene
  45016. */
  45017. set texturesEnabled(value: boolean);
  45018. get texturesEnabled(): boolean;
  45019. /**
  45020. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  45021. */
  45022. physicsEnabled: boolean;
  45023. /**
  45024. * Gets or sets a boolean indicating if particles are enabled on this scene
  45025. */
  45026. particlesEnabled: boolean;
  45027. /**
  45028. * Gets or sets a boolean indicating if sprites are enabled on this scene
  45029. */
  45030. spritesEnabled: boolean;
  45031. private _skeletonsEnabled;
  45032. /**
  45033. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  45034. */
  45035. set skeletonsEnabled(value: boolean);
  45036. get skeletonsEnabled(): boolean;
  45037. /**
  45038. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  45039. */
  45040. lensFlaresEnabled: boolean;
  45041. /**
  45042. * Gets or sets a boolean indicating if collisions are enabled on this scene
  45043. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  45044. */
  45045. collisionsEnabled: boolean;
  45046. private _collisionCoordinator;
  45047. /** @hidden */
  45048. get collisionCoordinator(): ICollisionCoordinator;
  45049. /**
  45050. * Defines the gravity applied to this scene (used only for collisions)
  45051. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  45052. */
  45053. gravity: Vector3;
  45054. /**
  45055. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  45056. */
  45057. postProcessesEnabled: boolean;
  45058. /**
  45059. * Gets the current postprocess manager
  45060. */
  45061. postProcessManager: PostProcessManager;
  45062. /**
  45063. * Gets or sets a boolean indicating if render targets are enabled on this scene
  45064. */
  45065. renderTargetsEnabled: boolean;
  45066. /**
  45067. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  45068. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  45069. */
  45070. dumpNextRenderTargets: boolean;
  45071. /**
  45072. * The list of user defined render targets added to the scene
  45073. */
  45074. customRenderTargets: RenderTargetTexture[];
  45075. /**
  45076. * Defines if texture loading must be delayed
  45077. * If true, textures will only be loaded when they need to be rendered
  45078. */
  45079. useDelayedTextureLoading: boolean;
  45080. /**
  45081. * Gets the list of meshes imported to the scene through SceneLoader
  45082. */
  45083. importedMeshesFiles: String[];
  45084. /**
  45085. * Gets or sets a boolean indicating if probes are enabled on this scene
  45086. */
  45087. probesEnabled: boolean;
  45088. /**
  45089. * Gets or sets the current offline provider to use to store scene data
  45090. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  45091. */
  45092. offlineProvider: IOfflineProvider;
  45093. /**
  45094. * Gets or sets the action manager associated with the scene
  45095. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45096. */
  45097. actionManager: AbstractActionManager;
  45098. private _meshesForIntersections;
  45099. /**
  45100. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  45101. */
  45102. proceduralTexturesEnabled: boolean;
  45103. private _engine;
  45104. private _totalVertices;
  45105. /** @hidden */
  45106. _activeIndices: PerfCounter;
  45107. /** @hidden */
  45108. _activeParticles: PerfCounter;
  45109. /** @hidden */
  45110. _activeBones: PerfCounter;
  45111. private _animationRatio;
  45112. /** @hidden */
  45113. _animationTimeLast: number;
  45114. /** @hidden */
  45115. _animationTime: number;
  45116. /**
  45117. * Gets or sets a general scale for animation speed
  45118. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  45119. */
  45120. animationTimeScale: number;
  45121. /** @hidden */
  45122. _cachedMaterial: Nullable<Material>;
  45123. /** @hidden */
  45124. _cachedEffect: Nullable<Effect>;
  45125. /** @hidden */
  45126. _cachedVisibility: Nullable<number>;
  45127. private _renderId;
  45128. private _frameId;
  45129. private _executeWhenReadyTimeoutId;
  45130. private _intermediateRendering;
  45131. private _viewUpdateFlag;
  45132. private _projectionUpdateFlag;
  45133. /** @hidden */
  45134. _toBeDisposed: Nullable<IDisposable>[];
  45135. private _activeRequests;
  45136. /** @hidden */
  45137. _pendingData: any[];
  45138. private _isDisposed;
  45139. /**
  45140. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  45141. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  45142. */
  45143. dispatchAllSubMeshesOfActiveMeshes: boolean;
  45144. private _activeMeshes;
  45145. private _processedMaterials;
  45146. private _renderTargets;
  45147. /** @hidden */
  45148. _activeParticleSystems: SmartArray<IParticleSystem>;
  45149. private _activeSkeletons;
  45150. private _softwareSkinnedMeshes;
  45151. private _renderingManager;
  45152. /** @hidden */
  45153. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  45154. private _transformMatrix;
  45155. private _sceneUbo;
  45156. /** @hidden */
  45157. _viewMatrix: Matrix;
  45158. private _projectionMatrix;
  45159. /** @hidden */
  45160. _forcedViewPosition: Nullable<Vector3>;
  45161. /** @hidden */
  45162. _frustumPlanes: Plane[];
  45163. /**
  45164. * Gets the list of frustum planes (built from the active camera)
  45165. */
  45166. get frustumPlanes(): Plane[];
  45167. /**
  45168. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  45169. * This is useful if there are more lights that the maximum simulteanous authorized
  45170. */
  45171. requireLightSorting: boolean;
  45172. /** @hidden */
  45173. readonly useMaterialMeshMap: boolean;
  45174. /** @hidden */
  45175. readonly useClonedMeshMap: boolean;
  45176. private _externalData;
  45177. private _uid;
  45178. /**
  45179. * @hidden
  45180. * Backing store of defined scene components.
  45181. */
  45182. _components: ISceneComponent[];
  45183. /**
  45184. * @hidden
  45185. * Backing store of defined scene components.
  45186. */
  45187. _serializableComponents: ISceneSerializableComponent[];
  45188. /**
  45189. * List of components to register on the next registration step.
  45190. */
  45191. private _transientComponents;
  45192. /**
  45193. * Registers the transient components if needed.
  45194. */
  45195. private _registerTransientComponents;
  45196. /**
  45197. * @hidden
  45198. * Add a component to the scene.
  45199. * Note that the ccomponent could be registered on th next frame if this is called after
  45200. * the register component stage.
  45201. * @param component Defines the component to add to the scene
  45202. */
  45203. _addComponent(component: ISceneComponent): void;
  45204. /**
  45205. * @hidden
  45206. * Gets a component from the scene.
  45207. * @param name defines the name of the component to retrieve
  45208. * @returns the component or null if not present
  45209. */
  45210. _getComponent(name: string): Nullable<ISceneComponent>;
  45211. /**
  45212. * @hidden
  45213. * Defines the actions happening before camera updates.
  45214. */
  45215. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  45216. /**
  45217. * @hidden
  45218. * Defines the actions happening before clear the canvas.
  45219. */
  45220. _beforeClearStage: Stage<SimpleStageAction>;
  45221. /**
  45222. * @hidden
  45223. * Defines the actions when collecting render targets for the frame.
  45224. */
  45225. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  45226. /**
  45227. * @hidden
  45228. * Defines the actions happening for one camera in the frame.
  45229. */
  45230. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  45231. /**
  45232. * @hidden
  45233. * Defines the actions happening during the per mesh ready checks.
  45234. */
  45235. _isReadyForMeshStage: Stage<MeshStageAction>;
  45236. /**
  45237. * @hidden
  45238. * Defines the actions happening before evaluate active mesh checks.
  45239. */
  45240. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  45241. /**
  45242. * @hidden
  45243. * Defines the actions happening during the evaluate sub mesh checks.
  45244. */
  45245. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  45246. /**
  45247. * @hidden
  45248. * Defines the actions happening during the active mesh stage.
  45249. */
  45250. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  45251. /**
  45252. * @hidden
  45253. * Defines the actions happening during the per camera render target step.
  45254. */
  45255. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  45256. /**
  45257. * @hidden
  45258. * Defines the actions happening just before the active camera is drawing.
  45259. */
  45260. _beforeCameraDrawStage: Stage<CameraStageAction>;
  45261. /**
  45262. * @hidden
  45263. * Defines the actions happening just before a render target is drawing.
  45264. */
  45265. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  45266. /**
  45267. * @hidden
  45268. * Defines the actions happening just before a rendering group is drawing.
  45269. */
  45270. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  45271. /**
  45272. * @hidden
  45273. * Defines the actions happening just before a mesh is drawing.
  45274. */
  45275. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  45276. /**
  45277. * @hidden
  45278. * Defines the actions happening just after a mesh has been drawn.
  45279. */
  45280. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  45281. /**
  45282. * @hidden
  45283. * Defines the actions happening just after a rendering group has been drawn.
  45284. */
  45285. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  45286. /**
  45287. * @hidden
  45288. * Defines the actions happening just after the active camera has been drawn.
  45289. */
  45290. _afterCameraDrawStage: Stage<CameraStageAction>;
  45291. /**
  45292. * @hidden
  45293. * Defines the actions happening just after a render target has been drawn.
  45294. */
  45295. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  45296. /**
  45297. * @hidden
  45298. * Defines the actions happening just after rendering all cameras and computing intersections.
  45299. */
  45300. _afterRenderStage: Stage<SimpleStageAction>;
  45301. /**
  45302. * @hidden
  45303. * Defines the actions happening when a pointer move event happens.
  45304. */
  45305. _pointerMoveStage: Stage<PointerMoveStageAction>;
  45306. /**
  45307. * @hidden
  45308. * Defines the actions happening when a pointer down event happens.
  45309. */
  45310. _pointerDownStage: Stage<PointerUpDownStageAction>;
  45311. /**
  45312. * @hidden
  45313. * Defines the actions happening when a pointer up event happens.
  45314. */
  45315. _pointerUpStage: Stage<PointerUpDownStageAction>;
  45316. /**
  45317. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  45318. */
  45319. private geometriesByUniqueId;
  45320. /**
  45321. * Creates a new Scene
  45322. * @param engine defines the engine to use to render this scene
  45323. * @param options defines the scene options
  45324. */
  45325. constructor(engine: Engine, options?: SceneOptions);
  45326. /**
  45327. * Gets a string identifying the name of the class
  45328. * @returns "Scene" string
  45329. */
  45330. getClassName(): string;
  45331. private _defaultMeshCandidates;
  45332. /**
  45333. * @hidden
  45334. */
  45335. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45336. private _defaultSubMeshCandidates;
  45337. /**
  45338. * @hidden
  45339. */
  45340. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45341. /**
  45342. * Sets the default candidate providers for the scene.
  45343. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  45344. * and getCollidingSubMeshCandidates to their default function
  45345. */
  45346. setDefaultCandidateProviders(): void;
  45347. /**
  45348. * Gets the mesh that is currently under the pointer
  45349. */
  45350. get meshUnderPointer(): Nullable<AbstractMesh>;
  45351. /**
  45352. * Gets or sets the current on-screen X position of the pointer
  45353. */
  45354. get pointerX(): number;
  45355. set pointerX(value: number);
  45356. /**
  45357. * Gets or sets the current on-screen Y position of the pointer
  45358. */
  45359. get pointerY(): number;
  45360. set pointerY(value: number);
  45361. /**
  45362. * Gets the cached material (ie. the latest rendered one)
  45363. * @returns the cached material
  45364. */
  45365. getCachedMaterial(): Nullable<Material>;
  45366. /**
  45367. * Gets the cached effect (ie. the latest rendered one)
  45368. * @returns the cached effect
  45369. */
  45370. getCachedEffect(): Nullable<Effect>;
  45371. /**
  45372. * Gets the cached visibility state (ie. the latest rendered one)
  45373. * @returns the cached visibility state
  45374. */
  45375. getCachedVisibility(): Nullable<number>;
  45376. /**
  45377. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  45378. * @param material defines the current material
  45379. * @param effect defines the current effect
  45380. * @param visibility defines the current visibility state
  45381. * @returns true if one parameter is not cached
  45382. */
  45383. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  45384. /**
  45385. * Gets the engine associated with the scene
  45386. * @returns an Engine
  45387. */
  45388. getEngine(): Engine;
  45389. /**
  45390. * Gets the total number of vertices rendered per frame
  45391. * @returns the total number of vertices rendered per frame
  45392. */
  45393. getTotalVertices(): number;
  45394. /**
  45395. * Gets the performance counter for total vertices
  45396. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45397. */
  45398. get totalVerticesPerfCounter(): PerfCounter;
  45399. /**
  45400. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  45401. * @returns the total number of active indices rendered per frame
  45402. */
  45403. getActiveIndices(): number;
  45404. /**
  45405. * Gets the performance counter for active indices
  45406. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45407. */
  45408. get totalActiveIndicesPerfCounter(): PerfCounter;
  45409. /**
  45410. * Gets the total number of active particles rendered per frame
  45411. * @returns the total number of active particles rendered per frame
  45412. */
  45413. getActiveParticles(): number;
  45414. /**
  45415. * Gets the performance counter for active particles
  45416. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45417. */
  45418. get activeParticlesPerfCounter(): PerfCounter;
  45419. /**
  45420. * Gets the total number of active bones rendered per frame
  45421. * @returns the total number of active bones rendered per frame
  45422. */
  45423. getActiveBones(): number;
  45424. /**
  45425. * Gets the performance counter for active bones
  45426. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45427. */
  45428. get activeBonesPerfCounter(): PerfCounter;
  45429. /**
  45430. * Gets the array of active meshes
  45431. * @returns an array of AbstractMesh
  45432. */
  45433. getActiveMeshes(): SmartArray<AbstractMesh>;
  45434. /**
  45435. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  45436. * @returns a number
  45437. */
  45438. getAnimationRatio(): number;
  45439. /**
  45440. * Gets an unique Id for the current render phase
  45441. * @returns a number
  45442. */
  45443. getRenderId(): number;
  45444. /**
  45445. * Gets an unique Id for the current frame
  45446. * @returns a number
  45447. */
  45448. getFrameId(): number;
  45449. /** Call this function if you want to manually increment the render Id*/
  45450. incrementRenderId(): void;
  45451. private _createUbo;
  45452. /**
  45453. * Use this method to simulate a pointer move on a mesh
  45454. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45455. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45456. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45457. * @returns the current scene
  45458. */
  45459. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  45460. /**
  45461. * Use this method to simulate a pointer down on a mesh
  45462. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45463. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45464. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45465. * @returns the current scene
  45466. */
  45467. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  45468. /**
  45469. * Use this method to simulate a pointer up on a mesh
  45470. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45471. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45472. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45473. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  45474. * @returns the current scene
  45475. */
  45476. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  45477. /**
  45478. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  45479. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  45480. * @returns true if the pointer was captured
  45481. */
  45482. isPointerCaptured(pointerId?: number): boolean;
  45483. /**
  45484. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  45485. * @param attachUp defines if you want to attach events to pointerup
  45486. * @param attachDown defines if you want to attach events to pointerdown
  45487. * @param attachMove defines if you want to attach events to pointermove
  45488. */
  45489. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  45490. /** Detaches all event handlers*/
  45491. detachControl(): void;
  45492. /**
  45493. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  45494. * Delay loaded resources are not taking in account
  45495. * @return true if all required resources are ready
  45496. */
  45497. isReady(): boolean;
  45498. /** Resets all cached information relative to material (including effect and visibility) */
  45499. resetCachedMaterial(): void;
  45500. /**
  45501. * Registers a function to be called before every frame render
  45502. * @param func defines the function to register
  45503. */
  45504. registerBeforeRender(func: () => void): void;
  45505. /**
  45506. * Unregisters a function called before every frame render
  45507. * @param func defines the function to unregister
  45508. */
  45509. unregisterBeforeRender(func: () => void): void;
  45510. /**
  45511. * Registers a function to be called after every frame render
  45512. * @param func defines the function to register
  45513. */
  45514. registerAfterRender(func: () => void): void;
  45515. /**
  45516. * Unregisters a function called after every frame render
  45517. * @param func defines the function to unregister
  45518. */
  45519. unregisterAfterRender(func: () => void): void;
  45520. private _executeOnceBeforeRender;
  45521. /**
  45522. * The provided function will run before render once and will be disposed afterwards.
  45523. * A timeout delay can be provided so that the function will be executed in N ms.
  45524. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  45525. * @param func The function to be executed.
  45526. * @param timeout optional delay in ms
  45527. */
  45528. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  45529. /** @hidden */
  45530. _addPendingData(data: any): void;
  45531. /** @hidden */
  45532. _removePendingData(data: any): void;
  45533. /**
  45534. * Returns the number of items waiting to be loaded
  45535. * @returns the number of items waiting to be loaded
  45536. */
  45537. getWaitingItemsCount(): number;
  45538. /**
  45539. * Returns a boolean indicating if the scene is still loading data
  45540. */
  45541. get isLoading(): boolean;
  45542. /**
  45543. * Registers a function to be executed when the scene is ready
  45544. * @param {Function} func - the function to be executed
  45545. */
  45546. executeWhenReady(func: () => void): void;
  45547. /**
  45548. * Returns a promise that resolves when the scene is ready
  45549. * @returns A promise that resolves when the scene is ready
  45550. */
  45551. whenReadyAsync(): Promise<void>;
  45552. /** @hidden */
  45553. _checkIsReady(): void;
  45554. /**
  45555. * Gets all animatable attached to the scene
  45556. */
  45557. get animatables(): Animatable[];
  45558. /**
  45559. * Resets the last animation time frame.
  45560. * Useful to override when animations start running when loading a scene for the first time.
  45561. */
  45562. resetLastAnimationTimeFrame(): void;
  45563. /**
  45564. * Gets the current view matrix
  45565. * @returns a Matrix
  45566. */
  45567. getViewMatrix(): Matrix;
  45568. /**
  45569. * Gets the current projection matrix
  45570. * @returns a Matrix
  45571. */
  45572. getProjectionMatrix(): Matrix;
  45573. /**
  45574. * Gets the current transform matrix
  45575. * @returns a Matrix made of View * Projection
  45576. */
  45577. getTransformMatrix(): Matrix;
  45578. /**
  45579. * Sets the current transform matrix
  45580. * @param viewL defines the View matrix to use
  45581. * @param projectionL defines the Projection matrix to use
  45582. * @param viewR defines the right View matrix to use (if provided)
  45583. * @param projectionR defines the right Projection matrix to use (if provided)
  45584. */
  45585. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  45586. /**
  45587. * Gets the uniform buffer used to store scene data
  45588. * @returns a UniformBuffer
  45589. */
  45590. getSceneUniformBuffer(): UniformBuffer;
  45591. /**
  45592. * Gets an unique (relatively to the current scene) Id
  45593. * @returns an unique number for the scene
  45594. */
  45595. getUniqueId(): number;
  45596. /**
  45597. * Add a mesh to the list of scene's meshes
  45598. * @param newMesh defines the mesh to add
  45599. * @param recursive if all child meshes should also be added to the scene
  45600. */
  45601. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  45602. /**
  45603. * Remove a mesh for the list of scene's meshes
  45604. * @param toRemove defines the mesh to remove
  45605. * @param recursive if all child meshes should also be removed from the scene
  45606. * @returns the index where the mesh was in the mesh list
  45607. */
  45608. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  45609. /**
  45610. * Add a transform node to the list of scene's transform nodes
  45611. * @param newTransformNode defines the transform node to add
  45612. */
  45613. addTransformNode(newTransformNode: TransformNode): void;
  45614. /**
  45615. * Remove a transform node for the list of scene's transform nodes
  45616. * @param toRemove defines the transform node to remove
  45617. * @returns the index where the transform node was in the transform node list
  45618. */
  45619. removeTransformNode(toRemove: TransformNode): number;
  45620. /**
  45621. * Remove a skeleton for the list of scene's skeletons
  45622. * @param toRemove defines the skeleton to remove
  45623. * @returns the index where the skeleton was in the skeleton list
  45624. */
  45625. removeSkeleton(toRemove: Skeleton): number;
  45626. /**
  45627. * Remove a morph target for the list of scene's morph targets
  45628. * @param toRemove defines the morph target to remove
  45629. * @returns the index where the morph target was in the morph target list
  45630. */
  45631. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  45632. /**
  45633. * Remove a light for the list of scene's lights
  45634. * @param toRemove defines the light to remove
  45635. * @returns the index where the light was in the light list
  45636. */
  45637. removeLight(toRemove: Light): number;
  45638. /**
  45639. * Remove a camera for the list of scene's cameras
  45640. * @param toRemove defines the camera to remove
  45641. * @returns the index where the camera was in the camera list
  45642. */
  45643. removeCamera(toRemove: Camera): number;
  45644. /**
  45645. * Remove a particle system for the list of scene's particle systems
  45646. * @param toRemove defines the particle system to remove
  45647. * @returns the index where the particle system was in the particle system list
  45648. */
  45649. removeParticleSystem(toRemove: IParticleSystem): number;
  45650. /**
  45651. * Remove a animation for the list of scene's animations
  45652. * @param toRemove defines the animation to remove
  45653. * @returns the index where the animation was in the animation list
  45654. */
  45655. removeAnimation(toRemove: Animation): number;
  45656. /**
  45657. * Will stop the animation of the given target
  45658. * @param target - the target
  45659. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  45660. * @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)
  45661. */
  45662. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  45663. /**
  45664. * Removes the given animation group from this scene.
  45665. * @param toRemove The animation group to remove
  45666. * @returns The index of the removed animation group
  45667. */
  45668. removeAnimationGroup(toRemove: AnimationGroup): number;
  45669. /**
  45670. * Removes the given multi-material from this scene.
  45671. * @param toRemove The multi-material to remove
  45672. * @returns The index of the removed multi-material
  45673. */
  45674. removeMultiMaterial(toRemove: MultiMaterial): number;
  45675. /**
  45676. * Removes the given material from this scene.
  45677. * @param toRemove The material to remove
  45678. * @returns The index of the removed material
  45679. */
  45680. removeMaterial(toRemove: Material): number;
  45681. /**
  45682. * Removes the given action manager from this scene.
  45683. * @param toRemove The action manager to remove
  45684. * @returns The index of the removed action manager
  45685. */
  45686. removeActionManager(toRemove: AbstractActionManager): number;
  45687. /**
  45688. * Removes the given texture from this scene.
  45689. * @param toRemove The texture to remove
  45690. * @returns The index of the removed texture
  45691. */
  45692. removeTexture(toRemove: BaseTexture): number;
  45693. /**
  45694. * Adds the given light to this scene
  45695. * @param newLight The light to add
  45696. */
  45697. addLight(newLight: Light): void;
  45698. /**
  45699. * Sorts the list list based on light priorities
  45700. */
  45701. sortLightsByPriority(): void;
  45702. /**
  45703. * Adds the given camera to this scene
  45704. * @param newCamera The camera to add
  45705. */
  45706. addCamera(newCamera: Camera): void;
  45707. /**
  45708. * Adds the given skeleton to this scene
  45709. * @param newSkeleton The skeleton to add
  45710. */
  45711. addSkeleton(newSkeleton: Skeleton): void;
  45712. /**
  45713. * Adds the given particle system to this scene
  45714. * @param newParticleSystem The particle system to add
  45715. */
  45716. addParticleSystem(newParticleSystem: IParticleSystem): void;
  45717. /**
  45718. * Adds the given animation to this scene
  45719. * @param newAnimation The animation to add
  45720. */
  45721. addAnimation(newAnimation: Animation): void;
  45722. /**
  45723. * Adds the given animation group to this scene.
  45724. * @param newAnimationGroup The animation group to add
  45725. */
  45726. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  45727. /**
  45728. * Adds the given multi-material to this scene
  45729. * @param newMultiMaterial The multi-material to add
  45730. */
  45731. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  45732. /**
  45733. * Adds the given material to this scene
  45734. * @param newMaterial The material to add
  45735. */
  45736. addMaterial(newMaterial: Material): void;
  45737. /**
  45738. * Adds the given morph target to this scene
  45739. * @param newMorphTargetManager The morph target to add
  45740. */
  45741. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  45742. /**
  45743. * Adds the given geometry to this scene
  45744. * @param newGeometry The geometry to add
  45745. */
  45746. addGeometry(newGeometry: Geometry): void;
  45747. /**
  45748. * Adds the given action manager to this scene
  45749. * @param newActionManager The action manager to add
  45750. */
  45751. addActionManager(newActionManager: AbstractActionManager): void;
  45752. /**
  45753. * Adds the given texture to this scene.
  45754. * @param newTexture The texture to add
  45755. */
  45756. addTexture(newTexture: BaseTexture): void;
  45757. /**
  45758. * Switch active camera
  45759. * @param newCamera defines the new active camera
  45760. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  45761. */
  45762. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  45763. /**
  45764. * sets the active camera of the scene using its ID
  45765. * @param id defines the camera's ID
  45766. * @return the new active camera or null if none found.
  45767. */
  45768. setActiveCameraByID(id: string): Nullable<Camera>;
  45769. /**
  45770. * sets the active camera of the scene using its name
  45771. * @param name defines the camera's name
  45772. * @returns the new active camera or null if none found.
  45773. */
  45774. setActiveCameraByName(name: string): Nullable<Camera>;
  45775. /**
  45776. * get an animation group using its name
  45777. * @param name defines the material's name
  45778. * @return the animation group or null if none found.
  45779. */
  45780. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  45781. /**
  45782. * Get a material using its unique id
  45783. * @param uniqueId defines the material's unique id
  45784. * @return the material or null if none found.
  45785. */
  45786. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  45787. /**
  45788. * get a material using its id
  45789. * @param id defines the material's ID
  45790. * @return the material or null if none found.
  45791. */
  45792. getMaterialByID(id: string): Nullable<Material>;
  45793. /**
  45794. * Gets a the last added material using a given id
  45795. * @param id defines the material's ID
  45796. * @return the last material with the given id or null if none found.
  45797. */
  45798. getLastMaterialByID(id: string): Nullable<Material>;
  45799. /**
  45800. * Gets a material using its name
  45801. * @param name defines the material's name
  45802. * @return the material or null if none found.
  45803. */
  45804. getMaterialByName(name: string): Nullable<Material>;
  45805. /**
  45806. * Get a texture using its unique id
  45807. * @param uniqueId defines the texture's unique id
  45808. * @return the texture or null if none found.
  45809. */
  45810. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  45811. /**
  45812. * Gets a camera using its id
  45813. * @param id defines the id to look for
  45814. * @returns the camera or null if not found
  45815. */
  45816. getCameraByID(id: string): Nullable<Camera>;
  45817. /**
  45818. * Gets a camera using its unique id
  45819. * @param uniqueId defines the unique id to look for
  45820. * @returns the camera or null if not found
  45821. */
  45822. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  45823. /**
  45824. * Gets a camera using its name
  45825. * @param name defines the camera's name
  45826. * @return the camera or null if none found.
  45827. */
  45828. getCameraByName(name: string): Nullable<Camera>;
  45829. /**
  45830. * Gets a bone using its id
  45831. * @param id defines the bone's id
  45832. * @return the bone or null if not found
  45833. */
  45834. getBoneByID(id: string): Nullable<Bone>;
  45835. /**
  45836. * Gets a bone using its id
  45837. * @param name defines the bone's name
  45838. * @return the bone or null if not found
  45839. */
  45840. getBoneByName(name: string): Nullable<Bone>;
  45841. /**
  45842. * Gets a light node using its name
  45843. * @param name defines the the light's name
  45844. * @return the light or null if none found.
  45845. */
  45846. getLightByName(name: string): Nullable<Light>;
  45847. /**
  45848. * Gets a light node using its id
  45849. * @param id defines the light's id
  45850. * @return the light or null if none found.
  45851. */
  45852. getLightByID(id: string): Nullable<Light>;
  45853. /**
  45854. * Gets a light node using its scene-generated unique ID
  45855. * @param uniqueId defines the light's unique id
  45856. * @return the light or null if none found.
  45857. */
  45858. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  45859. /**
  45860. * Gets a particle system by id
  45861. * @param id defines the particle system id
  45862. * @return the corresponding system or null if none found
  45863. */
  45864. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  45865. /**
  45866. * Gets a geometry using its ID
  45867. * @param id defines the geometry's id
  45868. * @return the geometry or null if none found.
  45869. */
  45870. getGeometryByID(id: string): Nullable<Geometry>;
  45871. private _getGeometryByUniqueID;
  45872. /**
  45873. * Add a new geometry to this scene
  45874. * @param geometry defines the geometry to be added to the scene.
  45875. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  45876. * @return a boolean defining if the geometry was added or not
  45877. */
  45878. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  45879. /**
  45880. * Removes an existing geometry
  45881. * @param geometry defines the geometry to be removed from the scene
  45882. * @return a boolean defining if the geometry was removed or not
  45883. */
  45884. removeGeometry(geometry: Geometry): boolean;
  45885. /**
  45886. * Gets the list of geometries attached to the scene
  45887. * @returns an array of Geometry
  45888. */
  45889. getGeometries(): Geometry[];
  45890. /**
  45891. * Gets the first added mesh found of a given ID
  45892. * @param id defines the id to search for
  45893. * @return the mesh found or null if not found at all
  45894. */
  45895. getMeshByID(id: string): Nullable<AbstractMesh>;
  45896. /**
  45897. * Gets a list of meshes using their id
  45898. * @param id defines the id to search for
  45899. * @returns a list of meshes
  45900. */
  45901. getMeshesByID(id: string): Array<AbstractMesh>;
  45902. /**
  45903. * Gets the first added transform node found of a given ID
  45904. * @param id defines the id to search for
  45905. * @return the found transform node or null if not found at all.
  45906. */
  45907. getTransformNodeByID(id: string): Nullable<TransformNode>;
  45908. /**
  45909. * Gets a transform node with its auto-generated unique id
  45910. * @param uniqueId efines the unique id to search for
  45911. * @return the found transform node or null if not found at all.
  45912. */
  45913. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  45914. /**
  45915. * Gets a list of transform nodes using their id
  45916. * @param id defines the id to search for
  45917. * @returns a list of transform nodes
  45918. */
  45919. getTransformNodesByID(id: string): Array<TransformNode>;
  45920. /**
  45921. * Gets a mesh with its auto-generated unique id
  45922. * @param uniqueId defines the unique id to search for
  45923. * @return the found mesh or null if not found at all.
  45924. */
  45925. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  45926. /**
  45927. * Gets a the last added mesh using a given id
  45928. * @param id defines the id to search for
  45929. * @return the found mesh or null if not found at all.
  45930. */
  45931. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  45932. /**
  45933. * Gets a the last added node (Mesh, Camera, Light) using a given id
  45934. * @param id defines the id to search for
  45935. * @return the found node or null if not found at all
  45936. */
  45937. getLastEntryByID(id: string): Nullable<Node>;
  45938. /**
  45939. * Gets a node (Mesh, Camera, Light) using a given id
  45940. * @param id defines the id to search for
  45941. * @return the found node or null if not found at all
  45942. */
  45943. getNodeByID(id: string): Nullable<Node>;
  45944. /**
  45945. * Gets a node (Mesh, Camera, Light) using a given name
  45946. * @param name defines the name to search for
  45947. * @return the found node or null if not found at all.
  45948. */
  45949. getNodeByName(name: string): Nullable<Node>;
  45950. /**
  45951. * Gets a mesh using a given name
  45952. * @param name defines the name to search for
  45953. * @return the found mesh or null if not found at all.
  45954. */
  45955. getMeshByName(name: string): Nullable<AbstractMesh>;
  45956. /**
  45957. * Gets a transform node using a given name
  45958. * @param name defines the name to search for
  45959. * @return the found transform node or null if not found at all.
  45960. */
  45961. getTransformNodeByName(name: string): Nullable<TransformNode>;
  45962. /**
  45963. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  45964. * @param id defines the id to search for
  45965. * @return the found skeleton or null if not found at all.
  45966. */
  45967. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  45968. /**
  45969. * Gets a skeleton using a given auto generated unique id
  45970. * @param uniqueId defines the unique id to search for
  45971. * @return the found skeleton or null if not found at all.
  45972. */
  45973. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  45974. /**
  45975. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  45976. * @param id defines the id to search for
  45977. * @return the found skeleton or null if not found at all.
  45978. */
  45979. getSkeletonById(id: string): Nullable<Skeleton>;
  45980. /**
  45981. * Gets a skeleton using a given name
  45982. * @param name defines the name to search for
  45983. * @return the found skeleton or null if not found at all.
  45984. */
  45985. getSkeletonByName(name: string): Nullable<Skeleton>;
  45986. /**
  45987. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  45988. * @param id defines the id to search for
  45989. * @return the found morph target manager or null if not found at all.
  45990. */
  45991. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  45992. /**
  45993. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  45994. * @param id defines the id to search for
  45995. * @return the found morph target or null if not found at all.
  45996. */
  45997. getMorphTargetById(id: string): Nullable<MorphTarget>;
  45998. /**
  45999. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  46000. * @param name defines the name to search for
  46001. * @return the found morph target or null if not found at all.
  46002. */
  46003. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  46004. /**
  46005. * Gets a post process using a given name (if many are found, this function will pick the first one)
  46006. * @param name defines the name to search for
  46007. * @return the found post process or null if not found at all.
  46008. */
  46009. getPostProcessByName(name: string): Nullable<PostProcess>;
  46010. /**
  46011. * Gets a boolean indicating if the given mesh is active
  46012. * @param mesh defines the mesh to look for
  46013. * @returns true if the mesh is in the active list
  46014. */
  46015. isActiveMesh(mesh: AbstractMesh): boolean;
  46016. /**
  46017. * Return a unique id as a string which can serve as an identifier for the scene
  46018. */
  46019. get uid(): string;
  46020. /**
  46021. * Add an externaly attached data from its key.
  46022. * This method call will fail and return false, if such key already exists.
  46023. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  46024. * @param key the unique key that identifies the data
  46025. * @param data the data object to associate to the key for this Engine instance
  46026. * @return true if no such key were already present and the data was added successfully, false otherwise
  46027. */
  46028. addExternalData<T>(key: string, data: T): boolean;
  46029. /**
  46030. * Get an externaly attached data from its key
  46031. * @param key the unique key that identifies the data
  46032. * @return the associated data, if present (can be null), or undefined if not present
  46033. */
  46034. getExternalData<T>(key: string): Nullable<T>;
  46035. /**
  46036. * Get an externaly attached data from its key, create it using a factory if it's not already present
  46037. * @param key the unique key that identifies the data
  46038. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  46039. * @return the associated data, can be null if the factory returned null.
  46040. */
  46041. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  46042. /**
  46043. * Remove an externaly attached data from the Engine instance
  46044. * @param key the unique key that identifies the data
  46045. * @return true if the data was successfully removed, false if it doesn't exist
  46046. */
  46047. removeExternalData(key: string): boolean;
  46048. private _evaluateSubMesh;
  46049. /**
  46050. * Clear the processed materials smart array preventing retention point in material dispose.
  46051. */
  46052. freeProcessedMaterials(): void;
  46053. private _preventFreeActiveMeshesAndRenderingGroups;
  46054. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  46055. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  46056. * when disposing several meshes in a row or a hierarchy of meshes.
  46057. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  46058. */
  46059. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  46060. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  46061. /**
  46062. * Clear the active meshes smart array preventing retention point in mesh dispose.
  46063. */
  46064. freeActiveMeshes(): void;
  46065. /**
  46066. * Clear the info related to rendering groups preventing retention points during dispose.
  46067. */
  46068. freeRenderingGroups(): void;
  46069. /** @hidden */
  46070. _isInIntermediateRendering(): boolean;
  46071. /**
  46072. * Lambda returning the list of potentially active meshes.
  46073. */
  46074. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  46075. /**
  46076. * Lambda returning the list of potentially active sub meshes.
  46077. */
  46078. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  46079. /**
  46080. * Lambda returning the list of potentially intersecting sub meshes.
  46081. */
  46082. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  46083. /**
  46084. * Lambda returning the list of potentially colliding sub meshes.
  46085. */
  46086. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  46087. private _activeMeshesFrozen;
  46088. private _skipEvaluateActiveMeshesCompletely;
  46089. /**
  46090. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  46091. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  46092. * @param onSuccess optional success callback
  46093. * @param onError optional error callback
  46094. * @returns the current scene
  46095. */
  46096. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  46097. /**
  46098. * Use this function to restart evaluating active meshes on every frame
  46099. * @returns the current scene
  46100. */
  46101. unfreezeActiveMeshes(): Scene;
  46102. private _evaluateActiveMeshes;
  46103. private _activeMesh;
  46104. /**
  46105. * Update the transform matrix to update from the current active camera
  46106. * @param force defines a boolean used to force the update even if cache is up to date
  46107. */
  46108. updateTransformMatrix(force?: boolean): void;
  46109. private _bindFrameBuffer;
  46110. /** @hidden */
  46111. _allowPostProcessClearColor: boolean;
  46112. /** @hidden */
  46113. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  46114. private _processSubCameras;
  46115. private _checkIntersections;
  46116. /** @hidden */
  46117. _advancePhysicsEngineStep(step: number): void;
  46118. /**
  46119. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  46120. */
  46121. getDeterministicFrameTime: () => number;
  46122. /** @hidden */
  46123. _animate(): void;
  46124. /** Execute all animations (for a frame) */
  46125. animate(): void;
  46126. /**
  46127. * Render the scene
  46128. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  46129. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  46130. */
  46131. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  46132. /**
  46133. * Freeze all materials
  46134. * A frozen material will not be updatable but should be faster to render
  46135. */
  46136. freezeMaterials(): void;
  46137. /**
  46138. * Unfreeze all materials
  46139. * A frozen material will not be updatable but should be faster to render
  46140. */
  46141. unfreezeMaterials(): void;
  46142. /**
  46143. * Releases all held ressources
  46144. */
  46145. dispose(): void;
  46146. /**
  46147. * Gets if the scene is already disposed
  46148. */
  46149. get isDisposed(): boolean;
  46150. /**
  46151. * Call this function to reduce memory footprint of the scene.
  46152. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  46153. */
  46154. clearCachedVertexData(): void;
  46155. /**
  46156. * This function will remove the local cached buffer data from texture.
  46157. * It will save memory but will prevent the texture from being rebuilt
  46158. */
  46159. cleanCachedTextureBuffer(): void;
  46160. /**
  46161. * Get the world extend vectors with an optional filter
  46162. *
  46163. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  46164. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  46165. */
  46166. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  46167. min: Vector3;
  46168. max: Vector3;
  46169. };
  46170. /**
  46171. * Creates a ray that can be used to pick in the scene
  46172. * @param x defines the x coordinate of the origin (on-screen)
  46173. * @param y defines the y coordinate of the origin (on-screen)
  46174. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  46175. * @param camera defines the camera to use for the picking
  46176. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  46177. * @returns a Ray
  46178. */
  46179. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  46180. /**
  46181. * Creates a ray that can be used to pick in the scene
  46182. * @param x defines the x coordinate of the origin (on-screen)
  46183. * @param y defines the y coordinate of the origin (on-screen)
  46184. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  46185. * @param result defines the ray where to store the picking ray
  46186. * @param camera defines the camera to use for the picking
  46187. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  46188. * @returns the current scene
  46189. */
  46190. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  46191. /**
  46192. * Creates a ray that can be used to pick in the scene
  46193. * @param x defines the x coordinate of the origin (on-screen)
  46194. * @param y defines the y coordinate of the origin (on-screen)
  46195. * @param camera defines the camera to use for the picking
  46196. * @returns a Ray
  46197. */
  46198. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  46199. /**
  46200. * Creates a ray that can be used to pick in the scene
  46201. * @param x defines the x coordinate of the origin (on-screen)
  46202. * @param y defines the y coordinate of the origin (on-screen)
  46203. * @param result defines the ray where to store the picking ray
  46204. * @param camera defines the camera to use for the picking
  46205. * @returns the current scene
  46206. */
  46207. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  46208. /** Launch a ray to try to pick a mesh in the scene
  46209. * @param x position on screen
  46210. * @param y position on screen
  46211. * @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
  46212. * @param fastCheck defines if the first intersection will be used (and not the closest)
  46213. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  46214. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46215. * @returns a PickingInfo
  46216. */
  46217. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  46218. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  46219. * @param x position on screen
  46220. * @param y position on screen
  46221. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  46222. * @param fastCheck defines if the first intersection will be used (and not the closest)
  46223. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  46224. * @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)
  46225. */
  46226. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  46227. /** Use the given ray to pick a mesh in the scene
  46228. * @param ray The ray to use to pick meshes
  46229. * @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
  46230. * @param fastCheck defines if the first intersection will be used (and not the closest)
  46231. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46232. * @returns a PickingInfo
  46233. */
  46234. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  46235. /**
  46236. * Launch a ray to try to pick a mesh in the scene
  46237. * @param x X position on screen
  46238. * @param y Y position on screen
  46239. * @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
  46240. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  46241. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46242. * @returns an array of PickingInfo
  46243. */
  46244. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  46245. /**
  46246. * Launch a ray to try to pick a mesh in the scene
  46247. * @param ray Ray to use
  46248. * @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
  46249. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46250. * @returns an array of PickingInfo
  46251. */
  46252. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  46253. /**
  46254. * Force the value of meshUnderPointer
  46255. * @param mesh defines the mesh to use
  46256. * @param pointerId optional pointer id when using more than one pointer
  46257. */
  46258. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  46259. /**
  46260. * Gets the mesh under the pointer
  46261. * @returns a Mesh or null if no mesh is under the pointer
  46262. */
  46263. getPointerOverMesh(): Nullable<AbstractMesh>;
  46264. /** @hidden */
  46265. _rebuildGeometries(): void;
  46266. /** @hidden */
  46267. _rebuildTextures(): void;
  46268. private _getByTags;
  46269. /**
  46270. * Get a list of meshes by tags
  46271. * @param tagsQuery defines the tags query to use
  46272. * @param forEach defines a predicate used to filter results
  46273. * @returns an array of Mesh
  46274. */
  46275. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  46276. /**
  46277. * Get a list of cameras by tags
  46278. * @param tagsQuery defines the tags query to use
  46279. * @param forEach defines a predicate used to filter results
  46280. * @returns an array of Camera
  46281. */
  46282. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  46283. /**
  46284. * Get a list of lights by tags
  46285. * @param tagsQuery defines the tags query to use
  46286. * @param forEach defines a predicate used to filter results
  46287. * @returns an array of Light
  46288. */
  46289. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  46290. /**
  46291. * Get a list of materials by tags
  46292. * @param tagsQuery defines the tags query to use
  46293. * @param forEach defines a predicate used to filter results
  46294. * @returns an array of Material
  46295. */
  46296. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  46297. /**
  46298. * Get a list of transform nodes by tags
  46299. * @param tagsQuery defines the tags query to use
  46300. * @param forEach defines a predicate used to filter results
  46301. * @returns an array of TransformNode
  46302. */
  46303. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  46304. /**
  46305. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  46306. * This allowed control for front to back rendering or reversly depending of the special needs.
  46307. *
  46308. * @param renderingGroupId The rendering group id corresponding to its index
  46309. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  46310. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  46311. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  46312. */
  46313. 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;
  46314. /**
  46315. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  46316. *
  46317. * @param renderingGroupId The rendering group id corresponding to its index
  46318. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  46319. * @param depth Automatically clears depth between groups if true and autoClear is true.
  46320. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  46321. */
  46322. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  46323. /**
  46324. * Gets the current auto clear configuration for one rendering group of the rendering
  46325. * manager.
  46326. * @param index the rendering group index to get the information for
  46327. * @returns The auto clear setup for the requested rendering group
  46328. */
  46329. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  46330. private _blockMaterialDirtyMechanism;
  46331. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  46332. get blockMaterialDirtyMechanism(): boolean;
  46333. set blockMaterialDirtyMechanism(value: boolean);
  46334. /**
  46335. * Will flag all materials as dirty to trigger new shader compilation
  46336. * @param flag defines the flag used to specify which material part must be marked as dirty
  46337. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  46338. */
  46339. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  46340. /** @hidden */
  46341. _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;
  46342. /** @hidden */
  46343. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  46344. /** @hidden */
  46345. _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;
  46346. /** @hidden */
  46347. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  46348. /** @hidden */
  46349. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  46350. /** @hidden */
  46351. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  46352. }
  46353. }
  46354. declare module "babylonjs/assetContainer" {
  46355. import { AbstractScene } from "babylonjs/abstractScene";
  46356. import { Scene } from "babylonjs/scene";
  46357. import { Mesh } from "babylonjs/Meshes/mesh";
  46358. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46359. import { Skeleton } from "babylonjs/Bones/skeleton";
  46360. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  46361. import { Animatable } from "babylonjs/Animations/animatable";
  46362. import { Nullable } from "babylonjs/types";
  46363. import { Node } from "babylonjs/node";
  46364. /**
  46365. * Set of assets to keep when moving a scene into an asset container.
  46366. */
  46367. export class KeepAssets extends AbstractScene {
  46368. }
  46369. /**
  46370. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  46371. */
  46372. export class InstantiatedEntries {
  46373. /**
  46374. * List of new root nodes (eg. nodes with no parent)
  46375. */
  46376. rootNodes: TransformNode[];
  46377. /**
  46378. * List of new skeletons
  46379. */
  46380. skeletons: Skeleton[];
  46381. /**
  46382. * List of new animation groups
  46383. */
  46384. animationGroups: AnimationGroup[];
  46385. }
  46386. /**
  46387. * Container with a set of assets that can be added or removed from a scene.
  46388. */
  46389. export class AssetContainer extends AbstractScene {
  46390. private _wasAddedToScene;
  46391. /**
  46392. * The scene the AssetContainer belongs to.
  46393. */
  46394. scene: Scene;
  46395. /**
  46396. * Instantiates an AssetContainer.
  46397. * @param scene The scene the AssetContainer belongs to.
  46398. */
  46399. constructor(scene: Scene);
  46400. /**
  46401. * Instantiate or clone all meshes and add the new ones to the scene.
  46402. * Skeletons and animation groups will all be cloned
  46403. * @param nameFunction defines an optional function used to get new names for clones
  46404. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  46405. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  46406. */
  46407. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  46408. /**
  46409. * Adds all the assets from the container to the scene.
  46410. */
  46411. addAllToScene(): void;
  46412. /**
  46413. * Removes all the assets in the container from the scene
  46414. */
  46415. removeAllFromScene(): void;
  46416. /**
  46417. * Disposes all the assets in the container
  46418. */
  46419. dispose(): void;
  46420. private _moveAssets;
  46421. /**
  46422. * Removes all the assets contained in the scene and adds them to the container.
  46423. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  46424. */
  46425. moveAllFromScene(keepAssets?: KeepAssets): void;
  46426. /**
  46427. * 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.
  46428. * @returns the root mesh
  46429. */
  46430. createRootMesh(): Mesh;
  46431. /**
  46432. * Merge animations (direct and animation groups) from this asset container into a scene
  46433. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46434. * @param animatables set of animatables to retarget to a node from the scene
  46435. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  46436. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  46437. */
  46438. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  46439. }
  46440. }
  46441. declare module "babylonjs/abstractScene" {
  46442. import { Scene } from "babylonjs/scene";
  46443. import { Nullable } from "babylonjs/types";
  46444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46445. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46446. import { Geometry } from "babylonjs/Meshes/geometry";
  46447. import { Skeleton } from "babylonjs/Bones/skeleton";
  46448. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  46449. import { AssetContainer } from "babylonjs/assetContainer";
  46450. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  46451. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  46452. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46453. import { Material } from "babylonjs/Materials/material";
  46454. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  46455. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  46456. import { Camera } from "babylonjs/Cameras/camera";
  46457. import { Light } from "babylonjs/Lights/light";
  46458. import { Node } from "babylonjs/node";
  46459. import { Animation } from "babylonjs/Animations/animation";
  46460. /**
  46461. * Defines how the parser contract is defined.
  46462. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  46463. */
  46464. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  46465. /**
  46466. * Defines how the individual parser contract is defined.
  46467. * These parser can parse an individual asset
  46468. */
  46469. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  46470. /**
  46471. * Base class of the scene acting as a container for the different elements composing a scene.
  46472. * This class is dynamically extended by the different components of the scene increasing
  46473. * flexibility and reducing coupling
  46474. */
  46475. export abstract class AbstractScene {
  46476. /**
  46477. * Stores the list of available parsers in the application.
  46478. */
  46479. private static _BabylonFileParsers;
  46480. /**
  46481. * Stores the list of available individual parsers in the application.
  46482. */
  46483. private static _IndividualBabylonFileParsers;
  46484. /**
  46485. * Adds a parser in the list of available ones
  46486. * @param name Defines the name of the parser
  46487. * @param parser Defines the parser to add
  46488. */
  46489. static AddParser(name: string, parser: BabylonFileParser): void;
  46490. /**
  46491. * Gets a general parser from the list of avaialble ones
  46492. * @param name Defines the name of the parser
  46493. * @returns the requested parser or null
  46494. */
  46495. static GetParser(name: string): Nullable<BabylonFileParser>;
  46496. /**
  46497. * Adds n individual parser in the list of available ones
  46498. * @param name Defines the name of the parser
  46499. * @param parser Defines the parser to add
  46500. */
  46501. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  46502. /**
  46503. * Gets an individual parser from the list of avaialble ones
  46504. * @param name Defines the name of the parser
  46505. * @returns the requested parser or null
  46506. */
  46507. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  46508. /**
  46509. * Parser json data and populate both a scene and its associated container object
  46510. * @param jsonData Defines the data to parse
  46511. * @param scene Defines the scene to parse the data for
  46512. * @param container Defines the container attached to the parsing sequence
  46513. * @param rootUrl Defines the root url of the data
  46514. */
  46515. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  46516. /**
  46517. * Gets the list of root nodes (ie. nodes with no parent)
  46518. */
  46519. rootNodes: Node[];
  46520. /** All of the cameras added to this scene
  46521. * @see https://doc.babylonjs.com/babylon101/cameras
  46522. */
  46523. cameras: Camera[];
  46524. /**
  46525. * All of the lights added to this scene
  46526. * @see https://doc.babylonjs.com/babylon101/lights
  46527. */
  46528. lights: Light[];
  46529. /**
  46530. * All of the (abstract) meshes added to this scene
  46531. */
  46532. meshes: AbstractMesh[];
  46533. /**
  46534. * The list of skeletons added to the scene
  46535. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  46536. */
  46537. skeletons: Skeleton[];
  46538. /**
  46539. * All of the particle systems added to this scene
  46540. * @see https://doc.babylonjs.com/babylon101/particles
  46541. */
  46542. particleSystems: IParticleSystem[];
  46543. /**
  46544. * Gets a list of Animations associated with the scene
  46545. */
  46546. animations: Animation[];
  46547. /**
  46548. * All of the animation groups added to this scene
  46549. * @see https://doc.babylonjs.com/how_to/group
  46550. */
  46551. animationGroups: AnimationGroup[];
  46552. /**
  46553. * All of the multi-materials added to this scene
  46554. * @see https://doc.babylonjs.com/how_to/multi_materials
  46555. */
  46556. multiMaterials: MultiMaterial[];
  46557. /**
  46558. * All of the materials added to this scene
  46559. * In the context of a Scene, it is not supposed to be modified manually.
  46560. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  46561. * Note also that the order of the Material within the array is not significant and might change.
  46562. * @see https://doc.babylonjs.com/babylon101/materials
  46563. */
  46564. materials: Material[];
  46565. /**
  46566. * The list of morph target managers added to the scene
  46567. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  46568. */
  46569. morphTargetManagers: MorphTargetManager[];
  46570. /**
  46571. * The list of geometries used in the scene.
  46572. */
  46573. geometries: Geometry[];
  46574. /**
  46575. * All of the tranform nodes added to this scene
  46576. * In the context of a Scene, it is not supposed to be modified manually.
  46577. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  46578. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  46579. * @see https://doc.babylonjs.com/how_to/transformnode
  46580. */
  46581. transformNodes: TransformNode[];
  46582. /**
  46583. * ActionManagers available on the scene.
  46584. */
  46585. actionManagers: AbstractActionManager[];
  46586. /**
  46587. * Textures to keep.
  46588. */
  46589. textures: BaseTexture[];
  46590. /** @hidden */
  46591. protected _environmentTexture: Nullable<BaseTexture>;
  46592. /**
  46593. * Texture used in all pbr material as the reflection texture.
  46594. * As in the majority of the scene they are the same (exception for multi room and so on),
  46595. * this is easier to reference from here than from all the materials.
  46596. */
  46597. get environmentTexture(): Nullable<BaseTexture>;
  46598. set environmentTexture(value: Nullable<BaseTexture>);
  46599. /**
  46600. * The list of postprocesses added to the scene
  46601. */
  46602. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  46603. /**
  46604. * @returns all meshes, lights, cameras, transformNodes and bones
  46605. */
  46606. getNodes(): Array<Node>;
  46607. }
  46608. }
  46609. declare module "babylonjs/Audio/Interfaces/ISoundOptions" {
  46610. /**
  46611. * Interface used to define options for Sound class
  46612. */
  46613. export interface ISoundOptions {
  46614. /**
  46615. * Does the sound autoplay once loaded.
  46616. */
  46617. autoplay?: boolean;
  46618. /**
  46619. * Does the sound loop after it finishes playing once.
  46620. */
  46621. loop?: boolean;
  46622. /**
  46623. * Sound's volume
  46624. */
  46625. volume?: number;
  46626. /**
  46627. * Is it a spatial sound?
  46628. */
  46629. spatialSound?: boolean;
  46630. /**
  46631. * Maximum distance to hear that sound
  46632. */
  46633. maxDistance?: number;
  46634. /**
  46635. * Uses user defined attenuation function
  46636. */
  46637. useCustomAttenuation?: boolean;
  46638. /**
  46639. * Define the roll off factor of spatial sounds.
  46640. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46641. */
  46642. rolloffFactor?: number;
  46643. /**
  46644. * Define the reference distance the sound should be heard perfectly.
  46645. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46646. */
  46647. refDistance?: number;
  46648. /**
  46649. * Define the distance attenuation model the sound will follow.
  46650. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46651. */
  46652. distanceModel?: string;
  46653. /**
  46654. * Defines the playback speed (1 by default)
  46655. */
  46656. playbackRate?: number;
  46657. /**
  46658. * Defines if the sound is from a streaming source
  46659. */
  46660. streaming?: boolean;
  46661. /**
  46662. * Defines an optional length (in seconds) inside the sound file
  46663. */
  46664. length?: number;
  46665. /**
  46666. * Defines an optional offset (in seconds) inside the sound file
  46667. */
  46668. offset?: number;
  46669. /**
  46670. * If true, URLs will not be required to state the audio file codec to use.
  46671. */
  46672. skipCodecCheck?: boolean;
  46673. }
  46674. }
  46675. declare module "babylonjs/Audio/sound" {
  46676. import { Observable } from "babylonjs/Misc/observable";
  46677. import { Vector3 } from "babylonjs/Maths/math.vector";
  46678. import { Nullable } from "babylonjs/types";
  46679. import { Scene } from "babylonjs/scene";
  46680. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46681. import { ISoundOptions } from "babylonjs/Audio/Interfaces/ISoundOptions";
  46682. /**
  46683. * Defines a sound that can be played in the application.
  46684. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  46685. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46686. */
  46687. export class Sound {
  46688. /**
  46689. * The name of the sound in the scene.
  46690. */
  46691. name: string;
  46692. /**
  46693. * Does the sound autoplay once loaded.
  46694. */
  46695. autoplay: boolean;
  46696. /**
  46697. * Does the sound loop after it finishes playing once.
  46698. */
  46699. loop: boolean;
  46700. /**
  46701. * Does the sound use a custom attenuation curve to simulate the falloff
  46702. * happening when the source gets further away from the camera.
  46703. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46704. */
  46705. useCustomAttenuation: boolean;
  46706. /**
  46707. * The sound track id this sound belongs to.
  46708. */
  46709. soundTrackId: number;
  46710. /**
  46711. * Is this sound currently played.
  46712. */
  46713. isPlaying: boolean;
  46714. /**
  46715. * Is this sound currently paused.
  46716. */
  46717. isPaused: boolean;
  46718. /**
  46719. * Does this sound enables spatial sound.
  46720. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46721. */
  46722. spatialSound: boolean;
  46723. /**
  46724. * Define the reference distance the sound should be heard perfectly.
  46725. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46726. */
  46727. refDistance: number;
  46728. /**
  46729. * Define the roll off factor of spatial sounds.
  46730. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46731. */
  46732. rolloffFactor: number;
  46733. /**
  46734. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  46735. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46736. */
  46737. maxDistance: number;
  46738. /**
  46739. * Define the distance attenuation model the sound will follow.
  46740. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46741. */
  46742. distanceModel: string;
  46743. /**
  46744. * @hidden
  46745. * Back Compat
  46746. **/
  46747. onended: () => any;
  46748. /**
  46749. * Gets or sets an object used to store user defined information for the sound.
  46750. */
  46751. metadata: any;
  46752. /**
  46753. * Observable event when the current playing sound finishes.
  46754. */
  46755. onEndedObservable: Observable<Sound>;
  46756. /**
  46757. * Gets the current time for the sound.
  46758. */
  46759. get currentTime(): number;
  46760. private _panningModel;
  46761. private _playbackRate;
  46762. private _streaming;
  46763. private _startTime;
  46764. private _startOffset;
  46765. private _position;
  46766. /** @hidden */
  46767. _positionInEmitterSpace: boolean;
  46768. private _localDirection;
  46769. private _volume;
  46770. private _isReadyToPlay;
  46771. private _isDirectional;
  46772. private _readyToPlayCallback;
  46773. private _audioBuffer;
  46774. private _soundSource;
  46775. private _streamingSource;
  46776. private _soundPanner;
  46777. private _soundGain;
  46778. private _inputAudioNode;
  46779. private _outputAudioNode;
  46780. private _coneInnerAngle;
  46781. private _coneOuterAngle;
  46782. private _coneOuterGain;
  46783. private _scene;
  46784. private _connectedTransformNode;
  46785. private _customAttenuationFunction;
  46786. private _registerFunc;
  46787. private _isOutputConnected;
  46788. private _htmlAudioElement;
  46789. private _urlType;
  46790. private _length?;
  46791. private _offset?;
  46792. /** @hidden */
  46793. static _SceneComponentInitialization: (scene: Scene) => void;
  46794. /**
  46795. * Create a sound and attach it to a scene
  46796. * @param name Name of your sound
  46797. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  46798. * @param scene defines the scene the sound belongs to
  46799. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  46800. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  46801. */
  46802. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  46803. /**
  46804. * Release the sound and its associated resources
  46805. */
  46806. dispose(): void;
  46807. /**
  46808. * Gets if the sounds is ready to be played or not.
  46809. * @returns true if ready, otherwise false
  46810. */
  46811. isReady(): boolean;
  46812. private _soundLoaded;
  46813. /**
  46814. * Sets the data of the sound from an audiobuffer
  46815. * @param audioBuffer The audioBuffer containing the data
  46816. */
  46817. setAudioBuffer(audioBuffer: AudioBuffer): void;
  46818. /**
  46819. * Updates the current sounds options such as maxdistance, loop...
  46820. * @param options A JSON object containing values named as the object properties
  46821. */
  46822. updateOptions(options: ISoundOptions): void;
  46823. private _createSpatialParameters;
  46824. private _updateSpatialParameters;
  46825. /**
  46826. * Switch the panning model to HRTF:
  46827. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46828. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46829. */
  46830. switchPanningModelToHRTF(): void;
  46831. /**
  46832. * Switch the panning model to Equal Power:
  46833. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46834. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46835. */
  46836. switchPanningModelToEqualPower(): void;
  46837. private _switchPanningModel;
  46838. /**
  46839. * Connect this sound to a sound track audio node like gain...
  46840. * @param soundTrackAudioNode the sound track audio node to connect to
  46841. */
  46842. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  46843. /**
  46844. * Transform this sound into a directional source
  46845. * @param coneInnerAngle Size of the inner cone in degree
  46846. * @param coneOuterAngle Size of the outer cone in degree
  46847. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  46848. */
  46849. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  46850. /**
  46851. * Gets or sets the inner angle for the directional cone.
  46852. */
  46853. get directionalConeInnerAngle(): number;
  46854. /**
  46855. * Gets or sets the inner angle for the directional cone.
  46856. */
  46857. set directionalConeInnerAngle(value: number);
  46858. /**
  46859. * Gets or sets the outer angle for the directional cone.
  46860. */
  46861. get directionalConeOuterAngle(): number;
  46862. /**
  46863. * Gets or sets the outer angle for the directional cone.
  46864. */
  46865. set directionalConeOuterAngle(value: number);
  46866. /**
  46867. * Sets the position of the emitter if spatial sound is enabled
  46868. * @param newPosition Defines the new posisiton
  46869. */
  46870. setPosition(newPosition: Vector3): void;
  46871. /**
  46872. * Sets the local direction of the emitter if spatial sound is enabled
  46873. * @param newLocalDirection Defines the new local direction
  46874. */
  46875. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  46876. private _updateDirection;
  46877. /** @hidden */
  46878. updateDistanceFromListener(): void;
  46879. /**
  46880. * Sets a new custom attenuation function for the sound.
  46881. * @param callback Defines the function used for the attenuation
  46882. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46883. */
  46884. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  46885. /**
  46886. * Play the sound
  46887. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  46888. * @param offset (optional) Start the sound at a specific time in seconds
  46889. * @param length (optional) Sound duration (in seconds)
  46890. */
  46891. play(time?: number, offset?: number, length?: number): void;
  46892. private _onended;
  46893. /**
  46894. * Stop the sound
  46895. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  46896. */
  46897. stop(time?: number): void;
  46898. /**
  46899. * Put the sound in pause
  46900. */
  46901. pause(): void;
  46902. /**
  46903. * Sets a dedicated volume for this sounds
  46904. * @param newVolume Define the new volume of the sound
  46905. * @param time Define time for gradual change to new volume
  46906. */
  46907. setVolume(newVolume: number, time?: number): void;
  46908. /**
  46909. * Set the sound play back rate
  46910. * @param newPlaybackRate Define the playback rate the sound should be played at
  46911. */
  46912. setPlaybackRate(newPlaybackRate: number): void;
  46913. /**
  46914. * Gets the volume of the sound.
  46915. * @returns the volume of the sound
  46916. */
  46917. getVolume(): number;
  46918. /**
  46919. * Attach the sound to a dedicated mesh
  46920. * @param transformNode The transform node to connect the sound with
  46921. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46922. */
  46923. attachToMesh(transformNode: TransformNode): void;
  46924. /**
  46925. * Detach the sound from the previously attached mesh
  46926. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46927. */
  46928. detachFromMesh(): void;
  46929. private _onRegisterAfterWorldMatrixUpdate;
  46930. /**
  46931. * Clone the current sound in the scene.
  46932. * @returns the new sound clone
  46933. */
  46934. clone(): Nullable<Sound>;
  46935. /**
  46936. * Gets the current underlying audio buffer containing the data
  46937. * @returns the audio buffer
  46938. */
  46939. getAudioBuffer(): Nullable<AudioBuffer>;
  46940. /**
  46941. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  46942. * @returns the source node
  46943. */
  46944. getSoundSource(): Nullable<AudioBufferSourceNode>;
  46945. /**
  46946. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  46947. * @returns the gain node
  46948. */
  46949. getSoundGain(): Nullable<GainNode>;
  46950. /**
  46951. * Serializes the Sound in a JSON representation
  46952. * @returns the JSON representation of the sound
  46953. */
  46954. serialize(): any;
  46955. /**
  46956. * Parse a JSON representation of a sound to innstantiate in a given scene
  46957. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  46958. * @param scene Define the scene the new parsed sound should be created in
  46959. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  46960. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  46961. * @returns the newly parsed sound
  46962. */
  46963. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  46964. }
  46965. }
  46966. declare module "babylonjs/Actions/directAudioActions" {
  46967. import { Action } from "babylonjs/Actions/action";
  46968. import { Condition } from "babylonjs/Actions/condition";
  46969. import { Sound } from "babylonjs/Audio/sound";
  46970. /**
  46971. * This defines an action helpful to play a defined sound on a triggered action.
  46972. */
  46973. export class PlaySoundAction extends Action {
  46974. private _sound;
  46975. /**
  46976. * Instantiate the action
  46977. * @param triggerOptions defines the trigger options
  46978. * @param sound defines the sound to play
  46979. * @param condition defines the trigger related conditions
  46980. */
  46981. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46982. /** @hidden */
  46983. _prepare(): void;
  46984. /**
  46985. * Execute the action and play the sound.
  46986. */
  46987. execute(): void;
  46988. /**
  46989. * Serializes the actions and its related information.
  46990. * @param parent defines the object to serialize in
  46991. * @returns the serialized object
  46992. */
  46993. serialize(parent: any): any;
  46994. }
  46995. /**
  46996. * This defines an action helpful to stop a defined sound on a triggered action.
  46997. */
  46998. export class StopSoundAction extends Action {
  46999. private _sound;
  47000. /**
  47001. * Instantiate the action
  47002. * @param triggerOptions defines the trigger options
  47003. * @param sound defines the sound to stop
  47004. * @param condition defines the trigger related conditions
  47005. */
  47006. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  47007. /** @hidden */
  47008. _prepare(): void;
  47009. /**
  47010. * Execute the action and stop the sound.
  47011. */
  47012. execute(): void;
  47013. /**
  47014. * Serializes the actions and its related information.
  47015. * @param parent defines the object to serialize in
  47016. * @returns the serialized object
  47017. */
  47018. serialize(parent: any): any;
  47019. }
  47020. }
  47021. declare module "babylonjs/Actions/interpolateValueAction" {
  47022. import { Action } from "babylonjs/Actions/action";
  47023. import { Condition } from "babylonjs/Actions/condition";
  47024. import { Observable } from "babylonjs/Misc/observable";
  47025. /**
  47026. * This defines an action responsible to change the value of a property
  47027. * by interpolating between its current value and the newly set one once triggered.
  47028. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  47029. */
  47030. export class InterpolateValueAction extends Action {
  47031. /**
  47032. * Defines the path of the property where the value should be interpolated
  47033. */
  47034. propertyPath: string;
  47035. /**
  47036. * Defines the target value at the end of the interpolation.
  47037. */
  47038. value: any;
  47039. /**
  47040. * Defines the time it will take for the property to interpolate to the value.
  47041. */
  47042. duration: number;
  47043. /**
  47044. * Defines if the other scene animations should be stopped when the action has been triggered
  47045. */
  47046. stopOtherAnimations?: boolean;
  47047. /**
  47048. * Defines a callback raised once the interpolation animation has been done.
  47049. */
  47050. onInterpolationDone?: () => void;
  47051. /**
  47052. * Observable triggered once the interpolation animation has been done.
  47053. */
  47054. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  47055. private _target;
  47056. private _effectiveTarget;
  47057. private _property;
  47058. /**
  47059. * Instantiate the action
  47060. * @param triggerOptions defines the trigger options
  47061. * @param target defines the object containing the value to interpolate
  47062. * @param propertyPath defines the path to the property in the target object
  47063. * @param value defines the target value at the end of the interpolation
  47064. * @param duration deines the time it will take for the property to interpolate to the value.
  47065. * @param condition defines the trigger related conditions
  47066. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  47067. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  47068. */
  47069. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  47070. /** @hidden */
  47071. _prepare(): void;
  47072. /**
  47073. * Execute the action starts the value interpolation.
  47074. */
  47075. execute(): void;
  47076. /**
  47077. * Serializes the actions and its related information.
  47078. * @param parent defines the object to serialize in
  47079. * @returns the serialized object
  47080. */
  47081. serialize(parent: any): any;
  47082. }
  47083. }
  47084. declare module "babylonjs/Actions/index" {
  47085. export * from "babylonjs/Actions/abstractActionManager";
  47086. export * from "babylonjs/Actions/action";
  47087. export * from "babylonjs/Actions/actionEvent";
  47088. export * from "babylonjs/Actions/actionManager";
  47089. export * from "babylonjs/Actions/condition";
  47090. export * from "babylonjs/Actions/directActions";
  47091. export * from "babylonjs/Actions/directAudioActions";
  47092. export * from "babylonjs/Actions/interpolateValueAction";
  47093. }
  47094. declare module "babylonjs/Animations/index" {
  47095. export * from "babylonjs/Animations/animatable";
  47096. export * from "babylonjs/Animations/animation";
  47097. export * from "babylonjs/Animations/animationGroup";
  47098. export * from "babylonjs/Animations/animationPropertiesOverride";
  47099. export * from "babylonjs/Animations/easing";
  47100. export * from "babylonjs/Animations/runtimeAnimation";
  47101. export * from "babylonjs/Animations/animationEvent";
  47102. export * from "babylonjs/Animations/animationGroup";
  47103. export * from "babylonjs/Animations/animationKey";
  47104. export * from "babylonjs/Animations/animationRange";
  47105. export * from "babylonjs/Animations/animatable.interface";
  47106. }
  47107. declare module "babylonjs/Audio/audioEngine" {
  47108. import { Analyser } from "babylonjs/Audio/analyser";
  47109. import { Nullable } from "babylonjs/types";
  47110. import { Observable } from "babylonjs/Misc/observable";
  47111. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  47112. /**
  47113. * This represents the default audio engine used in babylon.
  47114. * It is responsible to play, synchronize and analyse sounds throughout the application.
  47115. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47116. */
  47117. export class AudioEngine implements IAudioEngine {
  47118. private _audioContext;
  47119. private _audioContextInitialized;
  47120. private _muteButton;
  47121. private _hostElement;
  47122. /**
  47123. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  47124. */
  47125. canUseWebAudio: boolean;
  47126. /**
  47127. * The master gain node defines the global audio volume of your audio engine.
  47128. */
  47129. masterGain: GainNode;
  47130. /**
  47131. * Defines if Babylon should emit a warning if WebAudio is not supported.
  47132. * @ignoreNaming
  47133. */
  47134. WarnedWebAudioUnsupported: boolean;
  47135. /**
  47136. * Gets whether or not mp3 are supported by your browser.
  47137. */
  47138. isMP3supported: boolean;
  47139. /**
  47140. * Gets whether or not ogg are supported by your browser.
  47141. */
  47142. isOGGsupported: boolean;
  47143. /**
  47144. * Gets whether audio has been unlocked on the device.
  47145. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  47146. * a user interaction has happened.
  47147. */
  47148. unlocked: boolean;
  47149. /**
  47150. * Defines if the audio engine relies on a custom unlocked button.
  47151. * In this case, the embedded button will not be displayed.
  47152. */
  47153. useCustomUnlockedButton: boolean;
  47154. /**
  47155. * Event raised when audio has been unlocked on the browser.
  47156. */
  47157. onAudioUnlockedObservable: Observable<IAudioEngine>;
  47158. /**
  47159. * Event raised when audio has been locked on the browser.
  47160. */
  47161. onAudioLockedObservable: Observable<IAudioEngine>;
  47162. /**
  47163. * Gets the current AudioContext if available.
  47164. */
  47165. get audioContext(): Nullable<AudioContext>;
  47166. private _connectedAnalyser;
  47167. /**
  47168. * Instantiates a new audio engine.
  47169. *
  47170. * There should be only one per page as some browsers restrict the number
  47171. * of audio contexts you can create.
  47172. * @param hostElement defines the host element where to display the mute icon if necessary
  47173. */
  47174. constructor(hostElement?: Nullable<HTMLElement>);
  47175. /**
  47176. * Flags the audio engine in Locked state.
  47177. * This happens due to new browser policies preventing audio to autoplay.
  47178. */
  47179. lock(): void;
  47180. /**
  47181. * Unlocks the audio engine once a user action has been done on the dom.
  47182. * This is helpful to resume play once browser policies have been satisfied.
  47183. */
  47184. unlock(): void;
  47185. private _resumeAudioContext;
  47186. private _initializeAudioContext;
  47187. private _tryToRun;
  47188. private _triggerRunningState;
  47189. private _triggerSuspendedState;
  47190. private _displayMuteButton;
  47191. private _moveButtonToTopLeft;
  47192. private _onResize;
  47193. private _hideMuteButton;
  47194. /**
  47195. * Destroy and release the resources associated with the audio ccontext.
  47196. */
  47197. dispose(): void;
  47198. /**
  47199. * Gets the global volume sets on the master gain.
  47200. * @returns the global volume if set or -1 otherwise
  47201. */
  47202. getGlobalVolume(): number;
  47203. /**
  47204. * Sets the global volume of your experience (sets on the master gain).
  47205. * @param newVolume Defines the new global volume of the application
  47206. */
  47207. setGlobalVolume(newVolume: number): void;
  47208. /**
  47209. * Connect the audio engine to an audio analyser allowing some amazing
  47210. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  47211. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  47212. * @param analyser The analyser to connect to the engine
  47213. */
  47214. connectToAnalyser(analyser: Analyser): void;
  47215. }
  47216. }
  47217. declare module "babylonjs/Audio/soundTrack" {
  47218. import { Sound } from "babylonjs/Audio/sound";
  47219. import { Analyser } from "babylonjs/Audio/analyser";
  47220. import { Scene } from "babylonjs/scene";
  47221. /**
  47222. * Options allowed during the creation of a sound track.
  47223. */
  47224. export interface ISoundTrackOptions {
  47225. /**
  47226. * The volume the sound track should take during creation
  47227. */
  47228. volume?: number;
  47229. /**
  47230. * Define if the sound track is the main sound track of the scene
  47231. */
  47232. mainTrack?: boolean;
  47233. }
  47234. /**
  47235. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  47236. * It will be also used in a future release to apply effects on a specific track.
  47237. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  47238. */
  47239. export class SoundTrack {
  47240. /**
  47241. * The unique identifier of the sound track in the scene.
  47242. */
  47243. id: number;
  47244. /**
  47245. * The list of sounds included in the sound track.
  47246. */
  47247. soundCollection: Array<Sound>;
  47248. private _outputAudioNode;
  47249. private _scene;
  47250. private _connectedAnalyser;
  47251. private _options;
  47252. private _isInitialized;
  47253. /**
  47254. * Creates a new sound track.
  47255. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  47256. * @param scene Define the scene the sound track belongs to
  47257. * @param options
  47258. */
  47259. constructor(scene: Scene, options?: ISoundTrackOptions);
  47260. private _initializeSoundTrackAudioGraph;
  47261. /**
  47262. * Release the sound track and its associated resources
  47263. */
  47264. dispose(): void;
  47265. /**
  47266. * Adds a sound to this sound track
  47267. * @param sound define the cound to add
  47268. * @ignoreNaming
  47269. */
  47270. addSound(sound: Sound): void;
  47271. /**
  47272. * Removes a sound to this sound track
  47273. * @param sound define the cound to remove
  47274. * @ignoreNaming
  47275. */
  47276. removeSound(sound: Sound): void;
  47277. /**
  47278. * Set a global volume for the full sound track.
  47279. * @param newVolume Define the new volume of the sound track
  47280. */
  47281. setVolume(newVolume: number): void;
  47282. /**
  47283. * Switch the panning model to HRTF:
  47284. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  47285. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47286. */
  47287. switchPanningModelToHRTF(): void;
  47288. /**
  47289. * Switch the panning model to Equal Power:
  47290. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  47291. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47292. */
  47293. switchPanningModelToEqualPower(): void;
  47294. /**
  47295. * Connect the sound track to an audio analyser allowing some amazing
  47296. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  47297. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  47298. * @param analyser The analyser to connect to the engine
  47299. */
  47300. connectToAnalyser(analyser: Analyser): void;
  47301. }
  47302. }
  47303. declare module "babylonjs/Audio/audioSceneComponent" {
  47304. import { Sound } from "babylonjs/Audio/sound";
  47305. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  47306. import { Nullable } from "babylonjs/types";
  47307. import { Vector3 } from "babylonjs/Maths/math.vector";
  47308. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47309. import { Scene } from "babylonjs/scene";
  47310. import { AbstractScene } from "babylonjs/abstractScene";
  47311. import "babylonjs/Audio/audioEngine";
  47312. module "babylonjs/abstractScene" {
  47313. interface AbstractScene {
  47314. /**
  47315. * The list of sounds used in the scene.
  47316. */
  47317. sounds: Nullable<Array<Sound>>;
  47318. }
  47319. }
  47320. module "babylonjs/scene" {
  47321. interface Scene {
  47322. /**
  47323. * @hidden
  47324. * Backing field
  47325. */
  47326. _mainSoundTrack: SoundTrack;
  47327. /**
  47328. * The main sound track played by the scene.
  47329. * It cotains your primary collection of sounds.
  47330. */
  47331. mainSoundTrack: SoundTrack;
  47332. /**
  47333. * The list of sound tracks added to the scene
  47334. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47335. */
  47336. soundTracks: Nullable<Array<SoundTrack>>;
  47337. /**
  47338. * Gets a sound using a given name
  47339. * @param name defines the name to search for
  47340. * @return the found sound or null if not found at all.
  47341. */
  47342. getSoundByName(name: string): Nullable<Sound>;
  47343. /**
  47344. * Gets or sets if audio support is enabled
  47345. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47346. */
  47347. audioEnabled: boolean;
  47348. /**
  47349. * Gets or sets if audio will be output to headphones
  47350. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47351. */
  47352. headphone: boolean;
  47353. /**
  47354. * Gets or sets custom audio listener position provider
  47355. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47356. */
  47357. audioListenerPositionProvider: Nullable<() => Vector3>;
  47358. /**
  47359. * Gets or sets a refresh rate when using 3D audio positioning
  47360. */
  47361. audioPositioningRefreshRate: number;
  47362. }
  47363. }
  47364. /**
  47365. * Defines the sound scene component responsible to manage any sounds
  47366. * in a given scene.
  47367. */
  47368. export class AudioSceneComponent implements ISceneSerializableComponent {
  47369. private static _CameraDirectionLH;
  47370. private static _CameraDirectionRH;
  47371. /**
  47372. * The component name helpfull to identify the component in the list of scene components.
  47373. */
  47374. readonly name: string;
  47375. /**
  47376. * The scene the component belongs to.
  47377. */
  47378. scene: Scene;
  47379. private _audioEnabled;
  47380. /**
  47381. * Gets whether audio is enabled or not.
  47382. * Please use related enable/disable method to switch state.
  47383. */
  47384. get audioEnabled(): boolean;
  47385. private _headphone;
  47386. /**
  47387. * Gets whether audio is outputing to headphone or not.
  47388. * Please use the according Switch methods to change output.
  47389. */
  47390. get headphone(): boolean;
  47391. /**
  47392. * Gets or sets a refresh rate when using 3D audio positioning
  47393. */
  47394. audioPositioningRefreshRate: number;
  47395. private _audioListenerPositionProvider;
  47396. /**
  47397. * Gets the current audio listener position provider
  47398. */
  47399. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  47400. /**
  47401. * Sets a custom listener position for all sounds in the scene
  47402. * By default, this is the position of the first active camera
  47403. */
  47404. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  47405. /**
  47406. * Creates a new instance of the component for the given scene
  47407. * @param scene Defines the scene to register the component in
  47408. */
  47409. constructor(scene: Scene);
  47410. /**
  47411. * Registers the component in a given scene
  47412. */
  47413. register(): void;
  47414. /**
  47415. * Rebuilds the elements related to this component in case of
  47416. * context lost for instance.
  47417. */
  47418. rebuild(): void;
  47419. /**
  47420. * Serializes the component data to the specified json object
  47421. * @param serializationObject The object to serialize to
  47422. */
  47423. serialize(serializationObject: any): void;
  47424. /**
  47425. * Adds all the elements from the container to the scene
  47426. * @param container the container holding the elements
  47427. */
  47428. addFromContainer(container: AbstractScene): void;
  47429. /**
  47430. * Removes all the elements in the container from the scene
  47431. * @param container contains the elements to remove
  47432. * @param dispose if the removed element should be disposed (default: false)
  47433. */
  47434. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47435. /**
  47436. * Disposes the component and the associated ressources.
  47437. */
  47438. dispose(): void;
  47439. /**
  47440. * Disables audio in the associated scene.
  47441. */
  47442. disableAudio(): void;
  47443. /**
  47444. * Enables audio in the associated scene.
  47445. */
  47446. enableAudio(): void;
  47447. /**
  47448. * Switch audio to headphone output.
  47449. */
  47450. switchAudioModeForHeadphones(): void;
  47451. /**
  47452. * Switch audio to normal speakers.
  47453. */
  47454. switchAudioModeForNormalSpeakers(): void;
  47455. private _cachedCameraDirection;
  47456. private _cachedCameraPosition;
  47457. private _lastCheck;
  47458. private _afterRender;
  47459. }
  47460. }
  47461. declare module "babylonjs/Audio/weightedsound" {
  47462. import { Sound } from "babylonjs/Audio/sound";
  47463. /**
  47464. * Wraps one or more Sound objects and selects one with random weight for playback.
  47465. */
  47466. export class WeightedSound {
  47467. /** When true a Sound will be selected and played when the current playing Sound completes. */
  47468. loop: boolean;
  47469. private _coneInnerAngle;
  47470. private _coneOuterAngle;
  47471. private _volume;
  47472. /** A Sound is currently playing. */
  47473. isPlaying: boolean;
  47474. /** A Sound is currently paused. */
  47475. isPaused: boolean;
  47476. private _sounds;
  47477. private _weights;
  47478. private _currentIndex?;
  47479. /**
  47480. * Creates a new WeightedSound from the list of sounds given.
  47481. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  47482. * @param sounds Array of Sounds that will be selected from.
  47483. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  47484. */
  47485. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  47486. /**
  47487. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  47488. */
  47489. get directionalConeInnerAngle(): number;
  47490. /**
  47491. * The size of cone in degress for a directional sound in which there will be no attenuation.
  47492. */
  47493. set directionalConeInnerAngle(value: number);
  47494. /**
  47495. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  47496. * Listener angles between innerAngle and outerAngle will falloff linearly.
  47497. */
  47498. get directionalConeOuterAngle(): number;
  47499. /**
  47500. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  47501. * Listener angles between innerAngle and outerAngle will falloff linearly.
  47502. */
  47503. set directionalConeOuterAngle(value: number);
  47504. /**
  47505. * Playback volume.
  47506. */
  47507. get volume(): number;
  47508. /**
  47509. * Playback volume.
  47510. */
  47511. set volume(value: number);
  47512. private _onended;
  47513. /**
  47514. * Suspend playback
  47515. */
  47516. pause(): void;
  47517. /**
  47518. * Stop playback
  47519. */
  47520. stop(): void;
  47521. /**
  47522. * Start playback.
  47523. * @param startOffset Position the clip head at a specific time in seconds.
  47524. */
  47525. play(startOffset?: number): void;
  47526. }
  47527. }
  47528. declare module "babylonjs/Audio/index" {
  47529. export * from "babylonjs/Audio/Interfaces/IAudioEngine";
  47530. export * from "babylonjs/Audio/Interfaces/ISoundOptions";
  47531. export * from "babylonjs/Audio/analyser";
  47532. export * from "babylonjs/Audio/audioEngine";
  47533. export * from "babylonjs/Audio/audioSceneComponent";
  47534. export * from "babylonjs/Audio/sound";
  47535. export * from "babylonjs/Audio/soundTrack";
  47536. export * from "babylonjs/Audio/weightedsound";
  47537. }
  47538. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  47539. import { Behavior } from "babylonjs/Behaviors/behavior";
  47540. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47541. import { BackEase } from "babylonjs/Animations/easing";
  47542. /**
  47543. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  47544. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47545. */
  47546. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  47547. /**
  47548. * Gets the name of the behavior.
  47549. */
  47550. get name(): string;
  47551. /**
  47552. * The easing function used by animations
  47553. */
  47554. static EasingFunction: BackEase;
  47555. /**
  47556. * The easing mode used by animations
  47557. */
  47558. static EasingMode: number;
  47559. /**
  47560. * The duration of the animation, in milliseconds
  47561. */
  47562. transitionDuration: number;
  47563. /**
  47564. * Length of the distance animated by the transition when lower radius is reached
  47565. */
  47566. lowerRadiusTransitionRange: number;
  47567. /**
  47568. * Length of the distance animated by the transition when upper radius is reached
  47569. */
  47570. upperRadiusTransitionRange: number;
  47571. private _autoTransitionRange;
  47572. /**
  47573. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  47574. */
  47575. get autoTransitionRange(): boolean;
  47576. /**
  47577. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  47578. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  47579. */
  47580. set autoTransitionRange(value: boolean);
  47581. private _attachedCamera;
  47582. private _onAfterCheckInputsObserver;
  47583. private _onMeshTargetChangedObserver;
  47584. /**
  47585. * Initializes the behavior.
  47586. */
  47587. init(): void;
  47588. /**
  47589. * Attaches the behavior to its arc rotate camera.
  47590. * @param camera Defines the camera to attach the behavior to
  47591. */
  47592. attach(camera: ArcRotateCamera): void;
  47593. /**
  47594. * Detaches the behavior from its current arc rotate camera.
  47595. */
  47596. detach(): void;
  47597. private _radiusIsAnimating;
  47598. private _radiusBounceTransition;
  47599. private _animatables;
  47600. private _cachedWheelPrecision;
  47601. /**
  47602. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  47603. * @param radiusLimit The limit to check against.
  47604. * @return Bool to indicate if at limit.
  47605. */
  47606. private _isRadiusAtLimit;
  47607. /**
  47608. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  47609. * @param radiusDelta The delta by which to animate to. Can be negative.
  47610. */
  47611. private _applyBoundRadiusAnimation;
  47612. /**
  47613. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  47614. */
  47615. protected _clearAnimationLocks(): void;
  47616. /**
  47617. * Stops and removes all animations that have been applied to the camera
  47618. */
  47619. stopAllAnimations(): void;
  47620. }
  47621. }
  47622. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  47623. import { Behavior } from "babylonjs/Behaviors/behavior";
  47624. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47625. import { ExponentialEase } from "babylonjs/Animations/easing";
  47626. import { Nullable } from "babylonjs/types";
  47627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47628. import { Vector3 } from "babylonjs/Maths/math.vector";
  47629. /**
  47630. * 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.
  47631. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47632. */
  47633. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  47634. /**
  47635. * Gets the name of the behavior.
  47636. */
  47637. get name(): string;
  47638. private _mode;
  47639. private _radiusScale;
  47640. private _positionScale;
  47641. private _defaultElevation;
  47642. private _elevationReturnTime;
  47643. private _elevationReturnWaitTime;
  47644. private _zoomStopsAnimation;
  47645. private _framingTime;
  47646. /**
  47647. * The easing function used by animations
  47648. */
  47649. static EasingFunction: ExponentialEase;
  47650. /**
  47651. * The easing mode used by animations
  47652. */
  47653. static EasingMode: number;
  47654. /**
  47655. * Sets the current mode used by the behavior
  47656. */
  47657. set mode(mode: number);
  47658. /**
  47659. * Gets current mode used by the behavior.
  47660. */
  47661. get mode(): number;
  47662. /**
  47663. * Sets the scale applied to the radius (1 by default)
  47664. */
  47665. set radiusScale(radius: number);
  47666. /**
  47667. * Gets the scale applied to the radius
  47668. */
  47669. get radiusScale(): number;
  47670. /**
  47671. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47672. */
  47673. set positionScale(scale: number);
  47674. /**
  47675. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47676. */
  47677. get positionScale(): number;
  47678. /**
  47679. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47680. * behaviour is triggered, in radians.
  47681. */
  47682. set defaultElevation(elevation: number);
  47683. /**
  47684. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47685. * behaviour is triggered, in radians.
  47686. */
  47687. get defaultElevation(): number;
  47688. /**
  47689. * Sets the time (in milliseconds) taken to return to the default beta position.
  47690. * Negative value indicates camera should not return to default.
  47691. */
  47692. set elevationReturnTime(speed: number);
  47693. /**
  47694. * Gets the time (in milliseconds) taken to return to the default beta position.
  47695. * Negative value indicates camera should not return to default.
  47696. */
  47697. get elevationReturnTime(): number;
  47698. /**
  47699. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47700. */
  47701. set elevationReturnWaitTime(time: number);
  47702. /**
  47703. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47704. */
  47705. get elevationReturnWaitTime(): number;
  47706. /**
  47707. * Sets the flag that indicates if user zooming should stop animation.
  47708. */
  47709. set zoomStopsAnimation(flag: boolean);
  47710. /**
  47711. * Gets the flag that indicates if user zooming should stop animation.
  47712. */
  47713. get zoomStopsAnimation(): boolean;
  47714. /**
  47715. * Sets the transition time when framing the mesh, in milliseconds
  47716. */
  47717. set framingTime(time: number);
  47718. /**
  47719. * Gets the transition time when framing the mesh, in milliseconds
  47720. */
  47721. get framingTime(): number;
  47722. /**
  47723. * Define if the behavior should automatically change the configured
  47724. * camera limits and sensibilities.
  47725. */
  47726. autoCorrectCameraLimitsAndSensibility: boolean;
  47727. private _onPrePointerObservableObserver;
  47728. private _onAfterCheckInputsObserver;
  47729. private _onMeshTargetChangedObserver;
  47730. private _attachedCamera;
  47731. private _isPointerDown;
  47732. private _lastInteractionTime;
  47733. /**
  47734. * Initializes the behavior.
  47735. */
  47736. init(): void;
  47737. /**
  47738. * Attaches the behavior to its arc rotate camera.
  47739. * @param camera Defines the camera to attach the behavior to
  47740. */
  47741. attach(camera: ArcRotateCamera): void;
  47742. /**
  47743. * Detaches the behavior from its current arc rotate camera.
  47744. */
  47745. detach(): void;
  47746. private _animatables;
  47747. private _betaIsAnimating;
  47748. private _betaTransition;
  47749. private _radiusTransition;
  47750. private _vectorTransition;
  47751. /**
  47752. * Targets the given mesh and updates zoom level accordingly.
  47753. * @param mesh The mesh to target.
  47754. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47755. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47756. */
  47757. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47758. /**
  47759. * Targets the given mesh with its children and updates zoom level accordingly.
  47760. * @param mesh The mesh to target.
  47761. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47762. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47763. */
  47764. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47765. /**
  47766. * Targets the given meshes with their children and updates zoom level accordingly.
  47767. * @param meshes The mesh to target.
  47768. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47769. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47770. */
  47771. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47772. /**
  47773. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  47774. * @param minimumWorld Determines the smaller position of the bounding box extend
  47775. * @param maximumWorld Determines the bigger position of the bounding box extend
  47776. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47777. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47778. */
  47779. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47780. /**
  47781. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  47782. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  47783. * frustum width.
  47784. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  47785. * to fully enclose the mesh in the viewing frustum.
  47786. */
  47787. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  47788. /**
  47789. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  47790. * is automatically returned to its default position (expected to be above ground plane).
  47791. */
  47792. private _maintainCameraAboveGround;
  47793. /**
  47794. * Returns the frustum slope based on the canvas ratio and camera FOV
  47795. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  47796. */
  47797. private _getFrustumSlope;
  47798. /**
  47799. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  47800. */
  47801. private _clearAnimationLocks;
  47802. /**
  47803. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47804. */
  47805. private _applyUserInteraction;
  47806. /**
  47807. * Stops and removes all animations that have been applied to the camera
  47808. */
  47809. stopAllAnimations(): void;
  47810. /**
  47811. * Gets a value indicating if the user is moving the camera
  47812. */
  47813. get isUserIsMoving(): boolean;
  47814. /**
  47815. * The camera can move all the way towards the mesh.
  47816. */
  47817. static IgnoreBoundsSizeMode: number;
  47818. /**
  47819. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  47820. */
  47821. static FitFrustumSidesMode: number;
  47822. }
  47823. }
  47824. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  47825. import { Nullable } from "babylonjs/types";
  47826. import { Camera } from "babylonjs/Cameras/camera";
  47827. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47828. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47829. /**
  47830. * Base class for Camera Pointer Inputs.
  47831. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  47832. * for example usage.
  47833. */
  47834. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  47835. /**
  47836. * Defines the camera the input is attached to.
  47837. */
  47838. abstract camera: Camera;
  47839. /**
  47840. * Whether keyboard modifier keys are pressed at time of last mouse event.
  47841. */
  47842. protected _altKey: boolean;
  47843. protected _ctrlKey: boolean;
  47844. protected _metaKey: boolean;
  47845. protected _shiftKey: boolean;
  47846. /**
  47847. * Which mouse buttons were pressed at time of last mouse event.
  47848. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  47849. */
  47850. protected _buttonsPressed: number;
  47851. /**
  47852. * Defines the buttons associated with the input to handle camera move.
  47853. */
  47854. buttons: number[];
  47855. /**
  47856. * Attach the input controls to a specific dom element to get the input from.
  47857. * @param element Defines the element the controls should be listened from
  47858. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47859. */
  47860. attachControl(noPreventDefault?: boolean): void;
  47861. /**
  47862. * Detach the current controls from the specified dom element.
  47863. */
  47864. detachControl(): void;
  47865. /**
  47866. * Gets the class name of the current input.
  47867. * @returns the class name
  47868. */
  47869. getClassName(): string;
  47870. /**
  47871. * Get the friendly name associated with the input class.
  47872. * @returns the input friendly name
  47873. */
  47874. getSimpleName(): string;
  47875. /**
  47876. * Called on pointer POINTERDOUBLETAP event.
  47877. * Override this method to provide functionality on POINTERDOUBLETAP event.
  47878. */
  47879. protected onDoubleTap(type: string): void;
  47880. /**
  47881. * Called on pointer POINTERMOVE event if only a single touch is active.
  47882. * Override this method to provide functionality.
  47883. */
  47884. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47885. /**
  47886. * Called on pointer POINTERMOVE event if multiple touches are active.
  47887. * Override this method to provide functionality.
  47888. */
  47889. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47890. /**
  47891. * Called on JS contextmenu event.
  47892. * Override this method to provide functionality.
  47893. */
  47894. protected onContextMenu(evt: PointerEvent): void;
  47895. /**
  47896. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47897. * press.
  47898. * Override this method to provide functionality.
  47899. */
  47900. protected onButtonDown(evt: PointerEvent): void;
  47901. /**
  47902. * Called each time a new POINTERUP event occurs. Ie, for each button
  47903. * release.
  47904. * Override this method to provide functionality.
  47905. */
  47906. protected onButtonUp(evt: PointerEvent): void;
  47907. /**
  47908. * Called when window becomes inactive.
  47909. * Override this method to provide functionality.
  47910. */
  47911. protected onLostFocus(): void;
  47912. private _pointerInput;
  47913. private _observer;
  47914. private _onLostFocus;
  47915. private pointA;
  47916. private pointB;
  47917. }
  47918. }
  47919. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  47920. import { Nullable } from "babylonjs/types";
  47921. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47922. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  47923. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47924. /**
  47925. * Manage the pointers inputs to control an arc rotate camera.
  47926. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47927. */
  47928. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  47929. /**
  47930. * Defines the camera the input is attached to.
  47931. */
  47932. camera: ArcRotateCamera;
  47933. /**
  47934. * Gets the class name of the current input.
  47935. * @returns the class name
  47936. */
  47937. getClassName(): string;
  47938. /**
  47939. * Defines the buttons associated with the input to handle camera move.
  47940. */
  47941. buttons: number[];
  47942. /**
  47943. * Defines the pointer angular sensibility along the X axis or how fast is
  47944. * the camera rotating.
  47945. */
  47946. angularSensibilityX: number;
  47947. /**
  47948. * Defines the pointer angular sensibility along the Y axis or how fast is
  47949. * the camera rotating.
  47950. */
  47951. angularSensibilityY: number;
  47952. /**
  47953. * Defines the pointer pinch precision or how fast is the camera zooming.
  47954. */
  47955. pinchPrecision: number;
  47956. /**
  47957. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47958. * from 0.
  47959. * It defines the percentage of current camera.radius to use as delta when
  47960. * pinch zoom is used.
  47961. */
  47962. pinchDeltaPercentage: number;
  47963. /**
  47964. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47965. * that any object in the plane at the camera's target point will scale
  47966. * perfectly with finger motion.
  47967. * Overrides pinchDeltaPercentage and pinchPrecision.
  47968. */
  47969. useNaturalPinchZoom: boolean;
  47970. /**
  47971. * Defines the pointer panning sensibility or how fast is the camera moving.
  47972. */
  47973. panningSensibility: number;
  47974. /**
  47975. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  47976. */
  47977. multiTouchPanning: boolean;
  47978. /**
  47979. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  47980. * zoom (pinch) through multitouch.
  47981. */
  47982. multiTouchPanAndZoom: boolean;
  47983. /**
  47984. * Revers pinch action direction.
  47985. */
  47986. pinchInwards: boolean;
  47987. private _isPanClick;
  47988. private _twoFingerActivityCount;
  47989. private _isPinching;
  47990. /**
  47991. * Called on pointer POINTERMOVE event if only a single touch is active.
  47992. */
  47993. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47994. /**
  47995. * Called on pointer POINTERDOUBLETAP event.
  47996. */
  47997. protected onDoubleTap(type: string): void;
  47998. /**
  47999. * Called on pointer POINTERMOVE event if multiple touches are active.
  48000. */
  48001. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  48002. /**
  48003. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  48004. * press.
  48005. */
  48006. protected onButtonDown(evt: PointerEvent): void;
  48007. /**
  48008. * Called each time a new POINTERUP event occurs. Ie, for each button
  48009. * release.
  48010. */
  48011. protected onButtonUp(evt: PointerEvent): void;
  48012. /**
  48013. * Called when window becomes inactive.
  48014. */
  48015. protected onLostFocus(): void;
  48016. }
  48017. }
  48018. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  48019. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48020. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48021. /**
  48022. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  48023. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48024. */
  48025. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  48026. /**
  48027. * Defines the camera the input is attached to.
  48028. */
  48029. camera: ArcRotateCamera;
  48030. /**
  48031. * Defines the list of key codes associated with the up action (increase alpha)
  48032. */
  48033. keysUp: number[];
  48034. /**
  48035. * Defines the list of key codes associated with the down action (decrease alpha)
  48036. */
  48037. keysDown: number[];
  48038. /**
  48039. * Defines the list of key codes associated with the left action (increase beta)
  48040. */
  48041. keysLeft: number[];
  48042. /**
  48043. * Defines the list of key codes associated with the right action (decrease beta)
  48044. */
  48045. keysRight: number[];
  48046. /**
  48047. * Defines the list of key codes associated with the reset action.
  48048. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  48049. */
  48050. keysReset: number[];
  48051. /**
  48052. * Defines the panning sensibility of the inputs.
  48053. * (How fast is the camera panning)
  48054. */
  48055. panningSensibility: number;
  48056. /**
  48057. * Defines the zooming sensibility of the inputs.
  48058. * (How fast is the camera zooming)
  48059. */
  48060. zoomingSensibility: number;
  48061. /**
  48062. * Defines whether maintaining the alt key down switch the movement mode from
  48063. * orientation to zoom.
  48064. */
  48065. useAltToZoom: boolean;
  48066. /**
  48067. * Rotation speed of the camera
  48068. */
  48069. angularSpeed: number;
  48070. private _keys;
  48071. private _ctrlPressed;
  48072. private _altPressed;
  48073. private _onCanvasBlurObserver;
  48074. private _onKeyboardObserver;
  48075. private _engine;
  48076. private _scene;
  48077. /**
  48078. * Attach the input controls to a specific dom element to get the input from.
  48079. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48080. */
  48081. attachControl(noPreventDefault?: boolean): void;
  48082. /**
  48083. * Detach the current controls from the specified dom element.
  48084. */
  48085. detachControl(): void;
  48086. /**
  48087. * Update the current camera state depending on the inputs that have been used this frame.
  48088. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48089. */
  48090. checkInputs(): void;
  48091. /**
  48092. * Gets the class name of the current intput.
  48093. * @returns the class name
  48094. */
  48095. getClassName(): string;
  48096. /**
  48097. * Get the friendly name associated with the input class.
  48098. * @returns the input friendly name
  48099. */
  48100. getSimpleName(): string;
  48101. }
  48102. }
  48103. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  48104. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48105. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48106. /**
  48107. * Manage the mouse wheel inputs to control an arc rotate camera.
  48108. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48109. */
  48110. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  48111. /**
  48112. * Defines the camera the input is attached to.
  48113. */
  48114. camera: ArcRotateCamera;
  48115. /**
  48116. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  48117. */
  48118. wheelPrecision: number;
  48119. /**
  48120. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  48121. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  48122. */
  48123. wheelDeltaPercentage: number;
  48124. private _wheel;
  48125. private _observer;
  48126. private computeDeltaFromMouseWheelLegacyEvent;
  48127. /**
  48128. * Attach the input controls to a specific dom element to get the input from.
  48129. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48130. */
  48131. attachControl(noPreventDefault?: boolean): void;
  48132. /**
  48133. * Detach the current controls from the specified dom element.
  48134. */
  48135. detachControl(): void;
  48136. /**
  48137. * Gets the class name of the current intput.
  48138. * @returns the class name
  48139. */
  48140. getClassName(): string;
  48141. /**
  48142. * Get the friendly name associated with the input class.
  48143. * @returns the input friendly name
  48144. */
  48145. getSimpleName(): string;
  48146. }
  48147. }
  48148. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  48149. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48150. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  48151. /**
  48152. * Default Inputs manager for the ArcRotateCamera.
  48153. * It groups all the default supported inputs for ease of use.
  48154. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48155. */
  48156. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  48157. /**
  48158. * Instantiates a new ArcRotateCameraInputsManager.
  48159. * @param camera Defines the camera the inputs belong to
  48160. */
  48161. constructor(camera: ArcRotateCamera);
  48162. /**
  48163. * Add mouse wheel input support to the input manager.
  48164. * @returns the current input manager
  48165. */
  48166. addMouseWheel(): ArcRotateCameraInputsManager;
  48167. /**
  48168. * Add pointers input support to the input manager.
  48169. * @returns the current input manager
  48170. */
  48171. addPointers(): ArcRotateCameraInputsManager;
  48172. /**
  48173. * Add keyboard input support to the input manager.
  48174. * @returns the current input manager
  48175. */
  48176. addKeyboard(): ArcRotateCameraInputsManager;
  48177. }
  48178. }
  48179. declare module "babylonjs/Cameras/arcRotateCamera" {
  48180. import { Observable } from "babylonjs/Misc/observable";
  48181. import { Nullable } from "babylonjs/types";
  48182. import { Scene } from "babylonjs/scene";
  48183. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  48184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48185. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  48186. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  48187. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  48188. import { Camera } from "babylonjs/Cameras/camera";
  48189. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  48190. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  48191. import { Collider } from "babylonjs/Collisions/collider";
  48192. /**
  48193. * This represents an orbital type of camera.
  48194. *
  48195. * 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.
  48196. * 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.
  48197. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  48198. */
  48199. export class ArcRotateCamera extends TargetCamera {
  48200. /**
  48201. * Defines the rotation angle of the camera along the longitudinal axis.
  48202. */
  48203. alpha: number;
  48204. /**
  48205. * Defines the rotation angle of the camera along the latitudinal axis.
  48206. */
  48207. beta: number;
  48208. /**
  48209. * Defines the radius of the camera from it s target point.
  48210. */
  48211. radius: number;
  48212. protected _target: Vector3;
  48213. protected _targetHost: Nullable<AbstractMesh>;
  48214. /**
  48215. * Defines the target point of the camera.
  48216. * The camera looks towards it form the radius distance.
  48217. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  48218. */
  48219. get target(): Vector3;
  48220. set target(value: Vector3);
  48221. /**
  48222. * Define the current local position of the camera in the scene
  48223. */
  48224. get position(): Vector3;
  48225. set position(newPosition: Vector3);
  48226. protected _upToYMatrix: Matrix;
  48227. protected _YToUpMatrix: Matrix;
  48228. /**
  48229. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  48230. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  48231. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  48232. */
  48233. set upVector(vec: Vector3);
  48234. get upVector(): Vector3;
  48235. /**
  48236. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  48237. */
  48238. setMatUp(): void;
  48239. /**
  48240. * Current inertia value on the longitudinal axis.
  48241. * The bigger this number the longer it will take for the camera to stop.
  48242. */
  48243. inertialAlphaOffset: number;
  48244. /**
  48245. * Current inertia value on the latitudinal axis.
  48246. * The bigger this number the longer it will take for the camera to stop.
  48247. */
  48248. inertialBetaOffset: number;
  48249. /**
  48250. * Current inertia value on the radius axis.
  48251. * The bigger this number the longer it will take for the camera to stop.
  48252. */
  48253. inertialRadiusOffset: number;
  48254. /**
  48255. * Minimum allowed angle on the longitudinal axis.
  48256. * This can help limiting how the Camera is able to move in the scene.
  48257. */
  48258. lowerAlphaLimit: Nullable<number>;
  48259. /**
  48260. * Maximum allowed angle on the longitudinal axis.
  48261. * This can help limiting how the Camera is able to move in the scene.
  48262. */
  48263. upperAlphaLimit: Nullable<number>;
  48264. /**
  48265. * Minimum allowed angle on the latitudinal axis.
  48266. * This can help limiting how the Camera is able to move in the scene.
  48267. */
  48268. lowerBetaLimit: number;
  48269. /**
  48270. * Maximum allowed angle on the latitudinal axis.
  48271. * This can help limiting how the Camera is able to move in the scene.
  48272. */
  48273. upperBetaLimit: number;
  48274. /**
  48275. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  48276. * This can help limiting how the Camera is able to move in the scene.
  48277. */
  48278. lowerRadiusLimit: Nullable<number>;
  48279. /**
  48280. * Maximum allowed distance of the camera to the target (The camera can not get further).
  48281. * This can help limiting how the Camera is able to move in the scene.
  48282. */
  48283. upperRadiusLimit: Nullable<number>;
  48284. /**
  48285. * Defines the current inertia value used during panning of the camera along the X axis.
  48286. */
  48287. inertialPanningX: number;
  48288. /**
  48289. * Defines the current inertia value used during panning of the camera along the Y axis.
  48290. */
  48291. inertialPanningY: number;
  48292. /**
  48293. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  48294. * Basically if your fingers moves away from more than this distance you will be considered
  48295. * in pinch mode.
  48296. */
  48297. pinchToPanMaxDistance: number;
  48298. /**
  48299. * Defines the maximum distance the camera can pan.
  48300. * This could help keeping the cammera always in your scene.
  48301. */
  48302. panningDistanceLimit: Nullable<number>;
  48303. /**
  48304. * Defines the target of the camera before paning.
  48305. */
  48306. panningOriginTarget: Vector3;
  48307. /**
  48308. * Defines the value of the inertia used during panning.
  48309. * 0 would mean stop inertia and one would mean no decelleration at all.
  48310. */
  48311. panningInertia: number;
  48312. /**
  48313. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  48314. */
  48315. get angularSensibilityX(): number;
  48316. set angularSensibilityX(value: number);
  48317. /**
  48318. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  48319. */
  48320. get angularSensibilityY(): number;
  48321. set angularSensibilityY(value: number);
  48322. /**
  48323. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  48324. */
  48325. get pinchPrecision(): number;
  48326. set pinchPrecision(value: number);
  48327. /**
  48328. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  48329. * It will be used instead of pinchDeltaPrecision if different from 0.
  48330. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  48331. */
  48332. get pinchDeltaPercentage(): number;
  48333. set pinchDeltaPercentage(value: number);
  48334. /**
  48335. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  48336. * and pinch delta percentage.
  48337. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  48338. * that any object in the plane at the camera's target point will scale
  48339. * perfectly with finger motion.
  48340. */
  48341. get useNaturalPinchZoom(): boolean;
  48342. set useNaturalPinchZoom(value: boolean);
  48343. /**
  48344. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  48345. */
  48346. get panningSensibility(): number;
  48347. set panningSensibility(value: number);
  48348. /**
  48349. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  48350. */
  48351. get keysUp(): number[];
  48352. set keysUp(value: number[]);
  48353. /**
  48354. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  48355. */
  48356. get keysDown(): number[];
  48357. set keysDown(value: number[]);
  48358. /**
  48359. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  48360. */
  48361. get keysLeft(): number[];
  48362. set keysLeft(value: number[]);
  48363. /**
  48364. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  48365. */
  48366. get keysRight(): number[];
  48367. set keysRight(value: number[]);
  48368. /**
  48369. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  48370. */
  48371. get wheelPrecision(): number;
  48372. set wheelPrecision(value: number);
  48373. /**
  48374. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  48375. * It will be used instead of pinchDeltaPrecision if different from 0.
  48376. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  48377. */
  48378. get wheelDeltaPercentage(): number;
  48379. set wheelDeltaPercentage(value: number);
  48380. /**
  48381. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  48382. */
  48383. zoomOnFactor: number;
  48384. /**
  48385. * Defines a screen offset for the camera position.
  48386. */
  48387. targetScreenOffset: Vector2;
  48388. /**
  48389. * Allows the camera to be completely reversed.
  48390. * If false the camera can not arrive upside down.
  48391. */
  48392. allowUpsideDown: boolean;
  48393. /**
  48394. * Define if double tap/click is used to restore the previously saved state of the camera.
  48395. */
  48396. useInputToRestoreState: boolean;
  48397. /** @hidden */
  48398. _viewMatrix: Matrix;
  48399. /** @hidden */
  48400. _useCtrlForPanning: boolean;
  48401. /** @hidden */
  48402. _panningMouseButton: number;
  48403. /**
  48404. * Defines the input associated to the camera.
  48405. */
  48406. inputs: ArcRotateCameraInputsManager;
  48407. /** @hidden */
  48408. _reset: () => void;
  48409. /**
  48410. * Defines the allowed panning axis.
  48411. */
  48412. panningAxis: Vector3;
  48413. protected _localDirection: Vector3;
  48414. protected _transformedDirection: Vector3;
  48415. private _bouncingBehavior;
  48416. /**
  48417. * Gets the bouncing behavior of the camera if it has been enabled.
  48418. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48419. */
  48420. get bouncingBehavior(): Nullable<BouncingBehavior>;
  48421. /**
  48422. * Defines if the bouncing behavior of the camera is enabled on the camera.
  48423. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48424. */
  48425. get useBouncingBehavior(): boolean;
  48426. set useBouncingBehavior(value: boolean);
  48427. private _framingBehavior;
  48428. /**
  48429. * Gets the framing behavior of the camera if it has been enabled.
  48430. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48431. */
  48432. get framingBehavior(): Nullable<FramingBehavior>;
  48433. /**
  48434. * Defines if the framing behavior of the camera is enabled on the camera.
  48435. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48436. */
  48437. get useFramingBehavior(): boolean;
  48438. set useFramingBehavior(value: boolean);
  48439. private _autoRotationBehavior;
  48440. /**
  48441. * Gets the auto rotation behavior of the camera if it has been enabled.
  48442. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48443. */
  48444. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  48445. /**
  48446. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  48447. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48448. */
  48449. get useAutoRotationBehavior(): boolean;
  48450. set useAutoRotationBehavior(value: boolean);
  48451. /**
  48452. * Observable triggered when the mesh target has been changed on the camera.
  48453. */
  48454. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  48455. /**
  48456. * Event raised when the camera is colliding with a mesh.
  48457. */
  48458. onCollide: (collidedMesh: AbstractMesh) => void;
  48459. /**
  48460. * Defines whether the camera should check collision with the objects oh the scene.
  48461. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  48462. */
  48463. checkCollisions: boolean;
  48464. /**
  48465. * Defines the collision radius of the camera.
  48466. * This simulates a sphere around the camera.
  48467. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  48468. */
  48469. collisionRadius: Vector3;
  48470. protected _collider: Collider;
  48471. protected _previousPosition: Vector3;
  48472. protected _collisionVelocity: Vector3;
  48473. protected _newPosition: Vector3;
  48474. protected _previousAlpha: number;
  48475. protected _previousBeta: number;
  48476. protected _previousRadius: number;
  48477. protected _collisionTriggered: boolean;
  48478. protected _targetBoundingCenter: Nullable<Vector3>;
  48479. private _computationVector;
  48480. /**
  48481. * Instantiates a new ArcRotateCamera in a given scene
  48482. * @param name Defines the name of the camera
  48483. * @param alpha Defines the camera rotation along the logitudinal axis
  48484. * @param beta Defines the camera rotation along the latitudinal axis
  48485. * @param radius Defines the camera distance from its target
  48486. * @param target Defines the camera target
  48487. * @param scene Defines the scene the camera belongs to
  48488. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  48489. */
  48490. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  48491. /** @hidden */
  48492. _initCache(): void;
  48493. /** @hidden */
  48494. _updateCache(ignoreParentClass?: boolean): void;
  48495. protected _getTargetPosition(): Vector3;
  48496. private _storedAlpha;
  48497. private _storedBeta;
  48498. private _storedRadius;
  48499. private _storedTarget;
  48500. private _storedTargetScreenOffset;
  48501. /**
  48502. * Stores the current state of the camera (alpha, beta, radius and target)
  48503. * @returns the camera itself
  48504. */
  48505. storeState(): Camera;
  48506. /**
  48507. * @hidden
  48508. * Restored camera state. You must call storeState() first
  48509. */
  48510. _restoreStateValues(): boolean;
  48511. /** @hidden */
  48512. _isSynchronizedViewMatrix(): boolean;
  48513. /**
  48514. * Attach the input controls to a specific dom element to get the input from.
  48515. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48516. */
  48517. attachControl(noPreventDefault?: boolean): void;
  48518. /**
  48519. * Attach the input controls to a specific dom element to get the input from.
  48520. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  48521. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48522. */
  48523. attachControl(ignored: any, noPreventDefault?: boolean): void;
  48524. /**
  48525. * Attached controls to the current camera.
  48526. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48527. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48528. */
  48529. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  48530. /**
  48531. * Attached controls to the current camera.
  48532. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  48533. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48534. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48535. */
  48536. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  48537. /**
  48538. * Attached controls to the current camera.
  48539. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48540. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48541. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  48542. */
  48543. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  48544. /**
  48545. * Detach the current controls from the specified dom element.
  48546. */
  48547. detachControl(): void;
  48548. /**
  48549. * Detach the current controls from the specified dom element.
  48550. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  48551. */
  48552. detachControl(ignored: any): void;
  48553. /** @hidden */
  48554. _checkInputs(): void;
  48555. protected _checkLimits(): void;
  48556. /**
  48557. * Rebuilds angles (alpha, beta) and radius from the give position and target
  48558. */
  48559. rebuildAnglesAndRadius(): void;
  48560. /**
  48561. * Use a position to define the current camera related information like alpha, beta and radius
  48562. * @param position Defines the position to set the camera at
  48563. */
  48564. setPosition(position: Vector3): void;
  48565. /**
  48566. * Defines the target the camera should look at.
  48567. * This will automatically adapt alpha beta and radius to fit within the new target.
  48568. * @param target Defines the new target as a Vector or a mesh
  48569. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  48570. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  48571. */
  48572. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  48573. /** @hidden */
  48574. _getViewMatrix(): Matrix;
  48575. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  48576. /**
  48577. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  48578. * @param meshes Defines the mesh to zoom on
  48579. * @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)
  48580. */
  48581. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  48582. /**
  48583. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  48584. * The target will be changed but the radius
  48585. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  48586. * @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)
  48587. */
  48588. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  48589. min: Vector3;
  48590. max: Vector3;
  48591. distance: number;
  48592. }, doNotUpdateMaxZ?: boolean): void;
  48593. /**
  48594. * @override
  48595. * Override Camera.createRigCamera
  48596. */
  48597. createRigCamera(name: string, cameraIndex: number): Camera;
  48598. /**
  48599. * @hidden
  48600. * @override
  48601. * Override Camera._updateRigCameras
  48602. */
  48603. _updateRigCameras(): void;
  48604. /**
  48605. * Destroy the camera and release the current resources hold by it.
  48606. */
  48607. dispose(): void;
  48608. /**
  48609. * Gets the current object class name.
  48610. * @return the class name
  48611. */
  48612. getClassName(): string;
  48613. }
  48614. }
  48615. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  48616. import { Behavior } from "babylonjs/Behaviors/behavior";
  48617. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48618. /**
  48619. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  48620. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48621. */
  48622. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  48623. /**
  48624. * Gets the name of the behavior.
  48625. */
  48626. get name(): string;
  48627. private _zoomStopsAnimation;
  48628. private _idleRotationSpeed;
  48629. private _idleRotationWaitTime;
  48630. private _idleRotationSpinupTime;
  48631. /**
  48632. * Sets the flag that indicates if user zooming should stop animation.
  48633. */
  48634. set zoomStopsAnimation(flag: boolean);
  48635. /**
  48636. * Gets the flag that indicates if user zooming should stop animation.
  48637. */
  48638. get zoomStopsAnimation(): boolean;
  48639. /**
  48640. * Sets the default speed at which the camera rotates around the model.
  48641. */
  48642. set idleRotationSpeed(speed: number);
  48643. /**
  48644. * Gets the default speed at which the camera rotates around the model.
  48645. */
  48646. get idleRotationSpeed(): number;
  48647. /**
  48648. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  48649. */
  48650. set idleRotationWaitTime(time: number);
  48651. /**
  48652. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  48653. */
  48654. get idleRotationWaitTime(): number;
  48655. /**
  48656. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48657. */
  48658. set idleRotationSpinupTime(time: number);
  48659. /**
  48660. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48661. */
  48662. get idleRotationSpinupTime(): number;
  48663. /**
  48664. * Gets a value indicating if the camera is currently rotating because of this behavior
  48665. */
  48666. get rotationInProgress(): boolean;
  48667. private _onPrePointerObservableObserver;
  48668. private _onAfterCheckInputsObserver;
  48669. private _attachedCamera;
  48670. private _isPointerDown;
  48671. private _lastFrameTime;
  48672. private _lastInteractionTime;
  48673. private _cameraRotationSpeed;
  48674. /**
  48675. * Initializes the behavior.
  48676. */
  48677. init(): void;
  48678. /**
  48679. * Attaches the behavior to its arc rotate camera.
  48680. * @param camera Defines the camera to attach the behavior to
  48681. */
  48682. attach(camera: ArcRotateCamera): void;
  48683. /**
  48684. * Detaches the behavior from its current arc rotate camera.
  48685. */
  48686. detach(): void;
  48687. /**
  48688. * Returns true if user is scrolling.
  48689. * @return true if user is scrolling.
  48690. */
  48691. private _userIsZooming;
  48692. private _lastFrameRadius;
  48693. private _shouldAnimationStopForInteraction;
  48694. /**
  48695. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  48696. */
  48697. private _applyUserInteraction;
  48698. private _userIsMoving;
  48699. }
  48700. }
  48701. declare module "babylonjs/Behaviors/Cameras/index" {
  48702. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  48703. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  48704. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  48705. }
  48706. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  48707. import { Mesh } from "babylonjs/Meshes/mesh";
  48708. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48709. import { Behavior } from "babylonjs/Behaviors/behavior";
  48710. /**
  48711. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  48712. */
  48713. export class AttachToBoxBehavior implements Behavior<Mesh> {
  48714. private ui;
  48715. /**
  48716. * The name of the behavior
  48717. */
  48718. name: string;
  48719. /**
  48720. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  48721. */
  48722. distanceAwayFromFace: number;
  48723. /**
  48724. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  48725. */
  48726. distanceAwayFromBottomOfFace: number;
  48727. private _faceVectors;
  48728. private _target;
  48729. private _scene;
  48730. private _onRenderObserver;
  48731. private _tmpMatrix;
  48732. private _tmpVector;
  48733. /**
  48734. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  48735. * @param ui The transform node that should be attched to the mesh
  48736. */
  48737. constructor(ui: TransformNode);
  48738. /**
  48739. * Initializes the behavior
  48740. */
  48741. init(): void;
  48742. private _closestFace;
  48743. private _zeroVector;
  48744. private _lookAtTmpMatrix;
  48745. private _lookAtToRef;
  48746. /**
  48747. * Attaches the AttachToBoxBehavior to the passed in mesh
  48748. * @param target The mesh that the specified node will be attached to
  48749. */
  48750. attach(target: Mesh): void;
  48751. /**
  48752. * Detaches the behavior from the mesh
  48753. */
  48754. detach(): void;
  48755. }
  48756. }
  48757. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  48758. import { Behavior } from "babylonjs/Behaviors/behavior";
  48759. import { Mesh } from "babylonjs/Meshes/mesh";
  48760. /**
  48761. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  48762. */
  48763. export class FadeInOutBehavior implements Behavior<Mesh> {
  48764. /**
  48765. * Time in milliseconds to delay before fading in (Default: 0)
  48766. */
  48767. delay: number;
  48768. /**
  48769. * Time in milliseconds for the mesh to fade in (Default: 300)
  48770. */
  48771. fadeInTime: number;
  48772. private _millisecondsPerFrame;
  48773. private _hovered;
  48774. private _hoverValue;
  48775. private _ownerNode;
  48776. /**
  48777. * Instatiates the FadeInOutBehavior
  48778. */
  48779. constructor();
  48780. /**
  48781. * The name of the behavior
  48782. */
  48783. get name(): string;
  48784. /**
  48785. * Initializes the behavior
  48786. */
  48787. init(): void;
  48788. /**
  48789. * Attaches the fade behavior on the passed in mesh
  48790. * @param ownerNode The mesh that will be faded in/out once attached
  48791. */
  48792. attach(ownerNode: Mesh): void;
  48793. /**
  48794. * Detaches the behavior from the mesh
  48795. */
  48796. detach(): void;
  48797. /**
  48798. * Triggers the mesh to begin fading in or out
  48799. * @param value if the object should fade in or out (true to fade in)
  48800. */
  48801. fadeIn(value: boolean): void;
  48802. private _update;
  48803. private _setAllVisibility;
  48804. }
  48805. }
  48806. declare module "babylonjs/Misc/pivotTools" {
  48807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48808. /**
  48809. * Class containing a set of static utilities functions for managing Pivots
  48810. * @hidden
  48811. */
  48812. export class PivotTools {
  48813. private static _PivotCached;
  48814. private static _OldPivotPoint;
  48815. private static _PivotTranslation;
  48816. private static _PivotTmpVector;
  48817. private static _PivotPostMultiplyPivotMatrix;
  48818. /** @hidden */
  48819. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  48820. /** @hidden */
  48821. static _RestorePivotPoint(mesh: AbstractMesh): void;
  48822. }
  48823. }
  48824. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  48825. import { Scene } from "babylonjs/scene";
  48826. import { Vector4 } from "babylonjs/Maths/math.vector";
  48827. import { Mesh } from "babylonjs/Meshes/mesh";
  48828. import { Nullable } from "babylonjs/types";
  48829. import { Plane } from "babylonjs/Maths/math.plane";
  48830. /**
  48831. * Class containing static functions to help procedurally build meshes
  48832. */
  48833. export class PlaneBuilder {
  48834. /**
  48835. * Creates a plane mesh
  48836. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  48837. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  48838. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  48839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48840. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48842. * @param name defines the name of the mesh
  48843. * @param options defines the options used to create the mesh
  48844. * @param scene defines the hosting scene
  48845. * @returns the plane mesh
  48846. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  48847. */
  48848. static CreatePlane(name: string, options: {
  48849. size?: number;
  48850. width?: number;
  48851. height?: number;
  48852. sideOrientation?: number;
  48853. frontUVs?: Vector4;
  48854. backUVs?: Vector4;
  48855. updatable?: boolean;
  48856. sourcePlane?: Plane;
  48857. }, scene?: Nullable<Scene>): Mesh;
  48858. }
  48859. }
  48860. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  48861. import { Behavior } from "babylonjs/Behaviors/behavior";
  48862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48863. import { Observable } from "babylonjs/Misc/observable";
  48864. import { Vector3 } from "babylonjs/Maths/math.vector";
  48865. import { Ray } from "babylonjs/Culling/ray";
  48866. import "babylonjs/Meshes/Builders/planeBuilder";
  48867. /**
  48868. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  48869. */
  48870. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  48871. private static _AnyMouseID;
  48872. /**
  48873. * Abstract mesh the behavior is set on
  48874. */
  48875. attachedNode: AbstractMesh;
  48876. private _dragPlane;
  48877. private _scene;
  48878. private _pointerObserver;
  48879. private _beforeRenderObserver;
  48880. private static _planeScene;
  48881. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  48882. /**
  48883. * 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)
  48884. */
  48885. maxDragAngle: number;
  48886. /**
  48887. * @hidden
  48888. */
  48889. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  48890. /**
  48891. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48892. */
  48893. currentDraggingPointerID: number;
  48894. /**
  48895. * The last position where the pointer hit the drag plane in world space
  48896. */
  48897. lastDragPosition: Vector3;
  48898. /**
  48899. * If the behavior is currently in a dragging state
  48900. */
  48901. dragging: boolean;
  48902. /**
  48903. * 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)
  48904. */
  48905. dragDeltaRatio: number;
  48906. /**
  48907. * If the drag plane orientation should be updated during the dragging (Default: true)
  48908. */
  48909. updateDragPlane: boolean;
  48910. private _debugMode;
  48911. private _moving;
  48912. /**
  48913. * Fires each time the attached mesh is dragged with the pointer
  48914. * * delta between last drag position and current drag position in world space
  48915. * * dragDistance along the drag axis
  48916. * * dragPlaneNormal normal of the current drag plane used during the drag
  48917. * * dragPlanePoint in world space where the drag intersects the drag plane
  48918. */
  48919. onDragObservable: Observable<{
  48920. delta: Vector3;
  48921. dragPlanePoint: Vector3;
  48922. dragPlaneNormal: Vector3;
  48923. dragDistance: number;
  48924. pointerId: number;
  48925. }>;
  48926. /**
  48927. * Fires each time a drag begins (eg. mouse down on mesh)
  48928. */
  48929. onDragStartObservable: Observable<{
  48930. dragPlanePoint: Vector3;
  48931. pointerId: number;
  48932. }>;
  48933. /**
  48934. * Fires each time a drag ends (eg. mouse release after drag)
  48935. */
  48936. onDragEndObservable: Observable<{
  48937. dragPlanePoint: Vector3;
  48938. pointerId: number;
  48939. }>;
  48940. /**
  48941. * If the attached mesh should be moved when dragged
  48942. */
  48943. moveAttached: boolean;
  48944. /**
  48945. * If the drag behavior will react to drag events (Default: true)
  48946. */
  48947. enabled: boolean;
  48948. /**
  48949. * If pointer events should start and release the drag (Default: true)
  48950. */
  48951. startAndReleaseDragOnPointerEvents: boolean;
  48952. /**
  48953. * If camera controls should be detached during the drag
  48954. */
  48955. detachCameraControls: boolean;
  48956. /**
  48957. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  48958. */
  48959. useObjectOrientationForDragging: boolean;
  48960. private _options;
  48961. /**
  48962. * Gets the options used by the behavior
  48963. */
  48964. get options(): {
  48965. dragAxis?: Vector3;
  48966. dragPlaneNormal?: Vector3;
  48967. };
  48968. /**
  48969. * Sets the options used by the behavior
  48970. */
  48971. set options(options: {
  48972. dragAxis?: Vector3;
  48973. dragPlaneNormal?: Vector3;
  48974. });
  48975. /**
  48976. * Creates a pointer drag behavior that can be attached to a mesh
  48977. * @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)
  48978. */
  48979. constructor(options?: {
  48980. dragAxis?: Vector3;
  48981. dragPlaneNormal?: Vector3;
  48982. });
  48983. /**
  48984. * Predicate to determine if it is valid to move the object to a new position when it is moved
  48985. */
  48986. validateDrag: (targetPosition: Vector3) => boolean;
  48987. /**
  48988. * The name of the behavior
  48989. */
  48990. get name(): string;
  48991. /**
  48992. * Initializes the behavior
  48993. */
  48994. init(): void;
  48995. private _tmpVector;
  48996. private _alternatePickedPoint;
  48997. private _worldDragAxis;
  48998. private _targetPosition;
  48999. private _attachedToElement;
  49000. /**
  49001. * Attaches the drag behavior the passed in mesh
  49002. * @param ownerNode The mesh that will be dragged around once attached
  49003. * @param predicate Predicate to use for pick filtering
  49004. */
  49005. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  49006. /**
  49007. * Force relase the drag action by code.
  49008. */
  49009. releaseDrag(): void;
  49010. private _startDragRay;
  49011. private _lastPointerRay;
  49012. /**
  49013. * Simulates the start of a pointer drag event on the behavior
  49014. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  49015. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  49016. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  49017. */
  49018. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  49019. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  49020. private _dragDelta;
  49021. protected _moveDrag(ray: Ray): void;
  49022. private _pickWithRayOnDragPlane;
  49023. private _pointA;
  49024. private _pointC;
  49025. private _localAxis;
  49026. private _lookAt;
  49027. private _updateDragPlanePosition;
  49028. /**
  49029. * Detaches the behavior from the mesh
  49030. */
  49031. detach(): void;
  49032. }
  49033. }
  49034. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  49035. import { Mesh } from "babylonjs/Meshes/mesh";
  49036. import { Behavior } from "babylonjs/Behaviors/behavior";
  49037. /**
  49038. * A behavior that when attached to a mesh will allow the mesh to be scaled
  49039. */
  49040. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  49041. private _dragBehaviorA;
  49042. private _dragBehaviorB;
  49043. private _startDistance;
  49044. private _initialScale;
  49045. private _targetScale;
  49046. private _ownerNode;
  49047. private _sceneRenderObserver;
  49048. /**
  49049. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  49050. */
  49051. constructor();
  49052. /**
  49053. * The name of the behavior
  49054. */
  49055. get name(): string;
  49056. /**
  49057. * Initializes the behavior
  49058. */
  49059. init(): void;
  49060. private _getCurrentDistance;
  49061. /**
  49062. * Attaches the scale behavior the passed in mesh
  49063. * @param ownerNode The mesh that will be scaled around once attached
  49064. */
  49065. attach(ownerNode: Mesh): void;
  49066. /**
  49067. * Detaches the behavior from the mesh
  49068. */
  49069. detach(): void;
  49070. }
  49071. }
  49072. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  49073. import { Behavior } from "babylonjs/Behaviors/behavior";
  49074. import { Mesh } from "babylonjs/Meshes/mesh";
  49075. import { Observable } from "babylonjs/Misc/observable";
  49076. /**
  49077. * 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
  49078. */
  49079. export class SixDofDragBehavior implements Behavior<Mesh> {
  49080. private static _virtualScene;
  49081. private _ownerNode;
  49082. private _sceneRenderObserver;
  49083. private _scene;
  49084. private _targetPosition;
  49085. private _virtualOriginMesh;
  49086. private _virtualDragMesh;
  49087. private _pointerObserver;
  49088. private _moving;
  49089. private _startingOrientation;
  49090. private _attachedToElement;
  49091. /**
  49092. * 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)
  49093. */
  49094. private zDragFactor;
  49095. /**
  49096. * If the object should rotate to face the drag origin
  49097. */
  49098. rotateDraggedObject: boolean;
  49099. /**
  49100. * If the behavior is currently in a dragging state
  49101. */
  49102. dragging: boolean;
  49103. /**
  49104. * 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)
  49105. */
  49106. dragDeltaRatio: number;
  49107. /**
  49108. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  49109. */
  49110. currentDraggingPointerID: number;
  49111. /**
  49112. * If camera controls should be detached during the drag
  49113. */
  49114. detachCameraControls: boolean;
  49115. /**
  49116. * Fires each time a drag starts
  49117. */
  49118. onDragStartObservable: Observable<{}>;
  49119. /**
  49120. * Fires each time a drag happens
  49121. */
  49122. onDragObservable: Observable<void>;
  49123. /**
  49124. * Fires each time a drag ends (eg. mouse release after drag)
  49125. */
  49126. onDragEndObservable: Observable<{}>;
  49127. /**
  49128. * 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
  49129. */
  49130. constructor();
  49131. /**
  49132. * The name of the behavior
  49133. */
  49134. get name(): string;
  49135. /**
  49136. * Initializes the behavior
  49137. */
  49138. init(): void;
  49139. /**
  49140. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  49141. */
  49142. private get _pointerCamera();
  49143. /**
  49144. * Attaches the scale behavior the passed in mesh
  49145. * @param ownerNode The mesh that will be scaled around once attached
  49146. */
  49147. attach(ownerNode: Mesh): void;
  49148. /**
  49149. * Detaches the behavior from the mesh
  49150. */
  49151. detach(): void;
  49152. }
  49153. }
  49154. declare module "babylonjs/Behaviors/Meshes/index" {
  49155. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  49156. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  49157. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  49158. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  49159. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  49160. }
  49161. declare module "babylonjs/Behaviors/index" {
  49162. export * from "babylonjs/Behaviors/behavior";
  49163. export * from "babylonjs/Behaviors/Cameras/index";
  49164. export * from "babylonjs/Behaviors/Meshes/index";
  49165. }
  49166. declare module "babylonjs/Bones/boneIKController" {
  49167. import { Bone } from "babylonjs/Bones/bone";
  49168. import { Vector3 } from "babylonjs/Maths/math.vector";
  49169. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49170. import { Nullable } from "babylonjs/types";
  49171. /**
  49172. * Class used to apply inverse kinematics to bones
  49173. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  49174. */
  49175. export class BoneIKController {
  49176. private static _tmpVecs;
  49177. private static _tmpQuat;
  49178. private static _tmpMats;
  49179. /**
  49180. * Gets or sets the target mesh
  49181. */
  49182. targetMesh: AbstractMesh;
  49183. /** Gets or sets the mesh used as pole */
  49184. poleTargetMesh: AbstractMesh;
  49185. /**
  49186. * Gets or sets the bone used as pole
  49187. */
  49188. poleTargetBone: Nullable<Bone>;
  49189. /**
  49190. * Gets or sets the target position
  49191. */
  49192. targetPosition: Vector3;
  49193. /**
  49194. * Gets or sets the pole target position
  49195. */
  49196. poleTargetPosition: Vector3;
  49197. /**
  49198. * Gets or sets the pole target local offset
  49199. */
  49200. poleTargetLocalOffset: Vector3;
  49201. /**
  49202. * Gets or sets the pole angle
  49203. */
  49204. poleAngle: number;
  49205. /**
  49206. * Gets or sets the mesh associated with the controller
  49207. */
  49208. mesh: AbstractMesh;
  49209. /**
  49210. * 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)
  49211. */
  49212. slerpAmount: number;
  49213. private _bone1Quat;
  49214. private _bone1Mat;
  49215. private _bone2Ang;
  49216. private _bone1;
  49217. private _bone2;
  49218. private _bone1Length;
  49219. private _bone2Length;
  49220. private _maxAngle;
  49221. private _maxReach;
  49222. private _rightHandedSystem;
  49223. private _bendAxis;
  49224. private _slerping;
  49225. private _adjustRoll;
  49226. /**
  49227. * Gets or sets maximum allowed angle
  49228. */
  49229. get maxAngle(): number;
  49230. set maxAngle(value: number);
  49231. /**
  49232. * Creates a new BoneIKController
  49233. * @param mesh defines the mesh to control
  49234. * @param bone defines the bone to control
  49235. * @param options defines options to set up the controller
  49236. */
  49237. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  49238. targetMesh?: AbstractMesh;
  49239. poleTargetMesh?: AbstractMesh;
  49240. poleTargetBone?: Bone;
  49241. poleTargetLocalOffset?: Vector3;
  49242. poleAngle?: number;
  49243. bendAxis?: Vector3;
  49244. maxAngle?: number;
  49245. slerpAmount?: number;
  49246. });
  49247. private _setMaxAngle;
  49248. /**
  49249. * Force the controller to update the bones
  49250. */
  49251. update(): void;
  49252. }
  49253. }
  49254. declare module "babylonjs/Bones/boneLookController" {
  49255. import { Vector3 } from "babylonjs/Maths/math.vector";
  49256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49257. import { Bone } from "babylonjs/Bones/bone";
  49258. import { Space } from "babylonjs/Maths/math.axis";
  49259. /**
  49260. * Class used to make a bone look toward a point in space
  49261. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  49262. */
  49263. export class BoneLookController {
  49264. private static _tmpVecs;
  49265. private static _tmpQuat;
  49266. private static _tmpMats;
  49267. /**
  49268. * The target Vector3 that the bone will look at
  49269. */
  49270. target: Vector3;
  49271. /**
  49272. * The mesh that the bone is attached to
  49273. */
  49274. mesh: AbstractMesh;
  49275. /**
  49276. * The bone that will be looking to the target
  49277. */
  49278. bone: Bone;
  49279. /**
  49280. * The up axis of the coordinate system that is used when the bone is rotated
  49281. */
  49282. upAxis: Vector3;
  49283. /**
  49284. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  49285. */
  49286. upAxisSpace: Space;
  49287. /**
  49288. * Used to make an adjustment to the yaw of the bone
  49289. */
  49290. adjustYaw: number;
  49291. /**
  49292. * Used to make an adjustment to the pitch of the bone
  49293. */
  49294. adjustPitch: number;
  49295. /**
  49296. * Used to make an adjustment to the roll of the bone
  49297. */
  49298. adjustRoll: number;
  49299. /**
  49300. * 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)
  49301. */
  49302. slerpAmount: number;
  49303. private _minYaw;
  49304. private _maxYaw;
  49305. private _minPitch;
  49306. private _maxPitch;
  49307. private _minYawSin;
  49308. private _minYawCos;
  49309. private _maxYawSin;
  49310. private _maxYawCos;
  49311. private _midYawConstraint;
  49312. private _minPitchTan;
  49313. private _maxPitchTan;
  49314. private _boneQuat;
  49315. private _slerping;
  49316. private _transformYawPitch;
  49317. private _transformYawPitchInv;
  49318. private _firstFrameSkipped;
  49319. private _yawRange;
  49320. private _fowardAxis;
  49321. /**
  49322. * Gets or sets the minimum yaw angle that the bone can look to
  49323. */
  49324. get minYaw(): number;
  49325. set minYaw(value: number);
  49326. /**
  49327. * Gets or sets the maximum yaw angle that the bone can look to
  49328. */
  49329. get maxYaw(): number;
  49330. set maxYaw(value: number);
  49331. /**
  49332. * Gets or sets the minimum pitch angle that the bone can look to
  49333. */
  49334. get minPitch(): number;
  49335. set minPitch(value: number);
  49336. /**
  49337. * Gets or sets the maximum pitch angle that the bone can look to
  49338. */
  49339. get maxPitch(): number;
  49340. set maxPitch(value: number);
  49341. /**
  49342. * Create a BoneLookController
  49343. * @param mesh the mesh that the bone belongs to
  49344. * @param bone the bone that will be looking to the target
  49345. * @param target the target Vector3 to look at
  49346. * @param options optional settings:
  49347. * * maxYaw: the maximum angle the bone will yaw to
  49348. * * minYaw: the minimum angle the bone will yaw to
  49349. * * maxPitch: the maximum angle the bone will pitch to
  49350. * * minPitch: the minimum angle the bone will yaw to
  49351. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  49352. * * upAxis: the up axis of the coordinate system
  49353. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  49354. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  49355. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  49356. * * adjustYaw: used to make an adjustment to the yaw of the bone
  49357. * * adjustPitch: used to make an adjustment to the pitch of the bone
  49358. * * adjustRoll: used to make an adjustment to the roll of the bone
  49359. **/
  49360. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  49361. maxYaw?: number;
  49362. minYaw?: number;
  49363. maxPitch?: number;
  49364. minPitch?: number;
  49365. slerpAmount?: number;
  49366. upAxis?: Vector3;
  49367. upAxisSpace?: Space;
  49368. yawAxis?: Vector3;
  49369. pitchAxis?: Vector3;
  49370. adjustYaw?: number;
  49371. adjustPitch?: number;
  49372. adjustRoll?: number;
  49373. });
  49374. /**
  49375. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  49376. */
  49377. update(): void;
  49378. private _getAngleDiff;
  49379. private _getAngleBetween;
  49380. private _isAngleBetween;
  49381. }
  49382. }
  49383. declare module "babylonjs/Bones/index" {
  49384. export * from "babylonjs/Bones/bone";
  49385. export * from "babylonjs/Bones/boneIKController";
  49386. export * from "babylonjs/Bones/boneLookController";
  49387. export * from "babylonjs/Bones/skeleton";
  49388. }
  49389. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  49390. import { Nullable } from "babylonjs/types";
  49391. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  49392. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49393. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  49394. /**
  49395. * Manage the gamepad inputs to control an arc rotate camera.
  49396. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49397. */
  49398. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  49399. /**
  49400. * Defines the camera the input is attached to.
  49401. */
  49402. camera: ArcRotateCamera;
  49403. /**
  49404. * Defines the gamepad the input is gathering event from.
  49405. */
  49406. gamepad: Nullable<Gamepad>;
  49407. /**
  49408. * Defines the gamepad rotation sensiblity.
  49409. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49410. */
  49411. gamepadRotationSensibility: number;
  49412. /**
  49413. * Defines the gamepad move sensiblity.
  49414. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49415. */
  49416. gamepadMoveSensibility: number;
  49417. private _yAxisScale;
  49418. /**
  49419. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  49420. */
  49421. get invertYAxis(): boolean;
  49422. set invertYAxis(value: boolean);
  49423. private _onGamepadConnectedObserver;
  49424. private _onGamepadDisconnectedObserver;
  49425. /**
  49426. * Attach the input controls to a specific dom element to get the input from.
  49427. */
  49428. attachControl(): void;
  49429. /**
  49430. * Detach the current controls from the specified dom element.
  49431. */
  49432. detachControl(): void;
  49433. /**
  49434. * Update the current camera state depending on the inputs that have been used this frame.
  49435. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49436. */
  49437. checkInputs(): void;
  49438. /**
  49439. * Gets the class name of the current intput.
  49440. * @returns the class name
  49441. */
  49442. getClassName(): string;
  49443. /**
  49444. * Get the friendly name associated with the input class.
  49445. * @returns the input friendly name
  49446. */
  49447. getSimpleName(): string;
  49448. }
  49449. }
  49450. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  49451. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  49452. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49453. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  49454. interface ArcRotateCameraInputsManager {
  49455. /**
  49456. * Add orientation input support to the input manager.
  49457. * @returns the current input manager
  49458. */
  49459. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  49460. }
  49461. }
  49462. /**
  49463. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  49464. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49465. */
  49466. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  49467. /**
  49468. * Defines the camera the input is attached to.
  49469. */
  49470. camera: ArcRotateCamera;
  49471. /**
  49472. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  49473. */
  49474. alphaCorrection: number;
  49475. /**
  49476. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  49477. */
  49478. gammaCorrection: number;
  49479. private _alpha;
  49480. private _gamma;
  49481. private _dirty;
  49482. private _deviceOrientationHandler;
  49483. /**
  49484. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  49485. */
  49486. constructor();
  49487. /**
  49488. * Attach the input controls to a specific dom element to get the input from.
  49489. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49490. */
  49491. attachControl(noPreventDefault?: boolean): void;
  49492. /** @hidden */
  49493. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  49494. /**
  49495. * Update the current camera state depending on the inputs that have been used this frame.
  49496. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49497. */
  49498. checkInputs(): void;
  49499. /**
  49500. * Detach the current controls from the specified dom element.
  49501. */
  49502. detachControl(): void;
  49503. /**
  49504. * Gets the class name of the current intput.
  49505. * @returns the class name
  49506. */
  49507. getClassName(): string;
  49508. /**
  49509. * Get the friendly name associated with the input class.
  49510. * @returns the input friendly name
  49511. */
  49512. getSimpleName(): string;
  49513. }
  49514. }
  49515. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  49516. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49517. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49518. /**
  49519. * Listen to mouse events to control the camera.
  49520. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49521. */
  49522. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  49523. /**
  49524. * Defines the camera the input is attached to.
  49525. */
  49526. camera: FlyCamera;
  49527. /**
  49528. * Defines if touch is enabled. (Default is true.)
  49529. */
  49530. touchEnabled: boolean;
  49531. /**
  49532. * Defines the buttons associated with the input to handle camera rotation.
  49533. */
  49534. buttons: number[];
  49535. /**
  49536. * Assign buttons for Yaw control.
  49537. */
  49538. buttonsYaw: number[];
  49539. /**
  49540. * Assign buttons for Pitch control.
  49541. */
  49542. buttonsPitch: number[];
  49543. /**
  49544. * Assign buttons for Roll control.
  49545. */
  49546. buttonsRoll: number[];
  49547. /**
  49548. * Detect if any button is being pressed while mouse is moved.
  49549. * -1 = Mouse locked.
  49550. * 0 = Left button.
  49551. * 1 = Middle Button.
  49552. * 2 = Right Button.
  49553. */
  49554. activeButton: number;
  49555. /**
  49556. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  49557. * Higher values reduce its sensitivity.
  49558. */
  49559. angularSensibility: number;
  49560. private _observer;
  49561. private _rollObserver;
  49562. private previousPosition;
  49563. private noPreventDefault;
  49564. private element;
  49565. /**
  49566. * Listen to mouse events to control the camera.
  49567. * @param touchEnabled Define if touch is enabled. (Default is true.)
  49568. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49569. */
  49570. constructor(touchEnabled?: boolean);
  49571. /**
  49572. * Attach the mouse control to the HTML DOM element.
  49573. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  49574. */
  49575. attachControl(noPreventDefault?: boolean): void;
  49576. /**
  49577. * Detach the current controls from the specified dom element.
  49578. */
  49579. detachControl(): void;
  49580. /**
  49581. * Gets the class name of the current input.
  49582. * @returns the class name.
  49583. */
  49584. getClassName(): string;
  49585. /**
  49586. * Get the friendly name associated with the input class.
  49587. * @returns the input's friendly name.
  49588. */
  49589. getSimpleName(): string;
  49590. private _pointerInput;
  49591. private _onMouseMove;
  49592. /**
  49593. * Rotate camera by mouse offset.
  49594. */
  49595. private rotateCamera;
  49596. }
  49597. }
  49598. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  49599. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49600. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49601. /**
  49602. * Default Inputs manager for the FlyCamera.
  49603. * It groups all the default supported inputs for ease of use.
  49604. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49605. */
  49606. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  49607. /**
  49608. * Instantiates a new FlyCameraInputsManager.
  49609. * @param camera Defines the camera the inputs belong to.
  49610. */
  49611. constructor(camera: FlyCamera);
  49612. /**
  49613. * Add keyboard input support to the input manager.
  49614. * @returns the new FlyCameraKeyboardMoveInput().
  49615. */
  49616. addKeyboard(): FlyCameraInputsManager;
  49617. /**
  49618. * Add mouse input support to the input manager.
  49619. * @param touchEnabled Enable touch screen support.
  49620. * @returns the new FlyCameraMouseInput().
  49621. */
  49622. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  49623. }
  49624. }
  49625. declare module "babylonjs/Cameras/flyCamera" {
  49626. import { Scene } from "babylonjs/scene";
  49627. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  49628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49629. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49630. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  49631. /**
  49632. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49633. * such as in a 3D Space Shooter or a Flight Simulator.
  49634. */
  49635. export class FlyCamera extends TargetCamera {
  49636. /**
  49637. * Define the collision ellipsoid of the camera.
  49638. * This is helpful for simulating a camera body, like a player's body.
  49639. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49640. */
  49641. ellipsoid: Vector3;
  49642. /**
  49643. * Define an offset for the position of the ellipsoid around the camera.
  49644. * This can be helpful if the camera is attached away from the player's body center,
  49645. * such as at its head.
  49646. */
  49647. ellipsoidOffset: Vector3;
  49648. /**
  49649. * Enable or disable collisions of the camera with the rest of the scene objects.
  49650. */
  49651. checkCollisions: boolean;
  49652. /**
  49653. * Enable or disable gravity on the camera.
  49654. */
  49655. applyGravity: boolean;
  49656. /**
  49657. * Define the current direction the camera is moving to.
  49658. */
  49659. cameraDirection: Vector3;
  49660. /**
  49661. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  49662. * This overrides and empties cameraRotation.
  49663. */
  49664. rotationQuaternion: Quaternion;
  49665. /**
  49666. * Track Roll to maintain the wanted Rolling when looking around.
  49667. */
  49668. _trackRoll: number;
  49669. /**
  49670. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  49671. */
  49672. rollCorrect: number;
  49673. /**
  49674. * Mimic a banked turn, Rolling the camera when Yawing.
  49675. * It's recommended to use rollCorrect = 10 for faster banking correction.
  49676. */
  49677. bankedTurn: boolean;
  49678. /**
  49679. * Limit in radians for how much Roll banking will add. (Default: 90°)
  49680. */
  49681. bankedTurnLimit: number;
  49682. /**
  49683. * Value of 0 disables the banked Roll.
  49684. * Value of 1 is equal to the Yaw angle in radians.
  49685. */
  49686. bankedTurnMultiplier: number;
  49687. /**
  49688. * The inputs manager loads all the input sources, such as keyboard and mouse.
  49689. */
  49690. inputs: FlyCameraInputsManager;
  49691. /**
  49692. * Gets the input sensibility for mouse input.
  49693. * Higher values reduce sensitivity.
  49694. */
  49695. get angularSensibility(): number;
  49696. /**
  49697. * Sets the input sensibility for a mouse input.
  49698. * Higher values reduce sensitivity.
  49699. */
  49700. set angularSensibility(value: number);
  49701. /**
  49702. * Get the keys for camera movement forward.
  49703. */
  49704. get keysForward(): number[];
  49705. /**
  49706. * Set the keys for camera movement forward.
  49707. */
  49708. set keysForward(value: number[]);
  49709. /**
  49710. * Get the keys for camera movement backward.
  49711. */
  49712. get keysBackward(): number[];
  49713. set keysBackward(value: number[]);
  49714. /**
  49715. * Get the keys for camera movement up.
  49716. */
  49717. get keysUp(): number[];
  49718. /**
  49719. * Set the keys for camera movement up.
  49720. */
  49721. set keysUp(value: number[]);
  49722. /**
  49723. * Get the keys for camera movement down.
  49724. */
  49725. get keysDown(): number[];
  49726. /**
  49727. * Set the keys for camera movement down.
  49728. */
  49729. set keysDown(value: number[]);
  49730. /**
  49731. * Get the keys for camera movement left.
  49732. */
  49733. get keysLeft(): number[];
  49734. /**
  49735. * Set the keys for camera movement left.
  49736. */
  49737. set keysLeft(value: number[]);
  49738. /**
  49739. * Set the keys for camera movement right.
  49740. */
  49741. get keysRight(): number[];
  49742. /**
  49743. * Set the keys for camera movement right.
  49744. */
  49745. set keysRight(value: number[]);
  49746. /**
  49747. * Event raised when the camera collides with a mesh in the scene.
  49748. */
  49749. onCollide: (collidedMesh: AbstractMesh) => void;
  49750. private _collider;
  49751. private _needMoveForGravity;
  49752. private _oldPosition;
  49753. private _diffPosition;
  49754. private _newPosition;
  49755. /** @hidden */
  49756. _localDirection: Vector3;
  49757. /** @hidden */
  49758. _transformedDirection: Vector3;
  49759. /**
  49760. * Instantiates a FlyCamera.
  49761. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49762. * such as in a 3D Space Shooter or a Flight Simulator.
  49763. * @param name Define the name of the camera in the scene.
  49764. * @param position Define the starting position of the camera in the scene.
  49765. * @param scene Define the scene the camera belongs to.
  49766. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  49767. */
  49768. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49769. /**
  49770. * Attach the input controls to a specific dom element to get the input from.
  49771. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49772. */
  49773. attachControl(noPreventDefault?: boolean): void;
  49774. /**
  49775. * Detach a control from the HTML DOM element.
  49776. * The camera will stop reacting to that input.
  49777. */
  49778. detachControl(): void;
  49779. private _collisionMask;
  49780. /**
  49781. * Get the mask that the camera ignores in collision events.
  49782. */
  49783. get collisionMask(): number;
  49784. /**
  49785. * Set the mask that the camera ignores in collision events.
  49786. */
  49787. set collisionMask(mask: number);
  49788. /** @hidden */
  49789. _collideWithWorld(displacement: Vector3): void;
  49790. /** @hidden */
  49791. private _onCollisionPositionChange;
  49792. /** @hidden */
  49793. _checkInputs(): void;
  49794. /** @hidden */
  49795. _decideIfNeedsToMove(): boolean;
  49796. /** @hidden */
  49797. _updatePosition(): void;
  49798. /**
  49799. * Restore the Roll to its target value at the rate specified.
  49800. * @param rate - Higher means slower restoring.
  49801. * @hidden
  49802. */
  49803. restoreRoll(rate: number): void;
  49804. /**
  49805. * Destroy the camera and release the current resources held by it.
  49806. */
  49807. dispose(): void;
  49808. /**
  49809. * Get the current object class name.
  49810. * @returns the class name.
  49811. */
  49812. getClassName(): string;
  49813. }
  49814. }
  49815. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  49816. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49817. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49818. /**
  49819. * Listen to keyboard events to control the camera.
  49820. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49821. */
  49822. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  49823. /**
  49824. * Defines the camera the input is attached to.
  49825. */
  49826. camera: FlyCamera;
  49827. /**
  49828. * The list of keyboard keys used to control the forward move of the camera.
  49829. */
  49830. keysForward: number[];
  49831. /**
  49832. * The list of keyboard keys used to control the backward move of the camera.
  49833. */
  49834. keysBackward: number[];
  49835. /**
  49836. * The list of keyboard keys used to control the forward move of the camera.
  49837. */
  49838. keysUp: number[];
  49839. /**
  49840. * The list of keyboard keys used to control the backward move of the camera.
  49841. */
  49842. keysDown: number[];
  49843. /**
  49844. * The list of keyboard keys used to control the right strafe move of the camera.
  49845. */
  49846. keysRight: number[];
  49847. /**
  49848. * The list of keyboard keys used to control the left strafe move of the camera.
  49849. */
  49850. keysLeft: number[];
  49851. private _keys;
  49852. private _onCanvasBlurObserver;
  49853. private _onKeyboardObserver;
  49854. private _engine;
  49855. private _scene;
  49856. /**
  49857. * Attach the input controls to a specific dom element to get the input from.
  49858. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49859. */
  49860. attachControl(noPreventDefault?: boolean): void;
  49861. /**
  49862. * Detach the current controls from the specified dom element.
  49863. */
  49864. detachControl(): void;
  49865. /**
  49866. * Gets the class name of the current intput.
  49867. * @returns the class name
  49868. */
  49869. getClassName(): string;
  49870. /** @hidden */
  49871. _onLostFocus(e: FocusEvent): void;
  49872. /**
  49873. * Get the friendly name associated with the input class.
  49874. * @returns the input friendly name
  49875. */
  49876. getSimpleName(): string;
  49877. /**
  49878. * Update the current camera state depending on the inputs that have been used this frame.
  49879. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49880. */
  49881. checkInputs(): void;
  49882. }
  49883. }
  49884. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  49885. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49886. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49887. /**
  49888. * Manage the mouse wheel inputs to control a follow camera.
  49889. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49890. */
  49891. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  49892. /**
  49893. * Defines the camera the input is attached to.
  49894. */
  49895. camera: FollowCamera;
  49896. /**
  49897. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  49898. */
  49899. axisControlRadius: boolean;
  49900. /**
  49901. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  49902. */
  49903. axisControlHeight: boolean;
  49904. /**
  49905. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  49906. */
  49907. axisControlRotation: boolean;
  49908. /**
  49909. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  49910. * relation to mouseWheel events.
  49911. */
  49912. wheelPrecision: number;
  49913. /**
  49914. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49915. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49916. */
  49917. wheelDeltaPercentage: number;
  49918. private _wheel;
  49919. private _observer;
  49920. /**
  49921. * Attach the input controls to a specific dom element to get the input from.
  49922. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49923. */
  49924. attachControl(noPreventDefault?: boolean): void;
  49925. /**
  49926. * Detach the current controls from the specified dom element.
  49927. */
  49928. detachControl(): void;
  49929. /**
  49930. * Gets the class name of the current intput.
  49931. * @returns the class name
  49932. */
  49933. getClassName(): string;
  49934. /**
  49935. * Get the friendly name associated with the input class.
  49936. * @returns the input friendly name
  49937. */
  49938. getSimpleName(): string;
  49939. }
  49940. }
  49941. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  49942. import { Nullable } from "babylonjs/types";
  49943. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49944. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  49945. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  49946. /**
  49947. * Manage the pointers inputs to control an follow camera.
  49948. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49949. */
  49950. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  49951. /**
  49952. * Defines the camera the input is attached to.
  49953. */
  49954. camera: FollowCamera;
  49955. /**
  49956. * Gets the class name of the current input.
  49957. * @returns the class name
  49958. */
  49959. getClassName(): string;
  49960. /**
  49961. * Defines the pointer angular sensibility along the X axis or how fast is
  49962. * the camera rotating.
  49963. * A negative number will reverse the axis direction.
  49964. */
  49965. angularSensibilityX: number;
  49966. /**
  49967. * Defines the pointer angular sensibility along the Y axis or how fast is
  49968. * the camera rotating.
  49969. * A negative number will reverse the axis direction.
  49970. */
  49971. angularSensibilityY: number;
  49972. /**
  49973. * Defines the pointer pinch precision or how fast is the camera zooming.
  49974. * A negative number will reverse the axis direction.
  49975. */
  49976. pinchPrecision: number;
  49977. /**
  49978. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49979. * from 0.
  49980. * It defines the percentage of current camera.radius to use as delta when
  49981. * pinch zoom is used.
  49982. */
  49983. pinchDeltaPercentage: number;
  49984. /**
  49985. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  49986. */
  49987. axisXControlRadius: boolean;
  49988. /**
  49989. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  49990. */
  49991. axisXControlHeight: boolean;
  49992. /**
  49993. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  49994. */
  49995. axisXControlRotation: boolean;
  49996. /**
  49997. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  49998. */
  49999. axisYControlRadius: boolean;
  50000. /**
  50001. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  50002. */
  50003. axisYControlHeight: boolean;
  50004. /**
  50005. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  50006. */
  50007. axisYControlRotation: boolean;
  50008. /**
  50009. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  50010. */
  50011. axisPinchControlRadius: boolean;
  50012. /**
  50013. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  50014. */
  50015. axisPinchControlHeight: boolean;
  50016. /**
  50017. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  50018. */
  50019. axisPinchControlRotation: boolean;
  50020. /**
  50021. * Log error messages if basic misconfiguration has occurred.
  50022. */
  50023. warningEnable: boolean;
  50024. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  50025. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  50026. private _warningCounter;
  50027. private _warning;
  50028. }
  50029. }
  50030. declare module "babylonjs/Cameras/followCameraInputsManager" {
  50031. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  50032. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  50033. /**
  50034. * Default Inputs manager for the FollowCamera.
  50035. * It groups all the default supported inputs for ease of use.
  50036. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50037. */
  50038. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  50039. /**
  50040. * Instantiates a new FollowCameraInputsManager.
  50041. * @param camera Defines the camera the inputs belong to
  50042. */
  50043. constructor(camera: FollowCamera);
  50044. /**
  50045. * Add keyboard input support to the input manager.
  50046. * @returns the current input manager
  50047. */
  50048. addKeyboard(): FollowCameraInputsManager;
  50049. /**
  50050. * Add mouse wheel input support to the input manager.
  50051. * @returns the current input manager
  50052. */
  50053. addMouseWheel(): FollowCameraInputsManager;
  50054. /**
  50055. * Add pointers input support to the input manager.
  50056. * @returns the current input manager
  50057. */
  50058. addPointers(): FollowCameraInputsManager;
  50059. /**
  50060. * Add orientation input support to the input manager.
  50061. * @returns the current input manager
  50062. */
  50063. addVRDeviceOrientation(): FollowCameraInputsManager;
  50064. }
  50065. }
  50066. declare module "babylonjs/Cameras/followCamera" {
  50067. import { Nullable } from "babylonjs/types";
  50068. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  50069. import { Scene } from "babylonjs/scene";
  50070. import { Vector3 } from "babylonjs/Maths/math.vector";
  50071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50072. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  50073. /**
  50074. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  50075. * an arc rotate version arcFollowCamera are available.
  50076. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50077. */
  50078. export class FollowCamera extends TargetCamera {
  50079. /**
  50080. * Distance the follow camera should follow an object at
  50081. */
  50082. radius: number;
  50083. /**
  50084. * Minimum allowed distance of the camera to the axis of rotation
  50085. * (The camera can not get closer).
  50086. * This can help limiting how the Camera is able to move in the scene.
  50087. */
  50088. lowerRadiusLimit: Nullable<number>;
  50089. /**
  50090. * Maximum allowed distance of the camera to the axis of rotation
  50091. * (The camera can not get further).
  50092. * This can help limiting how the Camera is able to move in the scene.
  50093. */
  50094. upperRadiusLimit: Nullable<number>;
  50095. /**
  50096. * Define a rotation offset between the camera and the object it follows
  50097. */
  50098. rotationOffset: number;
  50099. /**
  50100. * Minimum allowed angle to camera position relative to target object.
  50101. * This can help limiting how the Camera is able to move in the scene.
  50102. */
  50103. lowerRotationOffsetLimit: Nullable<number>;
  50104. /**
  50105. * Maximum allowed angle to camera position relative to target object.
  50106. * This can help limiting how the Camera is able to move in the scene.
  50107. */
  50108. upperRotationOffsetLimit: Nullable<number>;
  50109. /**
  50110. * Define a height offset between the camera and the object it follows.
  50111. * It can help following an object from the top (like a car chaing a plane)
  50112. */
  50113. heightOffset: number;
  50114. /**
  50115. * Minimum allowed height of camera position relative to target object.
  50116. * This can help limiting how the Camera is able to move in the scene.
  50117. */
  50118. lowerHeightOffsetLimit: Nullable<number>;
  50119. /**
  50120. * Maximum allowed height of camera position relative to target object.
  50121. * This can help limiting how the Camera is able to move in the scene.
  50122. */
  50123. upperHeightOffsetLimit: Nullable<number>;
  50124. /**
  50125. * Define how fast the camera can accelerate to follow it s target.
  50126. */
  50127. cameraAcceleration: number;
  50128. /**
  50129. * Define the speed limit of the camera following an object.
  50130. */
  50131. maxCameraSpeed: number;
  50132. /**
  50133. * Define the target of the camera.
  50134. */
  50135. lockedTarget: Nullable<AbstractMesh>;
  50136. /**
  50137. * Defines the input associated with the camera.
  50138. */
  50139. inputs: FollowCameraInputsManager;
  50140. /**
  50141. * Instantiates the follow camera.
  50142. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50143. * @param name Define the name of the camera in the scene
  50144. * @param position Define the position of the camera
  50145. * @param scene Define the scene the camera belong to
  50146. * @param lockedTarget Define the target of the camera
  50147. */
  50148. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  50149. private _follow;
  50150. /**
  50151. * Attach the input controls to a specific dom element to get the input from.
  50152. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50153. */
  50154. attachControl(noPreventDefault?: boolean): void;
  50155. /**
  50156. * Detach the current controls from the specified dom element.
  50157. */
  50158. detachControl(): void;
  50159. /** @hidden */
  50160. _checkInputs(): void;
  50161. private _checkLimits;
  50162. /**
  50163. * Gets the camera class name.
  50164. * @returns the class name
  50165. */
  50166. getClassName(): string;
  50167. }
  50168. /**
  50169. * Arc Rotate version of the follow camera.
  50170. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  50171. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50172. */
  50173. export class ArcFollowCamera extends TargetCamera {
  50174. /** The longitudinal angle of the camera */
  50175. alpha: number;
  50176. /** The latitudinal angle of the camera */
  50177. beta: number;
  50178. /** The radius of the camera from its target */
  50179. radius: number;
  50180. private _cartesianCoordinates;
  50181. /** Define the camera target (the mesh it should follow) */
  50182. private _meshTarget;
  50183. /**
  50184. * Instantiates a new ArcFollowCamera
  50185. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50186. * @param name Define the name of the camera
  50187. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  50188. * @param beta Define the rotation angle of the camera around the elevation axis
  50189. * @param radius Define the radius of the camera from its target point
  50190. * @param target Define the target of the camera
  50191. * @param scene Define the scene the camera belongs to
  50192. */
  50193. constructor(name: string,
  50194. /** The longitudinal angle of the camera */
  50195. alpha: number,
  50196. /** The latitudinal angle of the camera */
  50197. beta: number,
  50198. /** The radius of the camera from its target */
  50199. radius: number,
  50200. /** Define the camera target (the mesh it should follow) */
  50201. target: Nullable<AbstractMesh>, scene: Scene);
  50202. private _follow;
  50203. /** @hidden */
  50204. _checkInputs(): void;
  50205. /**
  50206. * Returns the class name of the object.
  50207. * It is mostly used internally for serialization purposes.
  50208. */
  50209. getClassName(): string;
  50210. }
  50211. }
  50212. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  50213. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50214. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  50215. /**
  50216. * Manage the keyboard inputs to control the movement of a follow camera.
  50217. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50218. */
  50219. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  50220. /**
  50221. * Defines the camera the input is attached to.
  50222. */
  50223. camera: FollowCamera;
  50224. /**
  50225. * Defines the list of key codes associated with the up action (increase heightOffset)
  50226. */
  50227. keysHeightOffsetIncr: number[];
  50228. /**
  50229. * Defines the list of key codes associated with the down action (decrease heightOffset)
  50230. */
  50231. keysHeightOffsetDecr: number[];
  50232. /**
  50233. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  50234. */
  50235. keysHeightOffsetModifierAlt: boolean;
  50236. /**
  50237. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  50238. */
  50239. keysHeightOffsetModifierCtrl: boolean;
  50240. /**
  50241. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  50242. */
  50243. keysHeightOffsetModifierShift: boolean;
  50244. /**
  50245. * Defines the list of key codes associated with the left action (increase rotationOffset)
  50246. */
  50247. keysRotationOffsetIncr: number[];
  50248. /**
  50249. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  50250. */
  50251. keysRotationOffsetDecr: number[];
  50252. /**
  50253. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  50254. */
  50255. keysRotationOffsetModifierAlt: boolean;
  50256. /**
  50257. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  50258. */
  50259. keysRotationOffsetModifierCtrl: boolean;
  50260. /**
  50261. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  50262. */
  50263. keysRotationOffsetModifierShift: boolean;
  50264. /**
  50265. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  50266. */
  50267. keysRadiusIncr: number[];
  50268. /**
  50269. * Defines the list of key codes associated with the zoom-out action (increase radius)
  50270. */
  50271. keysRadiusDecr: number[];
  50272. /**
  50273. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  50274. */
  50275. keysRadiusModifierAlt: boolean;
  50276. /**
  50277. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  50278. */
  50279. keysRadiusModifierCtrl: boolean;
  50280. /**
  50281. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  50282. */
  50283. keysRadiusModifierShift: boolean;
  50284. /**
  50285. * Defines the rate of change of heightOffset.
  50286. */
  50287. heightSensibility: number;
  50288. /**
  50289. * Defines the rate of change of rotationOffset.
  50290. */
  50291. rotationSensibility: number;
  50292. /**
  50293. * Defines the rate of change of radius.
  50294. */
  50295. radiusSensibility: number;
  50296. private _keys;
  50297. private _ctrlPressed;
  50298. private _altPressed;
  50299. private _shiftPressed;
  50300. private _onCanvasBlurObserver;
  50301. private _onKeyboardObserver;
  50302. private _engine;
  50303. private _scene;
  50304. /**
  50305. * Attach the input controls to a specific dom element to get the input from.
  50306. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50307. */
  50308. attachControl(noPreventDefault?: boolean): void;
  50309. /**
  50310. * Detach the current controls from the specified dom element.
  50311. */
  50312. detachControl(): void;
  50313. /**
  50314. * Update the current camera state depending on the inputs that have been used this frame.
  50315. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50316. */
  50317. checkInputs(): void;
  50318. /**
  50319. * Gets the class name of the current input.
  50320. * @returns the class name
  50321. */
  50322. getClassName(): string;
  50323. /**
  50324. * Get the friendly name associated with the input class.
  50325. * @returns the input friendly name
  50326. */
  50327. getSimpleName(): string;
  50328. /**
  50329. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50330. * allow modification of the heightOffset value.
  50331. */
  50332. private _modifierHeightOffset;
  50333. /**
  50334. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50335. * allow modification of the rotationOffset value.
  50336. */
  50337. private _modifierRotationOffset;
  50338. /**
  50339. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50340. * allow modification of the radius value.
  50341. */
  50342. private _modifierRadius;
  50343. }
  50344. }
  50345. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  50346. import { Nullable } from "babylonjs/types";
  50347. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50348. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50349. import { Observable } from "babylonjs/Misc/observable";
  50350. module "babylonjs/Cameras/freeCameraInputsManager" {
  50351. interface FreeCameraInputsManager {
  50352. /**
  50353. * @hidden
  50354. */
  50355. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  50356. /**
  50357. * Add orientation input support to the input manager.
  50358. * @returns the current input manager
  50359. */
  50360. addDeviceOrientation(): FreeCameraInputsManager;
  50361. }
  50362. }
  50363. /**
  50364. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  50365. * Screen rotation is taken into account.
  50366. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50367. */
  50368. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  50369. private _camera;
  50370. private _screenOrientationAngle;
  50371. private _constantTranform;
  50372. private _screenQuaternion;
  50373. private _alpha;
  50374. private _beta;
  50375. private _gamma;
  50376. /**
  50377. * Can be used to detect if a device orientation sensor is available on a device
  50378. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  50379. * @returns a promise that will resolve on orientation change
  50380. */
  50381. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  50382. /**
  50383. * @hidden
  50384. */
  50385. _onDeviceOrientationChangedObservable: Observable<void>;
  50386. /**
  50387. * Instantiates a new input
  50388. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50389. */
  50390. constructor();
  50391. /**
  50392. * Define the camera controlled by the input.
  50393. */
  50394. get camera(): FreeCamera;
  50395. set camera(camera: FreeCamera);
  50396. /**
  50397. * Attach the input controls to a specific dom element to get the input from.
  50398. */
  50399. attachControl(): void;
  50400. private _orientationChanged;
  50401. private _deviceOrientation;
  50402. /**
  50403. * Detach the current controls from the specified dom element.
  50404. */
  50405. detachControl(): void;
  50406. /**
  50407. * Update the current camera state depending on the inputs that have been used this frame.
  50408. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50409. */
  50410. checkInputs(): void;
  50411. /**
  50412. * Gets the class name of the current intput.
  50413. * @returns the class name
  50414. */
  50415. getClassName(): string;
  50416. /**
  50417. * Get the friendly name associated with the input class.
  50418. * @returns the input friendly name
  50419. */
  50420. getSimpleName(): string;
  50421. }
  50422. }
  50423. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  50424. import { Nullable } from "babylonjs/types";
  50425. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50426. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50427. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50428. /**
  50429. * Manage the gamepad inputs to control a free camera.
  50430. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50431. */
  50432. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  50433. /**
  50434. * Define the camera the input is attached to.
  50435. */
  50436. camera: FreeCamera;
  50437. /**
  50438. * Define the Gamepad controlling the input
  50439. */
  50440. gamepad: Nullable<Gamepad>;
  50441. /**
  50442. * Defines the gamepad rotation sensiblity.
  50443. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50444. */
  50445. gamepadAngularSensibility: number;
  50446. /**
  50447. * Defines the gamepad move sensiblity.
  50448. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50449. */
  50450. gamepadMoveSensibility: number;
  50451. private _yAxisScale;
  50452. /**
  50453. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  50454. */
  50455. get invertYAxis(): boolean;
  50456. set invertYAxis(value: boolean);
  50457. private _onGamepadConnectedObserver;
  50458. private _onGamepadDisconnectedObserver;
  50459. private _cameraTransform;
  50460. private _deltaTransform;
  50461. private _vector3;
  50462. private _vector2;
  50463. /**
  50464. * Attach the input controls to a specific dom element to get the input from.
  50465. */
  50466. attachControl(): void;
  50467. /**
  50468. * Detach the current controls from the specified dom element.
  50469. */
  50470. detachControl(): void;
  50471. /**
  50472. * Update the current camera state depending on the inputs that have been used this frame.
  50473. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50474. */
  50475. checkInputs(): void;
  50476. /**
  50477. * Gets the class name of the current intput.
  50478. * @returns the class name
  50479. */
  50480. getClassName(): string;
  50481. /**
  50482. * Get the friendly name associated with the input class.
  50483. * @returns the input friendly name
  50484. */
  50485. getSimpleName(): string;
  50486. }
  50487. }
  50488. declare module "babylonjs/Misc/virtualJoystick" {
  50489. import { Nullable } from "babylonjs/types";
  50490. import { Vector3 } from "babylonjs/Maths/math.vector";
  50491. /**
  50492. * Defines the potential axis of a Joystick
  50493. */
  50494. export enum JoystickAxis {
  50495. /** X axis */
  50496. X = 0,
  50497. /** Y axis */
  50498. Y = 1,
  50499. /** Z axis */
  50500. Z = 2
  50501. }
  50502. /**
  50503. * Represents the different customization options available
  50504. * for VirtualJoystick
  50505. */
  50506. interface VirtualJoystickCustomizations {
  50507. /**
  50508. * Size of the joystick's puck
  50509. */
  50510. puckSize: number;
  50511. /**
  50512. * Size of the joystick's container
  50513. */
  50514. containerSize: number;
  50515. /**
  50516. * Color of the joystick && puck
  50517. */
  50518. color: string;
  50519. /**
  50520. * Image URL for the joystick's puck
  50521. */
  50522. puckImage?: string;
  50523. /**
  50524. * Image URL for the joystick's container
  50525. */
  50526. containerImage?: string;
  50527. /**
  50528. * Defines the unmoving position of the joystick container
  50529. */
  50530. position?: {
  50531. x: number;
  50532. y: number;
  50533. };
  50534. /**
  50535. * Defines whether or not the joystick container is always visible
  50536. */
  50537. alwaysVisible: boolean;
  50538. /**
  50539. * Defines whether or not to limit the movement of the puck to the joystick's container
  50540. */
  50541. limitToContainer: boolean;
  50542. }
  50543. /**
  50544. * Class used to define virtual joystick (used in touch mode)
  50545. */
  50546. export class VirtualJoystick {
  50547. /**
  50548. * Gets or sets a boolean indicating that left and right values must be inverted
  50549. */
  50550. reverseLeftRight: boolean;
  50551. /**
  50552. * Gets or sets a boolean indicating that up and down values must be inverted
  50553. */
  50554. reverseUpDown: boolean;
  50555. /**
  50556. * Gets the offset value for the position (ie. the change of the position value)
  50557. */
  50558. deltaPosition: Vector3;
  50559. /**
  50560. * Gets a boolean indicating if the virtual joystick was pressed
  50561. */
  50562. pressed: boolean;
  50563. /**
  50564. * Canvas the virtual joystick will render onto, default z-index of this is 5
  50565. */
  50566. static Canvas: Nullable<HTMLCanvasElement>;
  50567. /**
  50568. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  50569. */
  50570. limitToContainer: boolean;
  50571. private static _globalJoystickIndex;
  50572. private static _alwaysVisibleSticks;
  50573. private static vjCanvasContext;
  50574. private static vjCanvasWidth;
  50575. private static vjCanvasHeight;
  50576. private static halfWidth;
  50577. private static _GetDefaultOptions;
  50578. private _action;
  50579. private _axisTargetedByLeftAndRight;
  50580. private _axisTargetedByUpAndDown;
  50581. private _joystickSensibility;
  50582. private _inversedSensibility;
  50583. private _joystickPointerID;
  50584. private _joystickColor;
  50585. private _joystickPointerPos;
  50586. private _joystickPreviousPointerPos;
  50587. private _joystickPointerStartPos;
  50588. private _deltaJoystickVector;
  50589. private _leftJoystick;
  50590. private _touches;
  50591. private _joystickPosition;
  50592. private _alwaysVisible;
  50593. private _puckImage;
  50594. private _containerImage;
  50595. private _joystickPuckSize;
  50596. private _joystickContainerSize;
  50597. private _clearPuckSize;
  50598. private _clearContainerSize;
  50599. private _clearPuckSizeOffset;
  50600. private _clearContainerSizeOffset;
  50601. private _onPointerDownHandlerRef;
  50602. private _onPointerMoveHandlerRef;
  50603. private _onPointerUpHandlerRef;
  50604. private _onResize;
  50605. /**
  50606. * Creates a new virtual joystick
  50607. * @param leftJoystick defines that the joystick is for left hand (false by default)
  50608. * @param customizations Defines the options we want to customize the VirtualJoystick
  50609. */
  50610. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  50611. /**
  50612. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  50613. * @param newJoystickSensibility defines the new sensibility
  50614. */
  50615. setJoystickSensibility(newJoystickSensibility: number): void;
  50616. private _onPointerDown;
  50617. private _onPointerMove;
  50618. private _onPointerUp;
  50619. /**
  50620. * Change the color of the virtual joystick
  50621. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  50622. */
  50623. setJoystickColor(newColor: string): void;
  50624. /**
  50625. * Size of the joystick's container
  50626. */
  50627. set containerSize(newSize: number);
  50628. get containerSize(): number;
  50629. /**
  50630. * Size of the joystick's puck
  50631. */
  50632. set puckSize(newSize: number);
  50633. get puckSize(): number;
  50634. /**
  50635. * Clears the set position of the joystick
  50636. */
  50637. clearPosition(): void;
  50638. /**
  50639. * Defines whether or not the joystick container is always visible
  50640. */
  50641. set alwaysVisible(value: boolean);
  50642. get alwaysVisible(): boolean;
  50643. /**
  50644. * Sets the constant position of the Joystick container
  50645. * @param x X axis coordinate
  50646. * @param y Y axis coordinate
  50647. */
  50648. setPosition(x: number, y: number): void;
  50649. /**
  50650. * Defines a callback to call when the joystick is touched
  50651. * @param action defines the callback
  50652. */
  50653. setActionOnTouch(action: () => any): void;
  50654. /**
  50655. * Defines which axis you'd like to control for left & right
  50656. * @param axis defines the axis to use
  50657. */
  50658. setAxisForLeftRight(axis: JoystickAxis): void;
  50659. /**
  50660. * Defines which axis you'd like to control for up & down
  50661. * @param axis defines the axis to use
  50662. */
  50663. setAxisForUpDown(axis: JoystickAxis): void;
  50664. /**
  50665. * Clears the canvas from the previous puck / container draw
  50666. */
  50667. private _clearPreviousDraw;
  50668. /**
  50669. * Loads `urlPath` to be used for the container's image
  50670. * @param urlPath defines the urlPath of an image to use
  50671. */
  50672. setContainerImage(urlPath: string): void;
  50673. /**
  50674. * Loads `urlPath` to be used for the puck's image
  50675. * @param urlPath defines the urlPath of an image to use
  50676. */
  50677. setPuckImage(urlPath: string): void;
  50678. /**
  50679. * Draws the Virtual Joystick's container
  50680. */
  50681. private _drawContainer;
  50682. /**
  50683. * Draws the Virtual Joystick's puck
  50684. */
  50685. private _drawPuck;
  50686. private _drawVirtualJoystick;
  50687. /**
  50688. * Release internal HTML canvas
  50689. */
  50690. releaseCanvas(): void;
  50691. }
  50692. }
  50693. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  50694. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  50695. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50696. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50697. module "babylonjs/Cameras/freeCameraInputsManager" {
  50698. interface FreeCameraInputsManager {
  50699. /**
  50700. * Add virtual joystick input support to the input manager.
  50701. * @returns the current input manager
  50702. */
  50703. addVirtualJoystick(): FreeCameraInputsManager;
  50704. }
  50705. }
  50706. /**
  50707. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  50708. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50709. */
  50710. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  50711. /**
  50712. * Defines the camera the input is attached to.
  50713. */
  50714. camera: FreeCamera;
  50715. private _leftjoystick;
  50716. private _rightjoystick;
  50717. /**
  50718. * Gets the left stick of the virtual joystick.
  50719. * @returns The virtual Joystick
  50720. */
  50721. getLeftJoystick(): VirtualJoystick;
  50722. /**
  50723. * Gets the right stick of the virtual joystick.
  50724. * @returns The virtual Joystick
  50725. */
  50726. getRightJoystick(): VirtualJoystick;
  50727. /**
  50728. * Update the current camera state depending on the inputs that have been used this frame.
  50729. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50730. */
  50731. checkInputs(): void;
  50732. /**
  50733. * Attach the input controls to a specific dom element to get the input from.
  50734. */
  50735. attachControl(): void;
  50736. /**
  50737. * Detach the current controls from the specified dom element.
  50738. */
  50739. detachControl(): void;
  50740. /**
  50741. * Gets the class name of the current intput.
  50742. * @returns the class name
  50743. */
  50744. getClassName(): string;
  50745. /**
  50746. * Get the friendly name associated with the input class.
  50747. * @returns the input friendly name
  50748. */
  50749. getSimpleName(): string;
  50750. }
  50751. }
  50752. declare module "babylonjs/Cameras/Inputs/index" {
  50753. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  50754. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  50755. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  50756. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  50757. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  50758. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  50759. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  50760. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  50761. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  50762. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  50763. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50764. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  50765. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  50766. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  50767. export * from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  50768. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  50769. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  50770. }
  50771. declare module "babylonjs/Cameras/touchCamera" {
  50772. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50773. import { Scene } from "babylonjs/scene";
  50774. import { Vector3 } from "babylonjs/Maths/math.vector";
  50775. /**
  50776. * This represents a FPS type of camera controlled by touch.
  50777. * This is like a universal camera minus the Gamepad controls.
  50778. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50779. */
  50780. export class TouchCamera extends FreeCamera {
  50781. /**
  50782. * Defines the touch sensibility for rotation.
  50783. * The higher the faster.
  50784. */
  50785. get touchAngularSensibility(): number;
  50786. set touchAngularSensibility(value: number);
  50787. /**
  50788. * Defines the touch sensibility for move.
  50789. * The higher the faster.
  50790. */
  50791. get touchMoveSensibility(): number;
  50792. set touchMoveSensibility(value: number);
  50793. /**
  50794. * Instantiates a new touch camera.
  50795. * This represents a FPS type of camera controlled by touch.
  50796. * This is like a universal camera minus the Gamepad controls.
  50797. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50798. * @param name Define the name of the camera in the scene
  50799. * @param position Define the start position of the camera in the scene
  50800. * @param scene Define the scene the camera belongs to
  50801. */
  50802. constructor(name: string, position: Vector3, scene: Scene);
  50803. /**
  50804. * Gets the current object class name.
  50805. * @return the class name
  50806. */
  50807. getClassName(): string;
  50808. /** @hidden */
  50809. _setupInputs(): void;
  50810. }
  50811. }
  50812. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  50813. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50814. import { Scene } from "babylonjs/scene";
  50815. import { Vector3 } from "babylonjs/Maths/math.vector";
  50816. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50817. import { Axis } from "babylonjs/Maths/math.axis";
  50818. /**
  50819. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  50820. * being tilted forward or back and left or right.
  50821. */
  50822. export class DeviceOrientationCamera extends FreeCamera {
  50823. private _initialQuaternion;
  50824. private _quaternionCache;
  50825. private _tmpDragQuaternion;
  50826. private _disablePointerInputWhenUsingDeviceOrientation;
  50827. /**
  50828. * Creates a new device orientation camera
  50829. * @param name The name of the camera
  50830. * @param position The start position camera
  50831. * @param scene The scene the camera belongs to
  50832. */
  50833. constructor(name: string, position: Vector3, scene: Scene);
  50834. /**
  50835. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  50836. */
  50837. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  50838. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  50839. private _dragFactor;
  50840. /**
  50841. * Enabled turning on the y axis when the orientation sensor is active
  50842. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  50843. */
  50844. enableHorizontalDragging(dragFactor?: number): void;
  50845. /**
  50846. * Gets the current instance class name ("DeviceOrientationCamera").
  50847. * This helps avoiding instanceof at run time.
  50848. * @returns the class name
  50849. */
  50850. getClassName(): string;
  50851. /**
  50852. * @hidden
  50853. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  50854. */
  50855. _checkInputs(): void;
  50856. /**
  50857. * Reset the camera to its default orientation on the specified axis only.
  50858. * @param axis The axis to reset
  50859. */
  50860. resetToCurrentRotation(axis?: Axis): void;
  50861. }
  50862. }
  50863. declare module "babylonjs/Gamepads/xboxGamepad" {
  50864. import { Observable } from "babylonjs/Misc/observable";
  50865. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50866. /**
  50867. * Defines supported buttons for XBox360 compatible gamepads
  50868. */
  50869. export enum Xbox360Button {
  50870. /** A */
  50871. A = 0,
  50872. /** B */
  50873. B = 1,
  50874. /** X */
  50875. X = 2,
  50876. /** Y */
  50877. Y = 3,
  50878. /** Left button */
  50879. LB = 4,
  50880. /** Right button */
  50881. RB = 5,
  50882. /** Back */
  50883. Back = 8,
  50884. /** Start */
  50885. Start = 9,
  50886. /** Left stick */
  50887. LeftStick = 10,
  50888. /** Right stick */
  50889. RightStick = 11
  50890. }
  50891. /** Defines values for XBox360 DPad */
  50892. export enum Xbox360Dpad {
  50893. /** Up */
  50894. Up = 12,
  50895. /** Down */
  50896. Down = 13,
  50897. /** Left */
  50898. Left = 14,
  50899. /** Right */
  50900. Right = 15
  50901. }
  50902. /**
  50903. * Defines a XBox360 gamepad
  50904. */
  50905. export class Xbox360Pad extends Gamepad {
  50906. private _leftTrigger;
  50907. private _rightTrigger;
  50908. private _onlefttriggerchanged;
  50909. private _onrighttriggerchanged;
  50910. private _onbuttondown;
  50911. private _onbuttonup;
  50912. private _ondpaddown;
  50913. private _ondpadup;
  50914. /** Observable raised when a button is pressed */
  50915. onButtonDownObservable: Observable<Xbox360Button>;
  50916. /** Observable raised when a button is released */
  50917. onButtonUpObservable: Observable<Xbox360Button>;
  50918. /** Observable raised when a pad is pressed */
  50919. onPadDownObservable: Observable<Xbox360Dpad>;
  50920. /** Observable raised when a pad is released */
  50921. onPadUpObservable: Observable<Xbox360Dpad>;
  50922. private _buttonA;
  50923. private _buttonB;
  50924. private _buttonX;
  50925. private _buttonY;
  50926. private _buttonBack;
  50927. private _buttonStart;
  50928. private _buttonLB;
  50929. private _buttonRB;
  50930. private _buttonLeftStick;
  50931. private _buttonRightStick;
  50932. private _dPadUp;
  50933. private _dPadDown;
  50934. private _dPadLeft;
  50935. private _dPadRight;
  50936. private _isXboxOnePad;
  50937. /**
  50938. * Creates a new XBox360 gamepad object
  50939. * @param id defines the id of this gamepad
  50940. * @param index defines its index
  50941. * @param gamepad defines the internal HTML gamepad object
  50942. * @param xboxOne defines if it is a XBox One gamepad
  50943. */
  50944. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  50945. /**
  50946. * Defines the callback to call when left trigger is pressed
  50947. * @param callback defines the callback to use
  50948. */
  50949. onlefttriggerchanged(callback: (value: number) => void): void;
  50950. /**
  50951. * Defines the callback to call when right trigger is pressed
  50952. * @param callback defines the callback to use
  50953. */
  50954. onrighttriggerchanged(callback: (value: number) => void): void;
  50955. /**
  50956. * Gets the left trigger value
  50957. */
  50958. get leftTrigger(): number;
  50959. /**
  50960. * Sets the left trigger value
  50961. */
  50962. set leftTrigger(newValue: number);
  50963. /**
  50964. * Gets the right trigger value
  50965. */
  50966. get rightTrigger(): number;
  50967. /**
  50968. * Sets the right trigger value
  50969. */
  50970. set rightTrigger(newValue: number);
  50971. /**
  50972. * Defines the callback to call when a button is pressed
  50973. * @param callback defines the callback to use
  50974. */
  50975. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  50976. /**
  50977. * Defines the callback to call when a button is released
  50978. * @param callback defines the callback to use
  50979. */
  50980. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  50981. /**
  50982. * Defines the callback to call when a pad is pressed
  50983. * @param callback defines the callback to use
  50984. */
  50985. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  50986. /**
  50987. * Defines the callback to call when a pad is released
  50988. * @param callback defines the callback to use
  50989. */
  50990. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  50991. private _setButtonValue;
  50992. private _setDPadValue;
  50993. /**
  50994. * Gets the value of the `A` button
  50995. */
  50996. get buttonA(): number;
  50997. /**
  50998. * Sets the value of the `A` button
  50999. */
  51000. set buttonA(value: number);
  51001. /**
  51002. * Gets the value of the `B` button
  51003. */
  51004. get buttonB(): number;
  51005. /**
  51006. * Sets the value of the `B` button
  51007. */
  51008. set buttonB(value: number);
  51009. /**
  51010. * Gets the value of the `X` button
  51011. */
  51012. get buttonX(): number;
  51013. /**
  51014. * Sets the value of the `X` button
  51015. */
  51016. set buttonX(value: number);
  51017. /**
  51018. * Gets the value of the `Y` button
  51019. */
  51020. get buttonY(): number;
  51021. /**
  51022. * Sets the value of the `Y` button
  51023. */
  51024. set buttonY(value: number);
  51025. /**
  51026. * Gets the value of the `Start` button
  51027. */
  51028. get buttonStart(): number;
  51029. /**
  51030. * Sets the value of the `Start` button
  51031. */
  51032. set buttonStart(value: number);
  51033. /**
  51034. * Gets the value of the `Back` button
  51035. */
  51036. get buttonBack(): number;
  51037. /**
  51038. * Sets the value of the `Back` button
  51039. */
  51040. set buttonBack(value: number);
  51041. /**
  51042. * Gets the value of the `Left` button
  51043. */
  51044. get buttonLB(): number;
  51045. /**
  51046. * Sets the value of the `Left` button
  51047. */
  51048. set buttonLB(value: number);
  51049. /**
  51050. * Gets the value of the `Right` button
  51051. */
  51052. get buttonRB(): number;
  51053. /**
  51054. * Sets the value of the `Right` button
  51055. */
  51056. set buttonRB(value: number);
  51057. /**
  51058. * Gets the value of the Left joystick
  51059. */
  51060. get buttonLeftStick(): number;
  51061. /**
  51062. * Sets the value of the Left joystick
  51063. */
  51064. set buttonLeftStick(value: number);
  51065. /**
  51066. * Gets the value of the Right joystick
  51067. */
  51068. get buttonRightStick(): number;
  51069. /**
  51070. * Sets the value of the Right joystick
  51071. */
  51072. set buttonRightStick(value: number);
  51073. /**
  51074. * Gets the value of D-pad up
  51075. */
  51076. get dPadUp(): number;
  51077. /**
  51078. * Sets the value of D-pad up
  51079. */
  51080. set dPadUp(value: number);
  51081. /**
  51082. * Gets the value of D-pad down
  51083. */
  51084. get dPadDown(): number;
  51085. /**
  51086. * Sets the value of D-pad down
  51087. */
  51088. set dPadDown(value: number);
  51089. /**
  51090. * Gets the value of D-pad left
  51091. */
  51092. get dPadLeft(): number;
  51093. /**
  51094. * Sets the value of D-pad left
  51095. */
  51096. set dPadLeft(value: number);
  51097. /**
  51098. * Gets the value of D-pad right
  51099. */
  51100. get dPadRight(): number;
  51101. /**
  51102. * Sets the value of D-pad right
  51103. */
  51104. set dPadRight(value: number);
  51105. /**
  51106. * Force the gamepad to synchronize with device values
  51107. */
  51108. update(): void;
  51109. /**
  51110. * Disposes the gamepad
  51111. */
  51112. dispose(): void;
  51113. }
  51114. }
  51115. declare module "babylonjs/Gamepads/dualShockGamepad" {
  51116. import { Observable } from "babylonjs/Misc/observable";
  51117. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  51118. /**
  51119. * Defines supported buttons for DualShock compatible gamepads
  51120. */
  51121. export enum DualShockButton {
  51122. /** Cross */
  51123. Cross = 0,
  51124. /** Circle */
  51125. Circle = 1,
  51126. /** Square */
  51127. Square = 2,
  51128. /** Triangle */
  51129. Triangle = 3,
  51130. /** L1 */
  51131. L1 = 4,
  51132. /** R1 */
  51133. R1 = 5,
  51134. /** Share */
  51135. Share = 8,
  51136. /** Options */
  51137. Options = 9,
  51138. /** Left stick */
  51139. LeftStick = 10,
  51140. /** Right stick */
  51141. RightStick = 11
  51142. }
  51143. /** Defines values for DualShock DPad */
  51144. export enum DualShockDpad {
  51145. /** Up */
  51146. Up = 12,
  51147. /** Down */
  51148. Down = 13,
  51149. /** Left */
  51150. Left = 14,
  51151. /** Right */
  51152. Right = 15
  51153. }
  51154. /**
  51155. * Defines a DualShock gamepad
  51156. */
  51157. export class DualShockPad extends Gamepad {
  51158. private _leftTrigger;
  51159. private _rightTrigger;
  51160. private _onlefttriggerchanged;
  51161. private _onrighttriggerchanged;
  51162. private _onbuttondown;
  51163. private _onbuttonup;
  51164. private _ondpaddown;
  51165. private _ondpadup;
  51166. /** Observable raised when a button is pressed */
  51167. onButtonDownObservable: Observable<DualShockButton>;
  51168. /** Observable raised when a button is released */
  51169. onButtonUpObservable: Observable<DualShockButton>;
  51170. /** Observable raised when a pad is pressed */
  51171. onPadDownObservable: Observable<DualShockDpad>;
  51172. /** Observable raised when a pad is released */
  51173. onPadUpObservable: Observable<DualShockDpad>;
  51174. private _buttonCross;
  51175. private _buttonCircle;
  51176. private _buttonSquare;
  51177. private _buttonTriangle;
  51178. private _buttonShare;
  51179. private _buttonOptions;
  51180. private _buttonL1;
  51181. private _buttonR1;
  51182. private _buttonLeftStick;
  51183. private _buttonRightStick;
  51184. private _dPadUp;
  51185. private _dPadDown;
  51186. private _dPadLeft;
  51187. private _dPadRight;
  51188. /**
  51189. * Creates a new DualShock gamepad object
  51190. * @param id defines the id of this gamepad
  51191. * @param index defines its index
  51192. * @param gamepad defines the internal HTML gamepad object
  51193. */
  51194. constructor(id: string, index: number, gamepad: any);
  51195. /**
  51196. * Defines the callback to call when left trigger is pressed
  51197. * @param callback defines the callback to use
  51198. */
  51199. onlefttriggerchanged(callback: (value: number) => void): void;
  51200. /**
  51201. * Defines the callback to call when right trigger is pressed
  51202. * @param callback defines the callback to use
  51203. */
  51204. onrighttriggerchanged(callback: (value: number) => void): void;
  51205. /**
  51206. * Gets the left trigger value
  51207. */
  51208. get leftTrigger(): number;
  51209. /**
  51210. * Sets the left trigger value
  51211. */
  51212. set leftTrigger(newValue: number);
  51213. /**
  51214. * Gets the right trigger value
  51215. */
  51216. get rightTrigger(): number;
  51217. /**
  51218. * Sets the right trigger value
  51219. */
  51220. set rightTrigger(newValue: number);
  51221. /**
  51222. * Defines the callback to call when a button is pressed
  51223. * @param callback defines the callback to use
  51224. */
  51225. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  51226. /**
  51227. * Defines the callback to call when a button is released
  51228. * @param callback defines the callback to use
  51229. */
  51230. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  51231. /**
  51232. * Defines the callback to call when a pad is pressed
  51233. * @param callback defines the callback to use
  51234. */
  51235. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  51236. /**
  51237. * Defines the callback to call when a pad is released
  51238. * @param callback defines the callback to use
  51239. */
  51240. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  51241. private _setButtonValue;
  51242. private _setDPadValue;
  51243. /**
  51244. * Gets the value of the `Cross` button
  51245. */
  51246. get buttonCross(): number;
  51247. /**
  51248. * Sets the value of the `Cross` button
  51249. */
  51250. set buttonCross(value: number);
  51251. /**
  51252. * Gets the value of the `Circle` button
  51253. */
  51254. get buttonCircle(): number;
  51255. /**
  51256. * Sets the value of the `Circle` button
  51257. */
  51258. set buttonCircle(value: number);
  51259. /**
  51260. * Gets the value of the `Square` button
  51261. */
  51262. get buttonSquare(): number;
  51263. /**
  51264. * Sets the value of the `Square` button
  51265. */
  51266. set buttonSquare(value: number);
  51267. /**
  51268. * Gets the value of the `Triangle` button
  51269. */
  51270. get buttonTriangle(): number;
  51271. /**
  51272. * Sets the value of the `Triangle` button
  51273. */
  51274. set buttonTriangle(value: number);
  51275. /**
  51276. * Gets the value of the `Options` button
  51277. */
  51278. get buttonOptions(): number;
  51279. /**
  51280. * Sets the value of the `Options` button
  51281. */
  51282. set buttonOptions(value: number);
  51283. /**
  51284. * Gets the value of the `Share` button
  51285. */
  51286. get buttonShare(): number;
  51287. /**
  51288. * Sets the value of the `Share` button
  51289. */
  51290. set buttonShare(value: number);
  51291. /**
  51292. * Gets the value of the `L1` button
  51293. */
  51294. get buttonL1(): number;
  51295. /**
  51296. * Sets the value of the `L1` button
  51297. */
  51298. set buttonL1(value: number);
  51299. /**
  51300. * Gets the value of the `R1` button
  51301. */
  51302. get buttonR1(): number;
  51303. /**
  51304. * Sets the value of the `R1` button
  51305. */
  51306. set buttonR1(value: number);
  51307. /**
  51308. * Gets the value of the Left joystick
  51309. */
  51310. get buttonLeftStick(): number;
  51311. /**
  51312. * Sets the value of the Left joystick
  51313. */
  51314. set buttonLeftStick(value: number);
  51315. /**
  51316. * Gets the value of the Right joystick
  51317. */
  51318. get buttonRightStick(): number;
  51319. /**
  51320. * Sets the value of the Right joystick
  51321. */
  51322. set buttonRightStick(value: number);
  51323. /**
  51324. * Gets the value of D-pad up
  51325. */
  51326. get dPadUp(): number;
  51327. /**
  51328. * Sets the value of D-pad up
  51329. */
  51330. set dPadUp(value: number);
  51331. /**
  51332. * Gets the value of D-pad down
  51333. */
  51334. get dPadDown(): number;
  51335. /**
  51336. * Sets the value of D-pad down
  51337. */
  51338. set dPadDown(value: number);
  51339. /**
  51340. * Gets the value of D-pad left
  51341. */
  51342. get dPadLeft(): number;
  51343. /**
  51344. * Sets the value of D-pad left
  51345. */
  51346. set dPadLeft(value: number);
  51347. /**
  51348. * Gets the value of D-pad right
  51349. */
  51350. get dPadRight(): number;
  51351. /**
  51352. * Sets the value of D-pad right
  51353. */
  51354. set dPadRight(value: number);
  51355. /**
  51356. * Force the gamepad to synchronize with device values
  51357. */
  51358. update(): void;
  51359. /**
  51360. * Disposes the gamepad
  51361. */
  51362. dispose(): void;
  51363. }
  51364. }
  51365. declare module "babylonjs/Gamepads/gamepadManager" {
  51366. import { Observable } from "babylonjs/Misc/observable";
  51367. import { Nullable } from "babylonjs/types";
  51368. import { Scene } from "babylonjs/scene";
  51369. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  51370. /**
  51371. * Manager for handling gamepads
  51372. */
  51373. export class GamepadManager {
  51374. private _scene?;
  51375. private _babylonGamepads;
  51376. private _oneGamepadConnected;
  51377. /** @hidden */
  51378. _isMonitoring: boolean;
  51379. private _gamepadEventSupported;
  51380. private _gamepadSupport?;
  51381. /**
  51382. * observable to be triggered when the gamepad controller has been connected
  51383. */
  51384. onGamepadConnectedObservable: Observable<Gamepad>;
  51385. /**
  51386. * observable to be triggered when the gamepad controller has been disconnected
  51387. */
  51388. onGamepadDisconnectedObservable: Observable<Gamepad>;
  51389. private _onGamepadConnectedEvent;
  51390. private _onGamepadDisconnectedEvent;
  51391. /**
  51392. * Initializes the gamepad manager
  51393. * @param _scene BabylonJS scene
  51394. */
  51395. constructor(_scene?: Scene | undefined);
  51396. /**
  51397. * The gamepads in the game pad manager
  51398. */
  51399. get gamepads(): Gamepad[];
  51400. /**
  51401. * Get the gamepad controllers based on type
  51402. * @param type The type of gamepad controller
  51403. * @returns Nullable gamepad
  51404. */
  51405. getGamepadByType(type?: number): Nullable<Gamepad>;
  51406. /**
  51407. * Disposes the gamepad manager
  51408. */
  51409. dispose(): void;
  51410. private _addNewGamepad;
  51411. private _startMonitoringGamepads;
  51412. private _stopMonitoringGamepads;
  51413. /** @hidden */
  51414. _checkGamepadsStatus(): void;
  51415. private _updateGamepadObjects;
  51416. }
  51417. }
  51418. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  51419. import { Nullable } from "babylonjs/types";
  51420. import { Scene } from "babylonjs/scene";
  51421. import { ISceneComponent } from "babylonjs/sceneComponent";
  51422. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  51423. module "babylonjs/scene" {
  51424. interface Scene {
  51425. /** @hidden */
  51426. _gamepadManager: Nullable<GamepadManager>;
  51427. /**
  51428. * Gets the gamepad manager associated with the scene
  51429. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  51430. */
  51431. gamepadManager: GamepadManager;
  51432. }
  51433. }
  51434. module "babylonjs/Cameras/freeCameraInputsManager" {
  51435. /**
  51436. * Interface representing a free camera inputs manager
  51437. */
  51438. interface FreeCameraInputsManager {
  51439. /**
  51440. * Adds gamepad input support to the FreeCameraInputsManager.
  51441. * @returns the FreeCameraInputsManager
  51442. */
  51443. addGamepad(): FreeCameraInputsManager;
  51444. }
  51445. }
  51446. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  51447. /**
  51448. * Interface representing an arc rotate camera inputs manager
  51449. */
  51450. interface ArcRotateCameraInputsManager {
  51451. /**
  51452. * Adds gamepad input support to the ArcRotateCamera InputManager.
  51453. * @returns the camera inputs manager
  51454. */
  51455. addGamepad(): ArcRotateCameraInputsManager;
  51456. }
  51457. }
  51458. /**
  51459. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  51460. */
  51461. export class GamepadSystemSceneComponent implements ISceneComponent {
  51462. /**
  51463. * The component name helpfull to identify the component in the list of scene components.
  51464. */
  51465. readonly name: string;
  51466. /**
  51467. * The scene the component belongs to.
  51468. */
  51469. scene: Scene;
  51470. /**
  51471. * Creates a new instance of the component for the given scene
  51472. * @param scene Defines the scene to register the component in
  51473. */
  51474. constructor(scene: Scene);
  51475. /**
  51476. * Registers the component in a given scene
  51477. */
  51478. register(): void;
  51479. /**
  51480. * Rebuilds the elements related to this component in case of
  51481. * context lost for instance.
  51482. */
  51483. rebuild(): void;
  51484. /**
  51485. * Disposes the component and the associated ressources
  51486. */
  51487. dispose(): void;
  51488. private _beforeCameraUpdate;
  51489. }
  51490. }
  51491. declare module "babylonjs/Cameras/universalCamera" {
  51492. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  51493. import { Scene } from "babylonjs/scene";
  51494. import { Vector3 } from "babylonjs/Maths/math.vector";
  51495. import "babylonjs/Gamepads/gamepadSceneComponent";
  51496. /**
  51497. * 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,
  51498. * which still works and will still be found in many Playgrounds.
  51499. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51500. */
  51501. export class UniversalCamera extends TouchCamera {
  51502. /**
  51503. * Defines the gamepad rotation sensiblity.
  51504. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51505. */
  51506. get gamepadAngularSensibility(): number;
  51507. set gamepadAngularSensibility(value: number);
  51508. /**
  51509. * Defines the gamepad move sensiblity.
  51510. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51511. */
  51512. get gamepadMoveSensibility(): number;
  51513. set gamepadMoveSensibility(value: number);
  51514. /**
  51515. * 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,
  51516. * which still works and will still be found in many Playgrounds.
  51517. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51518. * @param name Define the name of the camera in the scene
  51519. * @param position Define the start position of the camera in the scene
  51520. * @param scene Define the scene the camera belongs to
  51521. */
  51522. constructor(name: string, position: Vector3, scene: Scene);
  51523. /**
  51524. * Gets the current object class name.
  51525. * @return the class name
  51526. */
  51527. getClassName(): string;
  51528. }
  51529. }
  51530. declare module "babylonjs/Cameras/gamepadCamera" {
  51531. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51532. import { Scene } from "babylonjs/scene";
  51533. import { Vector3 } from "babylonjs/Maths/math.vector";
  51534. /**
  51535. * This represents a FPS type of camera. This is only here for back compat purpose.
  51536. * Please use the UniversalCamera instead as both are identical.
  51537. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51538. */
  51539. export class GamepadCamera extends UniversalCamera {
  51540. /**
  51541. * Instantiates a new Gamepad Camera
  51542. * This represents a FPS type of camera. This is only here for back compat purpose.
  51543. * Please use the UniversalCamera instead as both are identical.
  51544. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51545. * @param name Define the name of the camera in the scene
  51546. * @param position Define the start position of the camera in the scene
  51547. * @param scene Define the scene the camera belongs to
  51548. */
  51549. constructor(name: string, position: Vector3, scene: Scene);
  51550. /**
  51551. * Gets the current object class name.
  51552. * @return the class name
  51553. */
  51554. getClassName(): string;
  51555. }
  51556. }
  51557. declare module "babylonjs/Shaders/pass.fragment" {
  51558. /** @hidden */
  51559. export var passPixelShader: {
  51560. name: string;
  51561. shader: string;
  51562. };
  51563. }
  51564. declare module "babylonjs/Shaders/passCube.fragment" {
  51565. /** @hidden */
  51566. export var passCubePixelShader: {
  51567. name: string;
  51568. shader: string;
  51569. };
  51570. }
  51571. declare module "babylonjs/PostProcesses/passPostProcess" {
  51572. import { Nullable } from "babylonjs/types";
  51573. import { Camera } from "babylonjs/Cameras/camera";
  51574. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51575. import { Engine } from "babylonjs/Engines/engine";
  51576. import "babylonjs/Shaders/pass.fragment";
  51577. import "babylonjs/Shaders/passCube.fragment";
  51578. import { Scene } from "babylonjs/scene";
  51579. /**
  51580. * PassPostProcess which produces an output the same as it's input
  51581. */
  51582. export class PassPostProcess extends PostProcess {
  51583. /**
  51584. * Gets a string identifying the name of the class
  51585. * @returns "PassPostProcess" string
  51586. */
  51587. getClassName(): string;
  51588. /**
  51589. * Creates the PassPostProcess
  51590. * @param name The name of the effect.
  51591. * @param options The required width/height ratio to downsize to before computing the render pass.
  51592. * @param camera The camera to apply the render pass to.
  51593. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51594. * @param engine The engine which the post process will be applied. (default: current engine)
  51595. * @param reusable If the post process can be reused on the same frame. (default: false)
  51596. * @param textureType The type of texture to be used when performing the post processing.
  51597. * @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)
  51598. */
  51599. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51600. /** @hidden */
  51601. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  51602. }
  51603. /**
  51604. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  51605. */
  51606. export class PassCubePostProcess extends PostProcess {
  51607. private _face;
  51608. /**
  51609. * Gets or sets the cube face to display.
  51610. * * 0 is +X
  51611. * * 1 is -X
  51612. * * 2 is +Y
  51613. * * 3 is -Y
  51614. * * 4 is +Z
  51615. * * 5 is -Z
  51616. */
  51617. get face(): number;
  51618. set face(value: number);
  51619. /**
  51620. * Gets a string identifying the name of the class
  51621. * @returns "PassCubePostProcess" string
  51622. */
  51623. getClassName(): string;
  51624. /**
  51625. * Creates the PassCubePostProcess
  51626. * @param name The name of the effect.
  51627. * @param options The required width/height ratio to downsize to before computing the render pass.
  51628. * @param camera The camera to apply the render pass to.
  51629. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51630. * @param engine The engine which the post process will be applied. (default: current engine)
  51631. * @param reusable If the post process can be reused on the same frame. (default: false)
  51632. * @param textureType The type of texture to be used when performing the post processing.
  51633. * @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)
  51634. */
  51635. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51636. /** @hidden */
  51637. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  51638. }
  51639. }
  51640. declare module "babylonjs/Shaders/anaglyph.fragment" {
  51641. /** @hidden */
  51642. export var anaglyphPixelShader: {
  51643. name: string;
  51644. shader: string;
  51645. };
  51646. }
  51647. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  51648. import { Engine } from "babylonjs/Engines/engine";
  51649. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51650. import { Camera } from "babylonjs/Cameras/camera";
  51651. import "babylonjs/Shaders/anaglyph.fragment";
  51652. /**
  51653. * Postprocess used to generate anaglyphic rendering
  51654. */
  51655. export class AnaglyphPostProcess extends PostProcess {
  51656. private _passedProcess;
  51657. /**
  51658. * Gets a string identifying the name of the class
  51659. * @returns "AnaglyphPostProcess" string
  51660. */
  51661. getClassName(): string;
  51662. /**
  51663. * Creates a new AnaglyphPostProcess
  51664. * @param name defines postprocess name
  51665. * @param options defines creation options or target ratio scale
  51666. * @param rigCameras defines cameras using this postprocess
  51667. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  51668. * @param engine defines hosting engine
  51669. * @param reusable defines if the postprocess will be reused multiple times per frame
  51670. */
  51671. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  51672. }
  51673. }
  51674. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  51675. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  51676. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51677. import { Scene } from "babylonjs/scene";
  51678. import { Vector3 } from "babylonjs/Maths/math.vector";
  51679. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51680. /**
  51681. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  51682. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51683. */
  51684. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  51685. /**
  51686. * Creates a new AnaglyphArcRotateCamera
  51687. * @param name defines camera name
  51688. * @param alpha defines alpha angle (in radians)
  51689. * @param beta defines beta angle (in radians)
  51690. * @param radius defines radius
  51691. * @param target defines camera target
  51692. * @param interaxialDistance defines distance between each color axis
  51693. * @param scene defines the hosting scene
  51694. */
  51695. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  51696. /**
  51697. * Gets camera class name
  51698. * @returns AnaglyphArcRotateCamera
  51699. */
  51700. getClassName(): string;
  51701. }
  51702. }
  51703. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  51704. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51705. import { Scene } from "babylonjs/scene";
  51706. import { Vector3 } from "babylonjs/Maths/math.vector";
  51707. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51708. /**
  51709. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  51710. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51711. */
  51712. export class AnaglyphFreeCamera extends FreeCamera {
  51713. /**
  51714. * Creates a new AnaglyphFreeCamera
  51715. * @param name defines camera name
  51716. * @param position defines initial position
  51717. * @param interaxialDistance defines distance between each color axis
  51718. * @param scene defines the hosting scene
  51719. */
  51720. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51721. /**
  51722. * Gets camera class name
  51723. * @returns AnaglyphFreeCamera
  51724. */
  51725. getClassName(): string;
  51726. }
  51727. }
  51728. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  51729. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51730. import { Scene } from "babylonjs/scene";
  51731. import { Vector3 } from "babylonjs/Maths/math.vector";
  51732. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51733. /**
  51734. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  51735. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51736. */
  51737. export class AnaglyphGamepadCamera extends GamepadCamera {
  51738. /**
  51739. * Creates a new AnaglyphGamepadCamera
  51740. * @param name defines camera name
  51741. * @param position defines initial position
  51742. * @param interaxialDistance defines distance between each color axis
  51743. * @param scene defines the hosting scene
  51744. */
  51745. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51746. /**
  51747. * Gets camera class name
  51748. * @returns AnaglyphGamepadCamera
  51749. */
  51750. getClassName(): string;
  51751. }
  51752. }
  51753. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  51754. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51755. import { Scene } from "babylonjs/scene";
  51756. import { Vector3 } from "babylonjs/Maths/math.vector";
  51757. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51758. /**
  51759. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  51760. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51761. */
  51762. export class AnaglyphUniversalCamera extends UniversalCamera {
  51763. /**
  51764. * Creates a new AnaglyphUniversalCamera
  51765. * @param name defines camera name
  51766. * @param position defines initial position
  51767. * @param interaxialDistance defines distance between each color axis
  51768. * @param scene defines the hosting scene
  51769. */
  51770. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51771. /**
  51772. * Gets camera class name
  51773. * @returns AnaglyphUniversalCamera
  51774. */
  51775. getClassName(): string;
  51776. }
  51777. }
  51778. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  51779. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  51780. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51781. import { Scene } from "babylonjs/scene";
  51782. import { Vector3 } from "babylonjs/Maths/math.vector";
  51783. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51784. /**
  51785. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  51786. * @see https://doc.babylonjs.com/features/cameras
  51787. */
  51788. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  51789. /**
  51790. * Creates a new StereoscopicArcRotateCamera
  51791. * @param name defines camera name
  51792. * @param alpha defines alpha angle (in radians)
  51793. * @param beta defines beta angle (in radians)
  51794. * @param radius defines radius
  51795. * @param target defines camera target
  51796. * @param interaxialDistance defines distance between each color axis
  51797. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51798. * @param scene defines the hosting scene
  51799. */
  51800. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51801. /**
  51802. * Gets camera class name
  51803. * @returns StereoscopicArcRotateCamera
  51804. */
  51805. getClassName(): string;
  51806. }
  51807. }
  51808. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  51809. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51810. import { Scene } from "babylonjs/scene";
  51811. import { Vector3 } from "babylonjs/Maths/math.vector";
  51812. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51813. /**
  51814. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  51815. * @see https://doc.babylonjs.com/features/cameras
  51816. */
  51817. export class StereoscopicFreeCamera extends FreeCamera {
  51818. /**
  51819. * Creates a new StereoscopicFreeCamera
  51820. * @param name defines camera name
  51821. * @param position defines initial position
  51822. * @param interaxialDistance defines distance between each color axis
  51823. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51824. * @param scene defines the hosting scene
  51825. */
  51826. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51827. /**
  51828. * Gets camera class name
  51829. * @returns StereoscopicFreeCamera
  51830. */
  51831. getClassName(): string;
  51832. }
  51833. }
  51834. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  51835. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51836. import { Scene } from "babylonjs/scene";
  51837. import { Vector3 } from "babylonjs/Maths/math.vector";
  51838. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51839. /**
  51840. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  51841. * @see https://doc.babylonjs.com/features/cameras
  51842. */
  51843. export class StereoscopicGamepadCamera extends GamepadCamera {
  51844. /**
  51845. * Creates a new StereoscopicGamepadCamera
  51846. * @param name defines camera name
  51847. * @param position defines initial position
  51848. * @param interaxialDistance defines distance between each color axis
  51849. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51850. * @param scene defines the hosting scene
  51851. */
  51852. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51853. /**
  51854. * Gets camera class name
  51855. * @returns StereoscopicGamepadCamera
  51856. */
  51857. getClassName(): string;
  51858. }
  51859. }
  51860. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  51861. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51862. import { Scene } from "babylonjs/scene";
  51863. import { Vector3 } from "babylonjs/Maths/math.vector";
  51864. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51865. /**
  51866. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  51867. * @see https://doc.babylonjs.com/features/cameras
  51868. */
  51869. export class StereoscopicUniversalCamera extends UniversalCamera {
  51870. /**
  51871. * Creates a new StereoscopicUniversalCamera
  51872. * @param name defines camera name
  51873. * @param position defines initial position
  51874. * @param interaxialDistance defines distance between each color axis
  51875. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51876. * @param scene defines the hosting scene
  51877. */
  51878. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51879. /**
  51880. * Gets camera class name
  51881. * @returns StereoscopicUniversalCamera
  51882. */
  51883. getClassName(): string;
  51884. }
  51885. }
  51886. declare module "babylonjs/Cameras/Stereoscopic/index" {
  51887. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  51888. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  51889. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  51890. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  51891. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  51892. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  51893. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  51894. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  51895. }
  51896. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  51897. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51898. import { Scene } from "babylonjs/scene";
  51899. import { Vector3 } from "babylonjs/Maths/math.vector";
  51900. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  51901. /**
  51902. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  51903. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51904. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51905. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51906. */
  51907. export class VirtualJoysticksCamera extends FreeCamera {
  51908. /**
  51909. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  51910. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51911. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51912. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51913. * @param name Define the name of the camera in the scene
  51914. * @param position Define the start position of the camera in the scene
  51915. * @param scene Define the scene the camera belongs to
  51916. */
  51917. constructor(name: string, position: Vector3, scene: Scene);
  51918. /**
  51919. * Gets the current object class name.
  51920. * @return the class name
  51921. */
  51922. getClassName(): string;
  51923. }
  51924. }
  51925. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  51926. import { Matrix } from "babylonjs/Maths/math.vector";
  51927. /**
  51928. * This represents all the required metrics to create a VR camera.
  51929. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  51930. */
  51931. export class VRCameraMetrics {
  51932. /**
  51933. * Define the horizontal resolution off the screen.
  51934. */
  51935. hResolution: number;
  51936. /**
  51937. * Define the vertical resolution off the screen.
  51938. */
  51939. vResolution: number;
  51940. /**
  51941. * Define the horizontal screen size.
  51942. */
  51943. hScreenSize: number;
  51944. /**
  51945. * Define the vertical screen size.
  51946. */
  51947. vScreenSize: number;
  51948. /**
  51949. * Define the vertical screen center position.
  51950. */
  51951. vScreenCenter: number;
  51952. /**
  51953. * Define the distance of the eyes to the screen.
  51954. */
  51955. eyeToScreenDistance: number;
  51956. /**
  51957. * Define the distance between both lenses
  51958. */
  51959. lensSeparationDistance: number;
  51960. /**
  51961. * Define the distance between both viewer's eyes.
  51962. */
  51963. interpupillaryDistance: number;
  51964. /**
  51965. * Define the distortion factor of the VR postprocess.
  51966. * Please, touch with care.
  51967. */
  51968. distortionK: number[];
  51969. /**
  51970. * Define the chromatic aberration correction factors for the VR post process.
  51971. */
  51972. chromaAbCorrection: number[];
  51973. /**
  51974. * Define the scale factor of the post process.
  51975. * The smaller the better but the slower.
  51976. */
  51977. postProcessScaleFactor: number;
  51978. /**
  51979. * Define an offset for the lens center.
  51980. */
  51981. lensCenterOffset: number;
  51982. /**
  51983. * Define if the current vr camera should compensate the distortion of the lense or not.
  51984. */
  51985. compensateDistortion: boolean;
  51986. /**
  51987. * Defines if multiview should be enabled when rendering (Default: false)
  51988. */
  51989. multiviewEnabled: boolean;
  51990. /**
  51991. * Gets the rendering aspect ratio based on the provided resolutions.
  51992. */
  51993. get aspectRatio(): number;
  51994. /**
  51995. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  51996. */
  51997. get aspectRatioFov(): number;
  51998. /**
  51999. * @hidden
  52000. */
  52001. get leftHMatrix(): Matrix;
  52002. /**
  52003. * @hidden
  52004. */
  52005. get rightHMatrix(): Matrix;
  52006. /**
  52007. * @hidden
  52008. */
  52009. get leftPreViewMatrix(): Matrix;
  52010. /**
  52011. * @hidden
  52012. */
  52013. get rightPreViewMatrix(): Matrix;
  52014. /**
  52015. * Get the default VRMetrics based on the most generic setup.
  52016. * @returns the default vr metrics
  52017. */
  52018. static GetDefault(): VRCameraMetrics;
  52019. }
  52020. }
  52021. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  52022. /** @hidden */
  52023. export var vrDistortionCorrectionPixelShader: {
  52024. name: string;
  52025. shader: string;
  52026. };
  52027. }
  52028. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  52029. import { Camera } from "babylonjs/Cameras/camera";
  52030. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52031. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52032. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  52033. /**
  52034. * VRDistortionCorrectionPostProcess used for mobile VR
  52035. */
  52036. export class VRDistortionCorrectionPostProcess extends PostProcess {
  52037. private _isRightEye;
  52038. private _distortionFactors;
  52039. private _postProcessScaleFactor;
  52040. private _lensCenterOffset;
  52041. private _scaleIn;
  52042. private _scaleFactor;
  52043. private _lensCenter;
  52044. /**
  52045. * Gets a string identifying the name of the class
  52046. * @returns "VRDistortionCorrectionPostProcess" string
  52047. */
  52048. getClassName(): string;
  52049. /**
  52050. * Initializes the VRDistortionCorrectionPostProcess
  52051. * @param name The name of the effect.
  52052. * @param camera The camera to apply the render pass to.
  52053. * @param isRightEye If this is for the right eye distortion
  52054. * @param vrMetrics All the required metrics for the VR camera
  52055. */
  52056. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  52057. }
  52058. }
  52059. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  52060. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  52061. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  52062. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52063. import { Scene } from "babylonjs/scene";
  52064. import { Vector3 } from "babylonjs/Maths/math.vector";
  52065. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  52066. import "babylonjs/Cameras/RigModes/vrRigMode";
  52067. /**
  52068. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  52069. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52070. */
  52071. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  52072. /**
  52073. * Creates a new VRDeviceOrientationArcRotateCamera
  52074. * @param name defines camera name
  52075. * @param alpha defines the camera rotation along the logitudinal axis
  52076. * @param beta defines the camera rotation along the latitudinal axis
  52077. * @param radius defines the camera distance from its target
  52078. * @param target defines the camera target
  52079. * @param scene defines the scene the camera belongs to
  52080. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52081. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52082. */
  52083. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52084. /**
  52085. * Gets camera class name
  52086. * @returns VRDeviceOrientationArcRotateCamera
  52087. */
  52088. getClassName(): string;
  52089. }
  52090. }
  52091. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  52092. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  52093. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52094. import { Scene } from "babylonjs/scene";
  52095. import { Vector3 } from "babylonjs/Maths/math.vector";
  52096. import "babylonjs/Cameras/RigModes/vrRigMode";
  52097. /**
  52098. * Camera used to simulate VR rendering (based on FreeCamera)
  52099. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52100. */
  52101. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  52102. /**
  52103. * Creates a new VRDeviceOrientationFreeCamera
  52104. * @param name defines camera name
  52105. * @param position defines the start position of the camera
  52106. * @param scene defines the scene the camera belongs to
  52107. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52108. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52109. */
  52110. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52111. /**
  52112. * Gets camera class name
  52113. * @returns VRDeviceOrientationFreeCamera
  52114. */
  52115. getClassName(): string;
  52116. }
  52117. }
  52118. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  52119. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  52120. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52121. import { Scene } from "babylonjs/scene";
  52122. import { Vector3 } from "babylonjs/Maths/math.vector";
  52123. import "babylonjs/Gamepads/gamepadSceneComponent";
  52124. /**
  52125. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  52126. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52127. */
  52128. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  52129. /**
  52130. * Creates a new VRDeviceOrientationGamepadCamera
  52131. * @param name defines camera name
  52132. * @param position defines the start position of the camera
  52133. * @param scene defines the scene the camera belongs to
  52134. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52135. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52136. */
  52137. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52138. /**
  52139. * Gets camera class name
  52140. * @returns VRDeviceOrientationGamepadCamera
  52141. */
  52142. getClassName(): string;
  52143. }
  52144. }
  52145. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  52146. import { Scene } from "babylonjs/scene";
  52147. import { Texture } from "babylonjs/Materials/Textures/texture";
  52148. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  52149. /**
  52150. * A class extending Texture allowing drawing on a texture
  52151. * @see https://doc.babylonjs.com/how_to/dynamictexture
  52152. */
  52153. export class DynamicTexture extends Texture {
  52154. private _generateMipMaps;
  52155. private _canvas;
  52156. private _context;
  52157. /**
  52158. * Creates a DynamicTexture
  52159. * @param name defines the name of the texture
  52160. * @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
  52161. * @param scene defines the scene where you want the texture
  52162. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  52163. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52164. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  52165. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  52166. */
  52167. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  52168. /**
  52169. * Get the current class name of the texture useful for serialization or dynamic coding.
  52170. * @returns "DynamicTexture"
  52171. */
  52172. getClassName(): string;
  52173. /**
  52174. * Gets the current state of canRescale
  52175. */
  52176. get canRescale(): boolean;
  52177. private _recreate;
  52178. /**
  52179. * Scales the texture
  52180. * @param ratio the scale factor to apply to both width and height
  52181. */
  52182. scale(ratio: number): void;
  52183. /**
  52184. * Resizes the texture
  52185. * @param width the new width
  52186. * @param height the new height
  52187. */
  52188. scaleTo(width: number, height: number): void;
  52189. /**
  52190. * Gets the context of the canvas used by the texture
  52191. * @returns the canvas context of the dynamic texture
  52192. */
  52193. getContext(): CanvasRenderingContext2D;
  52194. /**
  52195. * Clears the texture
  52196. */
  52197. clear(): void;
  52198. /**
  52199. * Updates the texture
  52200. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  52201. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  52202. */
  52203. update(invertY?: boolean, premulAlpha?: boolean): void;
  52204. /**
  52205. * Draws text onto the texture
  52206. * @param text defines the text to be drawn
  52207. * @param x defines the placement of the text from the left
  52208. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  52209. * @param font defines the font to be used with font-style, font-size, font-name
  52210. * @param color defines the color used for the text
  52211. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  52212. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  52213. * @param update defines whether texture is immediately update (default is true)
  52214. */
  52215. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  52216. /**
  52217. * Clones the texture
  52218. * @returns the clone of the texture.
  52219. */
  52220. clone(): DynamicTexture;
  52221. /**
  52222. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  52223. * @returns a serialized dynamic texture object
  52224. */
  52225. serialize(): any;
  52226. private _IsCanvasElement;
  52227. /** @hidden */
  52228. _rebuild(): void;
  52229. }
  52230. }
  52231. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  52232. import { Scene } from "babylonjs/scene";
  52233. import { Color3 } from "babylonjs/Maths/math.color";
  52234. import { Mesh } from "babylonjs/Meshes/mesh";
  52235. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52236. import { Nullable } from "babylonjs/types";
  52237. /**
  52238. * Class containing static functions to help procedurally build meshes
  52239. */
  52240. export class GroundBuilder {
  52241. /**
  52242. * Creates a ground mesh
  52243. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52244. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52246. * @param name defines the name of the mesh
  52247. * @param options defines the options used to create the mesh
  52248. * @param scene defines the hosting scene
  52249. * @returns the ground mesh
  52250. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52251. */
  52252. static CreateGround(name: string, options: {
  52253. width?: number;
  52254. height?: number;
  52255. subdivisions?: number;
  52256. subdivisionsX?: number;
  52257. subdivisionsY?: number;
  52258. updatable?: boolean;
  52259. }, scene: any): Mesh;
  52260. /**
  52261. * Creates a tiled ground mesh
  52262. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52263. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52264. * * 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
  52265. * * 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
  52266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52267. * @param name defines the name of the mesh
  52268. * @param options defines the options used to create the mesh
  52269. * @param scene defines the hosting scene
  52270. * @returns the tiled ground mesh
  52271. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52272. */
  52273. static CreateTiledGround(name: string, options: {
  52274. xmin: number;
  52275. zmin: number;
  52276. xmax: number;
  52277. zmax: number;
  52278. subdivisions?: {
  52279. w: number;
  52280. h: number;
  52281. };
  52282. precision?: {
  52283. w: number;
  52284. h: number;
  52285. };
  52286. updatable?: boolean;
  52287. }, scene?: Nullable<Scene>): Mesh;
  52288. /**
  52289. * Creates a ground mesh from a height map
  52290. * * The parameter `url` sets the URL of the height map image resource.
  52291. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52292. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52293. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52294. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52295. * * 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.
  52296. * * 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).
  52297. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52299. * @param name defines the name of the mesh
  52300. * @param url defines the url to the height map
  52301. * @param options defines the options used to create the mesh
  52302. * @param scene defines the hosting scene
  52303. * @returns the ground mesh
  52304. * @see https://doc.babylonjs.com/babylon101/height_map
  52305. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52306. */
  52307. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52308. width?: number;
  52309. height?: number;
  52310. subdivisions?: number;
  52311. minHeight?: number;
  52312. maxHeight?: number;
  52313. colorFilter?: Color3;
  52314. alphaFilter?: number;
  52315. updatable?: boolean;
  52316. onReady?: (mesh: GroundMesh) => void;
  52317. }, scene?: Nullable<Scene>): GroundMesh;
  52318. }
  52319. }
  52320. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  52321. import { Vector4 } from "babylonjs/Maths/math.vector";
  52322. import { Mesh } from "babylonjs/Meshes/mesh";
  52323. /**
  52324. * Class containing static functions to help procedurally build meshes
  52325. */
  52326. export class TorusBuilder {
  52327. /**
  52328. * Creates a torus mesh
  52329. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52330. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52331. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52333. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52335. * @param name defines the name of the mesh
  52336. * @param options defines the options used to create the mesh
  52337. * @param scene defines the hosting scene
  52338. * @returns the torus mesh
  52339. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52340. */
  52341. static CreateTorus(name: string, options: {
  52342. diameter?: number;
  52343. thickness?: number;
  52344. tessellation?: number;
  52345. updatable?: boolean;
  52346. sideOrientation?: number;
  52347. frontUVs?: Vector4;
  52348. backUVs?: Vector4;
  52349. }, scene: any): Mesh;
  52350. }
  52351. }
  52352. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  52353. import { Vector4 } from "babylonjs/Maths/math.vector";
  52354. import { Color4 } from "babylonjs/Maths/math.color";
  52355. import { Mesh } from "babylonjs/Meshes/mesh";
  52356. /**
  52357. * Class containing static functions to help procedurally build meshes
  52358. */
  52359. export class CylinderBuilder {
  52360. /**
  52361. * Creates a cylinder or a cone mesh
  52362. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52363. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52364. * * 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.
  52365. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52366. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52367. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52368. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52369. * * 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).
  52370. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52371. * * 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).
  52372. * * 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
  52373. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52374. * * 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
  52375. * * 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.
  52376. * * If `enclose` is false, a ring surface is one element.
  52377. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52378. * * 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
  52379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52380. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52382. * @param name defines the name of the mesh
  52383. * @param options defines the options used to create the mesh
  52384. * @param scene defines the hosting scene
  52385. * @returns the cylinder mesh
  52386. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52387. */
  52388. static CreateCylinder(name: string, options: {
  52389. height?: number;
  52390. diameterTop?: number;
  52391. diameterBottom?: number;
  52392. diameter?: number;
  52393. tessellation?: number;
  52394. subdivisions?: number;
  52395. arc?: number;
  52396. faceColors?: Color4[];
  52397. faceUV?: Vector4[];
  52398. updatable?: boolean;
  52399. hasRings?: boolean;
  52400. enclose?: boolean;
  52401. cap?: number;
  52402. sideOrientation?: number;
  52403. frontUVs?: Vector4;
  52404. backUVs?: Vector4;
  52405. }, scene: any): Mesh;
  52406. }
  52407. }
  52408. declare module "babylonjs/XR/webXRTypes" {
  52409. import { Nullable } from "babylonjs/types";
  52410. import { IDisposable } from "babylonjs/scene";
  52411. /**
  52412. * States of the webXR experience
  52413. */
  52414. export enum WebXRState {
  52415. /**
  52416. * Transitioning to being in XR mode
  52417. */
  52418. ENTERING_XR = 0,
  52419. /**
  52420. * Transitioning to non XR mode
  52421. */
  52422. EXITING_XR = 1,
  52423. /**
  52424. * In XR mode and presenting
  52425. */
  52426. IN_XR = 2,
  52427. /**
  52428. * Not entered XR mode
  52429. */
  52430. NOT_IN_XR = 3
  52431. }
  52432. /**
  52433. * The state of the XR camera's tracking
  52434. */
  52435. export enum WebXRTrackingState {
  52436. /**
  52437. * No transformation received, device is not being tracked
  52438. */
  52439. NOT_TRACKING = 0,
  52440. /**
  52441. * Tracking lost - using emulated position
  52442. */
  52443. TRACKING_LOST = 1,
  52444. /**
  52445. * Transformation tracking works normally
  52446. */
  52447. TRACKING = 2
  52448. }
  52449. /**
  52450. * Abstraction of the XR render target
  52451. */
  52452. export interface WebXRRenderTarget extends IDisposable {
  52453. /**
  52454. * xrpresent context of the canvas which can be used to display/mirror xr content
  52455. */
  52456. canvasContext: WebGLRenderingContext;
  52457. /**
  52458. * xr layer for the canvas
  52459. */
  52460. xrLayer: Nullable<XRWebGLLayer>;
  52461. /**
  52462. * Initializes the xr layer for the session
  52463. * @param xrSession xr session
  52464. * @returns a promise that will resolve once the XR Layer has been created
  52465. */
  52466. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  52467. }
  52468. }
  52469. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  52470. import { Nullable } from "babylonjs/types";
  52471. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  52472. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52473. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52474. import { Observable } from "babylonjs/Misc/observable";
  52475. /**
  52476. * COnfiguration object for WebXR output canvas
  52477. */
  52478. export class WebXRManagedOutputCanvasOptions {
  52479. /**
  52480. * An optional canvas in case you wish to create it yourself and provide it here.
  52481. * If not provided, a new canvas will be created
  52482. */
  52483. canvasElement?: HTMLCanvasElement;
  52484. /**
  52485. * Options for this XR Layer output
  52486. */
  52487. canvasOptions?: XRWebGLLayerInit;
  52488. /**
  52489. * CSS styling for a newly created canvas (if not provided)
  52490. */
  52491. newCanvasCssStyle?: string;
  52492. /**
  52493. * Get the default values of the configuration object
  52494. * @param engine defines the engine to use (can be null)
  52495. * @returns default values of this configuration object
  52496. */
  52497. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  52498. }
  52499. /**
  52500. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  52501. */
  52502. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  52503. private _options;
  52504. private _canvas;
  52505. private _engine;
  52506. private _originalCanvasSize;
  52507. /**
  52508. * Rendering context of the canvas which can be used to display/mirror xr content
  52509. */
  52510. canvasContext: WebGLRenderingContext;
  52511. /**
  52512. * xr layer for the canvas
  52513. */
  52514. xrLayer: Nullable<XRWebGLLayer>;
  52515. /**
  52516. * Obseervers registered here will be triggered when the xr layer was initialized
  52517. */
  52518. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  52519. /**
  52520. * Initializes the canvas to be added/removed upon entering/exiting xr
  52521. * @param _xrSessionManager The XR Session manager
  52522. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  52523. */
  52524. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  52525. /**
  52526. * Disposes of the object
  52527. */
  52528. dispose(): void;
  52529. /**
  52530. * Initializes the xr layer for the session
  52531. * @param xrSession xr session
  52532. * @returns a promise that will resolve once the XR Layer has been created
  52533. */
  52534. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  52535. private _addCanvas;
  52536. private _removeCanvas;
  52537. private _setCanvasSize;
  52538. private _setManagedOutputCanvas;
  52539. }
  52540. }
  52541. declare module "babylonjs/XR/webXRSessionManager" {
  52542. import { Observable } from "babylonjs/Misc/observable";
  52543. import { Nullable } from "babylonjs/types";
  52544. import { IDisposable, Scene } from "babylonjs/scene";
  52545. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52546. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52547. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  52548. /**
  52549. * Manages an XRSession to work with Babylon's engine
  52550. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  52551. */
  52552. export class WebXRSessionManager implements IDisposable {
  52553. /** The scene which the session should be created for */
  52554. scene: Scene;
  52555. private _referenceSpace;
  52556. private _rttProvider;
  52557. private _sessionEnded;
  52558. private _xrNavigator;
  52559. private baseLayer;
  52560. /**
  52561. * The base reference space from which the session started. good if you want to reset your
  52562. * reference space
  52563. */
  52564. baseReferenceSpace: XRReferenceSpace;
  52565. /**
  52566. * Current XR frame
  52567. */
  52568. currentFrame: Nullable<XRFrame>;
  52569. /** WebXR timestamp updated every frame */
  52570. currentTimestamp: number;
  52571. /**
  52572. * Used just in case of a failure to initialize an immersive session.
  52573. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  52574. */
  52575. defaultHeightCompensation: number;
  52576. /**
  52577. * Fires every time a new xrFrame arrives which can be used to update the camera
  52578. */
  52579. onXRFrameObservable: Observable<XRFrame>;
  52580. /**
  52581. * Fires when the reference space changed
  52582. */
  52583. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  52584. /**
  52585. * Fires when the xr session is ended either by the device or manually done
  52586. */
  52587. onXRSessionEnded: Observable<any>;
  52588. /**
  52589. * Fires when the xr session is ended either by the device or manually done
  52590. */
  52591. onXRSessionInit: Observable<XRSession>;
  52592. /**
  52593. * Underlying xr session
  52594. */
  52595. session: XRSession;
  52596. /**
  52597. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  52598. * or get the offset the player is currently at.
  52599. */
  52600. viewerReferenceSpace: XRReferenceSpace;
  52601. /**
  52602. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  52603. * @param scene The scene which the session should be created for
  52604. */
  52605. constructor(
  52606. /** The scene which the session should be created for */
  52607. scene: Scene);
  52608. /**
  52609. * The current reference space used in this session. This reference space can constantly change!
  52610. * It is mainly used to offset the camera's position.
  52611. */
  52612. get referenceSpace(): XRReferenceSpace;
  52613. /**
  52614. * Set a new reference space and triggers the observable
  52615. */
  52616. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  52617. /**
  52618. * Disposes of the session manager
  52619. */
  52620. dispose(): void;
  52621. /**
  52622. * Stops the xrSession and restores the render loop
  52623. * @returns Promise which resolves after it exits XR
  52624. */
  52625. exitXRAsync(): Promise<void>;
  52626. /**
  52627. * Gets the correct render target texture to be rendered this frame for this eye
  52628. * @param eye the eye for which to get the render target
  52629. * @returns the render target for the specified eye
  52630. */
  52631. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  52632. /**
  52633. * Creates a WebXRRenderTarget object for the XR session
  52634. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  52635. * @param options optional options to provide when creating a new render target
  52636. * @returns a WebXR render target to which the session can render
  52637. */
  52638. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  52639. /**
  52640. * Initializes the manager
  52641. * After initialization enterXR can be called to start an XR session
  52642. * @returns Promise which resolves after it is initialized
  52643. */
  52644. initializeAsync(): Promise<void>;
  52645. /**
  52646. * Initializes an xr session
  52647. * @param xrSessionMode mode to initialize
  52648. * @param xrSessionInit defines optional and required values to pass to the session builder
  52649. * @returns a promise which will resolve once the session has been initialized
  52650. */
  52651. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  52652. /**
  52653. * Checks if a session would be supported for the creation options specified
  52654. * @param sessionMode session mode to check if supported eg. immersive-vr
  52655. * @returns A Promise that resolves to true if supported and false if not
  52656. */
  52657. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52658. /**
  52659. * Resets the reference space to the one started the session
  52660. */
  52661. resetReferenceSpace(): void;
  52662. /**
  52663. * Starts rendering to the xr layer
  52664. */
  52665. runXRRenderLoop(): void;
  52666. /**
  52667. * Sets the reference space on the xr session
  52668. * @param referenceSpaceType space to set
  52669. * @returns a promise that will resolve once the reference space has been set
  52670. */
  52671. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  52672. /**
  52673. * Updates the render state of the session
  52674. * @param state state to set
  52675. * @returns a promise that resolves once the render state has been updated
  52676. */
  52677. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  52678. /**
  52679. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  52680. * @param sessionMode defines the session to test
  52681. * @returns a promise with boolean as final value
  52682. */
  52683. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52684. private _createRenderTargetTexture;
  52685. }
  52686. }
  52687. declare module "babylonjs/XR/webXRCamera" {
  52688. import { Vector3 } from "babylonjs/Maths/math.vector";
  52689. import { Scene } from "babylonjs/scene";
  52690. import { Camera } from "babylonjs/Cameras/camera";
  52691. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  52692. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52693. import { Observable } from "babylonjs/Misc/observable";
  52694. import { WebXRTrackingState } from "babylonjs/XR/webXRTypes";
  52695. /**
  52696. * WebXR Camera which holds the views for the xrSession
  52697. * @see https://doc.babylonjs.com/how_to/webxr_camera
  52698. */
  52699. export class WebXRCamera extends FreeCamera {
  52700. private _xrSessionManager;
  52701. private _firstFrame;
  52702. private _referenceQuaternion;
  52703. private _referencedPosition;
  52704. private _xrInvPositionCache;
  52705. private _xrInvQuaternionCache;
  52706. private _trackingState;
  52707. /**
  52708. * Observable raised before camera teleportation
  52709. */
  52710. onBeforeCameraTeleport: Observable<Vector3>;
  52711. /**
  52712. * Observable raised after camera teleportation
  52713. */
  52714. onAfterCameraTeleport: Observable<Vector3>;
  52715. /**
  52716. * Notifies when the camera's tracking state has changed.
  52717. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  52718. */
  52719. onTrackingStateChanged: Observable<WebXRTrackingState>;
  52720. /**
  52721. * Should position compensation execute on first frame.
  52722. * This is used when copying the position from a native (non XR) camera
  52723. */
  52724. compensateOnFirstFrame: boolean;
  52725. /**
  52726. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  52727. * @param name the name of the camera
  52728. * @param scene the scene to add the camera to
  52729. * @param _xrSessionManager a constructed xr session manager
  52730. */
  52731. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  52732. /**
  52733. * Get the current XR tracking state of the camera
  52734. */
  52735. get trackingState(): WebXRTrackingState;
  52736. private _setTrackingState;
  52737. /**
  52738. * Return the user's height, unrelated to the current ground.
  52739. * This will be the y position of this camera, when ground level is 0.
  52740. */
  52741. get realWorldHeight(): number;
  52742. /** @hidden */
  52743. _updateForDualEyeDebugging(): void;
  52744. /**
  52745. * Sets this camera's transformation based on a non-vr camera
  52746. * @param otherCamera the non-vr camera to copy the transformation from
  52747. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  52748. */
  52749. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  52750. /**
  52751. * Gets the current instance class name ("WebXRCamera").
  52752. * @returns the class name
  52753. */
  52754. getClassName(): string;
  52755. private _rotate180;
  52756. private _updateFromXRSession;
  52757. private _updateNumberOfRigCameras;
  52758. private _updateReferenceSpace;
  52759. private _updateReferenceSpaceOffset;
  52760. }
  52761. }
  52762. declare module "babylonjs/XR/webXRFeaturesManager" {
  52763. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52764. import { IDisposable } from "babylonjs/scene";
  52765. /**
  52766. * Defining the interface required for a (webxr) feature
  52767. */
  52768. export interface IWebXRFeature extends IDisposable {
  52769. /**
  52770. * Is this feature attached
  52771. */
  52772. attached: boolean;
  52773. /**
  52774. * Should auto-attach be disabled?
  52775. */
  52776. disableAutoAttach: boolean;
  52777. /**
  52778. * Attach the feature to the session
  52779. * Will usually be called by the features manager
  52780. *
  52781. * @param force should attachment be forced (even when already attached)
  52782. * @returns true if successful.
  52783. */
  52784. attach(force?: boolean): boolean;
  52785. /**
  52786. * Detach the feature from the session
  52787. * Will usually be called by the features manager
  52788. *
  52789. * @returns true if successful.
  52790. */
  52791. detach(): boolean;
  52792. /**
  52793. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52794. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52795. *
  52796. * @returns whether or not the feature is compatible in this environment
  52797. */
  52798. isCompatible(): boolean;
  52799. /**
  52800. * Was this feature disposed;
  52801. */
  52802. isDisposed: boolean;
  52803. /**
  52804. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  52805. */
  52806. xrNativeFeatureName?: string;
  52807. /**
  52808. * A list of (Babylon WebXR) features this feature depends on
  52809. */
  52810. dependsOn?: string[];
  52811. }
  52812. /**
  52813. * A list of the currently available features without referencing them
  52814. */
  52815. export class WebXRFeatureName {
  52816. /**
  52817. * The name of the anchor system feature
  52818. */
  52819. static readonly ANCHOR_SYSTEM: string;
  52820. /**
  52821. * The name of the background remover feature
  52822. */
  52823. static readonly BACKGROUND_REMOVER: string;
  52824. /**
  52825. * The name of the hit test feature
  52826. */
  52827. static readonly HIT_TEST: string;
  52828. /**
  52829. * physics impostors for xr controllers feature
  52830. */
  52831. static readonly PHYSICS_CONTROLLERS: string;
  52832. /**
  52833. * The name of the plane detection feature
  52834. */
  52835. static readonly PLANE_DETECTION: string;
  52836. /**
  52837. * The name of the pointer selection feature
  52838. */
  52839. static readonly POINTER_SELECTION: string;
  52840. /**
  52841. * The name of the teleportation feature
  52842. */
  52843. static readonly TELEPORTATION: string;
  52844. /**
  52845. * The name of the feature points feature.
  52846. */
  52847. static readonly FEATURE_POINTS: string;
  52848. /**
  52849. * The name of the hand tracking feature.
  52850. */
  52851. static readonly HAND_TRACKING: string;
  52852. }
  52853. /**
  52854. * Defining the constructor of a feature. Used to register the modules.
  52855. */
  52856. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  52857. /**
  52858. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  52859. * It is mainly used in AR sessions.
  52860. *
  52861. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  52862. */
  52863. export class WebXRFeaturesManager implements IDisposable {
  52864. private _xrSessionManager;
  52865. private static readonly _AvailableFeatures;
  52866. private _features;
  52867. /**
  52868. * constructs a new features manages.
  52869. *
  52870. * @param _xrSessionManager an instance of WebXRSessionManager
  52871. */
  52872. constructor(_xrSessionManager: WebXRSessionManager);
  52873. /**
  52874. * Used to register a module. After calling this function a developer can use this feature in the scene.
  52875. * Mainly used internally.
  52876. *
  52877. * @param featureName the name of the feature to register
  52878. * @param constructorFunction the function used to construct the module
  52879. * @param version the (babylon) version of the module
  52880. * @param stable is that a stable version of this module
  52881. */
  52882. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  52883. /**
  52884. * Returns a constructor of a specific feature.
  52885. *
  52886. * @param featureName the name of the feature to construct
  52887. * @param version the version of the feature to load
  52888. * @param xrSessionManager the xrSessionManager. Used to construct the module
  52889. * @param options optional options provided to the module.
  52890. * @returns a function that, when called, will return a new instance of this feature
  52891. */
  52892. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  52893. /**
  52894. * Can be used to return the list of features currently registered
  52895. *
  52896. * @returns an Array of available features
  52897. */
  52898. static GetAvailableFeatures(): string[];
  52899. /**
  52900. * Gets the versions available for a specific feature
  52901. * @param featureName the name of the feature
  52902. * @returns an array with the available versions
  52903. */
  52904. static GetAvailableVersions(featureName: string): string[];
  52905. /**
  52906. * Return the latest unstable version of this feature
  52907. * @param featureName the name of the feature to search
  52908. * @returns the version number. if not found will return -1
  52909. */
  52910. static GetLatestVersionOfFeature(featureName: string): number;
  52911. /**
  52912. * Return the latest stable version of this feature
  52913. * @param featureName the name of the feature to search
  52914. * @returns the version number. if not found will return -1
  52915. */
  52916. static GetStableVersionOfFeature(featureName: string): number;
  52917. /**
  52918. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  52919. * Can be used during a session to start a feature
  52920. * @param featureName the name of feature to attach
  52921. */
  52922. attachFeature(featureName: string): void;
  52923. /**
  52924. * Can be used inside a session or when the session ends to detach a specific feature
  52925. * @param featureName the name of the feature to detach
  52926. */
  52927. detachFeature(featureName: string): void;
  52928. /**
  52929. * Used to disable an already-enabled feature
  52930. * The feature will be disposed and will be recreated once enabled.
  52931. * @param featureName the feature to disable
  52932. * @returns true if disable was successful
  52933. */
  52934. disableFeature(featureName: string | {
  52935. Name: string;
  52936. }): boolean;
  52937. /**
  52938. * dispose this features manager
  52939. */
  52940. dispose(): void;
  52941. /**
  52942. * 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.
  52943. * 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.
  52944. *
  52945. * @param featureName the name of the feature to load or the class of the feature
  52946. * @param version optional version to load. if not provided the latest version will be enabled
  52947. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  52948. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  52949. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  52950. * @returns a new constructed feature or throws an error if feature not found.
  52951. */
  52952. enableFeature(featureName: string | {
  52953. Name: string;
  52954. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  52955. /**
  52956. * get the implementation of an enabled feature.
  52957. * @param featureName the name of the feature to load
  52958. * @returns the feature class, if found
  52959. */
  52960. getEnabledFeature(featureName: string): IWebXRFeature;
  52961. /**
  52962. * Get the list of enabled features
  52963. * @returns an array of enabled features
  52964. */
  52965. getEnabledFeatures(): string[];
  52966. /**
  52967. * This function will exten the session creation configuration object with enabled features.
  52968. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  52969. * according to the defined "required" variable, provided during enableFeature call
  52970. * @param xrSessionInit the xr Session init object to extend
  52971. *
  52972. * @returns an extended XRSessionInit object
  52973. */
  52974. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  52975. }
  52976. }
  52977. declare module "babylonjs/XR/webXRExperienceHelper" {
  52978. import { Observable } from "babylonjs/Misc/observable";
  52979. import { IDisposable, Scene } from "babylonjs/scene";
  52980. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52981. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  52982. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52983. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  52984. /**
  52985. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  52986. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  52987. */
  52988. export class WebXRExperienceHelper implements IDisposable {
  52989. private scene;
  52990. private _nonVRCamera;
  52991. private _originalSceneAutoClear;
  52992. private _supported;
  52993. /**
  52994. * Camera used to render xr content
  52995. */
  52996. camera: WebXRCamera;
  52997. /** A features manager for this xr session */
  52998. featuresManager: WebXRFeaturesManager;
  52999. /**
  53000. * Observers registered here will be triggered after the camera's initial transformation is set
  53001. * This can be used to set a different ground level or an extra rotation.
  53002. *
  53003. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  53004. * to the position set after this observable is done executing.
  53005. */
  53006. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  53007. /**
  53008. * Fires when the state of the experience helper has changed
  53009. */
  53010. onStateChangedObservable: Observable<WebXRState>;
  53011. /** Session manager used to keep track of xr session */
  53012. sessionManager: WebXRSessionManager;
  53013. /**
  53014. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  53015. */
  53016. state: WebXRState;
  53017. /**
  53018. * Creates a WebXRExperienceHelper
  53019. * @param scene The scene the helper should be created in
  53020. */
  53021. private constructor();
  53022. /**
  53023. * Creates the experience helper
  53024. * @param scene the scene to attach the experience helper to
  53025. * @returns a promise for the experience helper
  53026. */
  53027. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  53028. /**
  53029. * Disposes of the experience helper
  53030. */
  53031. dispose(): void;
  53032. /**
  53033. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  53034. * @param sessionMode options for the XR session
  53035. * @param referenceSpaceType frame of reference of the XR session
  53036. * @param renderTarget the output canvas that will be used to enter XR mode
  53037. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  53038. * @returns promise that resolves after xr mode has entered
  53039. */
  53040. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  53041. /**
  53042. * Exits XR mode and returns the scene to its original state
  53043. * @returns promise that resolves after xr mode has exited
  53044. */
  53045. exitXRAsync(): Promise<void>;
  53046. private _nonXRToXRCamera;
  53047. private _setState;
  53048. }
  53049. }
  53050. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  53051. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53052. import { Observable } from "babylonjs/Misc/observable";
  53053. import { IDisposable } from "babylonjs/scene";
  53054. /**
  53055. * X-Y values for axes in WebXR
  53056. */
  53057. export interface IWebXRMotionControllerAxesValue {
  53058. /**
  53059. * The value of the x axis
  53060. */
  53061. x: number;
  53062. /**
  53063. * The value of the y-axis
  53064. */
  53065. y: number;
  53066. }
  53067. /**
  53068. * changed / previous values for the values of this component
  53069. */
  53070. export interface IWebXRMotionControllerComponentChangesValues<T> {
  53071. /**
  53072. * current (this frame) value
  53073. */
  53074. current: T;
  53075. /**
  53076. * previous (last change) value
  53077. */
  53078. previous: T;
  53079. }
  53080. /**
  53081. * Represents changes in the component between current frame and last values recorded
  53082. */
  53083. export interface IWebXRMotionControllerComponentChanges {
  53084. /**
  53085. * will be populated with previous and current values if axes changed
  53086. */
  53087. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  53088. /**
  53089. * will be populated with previous and current values if pressed changed
  53090. */
  53091. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  53092. /**
  53093. * will be populated with previous and current values if touched changed
  53094. */
  53095. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  53096. /**
  53097. * will be populated with previous and current values if value changed
  53098. */
  53099. value?: IWebXRMotionControllerComponentChangesValues<number>;
  53100. }
  53101. /**
  53102. * This class represents a single component (for example button or thumbstick) of a motion controller
  53103. */
  53104. export class WebXRControllerComponent implements IDisposable {
  53105. /**
  53106. * the id of this component
  53107. */
  53108. id: string;
  53109. /**
  53110. * the type of the component
  53111. */
  53112. type: MotionControllerComponentType;
  53113. private _buttonIndex;
  53114. private _axesIndices;
  53115. private _axes;
  53116. private _changes;
  53117. private _currentValue;
  53118. private _hasChanges;
  53119. private _pressed;
  53120. private _touched;
  53121. /**
  53122. * button component type
  53123. */
  53124. static BUTTON_TYPE: MotionControllerComponentType;
  53125. /**
  53126. * squeeze component type
  53127. */
  53128. static SQUEEZE_TYPE: MotionControllerComponentType;
  53129. /**
  53130. * Thumbstick component type
  53131. */
  53132. static THUMBSTICK_TYPE: MotionControllerComponentType;
  53133. /**
  53134. * Touchpad component type
  53135. */
  53136. static TOUCHPAD_TYPE: MotionControllerComponentType;
  53137. /**
  53138. * trigger component type
  53139. */
  53140. static TRIGGER_TYPE: MotionControllerComponentType;
  53141. /**
  53142. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  53143. * the axes data changes
  53144. */
  53145. onAxisValueChangedObservable: Observable<{
  53146. x: number;
  53147. y: number;
  53148. }>;
  53149. /**
  53150. * Observers registered here will be triggered when the state of a button changes
  53151. * State change is either pressed / touched / value
  53152. */
  53153. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  53154. /**
  53155. * Creates a new component for a motion controller.
  53156. * It is created by the motion controller itself
  53157. *
  53158. * @param id the id of this component
  53159. * @param type the type of the component
  53160. * @param _buttonIndex index in the buttons array of the gamepad
  53161. * @param _axesIndices indices of the values in the axes array of the gamepad
  53162. */
  53163. constructor(
  53164. /**
  53165. * the id of this component
  53166. */
  53167. id: string,
  53168. /**
  53169. * the type of the component
  53170. */
  53171. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  53172. /**
  53173. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  53174. */
  53175. get axes(): IWebXRMotionControllerAxesValue;
  53176. /**
  53177. * Get the changes. Elements will be populated only if they changed with their previous and current value
  53178. */
  53179. get changes(): IWebXRMotionControllerComponentChanges;
  53180. /**
  53181. * Return whether or not the component changed the last frame
  53182. */
  53183. get hasChanges(): boolean;
  53184. /**
  53185. * is the button currently pressed
  53186. */
  53187. get pressed(): boolean;
  53188. /**
  53189. * is the button currently touched
  53190. */
  53191. get touched(): boolean;
  53192. /**
  53193. * Get the current value of this component
  53194. */
  53195. get value(): number;
  53196. /**
  53197. * Dispose this component
  53198. */
  53199. dispose(): void;
  53200. /**
  53201. * Are there axes correlating to this component
  53202. * @return true is axes data is available
  53203. */
  53204. isAxes(): boolean;
  53205. /**
  53206. * Is this component a button (hence - pressable)
  53207. * @returns true if can be pressed
  53208. */
  53209. isButton(): boolean;
  53210. /**
  53211. * update this component using the gamepad object it is in. Called on every frame
  53212. * @param nativeController the native gamepad controller object
  53213. */
  53214. update(nativeController: IMinimalMotionControllerObject): void;
  53215. }
  53216. }
  53217. declare module "babylonjs/Loading/sceneLoader" {
  53218. import { Observable } from "babylonjs/Misc/observable";
  53219. import { Nullable } from "babylonjs/types";
  53220. import { Scene } from "babylonjs/scene";
  53221. import { Engine } from "babylonjs/Engines/engine";
  53222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53223. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  53224. import { AssetContainer } from "babylonjs/assetContainer";
  53225. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53226. import { Skeleton } from "babylonjs/Bones/skeleton";
  53227. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  53228. import { WebRequest } from "babylonjs/Misc/webRequest";
  53229. /**
  53230. * Interface used to represent data loading progression
  53231. */
  53232. export interface ISceneLoaderProgressEvent {
  53233. /**
  53234. * Defines if data length to load can be evaluated
  53235. */
  53236. readonly lengthComputable: boolean;
  53237. /**
  53238. * Defines the loaded data length
  53239. */
  53240. readonly loaded: number;
  53241. /**
  53242. * Defines the data length to load
  53243. */
  53244. readonly total: number;
  53245. }
  53246. /**
  53247. * Interface used by SceneLoader plugins to define supported file extensions
  53248. */
  53249. export interface ISceneLoaderPluginExtensions {
  53250. /**
  53251. * Defines the list of supported extensions
  53252. */
  53253. [extension: string]: {
  53254. isBinary: boolean;
  53255. };
  53256. }
  53257. /**
  53258. * Interface used by SceneLoader plugin factory
  53259. */
  53260. export interface ISceneLoaderPluginFactory {
  53261. /**
  53262. * Defines the name of the factory
  53263. */
  53264. name: string;
  53265. /**
  53266. * Function called to create a new plugin
  53267. * @return the new plugin
  53268. */
  53269. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  53270. /**
  53271. * The callback that returns true if the data can be directly loaded.
  53272. * @param data string containing the file data
  53273. * @returns if the data can be loaded directly
  53274. */
  53275. canDirectLoad?(data: string): boolean;
  53276. }
  53277. /**
  53278. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  53279. */
  53280. export interface ISceneLoaderPluginBase {
  53281. /**
  53282. * The friendly name of this plugin.
  53283. */
  53284. name: string;
  53285. /**
  53286. * The file extensions supported by this plugin.
  53287. */
  53288. extensions: string | ISceneLoaderPluginExtensions;
  53289. /**
  53290. * The callback called when loading from a url.
  53291. * @param scene scene loading this url
  53292. * @param url url to load
  53293. * @param onSuccess callback called when the file successfully loads
  53294. * @param onProgress callback called while file is loading (if the server supports this mode)
  53295. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  53296. * @param onError callback called when the file fails to load
  53297. * @returns a file request object
  53298. */
  53299. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  53300. /**
  53301. * The callback called when loading from a file object.
  53302. * @param scene scene loading this file
  53303. * @param file defines the file to load
  53304. * @param onSuccess defines the callback to call when data is loaded
  53305. * @param onProgress defines the callback to call during loading process
  53306. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  53307. * @param onError defines the callback to call when an error occurs
  53308. * @returns a file request object
  53309. */
  53310. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  53311. /**
  53312. * The callback that returns true if the data can be directly loaded.
  53313. * @param data string containing the file data
  53314. * @returns if the data can be loaded directly
  53315. */
  53316. canDirectLoad?(data: string): boolean;
  53317. /**
  53318. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  53319. * @param scene scene loading this data
  53320. * @param data string containing the data
  53321. * @returns data to pass to the plugin
  53322. */
  53323. directLoad?(scene: Scene, data: string): any;
  53324. /**
  53325. * The callback that allows custom handling of the root url based on the response url.
  53326. * @param rootUrl the original root url
  53327. * @param responseURL the response url if available
  53328. * @returns the new root url
  53329. */
  53330. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  53331. }
  53332. /**
  53333. * Interface used to define a SceneLoader plugin
  53334. */
  53335. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  53336. /**
  53337. * Import meshes into a scene.
  53338. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53339. * @param scene The scene to import into
  53340. * @param data The data to import
  53341. * @param rootUrl The root url for scene and resources
  53342. * @param meshes The meshes array to import into
  53343. * @param particleSystems The particle systems array to import into
  53344. * @param skeletons The skeletons array to import into
  53345. * @param onError The callback when import fails
  53346. * @returns True if successful or false otherwise
  53347. */
  53348. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  53349. /**
  53350. * Load into a scene.
  53351. * @param scene The scene to load into
  53352. * @param data The data to import
  53353. * @param rootUrl The root url for scene and resources
  53354. * @param onError The callback when import fails
  53355. * @returns True if successful or false otherwise
  53356. */
  53357. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  53358. /**
  53359. * Load into an asset container.
  53360. * @param scene The scene to load into
  53361. * @param data The data to import
  53362. * @param rootUrl The root url for scene and resources
  53363. * @param onError The callback when import fails
  53364. * @returns The loaded asset container
  53365. */
  53366. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  53367. }
  53368. /**
  53369. * Interface used to define an async SceneLoader plugin
  53370. */
  53371. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  53372. /**
  53373. * Import meshes into a scene.
  53374. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53375. * @param scene The scene to import into
  53376. * @param data The data to import
  53377. * @param rootUrl The root url for scene and resources
  53378. * @param onProgress The callback when the load progresses
  53379. * @param fileName Defines the name of the file to load
  53380. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  53381. */
  53382. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  53383. meshes: AbstractMesh[];
  53384. particleSystems: IParticleSystem[];
  53385. skeletons: Skeleton[];
  53386. animationGroups: AnimationGroup[];
  53387. }>;
  53388. /**
  53389. * Load into a scene.
  53390. * @param scene The scene to load into
  53391. * @param data The data to import
  53392. * @param rootUrl The root url for scene and resources
  53393. * @param onProgress The callback when the load progresses
  53394. * @param fileName Defines the name of the file to load
  53395. * @returns Nothing
  53396. */
  53397. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  53398. /**
  53399. * Load into an asset container.
  53400. * @param scene The scene to load into
  53401. * @param data The data to import
  53402. * @param rootUrl The root url for scene and resources
  53403. * @param onProgress The callback when the load progresses
  53404. * @param fileName Defines the name of the file to load
  53405. * @returns The loaded asset container
  53406. */
  53407. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  53408. }
  53409. /**
  53410. * Mode that determines how to handle old animation groups before loading new ones.
  53411. */
  53412. export enum SceneLoaderAnimationGroupLoadingMode {
  53413. /**
  53414. * Reset all old animations to initial state then dispose them.
  53415. */
  53416. Clean = 0,
  53417. /**
  53418. * Stop all old animations.
  53419. */
  53420. Stop = 1,
  53421. /**
  53422. * Restart old animations from first frame.
  53423. */
  53424. Sync = 2,
  53425. /**
  53426. * Old animations remains untouched.
  53427. */
  53428. NoSync = 3
  53429. }
  53430. /**
  53431. * Defines a plugin registered by the SceneLoader
  53432. */
  53433. interface IRegisteredPlugin {
  53434. /**
  53435. * Defines the plugin to use
  53436. */
  53437. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  53438. /**
  53439. * Defines if the plugin supports binary data
  53440. */
  53441. isBinary: boolean;
  53442. }
  53443. /**
  53444. * Class used to load scene from various file formats using registered plugins
  53445. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  53446. */
  53447. export class SceneLoader {
  53448. /**
  53449. * No logging while loading
  53450. */
  53451. static readonly NO_LOGGING: number;
  53452. /**
  53453. * Minimal logging while loading
  53454. */
  53455. static readonly MINIMAL_LOGGING: number;
  53456. /**
  53457. * Summary logging while loading
  53458. */
  53459. static readonly SUMMARY_LOGGING: number;
  53460. /**
  53461. * Detailled logging while loading
  53462. */
  53463. static readonly DETAILED_LOGGING: number;
  53464. /**
  53465. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  53466. */
  53467. static get ForceFullSceneLoadingForIncremental(): boolean;
  53468. static set ForceFullSceneLoadingForIncremental(value: boolean);
  53469. /**
  53470. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  53471. */
  53472. static get ShowLoadingScreen(): boolean;
  53473. static set ShowLoadingScreen(value: boolean);
  53474. /**
  53475. * Defines the current logging level (while loading the scene)
  53476. * @ignorenaming
  53477. */
  53478. static get loggingLevel(): number;
  53479. static set loggingLevel(value: number);
  53480. /**
  53481. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  53482. */
  53483. static get CleanBoneMatrixWeights(): boolean;
  53484. static set CleanBoneMatrixWeights(value: boolean);
  53485. /**
  53486. * Event raised when a plugin is used to load a scene
  53487. */
  53488. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  53489. private static _registeredPlugins;
  53490. private static _showingLoadingScreen;
  53491. /**
  53492. * Gets the default plugin (used to load Babylon files)
  53493. * @returns the .babylon plugin
  53494. */
  53495. static GetDefaultPlugin(): IRegisteredPlugin;
  53496. private static _GetPluginForExtension;
  53497. private static _GetPluginForDirectLoad;
  53498. private static _GetPluginForFilename;
  53499. private static _GetDirectLoad;
  53500. private static _LoadData;
  53501. private static _GetFileInfo;
  53502. /**
  53503. * Gets a plugin that can load the given extension
  53504. * @param extension defines the extension to load
  53505. * @returns a plugin or null if none works
  53506. */
  53507. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  53508. /**
  53509. * Gets a boolean indicating that the given extension can be loaded
  53510. * @param extension defines the extension to load
  53511. * @returns true if the extension is supported
  53512. */
  53513. static IsPluginForExtensionAvailable(extension: string): boolean;
  53514. /**
  53515. * Adds a new plugin to the list of registered plugins
  53516. * @param plugin defines the plugin to add
  53517. */
  53518. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  53519. /**
  53520. * Import meshes into a scene
  53521. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53522. * @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)
  53523. * @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)
  53524. * @param scene the instance of BABYLON.Scene to append to
  53525. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  53526. * @param onProgress a callback with a progress event for each file being loaded
  53527. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53528. * @param pluginExtension the extension used to determine the plugin
  53529. * @returns The loaded plugin
  53530. */
  53531. 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>;
  53532. /**
  53533. * Import meshes into a scene
  53534. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53535. * @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)
  53536. * @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)
  53537. * @param scene the instance of BABYLON.Scene to append to
  53538. * @param onProgress a callback with a progress event for each file being loaded
  53539. * @param pluginExtension the extension used to determine the plugin
  53540. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  53541. */
  53542. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  53543. meshes: AbstractMesh[];
  53544. particleSystems: IParticleSystem[];
  53545. skeletons: Skeleton[];
  53546. animationGroups: AnimationGroup[];
  53547. }>;
  53548. /**
  53549. * Load a scene
  53550. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  53551. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  53552. * @param engine is the instance of BABYLON.Engine to use to create the scene
  53553. * @param onSuccess a callback with the scene when import succeeds
  53554. * @param onProgress a callback with a progress event for each file being loaded
  53555. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53556. * @param pluginExtension the extension used to determine the plugin
  53557. * @returns The loaded plugin
  53558. */
  53559. static 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>;
  53560. /**
  53561. * Load a scene
  53562. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  53563. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  53564. * @param engine is the instance of BABYLON.Engine to use to create the scene
  53565. * @param onProgress a callback with a progress event for each file being loaded
  53566. * @param pluginExtension the extension used to determine the plugin
  53567. * @returns The loaded scene
  53568. */
  53569. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  53570. /**
  53571. * Append a scene
  53572. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  53573. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  53574. * @param scene is the instance of BABYLON.Scene to append to
  53575. * @param onSuccess a callback with the scene when import succeeds
  53576. * @param onProgress a callback with a progress event for each file being loaded
  53577. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53578. * @param pluginExtension the extension used to determine the plugin
  53579. * @returns The loaded plugin
  53580. */
  53581. static 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>;
  53582. /**
  53583. * Append a scene
  53584. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  53585. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  53586. * @param scene is the instance of BABYLON.Scene to append to
  53587. * @param onProgress a callback with a progress event for each file being loaded
  53588. * @param pluginExtension the extension used to determine the plugin
  53589. * @returns The given scene
  53590. */
  53591. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  53592. /**
  53593. * Load a scene into an asset container
  53594. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  53595. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  53596. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53597. * @param onSuccess a callback with the scene when import succeeds
  53598. * @param onProgress a callback with a progress event for each file being loaded
  53599. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53600. * @param pluginExtension the extension used to determine the plugin
  53601. * @returns The loaded plugin
  53602. */
  53603. 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>;
  53604. /**
  53605. * Load a scene into an asset container
  53606. * @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)
  53607. * @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)
  53608. * @param scene is the instance of Scene to append to
  53609. * @param onProgress a callback with a progress event for each file being loaded
  53610. * @param pluginExtension the extension used to determine the plugin
  53611. * @returns The loaded asset container
  53612. */
  53613. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  53614. /**
  53615. * Import animations from a file into a scene
  53616. * @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)
  53617. * @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)
  53618. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53619. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53620. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53621. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53622. * @param onSuccess a callback with the scene when import succeeds
  53623. * @param onProgress a callback with a progress event for each file being loaded
  53624. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53625. * @param pluginExtension the extension used to determine the plugin
  53626. */
  53627. 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;
  53628. /**
  53629. * Import animations from a file into a scene
  53630. * @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)
  53631. * @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)
  53632. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53633. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53634. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53635. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53636. * @param onSuccess a callback with the scene when import succeeds
  53637. * @param onProgress a callback with a progress event for each file being loaded
  53638. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53639. * @param pluginExtension the extension used to determine the plugin
  53640. * @returns the updated scene with imported animations
  53641. */
  53642. 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>;
  53643. }
  53644. }
  53645. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  53646. import { IDisposable, Scene } from "babylonjs/scene";
  53647. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  53648. import { Observable } from "babylonjs/Misc/observable";
  53649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53650. import { Nullable } from "babylonjs/types";
  53651. /**
  53652. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  53653. */
  53654. export type MotionControllerHandedness = "none" | "left" | "right";
  53655. /**
  53656. * The type of components available in motion controllers.
  53657. * This is not the name of the component.
  53658. */
  53659. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  53660. /**
  53661. * The state of a controller component
  53662. */
  53663. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  53664. /**
  53665. * The schema of motion controller layout.
  53666. * No object will be initialized using this interface
  53667. * This is used just to define the profile.
  53668. */
  53669. export interface IMotionControllerLayout {
  53670. /**
  53671. * Path to load the assets. Usually relative to the base path
  53672. */
  53673. assetPath: string;
  53674. /**
  53675. * Available components (unsorted)
  53676. */
  53677. components: {
  53678. /**
  53679. * A map of component Ids
  53680. */
  53681. [componentId: string]: {
  53682. /**
  53683. * The type of input the component outputs
  53684. */
  53685. type: MotionControllerComponentType;
  53686. /**
  53687. * The indices of this component in the gamepad object
  53688. */
  53689. gamepadIndices: {
  53690. /**
  53691. * Index of button
  53692. */
  53693. button?: number;
  53694. /**
  53695. * If available, index of x-axis
  53696. */
  53697. xAxis?: number;
  53698. /**
  53699. * If available, index of y-axis
  53700. */
  53701. yAxis?: number;
  53702. };
  53703. /**
  53704. * The mesh's root node name
  53705. */
  53706. rootNodeName: string;
  53707. /**
  53708. * Animation definitions for this model
  53709. */
  53710. visualResponses: {
  53711. [stateKey: string]: {
  53712. /**
  53713. * What property will be animated
  53714. */
  53715. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  53716. /**
  53717. * What states influence this visual response
  53718. */
  53719. states: MotionControllerComponentStateType[];
  53720. /**
  53721. * Type of animation - movement or visibility
  53722. */
  53723. valueNodeProperty: "transform" | "visibility";
  53724. /**
  53725. * Base node name to move. Its position will be calculated according to the min and max nodes
  53726. */
  53727. valueNodeName?: string;
  53728. /**
  53729. * Minimum movement node
  53730. */
  53731. minNodeName?: string;
  53732. /**
  53733. * Max movement node
  53734. */
  53735. maxNodeName?: string;
  53736. };
  53737. };
  53738. /**
  53739. * If touch enabled, what is the name of node to display user feedback
  53740. */
  53741. touchPointNodeName?: string;
  53742. };
  53743. };
  53744. /**
  53745. * Is it xr standard mapping or not
  53746. */
  53747. gamepadMapping: "" | "xr-standard";
  53748. /**
  53749. * Base root node of this entire model
  53750. */
  53751. rootNodeName: string;
  53752. /**
  53753. * Defines the main button component id
  53754. */
  53755. selectComponentId: string;
  53756. }
  53757. /**
  53758. * A definition for the layout map in the input profile
  53759. */
  53760. export interface IMotionControllerLayoutMap {
  53761. /**
  53762. * Layouts with handedness type as a key
  53763. */
  53764. [handedness: string]: IMotionControllerLayout;
  53765. }
  53766. /**
  53767. * The XR Input profile schema
  53768. * Profiles can be found here:
  53769. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  53770. */
  53771. export interface IMotionControllerProfile {
  53772. /**
  53773. * fallback profiles for this profileId
  53774. */
  53775. fallbackProfileIds: string[];
  53776. /**
  53777. * The layout map, with handedness as key
  53778. */
  53779. layouts: IMotionControllerLayoutMap;
  53780. /**
  53781. * The id of this profile
  53782. * correlates to the profile(s) in the xrInput.profiles array
  53783. */
  53784. profileId: string;
  53785. }
  53786. /**
  53787. * A helper-interface for the 3 meshes needed for controller button animation
  53788. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  53789. */
  53790. export interface IMotionControllerButtonMeshMap {
  53791. /**
  53792. * the mesh that defines the pressed value mesh position.
  53793. * This is used to find the max-position of this button
  53794. */
  53795. pressedMesh: AbstractMesh;
  53796. /**
  53797. * the mesh that defines the unpressed value mesh position.
  53798. * This is used to find the min (or initial) position of this button
  53799. */
  53800. unpressedMesh: AbstractMesh;
  53801. /**
  53802. * The mesh that will be changed when value changes
  53803. */
  53804. valueMesh: AbstractMesh;
  53805. }
  53806. /**
  53807. * A helper-interface for the 3 meshes needed for controller axis animation.
  53808. * This will be expanded when touchpad animations are fully supported
  53809. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  53810. */
  53811. export interface IMotionControllerMeshMap {
  53812. /**
  53813. * the mesh that defines the maximum value mesh position.
  53814. */
  53815. maxMesh?: AbstractMesh;
  53816. /**
  53817. * the mesh that defines the minimum value mesh position.
  53818. */
  53819. minMesh?: AbstractMesh;
  53820. /**
  53821. * The mesh that will be changed when axis value changes
  53822. */
  53823. valueMesh?: AbstractMesh;
  53824. }
  53825. /**
  53826. * The elements needed for change-detection of the gamepad objects in motion controllers
  53827. */
  53828. export interface IMinimalMotionControllerObject {
  53829. /**
  53830. * Available axes of this controller
  53831. */
  53832. axes: number[];
  53833. /**
  53834. * An array of available buttons
  53835. */
  53836. buttons: Array<{
  53837. /**
  53838. * Value of the button/trigger
  53839. */
  53840. value: number;
  53841. /**
  53842. * If the button/trigger is currently touched
  53843. */
  53844. touched: boolean;
  53845. /**
  53846. * If the button/trigger is currently pressed
  53847. */
  53848. pressed: boolean;
  53849. }>;
  53850. /**
  53851. * EXPERIMENTAL haptic support.
  53852. */
  53853. hapticActuators?: Array<{
  53854. pulse: (value: number, duration: number) => Promise<boolean>;
  53855. }>;
  53856. }
  53857. /**
  53858. * An Abstract Motion controller
  53859. * This class receives an xrInput and a profile layout and uses those to initialize the components
  53860. * Each component has an observable to check for changes in value and state
  53861. */
  53862. export abstract class WebXRAbstractMotionController implements IDisposable {
  53863. protected scene: Scene;
  53864. protected layout: IMotionControllerLayout;
  53865. /**
  53866. * The gamepad object correlating to this controller
  53867. */
  53868. gamepadObject: IMinimalMotionControllerObject;
  53869. /**
  53870. * handedness (left/right/none) of this controller
  53871. */
  53872. handedness: MotionControllerHandedness;
  53873. private _initComponent;
  53874. private _modelReady;
  53875. /**
  53876. * A map of components (WebXRControllerComponent) in this motion controller
  53877. * Components have a ComponentType and can also have both button and axis definitions
  53878. */
  53879. readonly components: {
  53880. [id: string]: WebXRControllerComponent;
  53881. };
  53882. /**
  53883. * Disable the model's animation. Can be set at any time.
  53884. */
  53885. disableAnimation: boolean;
  53886. /**
  53887. * Observers registered here will be triggered when the model of this controller is done loading
  53888. */
  53889. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  53890. /**
  53891. * The profile id of this motion controller
  53892. */
  53893. abstract profileId: string;
  53894. /**
  53895. * The root mesh of the model. It is null if the model was not yet initialized
  53896. */
  53897. rootMesh: Nullable<AbstractMesh>;
  53898. /**
  53899. * constructs a new abstract motion controller
  53900. * @param scene the scene to which the model of the controller will be added
  53901. * @param layout The profile layout to load
  53902. * @param gamepadObject The gamepad object correlating to this controller
  53903. * @param handedness handedness (left/right/none) of this controller
  53904. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  53905. */
  53906. constructor(scene: Scene, layout: IMotionControllerLayout,
  53907. /**
  53908. * The gamepad object correlating to this controller
  53909. */
  53910. gamepadObject: IMinimalMotionControllerObject,
  53911. /**
  53912. * handedness (left/right/none) of this controller
  53913. */
  53914. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  53915. /**
  53916. * Dispose this controller, the model mesh and all its components
  53917. */
  53918. dispose(): void;
  53919. /**
  53920. * Returns all components of specific type
  53921. * @param type the type to search for
  53922. * @return an array of components with this type
  53923. */
  53924. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  53925. /**
  53926. * get a component based an its component id as defined in layout.components
  53927. * @param id the id of the component
  53928. * @returns the component correlates to the id or undefined if not found
  53929. */
  53930. getComponent(id: string): WebXRControllerComponent;
  53931. /**
  53932. * Get the list of components available in this motion controller
  53933. * @returns an array of strings correlating to available components
  53934. */
  53935. getComponentIds(): string[];
  53936. /**
  53937. * Get the first component of specific type
  53938. * @param type type of component to find
  53939. * @return a controller component or null if not found
  53940. */
  53941. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  53942. /**
  53943. * Get the main (Select) component of this controller as defined in the layout
  53944. * @returns the main component of this controller
  53945. */
  53946. getMainComponent(): WebXRControllerComponent;
  53947. /**
  53948. * Loads the model correlating to this controller
  53949. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  53950. * @returns A promise fulfilled with the result of the model loading
  53951. */
  53952. loadModel(): Promise<boolean>;
  53953. /**
  53954. * Update this model using the current XRFrame
  53955. * @param xrFrame the current xr frame to use and update the model
  53956. */
  53957. updateFromXRFrame(xrFrame: XRFrame): void;
  53958. /**
  53959. * Backwards compatibility due to a deeply-integrated typo
  53960. */
  53961. get handness(): XREye;
  53962. /**
  53963. * Pulse (vibrate) this controller
  53964. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  53965. * Consecutive calls to this function will cancel the last pulse call
  53966. *
  53967. * @param value the strength of the pulse in 0.0...1.0 range
  53968. * @param duration Duration of the pulse in milliseconds
  53969. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  53970. * @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
  53971. */
  53972. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  53973. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53974. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53975. /**
  53976. * Moves the axis on the controller mesh based on its current state
  53977. * @param axis the index of the axis
  53978. * @param axisValue the value of the axis which determines the meshes new position
  53979. * @hidden
  53980. */
  53981. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  53982. /**
  53983. * Update the model itself with the current frame data
  53984. * @param xrFrame the frame to use for updating the model mesh
  53985. */
  53986. protected updateModel(xrFrame: XRFrame): void;
  53987. /**
  53988. * Get the filename and path for this controller's model
  53989. * @returns a map of filename and path
  53990. */
  53991. protected abstract _getFilenameAndPath(): {
  53992. filename: string;
  53993. path: string;
  53994. };
  53995. /**
  53996. * This function is called before the mesh is loaded. It checks for loading constraints.
  53997. * For example, this function can check if the GLB loader is available
  53998. * If this function returns false, the generic controller will be loaded instead
  53999. * @returns Is the client ready to load the mesh
  54000. */
  54001. protected abstract _getModelLoadingConstraints(): boolean;
  54002. /**
  54003. * This function will be called after the model was successfully loaded and can be used
  54004. * for mesh transformations before it is available for the user
  54005. * @param meshes the loaded meshes
  54006. */
  54007. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  54008. /**
  54009. * Set the root mesh for this controller. Important for the WebXR controller class
  54010. * @param meshes the loaded meshes
  54011. */
  54012. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  54013. /**
  54014. * A function executed each frame that updates the mesh (if needed)
  54015. * @param xrFrame the current xrFrame
  54016. */
  54017. protected abstract _updateModel(xrFrame: XRFrame): void;
  54018. private _getGenericFilenameAndPath;
  54019. private _getGenericParentMesh;
  54020. }
  54021. }
  54022. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  54023. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54025. import { Scene } from "babylonjs/scene";
  54026. /**
  54027. * A generic trigger-only motion controller for WebXR
  54028. */
  54029. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  54030. /**
  54031. * Static version of the profile id of this controller
  54032. */
  54033. static ProfileId: string;
  54034. profileId: string;
  54035. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  54036. protected _getFilenameAndPath(): {
  54037. filename: string;
  54038. path: string;
  54039. };
  54040. protected _getModelLoadingConstraints(): boolean;
  54041. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  54042. protected _setRootMesh(meshes: AbstractMesh[]): void;
  54043. protected _updateModel(): void;
  54044. }
  54045. }
  54046. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  54047. import { Vector4 } from "babylonjs/Maths/math.vector";
  54048. import { Mesh } from "babylonjs/Meshes/mesh";
  54049. import { Scene } from "babylonjs/scene";
  54050. import { Nullable } from "babylonjs/types";
  54051. /**
  54052. * Class containing static functions to help procedurally build meshes
  54053. */
  54054. export class SphereBuilder {
  54055. /**
  54056. * Creates a sphere mesh
  54057. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54058. * * 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`)
  54059. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54060. * * 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
  54061. * * 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)
  54062. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54063. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54065. * @param name defines the name of the mesh
  54066. * @param options defines the options used to create the mesh
  54067. * @param scene defines the hosting scene
  54068. * @returns the sphere mesh
  54069. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54070. */
  54071. static CreateSphere(name: string, options: {
  54072. segments?: number;
  54073. diameter?: number;
  54074. diameterX?: number;
  54075. diameterY?: number;
  54076. diameterZ?: number;
  54077. arc?: number;
  54078. slice?: number;
  54079. sideOrientation?: number;
  54080. frontUVs?: Vector4;
  54081. backUVs?: Vector4;
  54082. updatable?: boolean;
  54083. }, scene?: Nullable<Scene>): Mesh;
  54084. }
  54085. }
  54086. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  54087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54088. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54089. import { Scene } from "babylonjs/scene";
  54090. /**
  54091. * A profiled motion controller has its profile loaded from an online repository.
  54092. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  54093. */
  54094. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  54095. private _repositoryUrl;
  54096. private _buttonMeshMapping;
  54097. private _touchDots;
  54098. /**
  54099. * The profile ID of this controller. Will be populated when the controller initializes.
  54100. */
  54101. profileId: string;
  54102. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  54103. dispose(): void;
  54104. protected _getFilenameAndPath(): {
  54105. filename: string;
  54106. path: string;
  54107. };
  54108. protected _getModelLoadingConstraints(): boolean;
  54109. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  54110. protected _setRootMesh(meshes: AbstractMesh[]): void;
  54111. protected _updateModel(_xrFrame: XRFrame): void;
  54112. }
  54113. }
  54114. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  54115. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54116. import { Scene } from "babylonjs/scene";
  54117. /**
  54118. * A construction function type to create a new controller based on an xrInput object
  54119. */
  54120. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  54121. /**
  54122. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  54123. *
  54124. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  54125. * it should be replaced with auto-loaded controllers.
  54126. *
  54127. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  54128. */
  54129. export class WebXRMotionControllerManager {
  54130. private static _AvailableControllers;
  54131. private static _Fallbacks;
  54132. private static _ProfileLoadingPromises;
  54133. private static _ProfilesList;
  54134. /**
  54135. * The base URL of the online controller repository. Can be changed at any time.
  54136. */
  54137. static BaseRepositoryUrl: string;
  54138. /**
  54139. * Which repository gets priority - local or online
  54140. */
  54141. static PrioritizeOnlineRepository: boolean;
  54142. /**
  54143. * Use the online repository, or use only locally-defined controllers
  54144. */
  54145. static UseOnlineRepository: boolean;
  54146. /**
  54147. * Clear the cache used for profile loading and reload when requested again
  54148. */
  54149. static ClearProfilesCache(): void;
  54150. /**
  54151. * Register the default fallbacks.
  54152. * This function is called automatically when this file is imported.
  54153. */
  54154. static DefaultFallbacks(): void;
  54155. /**
  54156. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  54157. * @param profileId the profile to which a fallback needs to be found
  54158. * @return an array with corresponding fallback profiles
  54159. */
  54160. static FindFallbackWithProfileId(profileId: string): string[];
  54161. /**
  54162. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  54163. * The order of search:
  54164. *
  54165. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  54166. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  54167. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  54168. * 4) return the generic trigger controller if none were found
  54169. *
  54170. * @param xrInput the xrInput to which a new controller is initialized
  54171. * @param scene the scene to which the model will be added
  54172. * @param forceProfile force a certain profile for this controller
  54173. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  54174. */
  54175. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  54176. /**
  54177. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  54178. *
  54179. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  54180. *
  54181. * @param type the profile type to register
  54182. * @param constructFunction the function to be called when loading this profile
  54183. */
  54184. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  54185. /**
  54186. * Register a fallback to a specific profile.
  54187. * @param profileId the profileId that will receive the fallbacks
  54188. * @param fallbacks A list of fallback profiles
  54189. */
  54190. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  54191. /**
  54192. * Will update the list of profiles available in the repository
  54193. * @return a promise that resolves to a map of profiles available online
  54194. */
  54195. static UpdateProfilesList(): Promise<{
  54196. [profile: string]: string;
  54197. }>;
  54198. private static _LoadProfileFromRepository;
  54199. private static _LoadProfilesFromAvailableControllers;
  54200. }
  54201. }
  54202. declare module "babylonjs/XR/webXRInputSource" {
  54203. import { Observable } from "babylonjs/Misc/observable";
  54204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54205. import { Ray } from "babylonjs/Culling/ray";
  54206. import { Scene } from "babylonjs/scene";
  54207. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54208. /**
  54209. * Configuration options for the WebXR controller creation
  54210. */
  54211. export interface IWebXRControllerOptions {
  54212. /**
  54213. * Should the controller mesh be animated when a user interacts with it
  54214. * The pressed buttons / thumbstick and touchpad animations will be disabled
  54215. */
  54216. disableMotionControllerAnimation?: boolean;
  54217. /**
  54218. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  54219. */
  54220. doNotLoadControllerMesh?: boolean;
  54221. /**
  54222. * Force a specific controller type for this controller.
  54223. * This can be used when creating your own profile or when testing different controllers
  54224. */
  54225. forceControllerProfile?: string;
  54226. /**
  54227. * Defines a rendering group ID for meshes that will be loaded.
  54228. * This is for the default controllers only.
  54229. */
  54230. renderingGroupId?: number;
  54231. }
  54232. /**
  54233. * Represents an XR controller
  54234. */
  54235. export class WebXRInputSource {
  54236. private _scene;
  54237. /** The underlying input source for the controller */
  54238. inputSource: XRInputSource;
  54239. private _options;
  54240. private _tmpVector;
  54241. private _uniqueId;
  54242. private _disposed;
  54243. /**
  54244. * 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
  54245. */
  54246. grip?: AbstractMesh;
  54247. /**
  54248. * If available, this is the gamepad object related to this controller.
  54249. * Using this object it is possible to get click events and trackpad changes of the
  54250. * webxr controller that is currently being used.
  54251. */
  54252. motionController?: WebXRAbstractMotionController;
  54253. /**
  54254. * Event that fires when the controller is removed/disposed.
  54255. * The object provided as event data is this controller, after associated assets were disposed.
  54256. * uniqueId is still available.
  54257. */
  54258. onDisposeObservable: Observable<WebXRInputSource>;
  54259. /**
  54260. * Will be triggered when the mesh associated with the motion controller is done loading.
  54261. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  54262. * A shortened version of controller -> motion controller -> on mesh loaded.
  54263. */
  54264. onMeshLoadedObservable: Observable<AbstractMesh>;
  54265. /**
  54266. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  54267. */
  54268. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  54269. /**
  54270. * Pointer which can be used to select objects or attach a visible laser to
  54271. */
  54272. pointer: AbstractMesh;
  54273. /**
  54274. * Creates the input source object
  54275. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  54276. * @param _scene the scene which the controller should be associated to
  54277. * @param inputSource the underlying input source for the controller
  54278. * @param _options options for this controller creation
  54279. */
  54280. constructor(_scene: Scene,
  54281. /** The underlying input source for the controller */
  54282. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  54283. /**
  54284. * Get this controllers unique id
  54285. */
  54286. get uniqueId(): string;
  54287. /**
  54288. * Disposes of the object
  54289. */
  54290. dispose(): void;
  54291. /**
  54292. * Gets a world space ray coming from the pointer or grip
  54293. * @param result the resulting ray
  54294. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  54295. */
  54296. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  54297. /**
  54298. * Updates the controller pose based on the given XRFrame
  54299. * @param xrFrame xr frame to update the pose with
  54300. * @param referenceSpace reference space to use
  54301. */
  54302. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  54303. }
  54304. }
  54305. declare module "babylonjs/XR/webXRInput" {
  54306. import { Observable } from "babylonjs/Misc/observable";
  54307. import { IDisposable } from "babylonjs/scene";
  54308. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  54309. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54310. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  54311. /**
  54312. * The schema for initialization options of the XR Input class
  54313. */
  54314. export interface IWebXRInputOptions {
  54315. /**
  54316. * If set to true no model will be automatically loaded
  54317. */
  54318. doNotLoadControllerMeshes?: boolean;
  54319. /**
  54320. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  54321. * If not found, the xr input profile data will be used.
  54322. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  54323. */
  54324. forceInputProfile?: string;
  54325. /**
  54326. * Do not send a request to the controller repository to load the profile.
  54327. *
  54328. * Instead, use the controllers available in babylon itself.
  54329. */
  54330. disableOnlineControllerRepository?: boolean;
  54331. /**
  54332. * A custom URL for the controllers repository
  54333. */
  54334. customControllersRepositoryURL?: string;
  54335. /**
  54336. * Should the controller model's components not move according to the user input
  54337. */
  54338. disableControllerAnimation?: boolean;
  54339. /**
  54340. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  54341. */
  54342. controllerOptions?: IWebXRControllerOptions;
  54343. }
  54344. /**
  54345. * XR input used to track XR inputs such as controllers/rays
  54346. */
  54347. export class WebXRInput implements IDisposable {
  54348. /**
  54349. * the xr session manager for this session
  54350. */
  54351. xrSessionManager: WebXRSessionManager;
  54352. /**
  54353. * the WebXR camera for this session. Mainly used for teleportation
  54354. */
  54355. xrCamera: WebXRCamera;
  54356. private readonly options;
  54357. /**
  54358. * XR controllers being tracked
  54359. */
  54360. controllers: Array<WebXRInputSource>;
  54361. private _frameObserver;
  54362. private _sessionEndedObserver;
  54363. private _sessionInitObserver;
  54364. /**
  54365. * Event when a controller has been connected/added
  54366. */
  54367. onControllerAddedObservable: Observable<WebXRInputSource>;
  54368. /**
  54369. * Event when a controller has been removed/disconnected
  54370. */
  54371. onControllerRemovedObservable: Observable<WebXRInputSource>;
  54372. /**
  54373. * Initializes the WebXRInput
  54374. * @param xrSessionManager the xr session manager for this session
  54375. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  54376. * @param options = initialization options for this xr input
  54377. */
  54378. constructor(
  54379. /**
  54380. * the xr session manager for this session
  54381. */
  54382. xrSessionManager: WebXRSessionManager,
  54383. /**
  54384. * the WebXR camera for this session. Mainly used for teleportation
  54385. */
  54386. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  54387. private _onInputSourcesChange;
  54388. private _addAndRemoveControllers;
  54389. /**
  54390. * Disposes of the object
  54391. */
  54392. dispose(): void;
  54393. }
  54394. }
  54395. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  54396. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  54397. import { Observable, EventState } from "babylonjs/Misc/observable";
  54398. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54399. /**
  54400. * This is the base class for all WebXR features.
  54401. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  54402. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  54403. */
  54404. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  54405. protected _xrSessionManager: WebXRSessionManager;
  54406. private _attached;
  54407. private _removeOnDetach;
  54408. /**
  54409. * Is this feature disposed?
  54410. */
  54411. isDisposed: boolean;
  54412. /**
  54413. * Should auto-attach be disabled?
  54414. */
  54415. disableAutoAttach: boolean;
  54416. /**
  54417. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  54418. */
  54419. xrNativeFeatureName: string;
  54420. /**
  54421. * Construct a new (abstract) WebXR feature
  54422. * @param _xrSessionManager the xr session manager for this feature
  54423. */
  54424. constructor(_xrSessionManager: WebXRSessionManager);
  54425. /**
  54426. * Is this feature attached
  54427. */
  54428. get attached(): boolean;
  54429. /**
  54430. * attach this feature
  54431. *
  54432. * @param force should attachment be forced (even when already attached)
  54433. * @returns true if successful, false is failed or already attached
  54434. */
  54435. attach(force?: boolean): boolean;
  54436. /**
  54437. * detach this feature.
  54438. *
  54439. * @returns true if successful, false if failed or already detached
  54440. */
  54441. detach(): boolean;
  54442. /**
  54443. * Dispose this feature and all of the resources attached
  54444. */
  54445. dispose(): void;
  54446. /**
  54447. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  54448. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  54449. *
  54450. * @returns whether or not the feature is compatible in this environment
  54451. */
  54452. isCompatible(): boolean;
  54453. /**
  54454. * This is used to register callbacks that will automatically be removed when detach is called.
  54455. * @param observable the observable to which the observer will be attached
  54456. * @param callback the callback to register
  54457. */
  54458. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  54459. /**
  54460. * Code in this function will be executed on each xrFrame received from the browser.
  54461. * This function will not execute after the feature is detached.
  54462. * @param _xrFrame the current frame
  54463. */
  54464. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  54465. }
  54466. }
  54467. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  54468. import { IDisposable, Scene } from "babylonjs/scene";
  54469. import { Nullable } from "babylonjs/types";
  54470. import { Observable } from "babylonjs/Misc/observable";
  54471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54472. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  54473. import { Camera } from "babylonjs/Cameras/camera";
  54474. /**
  54475. * Renders a layer on top of an existing scene
  54476. */
  54477. export class UtilityLayerRenderer implements IDisposable {
  54478. /** the original scene that will be rendered on top of */
  54479. originalScene: Scene;
  54480. private _pointerCaptures;
  54481. private _lastPointerEvents;
  54482. private static _DefaultUtilityLayer;
  54483. private static _DefaultKeepDepthUtilityLayer;
  54484. private _sharedGizmoLight;
  54485. private _renderCamera;
  54486. /**
  54487. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  54488. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  54489. * @returns the camera that is used when rendering the utility layer
  54490. */
  54491. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  54492. /**
  54493. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  54494. * @param cam the camera that should be used when rendering the utility layer
  54495. */
  54496. setRenderCamera(cam: Nullable<Camera>): void;
  54497. /**
  54498. * @hidden
  54499. * Light which used by gizmos to get light shading
  54500. */
  54501. _getSharedGizmoLight(): HemisphericLight;
  54502. /**
  54503. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  54504. */
  54505. pickUtilitySceneFirst: boolean;
  54506. /**
  54507. * 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)
  54508. */
  54509. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  54510. /**
  54511. * 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)
  54512. */
  54513. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  54514. /**
  54515. * The scene that is rendered on top of the original scene
  54516. */
  54517. utilityLayerScene: Scene;
  54518. /**
  54519. * If the utility layer should automatically be rendered on top of existing scene
  54520. */
  54521. shouldRender: boolean;
  54522. /**
  54523. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  54524. */
  54525. onlyCheckPointerDownEvents: boolean;
  54526. /**
  54527. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  54528. */
  54529. processAllEvents: boolean;
  54530. /**
  54531. * Observable raised when the pointer move from the utility layer scene to the main scene
  54532. */
  54533. onPointerOutObservable: Observable<number>;
  54534. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  54535. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  54536. private _afterRenderObserver;
  54537. private _sceneDisposeObserver;
  54538. private _originalPointerObserver;
  54539. /**
  54540. * Instantiates a UtilityLayerRenderer
  54541. * @param originalScene the original scene that will be rendered on top of
  54542. * @param handleEvents boolean indicating if the utility layer should handle events
  54543. */
  54544. constructor(
  54545. /** the original scene that will be rendered on top of */
  54546. originalScene: Scene, handleEvents?: boolean);
  54547. private _notifyObservers;
  54548. /**
  54549. * Renders the utility layers scene on top of the original scene
  54550. */
  54551. render(): void;
  54552. /**
  54553. * Disposes of the renderer
  54554. */
  54555. dispose(): void;
  54556. private _updateCamera;
  54557. }
  54558. }
  54559. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  54560. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54561. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54562. import { WebXRInput } from "babylonjs/XR/webXRInput";
  54563. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  54564. import { Scene } from "babylonjs/scene";
  54565. import { Nullable } from "babylonjs/types";
  54566. import { Color3 } from "babylonjs/Maths/math.color";
  54567. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  54568. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  54569. /**
  54570. * Options interface for the pointer selection module
  54571. */
  54572. export interface IWebXRControllerPointerSelectionOptions {
  54573. /**
  54574. * if provided, this scene will be used to render meshes.
  54575. */
  54576. customUtilityLayerScene?: Scene;
  54577. /**
  54578. * 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)
  54579. * If not disabled, the last picked point will be used to execute a pointer up event
  54580. * If disabled, pointer up event will be triggered right after the pointer down event.
  54581. * Used in screen and gaze target ray mode only
  54582. */
  54583. disablePointerUpOnTouchOut: boolean;
  54584. /**
  54585. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  54586. */
  54587. forceGazeMode: boolean;
  54588. /**
  54589. * 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
  54590. * to start a new countdown to the pointer down event.
  54591. * Defaults to 1.
  54592. */
  54593. gazeModePointerMovedFactor?: number;
  54594. /**
  54595. * Different button type to use instead of the main component
  54596. */
  54597. overrideButtonId?: string;
  54598. /**
  54599. * use this rendering group id for the meshes (optional)
  54600. */
  54601. renderingGroupId?: number;
  54602. /**
  54603. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  54604. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  54605. * 3000 means 3 seconds between pointing at something and selecting it
  54606. */
  54607. timeToSelect?: number;
  54608. /**
  54609. * Should meshes created here be added to a utility layer or the main scene
  54610. */
  54611. useUtilityLayer?: boolean;
  54612. /**
  54613. * Optional WebXR camera to be used for gaze selection
  54614. */
  54615. gazeCamera?: WebXRCamera;
  54616. /**
  54617. * the xr input to use with this pointer selection
  54618. */
  54619. xrInput: WebXRInput;
  54620. /**
  54621. * Should the scene pointerX and pointerY update be disabled
  54622. * This is required for fullscreen AR GUI, but might slow down other experiences.
  54623. * Disable in VR, if not needed.
  54624. * The first rig camera (left eye) will be used to calculate the projection
  54625. */
  54626. disableScenePointerVectorUpdate: boolean;
  54627. /**
  54628. * Enable pointer selection on all controllers instead of switching between them
  54629. */
  54630. enablePointerSelectionOnAllControllers?: boolean;
  54631. /**
  54632. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  54633. * If switch is enabled, it will still allow the user to switch between the different controllers
  54634. */
  54635. preferredHandedness?: XRHandedness;
  54636. /**
  54637. * Disable switching the pointer selection from one controller to the other.
  54638. * If the preferred hand is set it will be fixed on this hand, and if not it will be fixed on the first controller added to the scene
  54639. */
  54640. disableSwitchOnClick?: boolean;
  54641. /**
  54642. * The maximum distance of the pointer selection feature. Defaults to 100.
  54643. */
  54644. maxPointerDistance?: number;
  54645. }
  54646. /**
  54647. * A module that will enable pointer selection for motion controllers of XR Input Sources
  54648. */
  54649. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  54650. private readonly _options;
  54651. private static _idCounter;
  54652. private _attachController;
  54653. private _controllers;
  54654. private _scene;
  54655. private _tmpVectorForPickCompare;
  54656. private _attachedController;
  54657. /**
  54658. * The module's name
  54659. */
  54660. static readonly Name: string;
  54661. /**
  54662. * The (Babylon) version of this module.
  54663. * This is an integer representing the implementation version.
  54664. * This number does not correspond to the WebXR specs version
  54665. */
  54666. static readonly Version: number;
  54667. /**
  54668. * Disable lighting on the laser pointer (so it will always be visible)
  54669. */
  54670. disablePointerLighting: boolean;
  54671. /**
  54672. * Disable lighting on the selection mesh (so it will always be visible)
  54673. */
  54674. disableSelectionMeshLighting: boolean;
  54675. /**
  54676. * Should the laser pointer be displayed
  54677. */
  54678. displayLaserPointer: boolean;
  54679. /**
  54680. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  54681. */
  54682. displaySelectionMesh: boolean;
  54683. /**
  54684. * This color will be set to the laser pointer when selection is triggered
  54685. */
  54686. laserPointerPickedColor: Color3;
  54687. /**
  54688. * Default color of the laser pointer
  54689. */
  54690. laserPointerDefaultColor: Color3;
  54691. /**
  54692. * default color of the selection ring
  54693. */
  54694. selectionMeshDefaultColor: Color3;
  54695. /**
  54696. * This color will be applied to the selection ring when selection is triggered
  54697. */
  54698. selectionMeshPickedColor: Color3;
  54699. /**
  54700. * Optional filter to be used for ray selection. This predicate shares behavior with
  54701. * scene.pointerMovePredicate which takes priority if it is also assigned.
  54702. */
  54703. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  54704. /**
  54705. * constructs a new background remover module
  54706. * @param _xrSessionManager the session manager for this module
  54707. * @param _options read-only options to be used in this module
  54708. */
  54709. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  54710. /**
  54711. * attach this feature
  54712. * Will usually be called by the features manager
  54713. *
  54714. * @returns true if successful.
  54715. */
  54716. attach(): boolean;
  54717. /**
  54718. * detach this feature.
  54719. * Will usually be called by the features manager
  54720. *
  54721. * @returns true if successful.
  54722. */
  54723. detach(): boolean;
  54724. /**
  54725. * Will get the mesh under a specific pointer.
  54726. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  54727. * @param controllerId the controllerId to check
  54728. * @returns The mesh under pointer or null if no mesh is under the pointer
  54729. */
  54730. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  54731. /**
  54732. * Get the xr controller that correlates to the pointer id in the pointer event
  54733. *
  54734. * @param id the pointer id to search for
  54735. * @returns the controller that correlates to this id or null if not found
  54736. */
  54737. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  54738. private _identityMatrix;
  54739. private _screenCoordinatesRef;
  54740. private _viewportRef;
  54741. protected _onXRFrame(_xrFrame: XRFrame): void;
  54742. private _attachGazeMode;
  54743. private _attachScreenRayMode;
  54744. private _attachTrackedPointerRayMode;
  54745. private _convertNormalToDirectionOfRay;
  54746. private _detachController;
  54747. private _generateNewMeshPair;
  54748. private _pickingMoved;
  54749. private _updatePointerDistance;
  54750. /** @hidden */
  54751. get lasterPointerDefaultColor(): Color3;
  54752. }
  54753. }
  54754. declare module "babylonjs/XR/webXREnterExitUI" {
  54755. import { Nullable } from "babylonjs/types";
  54756. import { Observable } from "babylonjs/Misc/observable";
  54757. import { IDisposable, Scene } from "babylonjs/scene";
  54758. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54759. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54760. /**
  54761. * Button which can be used to enter a different mode of XR
  54762. */
  54763. export class WebXREnterExitUIButton {
  54764. /** button element */
  54765. element: HTMLElement;
  54766. /** XR initialization options for the button */
  54767. sessionMode: XRSessionMode;
  54768. /** Reference space type */
  54769. referenceSpaceType: XRReferenceSpaceType;
  54770. /**
  54771. * Creates a WebXREnterExitUIButton
  54772. * @param element button element
  54773. * @param sessionMode XR initialization session mode
  54774. * @param referenceSpaceType the type of reference space to be used
  54775. */
  54776. constructor(
  54777. /** button element */
  54778. element: HTMLElement,
  54779. /** XR initialization options for the button */
  54780. sessionMode: XRSessionMode,
  54781. /** Reference space type */
  54782. referenceSpaceType: XRReferenceSpaceType);
  54783. /**
  54784. * Extendable function which can be used to update the button's visuals when the state changes
  54785. * @param activeButton the current active button in the UI
  54786. */
  54787. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  54788. }
  54789. /**
  54790. * Options to create the webXR UI
  54791. */
  54792. export class WebXREnterExitUIOptions {
  54793. /**
  54794. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  54795. */
  54796. customButtons?: Array<WebXREnterExitUIButton>;
  54797. /**
  54798. * A reference space type to use when creating the default button.
  54799. * Default is local-floor
  54800. */
  54801. referenceSpaceType?: XRReferenceSpaceType;
  54802. /**
  54803. * Context to enter xr with
  54804. */
  54805. renderTarget?: Nullable<WebXRRenderTarget>;
  54806. /**
  54807. * A session mode to use when creating the default button.
  54808. * Default is immersive-vr
  54809. */
  54810. sessionMode?: XRSessionMode;
  54811. /**
  54812. * A list of optional features to init the session with
  54813. */
  54814. optionalFeatures?: string[];
  54815. /**
  54816. * A list of optional features to init the session with
  54817. */
  54818. requiredFeatures?: string[];
  54819. /**
  54820. * If defined, this function will be executed if the UI encounters an error when entering XR
  54821. */
  54822. onError?: (error: any) => void;
  54823. }
  54824. /**
  54825. * UI to allow the user to enter/exit XR mode
  54826. */
  54827. export class WebXREnterExitUI implements IDisposable {
  54828. private scene;
  54829. /** version of the options passed to this UI */
  54830. options: WebXREnterExitUIOptions;
  54831. private _activeButton;
  54832. private _buttons;
  54833. /**
  54834. * The HTML Div Element to which buttons are added.
  54835. */
  54836. readonly overlay: HTMLDivElement;
  54837. /**
  54838. * Fired every time the active button is changed.
  54839. *
  54840. * When xr is entered via a button that launches xr that button will be the callback parameter
  54841. *
  54842. * When exiting xr the callback parameter will be null)
  54843. */
  54844. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  54845. /**
  54846. *
  54847. * @param scene babylon scene object to use
  54848. * @param options (read-only) version of the options passed to this UI
  54849. */
  54850. private constructor();
  54851. /**
  54852. * Creates UI to allow the user to enter/exit XR mode
  54853. * @param scene the scene to add the ui to
  54854. * @param helper the xr experience helper to enter/exit xr with
  54855. * @param options options to configure the UI
  54856. * @returns the created ui
  54857. */
  54858. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  54859. /**
  54860. * Disposes of the XR UI component
  54861. */
  54862. dispose(): void;
  54863. private _updateButtons;
  54864. }
  54865. }
  54866. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  54867. import { Vector3 } from "babylonjs/Maths/math.vector";
  54868. import { Color4 } from "babylonjs/Maths/math.color";
  54869. import { Nullable } from "babylonjs/types";
  54870. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54871. import { Scene } from "babylonjs/scene";
  54872. /**
  54873. * Class containing static functions to help procedurally build meshes
  54874. */
  54875. export class LinesBuilder {
  54876. /**
  54877. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54878. * * 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
  54879. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54880. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54881. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54882. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54883. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54884. * * 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
  54885. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54887. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54888. * @param name defines the name of the new line system
  54889. * @param options defines the options used to create the line system
  54890. * @param scene defines the hosting scene
  54891. * @returns a new line system mesh
  54892. */
  54893. static CreateLineSystem(name: string, options: {
  54894. lines: Vector3[][];
  54895. updatable?: boolean;
  54896. instance?: Nullable<LinesMesh>;
  54897. colors?: Nullable<Color4[][]>;
  54898. useVertexAlpha?: boolean;
  54899. }, scene: Nullable<Scene>): LinesMesh;
  54900. /**
  54901. * Creates a line mesh
  54902. * 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
  54903. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54904. * * The parameter `points` is an array successive Vector3
  54905. * * 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
  54906. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54907. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54908. * * When updating an instance, remember that only point positions can change, not the number of points
  54909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54910. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54911. * @param name defines the name of the new line system
  54912. * @param options defines the options used to create the line system
  54913. * @param scene defines the hosting scene
  54914. * @returns a new line mesh
  54915. */
  54916. static CreateLines(name: string, options: {
  54917. points: Vector3[];
  54918. updatable?: boolean;
  54919. instance?: Nullable<LinesMesh>;
  54920. colors?: Color4[];
  54921. useVertexAlpha?: boolean;
  54922. }, scene?: Nullable<Scene>): LinesMesh;
  54923. /**
  54924. * Creates a dashed line mesh
  54925. * * 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
  54926. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54927. * * The parameter `points` is an array successive Vector3
  54928. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54929. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54930. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54931. * * 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
  54932. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54933. * * When updating an instance, remember that only point positions can change, not the number of points
  54934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54935. * @param name defines the name of the mesh
  54936. * @param options defines the options used to create the mesh
  54937. * @param scene defines the hosting scene
  54938. * @returns the dashed line mesh
  54939. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54940. */
  54941. static CreateDashedLines(name: string, options: {
  54942. points: Vector3[];
  54943. dashSize?: number;
  54944. gapSize?: number;
  54945. dashNb?: number;
  54946. updatable?: boolean;
  54947. instance?: LinesMesh;
  54948. useVertexAlpha?: boolean;
  54949. }, scene?: Nullable<Scene>): LinesMesh;
  54950. }
  54951. }
  54952. declare module "babylonjs/Misc/timer" {
  54953. import { Observable, Observer } from "babylonjs/Misc/observable";
  54954. import { Nullable } from "babylonjs/types";
  54955. import { IDisposable } from "babylonjs/scene";
  54956. /**
  54957. * Construction options for a timer
  54958. */
  54959. export interface ITimerOptions<T> {
  54960. /**
  54961. * Time-to-end
  54962. */
  54963. timeout: number;
  54964. /**
  54965. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  54966. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  54967. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  54968. */
  54969. contextObservable: Observable<T>;
  54970. /**
  54971. * Optional parameters when adding an observer to the observable
  54972. */
  54973. observableParameters?: {
  54974. mask?: number;
  54975. insertFirst?: boolean;
  54976. scope?: any;
  54977. };
  54978. /**
  54979. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  54980. */
  54981. breakCondition?: (data?: ITimerData<T>) => boolean;
  54982. /**
  54983. * Will be triggered when the time condition has met
  54984. */
  54985. onEnded?: (data: ITimerData<any>) => void;
  54986. /**
  54987. * Will be triggered when the break condition has met (prematurely ended)
  54988. */
  54989. onAborted?: (data: ITimerData<any>) => void;
  54990. /**
  54991. * Optional function to execute on each tick (or count)
  54992. */
  54993. onTick?: (data: ITimerData<any>) => void;
  54994. }
  54995. /**
  54996. * An interface defining the data sent by the timer
  54997. */
  54998. export interface ITimerData<T> {
  54999. /**
  55000. * When did it start
  55001. */
  55002. startTime: number;
  55003. /**
  55004. * Time now
  55005. */
  55006. currentTime: number;
  55007. /**
  55008. * Time passed since started
  55009. */
  55010. deltaTime: number;
  55011. /**
  55012. * How much is completed, in [0.0...1.0].
  55013. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  55014. */
  55015. completeRate: number;
  55016. /**
  55017. * What the registered observable sent in the last count
  55018. */
  55019. payload: T;
  55020. }
  55021. /**
  55022. * The current state of the timer
  55023. */
  55024. export enum TimerState {
  55025. /**
  55026. * Timer initialized, not yet started
  55027. */
  55028. INIT = 0,
  55029. /**
  55030. * Timer started and counting
  55031. */
  55032. STARTED = 1,
  55033. /**
  55034. * Timer ended (whether aborted or time reached)
  55035. */
  55036. ENDED = 2
  55037. }
  55038. /**
  55039. * A simple version of the timer. Will take options and start the timer immediately after calling it
  55040. *
  55041. * @param options options with which to initialize this timer
  55042. */
  55043. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  55044. /**
  55045. * An advanced implementation of a timer class
  55046. */
  55047. export class AdvancedTimer<T = any> implements IDisposable {
  55048. /**
  55049. * Will notify each time the timer calculates the remaining time
  55050. */
  55051. onEachCountObservable: Observable<ITimerData<T>>;
  55052. /**
  55053. * Will trigger when the timer was aborted due to the break condition
  55054. */
  55055. onTimerAbortedObservable: Observable<ITimerData<T>>;
  55056. /**
  55057. * Will trigger when the timer ended successfully
  55058. */
  55059. onTimerEndedObservable: Observable<ITimerData<T>>;
  55060. /**
  55061. * Will trigger when the timer state has changed
  55062. */
  55063. onStateChangedObservable: Observable<TimerState>;
  55064. private _observer;
  55065. private _contextObservable;
  55066. private _observableParameters;
  55067. private _startTime;
  55068. private _timer;
  55069. private _state;
  55070. private _breakCondition;
  55071. private _timeToEnd;
  55072. private _breakOnNextTick;
  55073. /**
  55074. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  55075. * @param options construction options for this advanced timer
  55076. */
  55077. constructor(options: ITimerOptions<T>);
  55078. /**
  55079. * set a breaking condition for this timer. Default is to never break during count
  55080. * @param predicate the new break condition. Returns true to break, false otherwise
  55081. */
  55082. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  55083. /**
  55084. * Reset ALL associated observables in this advanced timer
  55085. */
  55086. clearObservables(): void;
  55087. /**
  55088. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  55089. *
  55090. * @param timeToEnd how much time to measure until timer ended
  55091. */
  55092. start(timeToEnd?: number): void;
  55093. /**
  55094. * Will force a stop on the next tick.
  55095. */
  55096. stop(): void;
  55097. /**
  55098. * Dispose this timer, clearing all resources
  55099. */
  55100. dispose(): void;
  55101. private _setState;
  55102. private _tick;
  55103. private _stop;
  55104. }
  55105. }
  55106. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  55107. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  55108. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  55109. import { Nullable } from "babylonjs/types";
  55110. import { WebXRInput } from "babylonjs/XR/webXRInput";
  55111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55112. import { Vector3 } from "babylonjs/Maths/math.vector";
  55113. import { Material } from "babylonjs/Materials/material";
  55114. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  55115. import { Scene } from "babylonjs/scene";
  55116. /**
  55117. * The options container for the teleportation module
  55118. */
  55119. export interface IWebXRTeleportationOptions {
  55120. /**
  55121. * if provided, this scene will be used to render meshes.
  55122. */
  55123. customUtilityLayerScene?: Scene;
  55124. /**
  55125. * Values to configure the default target mesh
  55126. */
  55127. defaultTargetMeshOptions?: {
  55128. /**
  55129. * Fill color of the teleportation area
  55130. */
  55131. teleportationFillColor?: string;
  55132. /**
  55133. * Border color for the teleportation area
  55134. */
  55135. teleportationBorderColor?: string;
  55136. /**
  55137. * Disable the mesh's animation sequence
  55138. */
  55139. disableAnimation?: boolean;
  55140. /**
  55141. * Disable lighting on the material or the ring and arrow
  55142. */
  55143. disableLighting?: boolean;
  55144. /**
  55145. * Override the default material of the torus and arrow
  55146. */
  55147. torusArrowMaterial?: Material;
  55148. };
  55149. /**
  55150. * A list of meshes to use as floor meshes.
  55151. * Meshes can be added and removed after initializing the feature using the
  55152. * addFloorMesh and removeFloorMesh functions
  55153. * If empty, rotation will still work
  55154. */
  55155. floorMeshes?: AbstractMesh[];
  55156. /**
  55157. * use this rendering group id for the meshes (optional)
  55158. */
  55159. renderingGroupId?: number;
  55160. /**
  55161. * Should teleportation move only to snap points
  55162. */
  55163. snapPointsOnly?: boolean;
  55164. /**
  55165. * An array of points to which the teleportation will snap to.
  55166. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  55167. */
  55168. snapPositions?: Vector3[];
  55169. /**
  55170. * How close should the teleportation ray be in order to snap to position.
  55171. * Default to 0.8 units (meters)
  55172. */
  55173. snapToPositionRadius?: number;
  55174. /**
  55175. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  55176. * If you want to support rotation, make sure your mesh has a direction indicator.
  55177. *
  55178. * When left untouched, the default mesh will be initialized.
  55179. */
  55180. teleportationTargetMesh?: AbstractMesh;
  55181. /**
  55182. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  55183. */
  55184. timeToTeleport?: number;
  55185. /**
  55186. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  55187. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  55188. */
  55189. useMainComponentOnly?: boolean;
  55190. /**
  55191. * Should meshes created here be added to a utility layer or the main scene
  55192. */
  55193. useUtilityLayer?: boolean;
  55194. /**
  55195. * Babylon XR Input class for controller
  55196. */
  55197. xrInput: WebXRInput;
  55198. /**
  55199. * Meshes that the teleportation ray cannot go through
  55200. */
  55201. pickBlockerMeshes?: AbstractMesh[];
  55202. /**
  55203. * Should teleport work only on a specific hand?
  55204. */
  55205. forceHandedness?: XRHandedness;
  55206. /**
  55207. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  55208. */
  55209. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  55210. }
  55211. /**
  55212. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  55213. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  55214. * the input of the attached controllers.
  55215. */
  55216. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  55217. private _options;
  55218. private _controllers;
  55219. private _currentTeleportationControllerId;
  55220. private _floorMeshes;
  55221. private _quadraticBezierCurve;
  55222. private _selectionFeature;
  55223. private _snapToPositions;
  55224. private _snappedToPoint;
  55225. private _teleportationRingMaterial?;
  55226. private _tmpRay;
  55227. private _tmpVector;
  55228. private _tmpQuaternion;
  55229. /**
  55230. * The module's name
  55231. */
  55232. static readonly Name: string;
  55233. /**
  55234. * The (Babylon) version of this module.
  55235. * This is an integer representing the implementation version.
  55236. * This number does not correspond to the webxr specs version
  55237. */
  55238. static readonly Version: number;
  55239. /**
  55240. * Is movement backwards enabled
  55241. */
  55242. backwardsMovementEnabled: boolean;
  55243. /**
  55244. * Distance to travel when moving backwards
  55245. */
  55246. backwardsTeleportationDistance: number;
  55247. /**
  55248. * The distance from the user to the inspection point in the direction of the controller
  55249. * A higher number will allow the user to move further
  55250. * defaults to 5 (meters, in xr units)
  55251. */
  55252. parabolicCheckRadius: number;
  55253. /**
  55254. * Should the module support parabolic ray on top of direct ray
  55255. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  55256. * Very helpful when moving between floors / different heights
  55257. */
  55258. parabolicRayEnabled: boolean;
  55259. /**
  55260. * The second type of ray - straight line.
  55261. * Should it be enabled or should the parabolic line be the only one.
  55262. */
  55263. straightRayEnabled: boolean;
  55264. /**
  55265. * How much rotation should be applied when rotating right and left
  55266. */
  55267. rotationAngle: number;
  55268. private _rotationEnabled;
  55269. /**
  55270. * Is rotation enabled when moving forward?
  55271. * Disabling this feature will prevent the user from deciding the direction when teleporting
  55272. */
  55273. get rotationEnabled(): boolean;
  55274. /**
  55275. * Sets wether rotation is enabled or not
  55276. * @param enabled is rotation enabled when teleportation is shown
  55277. */
  55278. set rotationEnabled(enabled: boolean);
  55279. /**
  55280. * Exposes the currently set teleportation target mesh.
  55281. */
  55282. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  55283. /**
  55284. * constructs a new anchor system
  55285. * @param _xrSessionManager an instance of WebXRSessionManager
  55286. * @param _options configuration object for this feature
  55287. */
  55288. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  55289. /**
  55290. * Get the snapPointsOnly flag
  55291. */
  55292. get snapPointsOnly(): boolean;
  55293. /**
  55294. * Sets the snapPointsOnly flag
  55295. * @param snapToPoints should teleportation be exclusively to snap points
  55296. */
  55297. set snapPointsOnly(snapToPoints: boolean);
  55298. /**
  55299. * Add a new mesh to the floor meshes array
  55300. * @param mesh the mesh to use as floor mesh
  55301. */
  55302. addFloorMesh(mesh: AbstractMesh): void;
  55303. /**
  55304. * Add a new snap-to point to fix teleportation to this position
  55305. * @param newSnapPoint The new Snap-To point
  55306. */
  55307. addSnapPoint(newSnapPoint: Vector3): void;
  55308. attach(): boolean;
  55309. detach(): boolean;
  55310. dispose(): void;
  55311. /**
  55312. * Remove a mesh from the floor meshes array
  55313. * @param mesh the mesh to remove
  55314. */
  55315. removeFloorMesh(mesh: AbstractMesh): void;
  55316. /**
  55317. * Remove a mesh from the floor meshes array using its name
  55318. * @param name the mesh name to remove
  55319. */
  55320. removeFloorMeshByName(name: string): void;
  55321. /**
  55322. * 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
  55323. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  55324. * @returns was the point found and removed or not
  55325. */
  55326. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  55327. /**
  55328. * This function sets a selection feature that will be disabled when
  55329. * the forward ray is shown and will be reattached when hidden.
  55330. * This is used to remove the selection rays when moving.
  55331. * @param selectionFeature the feature to disable when forward movement is enabled
  55332. */
  55333. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  55334. protected _onXRFrame(_xrFrame: XRFrame): void;
  55335. private _attachController;
  55336. private _createDefaultTargetMesh;
  55337. private _detachController;
  55338. private _findClosestSnapPointWithRadius;
  55339. private _setTargetMeshPosition;
  55340. private _setTargetMeshVisibility;
  55341. private _showParabolicPath;
  55342. private _teleportForward;
  55343. }
  55344. }
  55345. declare module "babylonjs/XR/webXRDefaultExperience" {
  55346. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  55347. import { Scene } from "babylonjs/scene";
  55348. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  55349. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  55350. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  55351. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  55352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55353. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  55354. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  55355. /**
  55356. * Options for the default xr helper
  55357. */
  55358. export class WebXRDefaultExperienceOptions {
  55359. /**
  55360. * Enable or disable default UI to enter XR
  55361. */
  55362. disableDefaultUI?: boolean;
  55363. /**
  55364. * Should teleportation not initialize. defaults to false.
  55365. */
  55366. disableTeleportation?: boolean;
  55367. /**
  55368. * Floor meshes that will be used for teleport
  55369. */
  55370. floorMeshes?: Array<AbstractMesh>;
  55371. /**
  55372. * If set to true, the first frame will not be used to reset position
  55373. * The first frame is mainly used when copying transformation from the old camera
  55374. * Mainly used in AR
  55375. */
  55376. ignoreNativeCameraTransformation?: boolean;
  55377. /**
  55378. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  55379. */
  55380. inputOptions?: IWebXRInputOptions;
  55381. /**
  55382. * optional configuration for the output canvas
  55383. */
  55384. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  55385. /**
  55386. * optional UI options. This can be used among other to change session mode and reference space type
  55387. */
  55388. uiOptions?: WebXREnterExitUIOptions;
  55389. /**
  55390. * When loading teleportation and pointer select, use stable versions instead of latest.
  55391. */
  55392. useStablePlugins?: boolean;
  55393. /**
  55394. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  55395. */
  55396. renderingGroupId?: number;
  55397. /**
  55398. * A list of optional features to init the session with
  55399. * If set to true, all features we support will be added
  55400. */
  55401. optionalFeatures?: boolean | string[];
  55402. }
  55403. /**
  55404. * Default experience which provides a similar setup to the previous webVRExperience
  55405. */
  55406. export class WebXRDefaultExperience {
  55407. /**
  55408. * Base experience
  55409. */
  55410. baseExperience: WebXRExperienceHelper;
  55411. /**
  55412. * Enables ui for entering/exiting xr
  55413. */
  55414. enterExitUI: WebXREnterExitUI;
  55415. /**
  55416. * Input experience extension
  55417. */
  55418. input: WebXRInput;
  55419. /**
  55420. * Enables laser pointer and selection
  55421. */
  55422. pointerSelection: WebXRControllerPointerSelection;
  55423. /**
  55424. * Default target xr should render to
  55425. */
  55426. renderTarget: WebXRRenderTarget;
  55427. /**
  55428. * Enables teleportation
  55429. */
  55430. teleportation: WebXRMotionControllerTeleportation;
  55431. private constructor();
  55432. /**
  55433. * Creates the default xr experience
  55434. * @param scene scene
  55435. * @param options options for basic configuration
  55436. * @returns resulting WebXRDefaultExperience
  55437. */
  55438. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55439. /**
  55440. * DIsposes of the experience helper
  55441. */
  55442. dispose(): void;
  55443. }
  55444. }
  55445. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  55446. import { Observable } from "babylonjs/Misc/observable";
  55447. import { Nullable } from "babylonjs/types";
  55448. import { Camera } from "babylonjs/Cameras/camera";
  55449. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  55450. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55451. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  55452. import { Scene } from "babylonjs/scene";
  55453. import { Vector3 } from "babylonjs/Maths/math.vector";
  55454. import { Color3 } from "babylonjs/Maths/math.color";
  55455. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55457. import { Mesh } from "babylonjs/Meshes/mesh";
  55458. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  55459. import { EasingFunction } from "babylonjs/Animations/easing";
  55460. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  55461. import "babylonjs/Meshes/Builders/groundBuilder";
  55462. import "babylonjs/Meshes/Builders/torusBuilder";
  55463. import "babylonjs/Meshes/Builders/cylinderBuilder";
  55464. import "babylonjs/Gamepads/gamepadSceneComponent";
  55465. import "babylonjs/Animations/animatable";
  55466. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  55467. /**
  55468. * Options to modify the vr teleportation behavior.
  55469. */
  55470. export interface VRTeleportationOptions {
  55471. /**
  55472. * The name of the mesh which should be used as the teleportation floor. (default: null)
  55473. */
  55474. floorMeshName?: string;
  55475. /**
  55476. * A list of meshes to be used as the teleportation floor. (default: empty)
  55477. */
  55478. floorMeshes?: Mesh[];
  55479. /**
  55480. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  55481. */
  55482. teleportationMode?: number;
  55483. /**
  55484. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  55485. */
  55486. teleportationTime?: number;
  55487. /**
  55488. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  55489. */
  55490. teleportationSpeed?: number;
  55491. /**
  55492. * The easing function used in the animation or null for Linear. (default CircleEase)
  55493. */
  55494. easingFunction?: EasingFunction;
  55495. }
  55496. /**
  55497. * Options to modify the vr experience helper's behavior.
  55498. */
  55499. export interface VRExperienceHelperOptions extends WebVROptions {
  55500. /**
  55501. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  55502. */
  55503. createDeviceOrientationCamera?: boolean;
  55504. /**
  55505. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  55506. */
  55507. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  55508. /**
  55509. * Uses the main button on the controller to toggle the laser casted. (default: true)
  55510. */
  55511. laserToggle?: boolean;
  55512. /**
  55513. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  55514. */
  55515. floorMeshes?: Mesh[];
  55516. /**
  55517. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  55518. */
  55519. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  55520. /**
  55521. * Defines if WebXR should be used instead of WebVR (if available)
  55522. */
  55523. useXR?: boolean;
  55524. }
  55525. /**
  55526. * Event containing information after VR has been entered
  55527. */
  55528. export class OnAfterEnteringVRObservableEvent {
  55529. /**
  55530. * If entering vr was successful
  55531. */
  55532. success: boolean;
  55533. }
  55534. /**
  55535. * Helps to quickly add VR support to an existing scene.
  55536. * See https://doc.babylonjs.com/how_to/webvr_helper
  55537. */
  55538. export class VRExperienceHelper {
  55539. /** Options to modify the vr experience helper's behavior. */
  55540. webVROptions: VRExperienceHelperOptions;
  55541. private _scene;
  55542. private _position;
  55543. private _btnVR;
  55544. private _btnVRDisplayed;
  55545. private _webVRsupported;
  55546. private _webVRready;
  55547. private _webVRrequesting;
  55548. private _webVRpresenting;
  55549. private _hasEnteredVR;
  55550. private _fullscreenVRpresenting;
  55551. private _inputElement;
  55552. private _webVRCamera;
  55553. private _vrDeviceOrientationCamera;
  55554. private _deviceOrientationCamera;
  55555. private _existingCamera;
  55556. private _onKeyDown;
  55557. private _onVrDisplayPresentChange;
  55558. private _onVRDisplayChanged;
  55559. private _onVRRequestPresentStart;
  55560. private _onVRRequestPresentComplete;
  55561. /**
  55562. * 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)
  55563. */
  55564. enableGazeEvenWhenNoPointerLock: boolean;
  55565. /**
  55566. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  55567. */
  55568. exitVROnDoubleTap: boolean;
  55569. /**
  55570. * Observable raised right before entering VR.
  55571. */
  55572. onEnteringVRObservable: Observable<VRExperienceHelper>;
  55573. /**
  55574. * Observable raised when entering VR has completed.
  55575. */
  55576. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  55577. /**
  55578. * Observable raised when exiting VR.
  55579. */
  55580. onExitingVRObservable: Observable<VRExperienceHelper>;
  55581. /**
  55582. * Observable raised when controller mesh is loaded.
  55583. */
  55584. onControllerMeshLoadedObservable: Observable<WebVRController>;
  55585. /** Return this.onEnteringVRObservable
  55586. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  55587. */
  55588. get onEnteringVR(): Observable<VRExperienceHelper>;
  55589. /** Return this.onExitingVRObservable
  55590. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  55591. */
  55592. get onExitingVR(): Observable<VRExperienceHelper>;
  55593. /** Return this.onControllerMeshLoadedObservable
  55594. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  55595. */
  55596. get onControllerMeshLoaded(): Observable<WebVRController>;
  55597. private _rayLength;
  55598. private _useCustomVRButton;
  55599. private _teleportationRequested;
  55600. private _teleportActive;
  55601. private _floorMeshName;
  55602. private _floorMeshesCollection;
  55603. private _teleportationMode;
  55604. private _teleportationTime;
  55605. private _teleportationSpeed;
  55606. private _teleportationEasing;
  55607. private _rotationAllowed;
  55608. private _teleportBackwardsVector;
  55609. private _teleportationTarget;
  55610. private _isDefaultTeleportationTarget;
  55611. private _postProcessMove;
  55612. private _teleportationFillColor;
  55613. private _teleportationBorderColor;
  55614. private _rotationAngle;
  55615. private _haloCenter;
  55616. private _cameraGazer;
  55617. private _padSensibilityUp;
  55618. private _padSensibilityDown;
  55619. private _leftController;
  55620. private _rightController;
  55621. private _gazeColor;
  55622. private _laserColor;
  55623. private _pickedLaserColor;
  55624. private _pickedGazeColor;
  55625. /**
  55626. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  55627. */
  55628. onNewMeshSelected: Observable<AbstractMesh>;
  55629. /**
  55630. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  55631. * This observable will provide the mesh and the controller used to select the mesh
  55632. */
  55633. onMeshSelectedWithController: Observable<{
  55634. mesh: AbstractMesh;
  55635. controller: WebVRController;
  55636. }>;
  55637. /**
  55638. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  55639. */
  55640. onNewMeshPicked: Observable<PickingInfo>;
  55641. private _circleEase;
  55642. /**
  55643. * Observable raised before camera teleportation
  55644. */
  55645. onBeforeCameraTeleport: Observable<Vector3>;
  55646. /**
  55647. * Observable raised after camera teleportation
  55648. */
  55649. onAfterCameraTeleport: Observable<Vector3>;
  55650. /**
  55651. * Observable raised when current selected mesh gets unselected
  55652. */
  55653. onSelectedMeshUnselected: Observable<AbstractMesh>;
  55654. private _raySelectionPredicate;
  55655. /**
  55656. * To be optionaly changed by user to define custom ray selection
  55657. */
  55658. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55659. /**
  55660. * To be optionaly changed by user to define custom selection logic (after ray selection)
  55661. */
  55662. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  55663. /**
  55664. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  55665. */
  55666. teleportationEnabled: boolean;
  55667. private _defaultHeight;
  55668. private _teleportationInitialized;
  55669. private _interactionsEnabled;
  55670. private _interactionsRequested;
  55671. private _displayGaze;
  55672. private _displayLaserPointer;
  55673. /**
  55674. * The mesh used to display where the user is going to teleport.
  55675. */
  55676. get teleportationTarget(): Mesh;
  55677. /**
  55678. * Sets the mesh to be used to display where the user is going to teleport.
  55679. */
  55680. set teleportationTarget(value: Mesh);
  55681. /**
  55682. * 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
  55683. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  55684. * See https://doc.babylonjs.com/resources/baking_transformations
  55685. */
  55686. get gazeTrackerMesh(): Mesh;
  55687. set gazeTrackerMesh(value: Mesh);
  55688. /**
  55689. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  55690. */
  55691. updateGazeTrackerScale: boolean;
  55692. /**
  55693. * If the gaze trackers color should be updated when selecting meshes
  55694. */
  55695. updateGazeTrackerColor: boolean;
  55696. /**
  55697. * If the controller laser color should be updated when selecting meshes
  55698. */
  55699. updateControllerLaserColor: boolean;
  55700. /**
  55701. * The gaze tracking mesh corresponding to the left controller
  55702. */
  55703. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  55704. /**
  55705. * The gaze tracking mesh corresponding to the right controller
  55706. */
  55707. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  55708. /**
  55709. * If the ray of the gaze should be displayed.
  55710. */
  55711. get displayGaze(): boolean;
  55712. /**
  55713. * Sets if the ray of the gaze should be displayed.
  55714. */
  55715. set displayGaze(value: boolean);
  55716. /**
  55717. * If the ray of the LaserPointer should be displayed.
  55718. */
  55719. get displayLaserPointer(): boolean;
  55720. /**
  55721. * Sets if the ray of the LaserPointer should be displayed.
  55722. */
  55723. set displayLaserPointer(value: boolean);
  55724. /**
  55725. * The deviceOrientationCamera used as the camera when not in VR.
  55726. */
  55727. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  55728. /**
  55729. * Based on the current WebVR support, returns the current VR camera used.
  55730. */
  55731. get currentVRCamera(): Nullable<Camera>;
  55732. /**
  55733. * The webVRCamera which is used when in VR.
  55734. */
  55735. get webVRCamera(): WebVRFreeCamera;
  55736. /**
  55737. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  55738. */
  55739. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  55740. /**
  55741. * The html button that is used to trigger entering into VR.
  55742. */
  55743. get vrButton(): Nullable<HTMLButtonElement>;
  55744. private get _teleportationRequestInitiated();
  55745. /**
  55746. * Defines whether or not Pointer lock should be requested when switching to
  55747. * full screen.
  55748. */
  55749. requestPointerLockOnFullScreen: boolean;
  55750. /**
  55751. * If asking to force XR, this will be populated with the default xr experience
  55752. */
  55753. xr: WebXRDefaultExperience;
  55754. /**
  55755. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  55756. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  55757. */
  55758. xrTestDone: boolean;
  55759. /**
  55760. * Instantiates a VRExperienceHelper.
  55761. * Helps to quickly add VR support to an existing scene.
  55762. * @param scene The scene the VRExperienceHelper belongs to.
  55763. * @param webVROptions Options to modify the vr experience helper's behavior.
  55764. */
  55765. constructor(scene: Scene,
  55766. /** Options to modify the vr experience helper's behavior. */
  55767. webVROptions?: VRExperienceHelperOptions);
  55768. private completeVRInit;
  55769. private _onDefaultMeshLoaded;
  55770. private _onResize;
  55771. private _onFullscreenChange;
  55772. /**
  55773. * Gets a value indicating if we are currently in VR mode.
  55774. */
  55775. get isInVRMode(): boolean;
  55776. private onVrDisplayPresentChange;
  55777. private onVRDisplayChanged;
  55778. private moveButtonToBottomRight;
  55779. private displayVRButton;
  55780. private updateButtonVisibility;
  55781. private _cachedAngularSensibility;
  55782. /**
  55783. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  55784. * Otherwise, will use the fullscreen API.
  55785. */
  55786. enterVR(): void;
  55787. /**
  55788. * Attempt to exit VR, or fullscreen.
  55789. */
  55790. exitVR(): void;
  55791. /**
  55792. * The position of the vr experience helper.
  55793. */
  55794. get position(): Vector3;
  55795. /**
  55796. * Sets the position of the vr experience helper.
  55797. */
  55798. set position(value: Vector3);
  55799. /**
  55800. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  55801. */
  55802. enableInteractions(): void;
  55803. private get _noControllerIsActive();
  55804. private beforeRender;
  55805. private _isTeleportationFloor;
  55806. /**
  55807. * Adds a floor mesh to be used for teleportation.
  55808. * @param floorMesh the mesh to be used for teleportation.
  55809. */
  55810. addFloorMesh(floorMesh: Mesh): void;
  55811. /**
  55812. * Removes a floor mesh from being used for teleportation.
  55813. * @param floorMesh the mesh to be removed.
  55814. */
  55815. removeFloorMesh(floorMesh: Mesh): void;
  55816. /**
  55817. * Enables interactions and teleportation using the VR controllers and gaze.
  55818. * @param vrTeleportationOptions options to modify teleportation behavior.
  55819. */
  55820. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  55821. private _onNewGamepadConnected;
  55822. private _tryEnableInteractionOnController;
  55823. private _onNewGamepadDisconnected;
  55824. private _enableInteractionOnController;
  55825. private _checkTeleportWithRay;
  55826. private _checkRotate;
  55827. private _checkTeleportBackwards;
  55828. private _enableTeleportationOnController;
  55829. private _createTeleportationCircles;
  55830. private _displayTeleportationTarget;
  55831. private _hideTeleportationTarget;
  55832. private _rotateCamera;
  55833. private _moveTeleportationSelectorTo;
  55834. private _workingVector;
  55835. private _workingQuaternion;
  55836. private _workingMatrix;
  55837. /**
  55838. * Time Constant Teleportation Mode
  55839. */
  55840. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  55841. /**
  55842. * Speed Constant Teleportation Mode
  55843. */
  55844. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  55845. /**
  55846. * Teleports the users feet to the desired location
  55847. * @param location The location where the user's feet should be placed
  55848. */
  55849. teleportCamera(location: Vector3): void;
  55850. private _convertNormalToDirectionOfRay;
  55851. private _castRayAndSelectObject;
  55852. private _notifySelectedMeshUnselected;
  55853. /**
  55854. * Permanently set new colors for the laser pointer
  55855. * @param color the new laser color
  55856. * @param pickedColor the new laser color when picked mesh detected
  55857. */
  55858. setLaserColor(color: Color3, pickedColor?: Color3): void;
  55859. /**
  55860. * Set lighting enabled / disabled on the laser pointer of both controllers
  55861. * @param enabled should the lighting be enabled on the laser pointer
  55862. */
  55863. setLaserLightingState(enabled?: boolean): void;
  55864. /**
  55865. * Permanently set new colors for the gaze pointer
  55866. * @param color the new gaze color
  55867. * @param pickedColor the new gaze color when picked mesh detected
  55868. */
  55869. setGazeColor(color: Color3, pickedColor?: Color3): void;
  55870. /**
  55871. * Sets the color of the laser ray from the vr controllers.
  55872. * @param color new color for the ray.
  55873. */
  55874. changeLaserColor(color: Color3): void;
  55875. /**
  55876. * Sets the color of the ray from the vr headsets gaze.
  55877. * @param color new color for the ray.
  55878. */
  55879. changeGazeColor(color: Color3): void;
  55880. /**
  55881. * Exits VR and disposes of the vr experience helper
  55882. */
  55883. dispose(): void;
  55884. /**
  55885. * Gets the name of the VRExperienceHelper class
  55886. * @returns "VRExperienceHelper"
  55887. */
  55888. getClassName(): string;
  55889. }
  55890. }
  55891. declare module "babylonjs/Cameras/VR/index" {
  55892. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  55893. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  55894. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55895. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  55896. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  55897. export * from "babylonjs/Cameras/VR/webVRCamera";
  55898. }
  55899. declare module "babylonjs/Cameras/RigModes/index" {
  55900. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  55901. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  55902. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  55903. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  55904. }
  55905. declare module "babylonjs/Cameras/index" {
  55906. export * from "babylonjs/Cameras/Inputs/index";
  55907. export * from "babylonjs/Cameras/cameraInputsManager";
  55908. export * from "babylonjs/Cameras/camera";
  55909. export * from "babylonjs/Cameras/targetCamera";
  55910. export * from "babylonjs/Cameras/freeCamera";
  55911. export * from "babylonjs/Cameras/freeCameraInputsManager";
  55912. export * from "babylonjs/Cameras/touchCamera";
  55913. export * from "babylonjs/Cameras/arcRotateCamera";
  55914. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  55915. export * from "babylonjs/Cameras/deviceOrientationCamera";
  55916. export * from "babylonjs/Cameras/flyCamera";
  55917. export * from "babylonjs/Cameras/flyCameraInputsManager";
  55918. export * from "babylonjs/Cameras/followCamera";
  55919. export * from "babylonjs/Cameras/followCameraInputsManager";
  55920. export * from "babylonjs/Cameras/gamepadCamera";
  55921. export * from "babylonjs/Cameras/Stereoscopic/index";
  55922. export * from "babylonjs/Cameras/universalCamera";
  55923. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  55924. export * from "babylonjs/Cameras/VR/index";
  55925. export * from "babylonjs/Cameras/RigModes/index";
  55926. }
  55927. declare module "babylonjs/Collisions/index" {
  55928. export * from "babylonjs/Collisions/collider";
  55929. export * from "babylonjs/Collisions/collisionCoordinator";
  55930. export * from "babylonjs/Collisions/pickingInfo";
  55931. export * from "babylonjs/Collisions/intersectionInfo";
  55932. export * from "babylonjs/Collisions/meshCollisionData";
  55933. }
  55934. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  55935. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  55936. import { Vector3 } from "babylonjs/Maths/math.vector";
  55937. import { Ray } from "babylonjs/Culling/ray";
  55938. import { Plane } from "babylonjs/Maths/math.plane";
  55939. /**
  55940. * Contains an array of blocks representing the octree
  55941. */
  55942. export interface IOctreeContainer<T> {
  55943. /**
  55944. * Blocks within the octree
  55945. */
  55946. blocks: Array<OctreeBlock<T>>;
  55947. }
  55948. /**
  55949. * Class used to store a cell in an octree
  55950. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55951. */
  55952. export class OctreeBlock<T> {
  55953. /**
  55954. * Gets the content of the current block
  55955. */
  55956. entries: T[];
  55957. /**
  55958. * Gets the list of block children
  55959. */
  55960. blocks: Array<OctreeBlock<T>>;
  55961. private _depth;
  55962. private _maxDepth;
  55963. private _capacity;
  55964. private _minPoint;
  55965. private _maxPoint;
  55966. private _boundingVectors;
  55967. private _creationFunc;
  55968. /**
  55969. * Creates a new block
  55970. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  55971. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  55972. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55973. * @param depth defines the current depth of this block in the octree
  55974. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  55975. * @param creationFunc defines a callback to call when an element is added to the block
  55976. */
  55977. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  55978. /**
  55979. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55980. */
  55981. get capacity(): number;
  55982. /**
  55983. * Gets the minimum vector (in world space) of the block's bounding box
  55984. */
  55985. get minPoint(): Vector3;
  55986. /**
  55987. * Gets the maximum vector (in world space) of the block's bounding box
  55988. */
  55989. get maxPoint(): Vector3;
  55990. /**
  55991. * Add a new element to this block
  55992. * @param entry defines the element to add
  55993. */
  55994. addEntry(entry: T): void;
  55995. /**
  55996. * Remove an element from this block
  55997. * @param entry defines the element to remove
  55998. */
  55999. removeEntry(entry: T): void;
  56000. /**
  56001. * Add an array of elements to this block
  56002. * @param entries defines the array of elements to add
  56003. */
  56004. addEntries(entries: T[]): void;
  56005. /**
  56006. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  56007. * @param frustumPlanes defines the frustum planes to test
  56008. * @param selection defines the array to store current content if selection is positive
  56009. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56010. */
  56011. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56012. /**
  56013. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  56014. * @param sphereCenter defines the bounding sphere center
  56015. * @param sphereRadius defines the bounding sphere radius
  56016. * @param selection defines the array to store current content if selection is positive
  56017. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56018. */
  56019. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56020. /**
  56021. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  56022. * @param ray defines the ray to test with
  56023. * @param selection defines the array to store current content if selection is positive
  56024. */
  56025. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  56026. /**
  56027. * Subdivide the content into child blocks (this block will then be empty)
  56028. */
  56029. createInnerBlocks(): void;
  56030. /**
  56031. * @hidden
  56032. */
  56033. 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;
  56034. }
  56035. }
  56036. declare module "babylonjs/Culling/Octrees/octree" {
  56037. import { SmartArray } from "babylonjs/Misc/smartArray";
  56038. import { Vector3 } from "babylonjs/Maths/math.vector";
  56039. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56041. import { Ray } from "babylonjs/Culling/ray";
  56042. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  56043. import { Plane } from "babylonjs/Maths/math.plane";
  56044. /**
  56045. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  56046. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56047. */
  56048. export class Octree<T> {
  56049. /** 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.) */
  56050. maxDepth: number;
  56051. /**
  56052. * Blocks within the octree containing objects
  56053. */
  56054. blocks: Array<OctreeBlock<T>>;
  56055. /**
  56056. * Content stored in the octree
  56057. */
  56058. dynamicContent: T[];
  56059. private _maxBlockCapacity;
  56060. private _selectionContent;
  56061. private _creationFunc;
  56062. /**
  56063. * Creates a octree
  56064. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56065. * @param creationFunc function to be used to instatiate the octree
  56066. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  56067. * @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.)
  56068. */
  56069. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  56070. /** 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.) */
  56071. maxDepth?: number);
  56072. /**
  56073. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  56074. * @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);
  56075. * @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);
  56076. * @param entries meshes to be added to the octree blocks
  56077. */
  56078. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  56079. /**
  56080. * Adds a mesh to the octree
  56081. * @param entry Mesh to add to the octree
  56082. */
  56083. addMesh(entry: T): void;
  56084. /**
  56085. * Remove an element from the octree
  56086. * @param entry defines the element to remove
  56087. */
  56088. removeMesh(entry: T): void;
  56089. /**
  56090. * Selects an array of meshes within the frustum
  56091. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  56092. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  56093. * @returns array of meshes within the frustum
  56094. */
  56095. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  56096. /**
  56097. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  56098. * @param sphereCenter defines the bounding sphere center
  56099. * @param sphereRadius defines the bounding sphere radius
  56100. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56101. * @returns an array of objects that intersect the sphere
  56102. */
  56103. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  56104. /**
  56105. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  56106. * @param ray defines the ray to test with
  56107. * @returns array of intersected objects
  56108. */
  56109. intersectsRay(ray: Ray): SmartArray<T>;
  56110. /**
  56111. * Adds a mesh into the octree block if it intersects the block
  56112. */
  56113. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  56114. /**
  56115. * Adds a submesh into the octree block if it intersects the block
  56116. */
  56117. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  56118. }
  56119. }
  56120. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  56121. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  56122. import { Scene } from "babylonjs/scene";
  56123. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56125. import { Ray } from "babylonjs/Culling/ray";
  56126. import { Octree } from "babylonjs/Culling/Octrees/octree";
  56127. import { Collider } from "babylonjs/Collisions/collider";
  56128. module "babylonjs/scene" {
  56129. interface Scene {
  56130. /**
  56131. * @hidden
  56132. * Backing Filed
  56133. */
  56134. _selectionOctree: Octree<AbstractMesh>;
  56135. /**
  56136. * Gets the octree used to boost mesh selection (picking)
  56137. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56138. */
  56139. selectionOctree: Octree<AbstractMesh>;
  56140. /**
  56141. * Creates or updates the octree used to boost selection (picking)
  56142. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56143. * @param maxCapacity defines the maximum capacity per leaf
  56144. * @param maxDepth defines the maximum depth of the octree
  56145. * @returns an octree of AbstractMesh
  56146. */
  56147. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  56148. }
  56149. }
  56150. module "babylonjs/Meshes/abstractMesh" {
  56151. interface AbstractMesh {
  56152. /**
  56153. * @hidden
  56154. * Backing Field
  56155. */
  56156. _submeshesOctree: Octree<SubMesh>;
  56157. /**
  56158. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  56159. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  56160. * @param maxCapacity defines the maximum size of each block (64 by default)
  56161. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  56162. * @returns the new octree
  56163. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  56164. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56165. */
  56166. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  56167. }
  56168. }
  56169. /**
  56170. * Defines the octree scene component responsible to manage any octrees
  56171. * in a given scene.
  56172. */
  56173. export class OctreeSceneComponent {
  56174. /**
  56175. * The component name help to identify the component in the list of scene components.
  56176. */
  56177. readonly name: string;
  56178. /**
  56179. * The scene the component belongs to.
  56180. */
  56181. scene: Scene;
  56182. /**
  56183. * Indicates if the meshes have been checked to make sure they are isEnabled()
  56184. */
  56185. readonly checksIsEnabled: boolean;
  56186. /**
  56187. * Creates a new instance of the component for the given scene
  56188. * @param scene Defines the scene to register the component in
  56189. */
  56190. constructor(scene: Scene);
  56191. /**
  56192. * Registers the component in a given scene
  56193. */
  56194. register(): void;
  56195. /**
  56196. * Return the list of active meshes
  56197. * @returns the list of active meshes
  56198. */
  56199. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  56200. /**
  56201. * Return the list of active sub meshes
  56202. * @param mesh The mesh to get the candidates sub meshes from
  56203. * @returns the list of active sub meshes
  56204. */
  56205. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  56206. private _tempRay;
  56207. /**
  56208. * Return the list of sub meshes intersecting with a given local ray
  56209. * @param mesh defines the mesh to find the submesh for
  56210. * @param localRay defines the ray in local space
  56211. * @returns the list of intersecting sub meshes
  56212. */
  56213. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  56214. /**
  56215. * Return the list of sub meshes colliding with a collider
  56216. * @param mesh defines the mesh to find the submesh for
  56217. * @param collider defines the collider to evaluate the collision against
  56218. * @returns the list of colliding sub meshes
  56219. */
  56220. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  56221. /**
  56222. * Rebuilds the elements related to this component in case of
  56223. * context lost for instance.
  56224. */
  56225. rebuild(): void;
  56226. /**
  56227. * Disposes the component and the associated ressources.
  56228. */
  56229. dispose(): void;
  56230. }
  56231. }
  56232. declare module "babylonjs/Culling/Octrees/index" {
  56233. export * from "babylonjs/Culling/Octrees/octree";
  56234. export * from "babylonjs/Culling/Octrees/octreeBlock";
  56235. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  56236. }
  56237. declare module "babylonjs/Culling/index" {
  56238. export * from "babylonjs/Culling/boundingBox";
  56239. export * from "babylonjs/Culling/boundingInfo";
  56240. export * from "babylonjs/Culling/boundingSphere";
  56241. export * from "babylonjs/Culling/Octrees/index";
  56242. export * from "babylonjs/Culling/ray";
  56243. }
  56244. declare module "babylonjs/Gizmos/gizmo" {
  56245. import { Observer } from "babylonjs/Misc/observable";
  56246. import { Nullable } from "babylonjs/types";
  56247. import { IDisposable } from "babylonjs/scene";
  56248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56249. import { Mesh } from "babylonjs/Meshes/mesh";
  56250. import { Node } from "babylonjs/node";
  56251. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56252. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56253. import { PointerInfo } from "babylonjs/Events/pointerEvents";
  56254. /**
  56255. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  56256. */
  56257. export interface GizmoAxisCache {
  56258. /** Mesh used to runder the Gizmo */
  56259. gizmoMeshes: Mesh[];
  56260. /** Mesh used to detect user interaction with Gizmo */
  56261. colliderMeshes: Mesh[];
  56262. /** Material used to inicate color of gizmo mesh */
  56263. material: StandardMaterial;
  56264. /** Material used to inicate hover state of the Gizmo */
  56265. hoverMaterial: StandardMaterial;
  56266. /** Material used to inicate disabled state of the Gizmo */
  56267. disableMaterial: StandardMaterial;
  56268. /** Used to indicate Active state of the Gizmo */
  56269. active: boolean;
  56270. }
  56271. /**
  56272. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  56273. */
  56274. export class Gizmo implements IDisposable {
  56275. /** The utility layer the gizmo will be added to */
  56276. gizmoLayer: UtilityLayerRenderer;
  56277. /**
  56278. * The root mesh of the gizmo
  56279. */
  56280. _rootMesh: Mesh;
  56281. private _attachedMesh;
  56282. private _attachedNode;
  56283. /**
  56284. * Ratio for the scale of the gizmo (Default: 1)
  56285. */
  56286. protected _scaleRatio: number;
  56287. /**
  56288. * boolean updated by pointermove when a gizmo mesh is hovered
  56289. */
  56290. protected _isHovered: boolean;
  56291. /**
  56292. * Ratio for the scale of the gizmo (Default: 1)
  56293. */
  56294. set scaleRatio(value: number);
  56295. get scaleRatio(): number;
  56296. /**
  56297. * True when the mouse pointer is hovered a gizmo mesh
  56298. */
  56299. get isHovered(): boolean;
  56300. /**
  56301. * If a custom mesh has been set (Default: false)
  56302. */
  56303. protected _customMeshSet: boolean;
  56304. /**
  56305. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  56306. * * When set, interactions will be enabled
  56307. */
  56308. get attachedMesh(): Nullable<AbstractMesh>;
  56309. set attachedMesh(value: Nullable<AbstractMesh>);
  56310. /**
  56311. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  56312. * * When set, interactions will be enabled
  56313. */
  56314. get attachedNode(): Nullable<Node>;
  56315. set attachedNode(value: Nullable<Node>);
  56316. /**
  56317. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56318. * @param mesh The mesh to replace the default mesh of the gizmo
  56319. */
  56320. setCustomMesh(mesh: Mesh): void;
  56321. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  56322. /**
  56323. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  56324. */
  56325. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56326. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56327. /**
  56328. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  56329. */
  56330. updateGizmoPositionToMatchAttachedMesh: boolean;
  56331. /**
  56332. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  56333. */
  56334. updateScale: boolean;
  56335. protected _interactionsEnabled: boolean;
  56336. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56337. private _beforeRenderObserver;
  56338. private _tempQuaternion;
  56339. private _tempVector;
  56340. private _tempVector2;
  56341. private _tempMatrix1;
  56342. private _tempMatrix2;
  56343. private _rightHandtoLeftHandMatrix;
  56344. /**
  56345. * Creates a gizmo
  56346. * @param gizmoLayer The utility layer the gizmo will be added to
  56347. */
  56348. constructor(
  56349. /** The utility layer the gizmo will be added to */
  56350. gizmoLayer?: UtilityLayerRenderer);
  56351. /**
  56352. * Updates the gizmo to match the attached mesh's position/rotation
  56353. */
  56354. protected _update(): void;
  56355. /**
  56356. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  56357. * @param value Node, TransformNode or mesh
  56358. */
  56359. protected _matrixChanged(): void;
  56360. /**
  56361. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  56362. * @param gizmoLayer The utility layer the gizmo will be added to
  56363. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  56364. * @returns {Observer<PointerInfo>} pointerObserver
  56365. */
  56366. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  56367. /**
  56368. * Disposes of the gizmo
  56369. */
  56370. dispose(): void;
  56371. }
  56372. }
  56373. declare module "babylonjs/Gizmos/planeDragGizmo" {
  56374. import { Observable } from "babylonjs/Misc/observable";
  56375. import { Nullable } from "babylonjs/types";
  56376. import { Vector3 } from "babylonjs/Maths/math.vector";
  56377. import { Color3 } from "babylonjs/Maths/math.color";
  56378. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56379. import { Node } from "babylonjs/node";
  56380. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56381. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56382. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56383. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56384. import { Scene } from "babylonjs/scene";
  56385. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56386. /**
  56387. * Single plane drag gizmo
  56388. */
  56389. export class PlaneDragGizmo extends Gizmo {
  56390. /**
  56391. * Drag behavior responsible for the gizmos dragging interactions
  56392. */
  56393. dragBehavior: PointerDragBehavior;
  56394. private _pointerObserver;
  56395. /**
  56396. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56397. */
  56398. snapDistance: number;
  56399. /**
  56400. * Event that fires each time the gizmo snaps to a new location.
  56401. * * snapDistance is the the change in distance
  56402. */
  56403. onSnapObservable: Observable<{
  56404. snapDistance: number;
  56405. }>;
  56406. private _gizmoMesh;
  56407. private _coloredMaterial;
  56408. private _hoverMaterial;
  56409. private _disableMaterial;
  56410. private _isEnabled;
  56411. private _parent;
  56412. private _dragging;
  56413. /** @hidden */
  56414. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  56415. /**
  56416. * Creates a PlaneDragGizmo
  56417. * @param gizmoLayer The utility layer the gizmo will be added to
  56418. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  56419. * @param color The color of the gizmo
  56420. */
  56421. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  56422. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56423. /**
  56424. * If the gizmo is enabled
  56425. */
  56426. set isEnabled(value: boolean);
  56427. get isEnabled(): boolean;
  56428. /**
  56429. * Disposes of the gizmo
  56430. */
  56431. dispose(): void;
  56432. }
  56433. }
  56434. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  56435. import { Observable } from "babylonjs/Misc/observable";
  56436. import { Nullable } from "babylonjs/types";
  56437. import { Vector3 } from "babylonjs/Maths/math.vector";
  56438. import { Color3 } from "babylonjs/Maths/math.color";
  56439. import "babylonjs/Meshes/Builders/linesBuilder";
  56440. import { Node } from "babylonjs/node";
  56441. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56442. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56443. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56444. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56445. /**
  56446. * Single plane rotation gizmo
  56447. */
  56448. export class PlaneRotationGizmo extends Gizmo {
  56449. /**
  56450. * Drag behavior responsible for the gizmos dragging interactions
  56451. */
  56452. dragBehavior: PointerDragBehavior;
  56453. private _pointerObserver;
  56454. /**
  56455. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56456. */
  56457. snapDistance: number;
  56458. /**
  56459. * Event that fires each time the gizmo snaps to a new location.
  56460. * * snapDistance is the the change in distance
  56461. */
  56462. onSnapObservable: Observable<{
  56463. snapDistance: number;
  56464. }>;
  56465. private _isEnabled;
  56466. private _parent;
  56467. private _coloredMaterial;
  56468. private _hoverMaterial;
  56469. private _disableMaterial;
  56470. private _gizmoMesh;
  56471. private _rotationCircle;
  56472. private _dragging;
  56473. private static _CircleConstants;
  56474. /**
  56475. * Creates a PlaneRotationGizmo
  56476. * @param gizmoLayer The utility layer the gizmo will be added to
  56477. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56478. * @param color The color of the gizmo
  56479. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56480. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56481. * @param thickness display gizmo axis thickness
  56482. */
  56483. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56484. /** Create Geometry for Gizmo */
  56485. private _createGizmoMesh;
  56486. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56487. private setupRotationCircle;
  56488. private updateRotationPath;
  56489. private updateRotationCircle;
  56490. /**
  56491. * If the gizmo is enabled
  56492. */
  56493. set isEnabled(value: boolean);
  56494. get isEnabled(): boolean;
  56495. /**
  56496. * Disposes of the gizmo
  56497. */
  56498. dispose(): void;
  56499. }
  56500. }
  56501. declare module "babylonjs/Gizmos/rotationGizmo" {
  56502. import { Observable } from "babylonjs/Misc/observable";
  56503. import { Nullable } from "babylonjs/types";
  56504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56505. import { Mesh } from "babylonjs/Meshes/mesh";
  56506. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  56507. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  56508. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56509. import { Node } from "babylonjs/node";
  56510. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  56511. /**
  56512. * Gizmo that enables rotating a mesh along 3 axis
  56513. */
  56514. export class RotationGizmo extends Gizmo {
  56515. /**
  56516. * Internal gizmo used for interactions on the x axis
  56517. */
  56518. xGizmo: PlaneRotationGizmo;
  56519. /**
  56520. * Internal gizmo used for interactions on the y axis
  56521. */
  56522. yGizmo: PlaneRotationGizmo;
  56523. /**
  56524. * Internal gizmo used for interactions on the z axis
  56525. */
  56526. zGizmo: PlaneRotationGizmo;
  56527. /** Fires an event when any of it's sub gizmos are dragged */
  56528. onDragStartObservable: Observable<unknown>;
  56529. /** Fires an event when any of it's sub gizmos are released from dragging */
  56530. onDragEndObservable: Observable<unknown>;
  56531. private _meshAttached;
  56532. private _nodeAttached;
  56533. private _observables;
  56534. /** Node Caching for quick lookup */
  56535. private _gizmoAxisCache;
  56536. get attachedMesh(): Nullable<AbstractMesh>;
  56537. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56538. get attachedNode(): Nullable<Node>;
  56539. set attachedNode(node: Nullable<Node>);
  56540. protected _checkBillboardTransform(): void;
  56541. /**
  56542. * True when the mouse pointer is hovering a gizmo mesh
  56543. */
  56544. get isHovered(): boolean;
  56545. /**
  56546. * Creates a RotationGizmo
  56547. * @param gizmoLayer The utility layer the gizmo will be added to
  56548. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56549. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56550. * @param thickness display gizmo axis thickness
  56551. */
  56552. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  56553. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56554. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56555. /**
  56556. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56557. */
  56558. set snapDistance(value: number);
  56559. get snapDistance(): number;
  56560. /**
  56561. * Ratio for the scale of the gizmo (Default: 1)
  56562. */
  56563. set scaleRatio(value: number);
  56564. get scaleRatio(): number;
  56565. /**
  56566. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  56567. * @param mesh Axis gizmo mesh
  56568. * @param cache Gizmo axis definition used for reactive gizmo UI
  56569. */
  56570. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  56571. /**
  56572. * Disposes of the gizmo
  56573. */
  56574. dispose(): void;
  56575. /**
  56576. * CustomMeshes are not supported by this gizmo
  56577. * @param mesh The mesh to replace the default mesh of the gizmo
  56578. */
  56579. setCustomMesh(mesh: Mesh): void;
  56580. }
  56581. }
  56582. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  56583. import { Scene } from "babylonjs/scene";
  56584. import { Vector4 } from "babylonjs/Maths/math.vector";
  56585. import { Color4 } from "babylonjs/Maths/math.color";
  56586. import { Mesh } from "babylonjs/Meshes/mesh";
  56587. import { Nullable } from "babylonjs/types";
  56588. /**
  56589. * Class containing static functions to help procedurally build meshes
  56590. */
  56591. export class PolyhedronBuilder {
  56592. /**
  56593. * Creates a polyhedron mesh
  56594. * * 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
  56595. * * The parameter `size` (positive float, default 1) sets the polygon size
  56596. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56597. * * 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`
  56598. * * 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
  56599. * * 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)`)
  56600. * * 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
  56601. * * 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
  56602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56603. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56605. * @param name defines the name of the mesh
  56606. * @param options defines the options used to create the mesh
  56607. * @param scene defines the hosting scene
  56608. * @returns the polyhedron mesh
  56609. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56610. */
  56611. static CreatePolyhedron(name: string, options: {
  56612. type?: number;
  56613. size?: number;
  56614. sizeX?: number;
  56615. sizeY?: number;
  56616. sizeZ?: number;
  56617. custom?: any;
  56618. faceUV?: Vector4[];
  56619. faceColors?: Color4[];
  56620. flat?: boolean;
  56621. updatable?: boolean;
  56622. sideOrientation?: number;
  56623. frontUVs?: Vector4;
  56624. backUVs?: Vector4;
  56625. }, scene?: Nullable<Scene>): Mesh;
  56626. }
  56627. }
  56628. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  56629. import { Nullable } from "babylonjs/types";
  56630. import { Scene } from "babylonjs/scene";
  56631. import { Vector4 } from "babylonjs/Maths/math.vector";
  56632. import { Color4 } from "babylonjs/Maths/math.color";
  56633. import { Mesh } from "babylonjs/Meshes/mesh";
  56634. /**
  56635. * Class containing static functions to help procedurally build meshes
  56636. */
  56637. export class BoxBuilder {
  56638. /**
  56639. * Creates a box mesh
  56640. * * The parameter `size` sets the size (float) of each box side (default 1)
  56641. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56642. * * 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)
  56643. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56645. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56647. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56648. * @param name defines the name of the mesh
  56649. * @param options defines the options used to create the mesh
  56650. * @param scene defines the hosting scene
  56651. * @returns the box mesh
  56652. */
  56653. static CreateBox(name: string, options: {
  56654. size?: number;
  56655. width?: number;
  56656. height?: number;
  56657. depth?: number;
  56658. faceUV?: Vector4[];
  56659. faceColors?: Color4[];
  56660. sideOrientation?: number;
  56661. frontUVs?: Vector4;
  56662. backUVs?: Vector4;
  56663. wrap?: boolean;
  56664. topBaseAt?: number;
  56665. bottomBaseAt?: number;
  56666. updatable?: boolean;
  56667. }, scene?: Nullable<Scene>): Mesh;
  56668. }
  56669. }
  56670. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  56671. import { Observable } from "babylonjs/Misc/observable";
  56672. import { Nullable } from "babylonjs/types";
  56673. import { Vector3 } from "babylonjs/Maths/math.vector";
  56674. import { Node } from "babylonjs/node";
  56675. import { Mesh } from "babylonjs/Meshes/mesh";
  56676. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56677. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56678. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56679. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56680. import { Color3 } from "babylonjs/Maths/math.color";
  56681. /**
  56682. * Single axis scale gizmo
  56683. */
  56684. export class AxisScaleGizmo extends Gizmo {
  56685. /**
  56686. * Drag behavior responsible for the gizmos dragging interactions
  56687. */
  56688. dragBehavior: PointerDragBehavior;
  56689. private _pointerObserver;
  56690. /**
  56691. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56692. */
  56693. snapDistance: number;
  56694. /**
  56695. * Event that fires each time the gizmo snaps to a new location.
  56696. * * snapDistance is the the change in distance
  56697. */
  56698. onSnapObservable: Observable<{
  56699. snapDistance: number;
  56700. }>;
  56701. /**
  56702. * If the scaling operation should be done on all axis (default: false)
  56703. */
  56704. uniformScaling: boolean;
  56705. /**
  56706. * Custom sensitivity value for the drag strength
  56707. */
  56708. sensitivity: number;
  56709. private _isEnabled;
  56710. private _parent;
  56711. private _gizmoMesh;
  56712. private _coloredMaterial;
  56713. private _hoverMaterial;
  56714. private _disableMaterial;
  56715. private _dragging;
  56716. /**
  56717. * Creates an AxisScaleGizmo
  56718. * @param gizmoLayer The utility layer the gizmo will be added to
  56719. * @param dragAxis The axis which the gizmo will be able to scale on
  56720. * @param color The color of the gizmo
  56721. * @param thickness display gizmo axis thickness
  56722. */
  56723. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56724. /** Create Geometry for Gizmo */
  56725. private _createGizmoMesh;
  56726. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56727. /**
  56728. * If the gizmo is enabled
  56729. */
  56730. set isEnabled(value: boolean);
  56731. get isEnabled(): boolean;
  56732. /**
  56733. * Disposes of the gizmo
  56734. */
  56735. dispose(): void;
  56736. /**
  56737. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56738. * @param mesh The mesh to replace the default mesh of the gizmo
  56739. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56740. */
  56741. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56742. }
  56743. }
  56744. declare module "babylonjs/Gizmos/scaleGizmo" {
  56745. import { Observable } from "babylonjs/Misc/observable";
  56746. import { Nullable } from "babylonjs/types";
  56747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56748. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  56749. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  56750. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56751. import { Mesh } from "babylonjs/Meshes/mesh";
  56752. import { Node } from "babylonjs/node";
  56753. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  56754. /**
  56755. * Gizmo that enables scaling a mesh along 3 axis
  56756. */
  56757. export class ScaleGizmo extends Gizmo {
  56758. /**
  56759. * Internal gizmo used for interactions on the x axis
  56760. */
  56761. xGizmo: AxisScaleGizmo;
  56762. /**
  56763. * Internal gizmo used for interactions on the y axis
  56764. */
  56765. yGizmo: AxisScaleGizmo;
  56766. /**
  56767. * Internal gizmo used for interactions on the z axis
  56768. */
  56769. zGizmo: AxisScaleGizmo;
  56770. /**
  56771. * Internal gizmo used to scale all axis equally
  56772. */
  56773. uniformScaleGizmo: AxisScaleGizmo;
  56774. private _meshAttached;
  56775. private _nodeAttached;
  56776. private _snapDistance;
  56777. private _uniformScalingMesh;
  56778. private _octahedron;
  56779. private _sensitivity;
  56780. private _coloredMaterial;
  56781. private _hoverMaterial;
  56782. private _disableMaterial;
  56783. private _observables;
  56784. /** Node Caching for quick lookup */
  56785. private _gizmoAxisCache;
  56786. /** Fires an event when any of it's sub gizmos are dragged */
  56787. onDragStartObservable: Observable<unknown>;
  56788. /** Fires an event when any of it's sub gizmos are released from dragging */
  56789. onDragEndObservable: Observable<unknown>;
  56790. get attachedMesh(): Nullable<AbstractMesh>;
  56791. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56792. get attachedNode(): Nullable<Node>;
  56793. set attachedNode(node: Nullable<Node>);
  56794. /**
  56795. * True when the mouse pointer is hovering a gizmo mesh
  56796. */
  56797. get isHovered(): boolean;
  56798. /**
  56799. * Creates a ScaleGizmo
  56800. * @param gizmoLayer The utility layer the gizmo will be added to
  56801. * @param thickness display gizmo axis thickness
  56802. */
  56803. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  56804. /** Create Geometry for Gizmo */
  56805. private _createUniformScaleMesh;
  56806. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56807. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56808. /**
  56809. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56810. */
  56811. set snapDistance(value: number);
  56812. get snapDistance(): number;
  56813. /**
  56814. * Ratio for the scale of the gizmo (Default: 1)
  56815. */
  56816. set scaleRatio(value: number);
  56817. get scaleRatio(): number;
  56818. /**
  56819. * Sensitivity factor for dragging (Default: 1)
  56820. */
  56821. set sensitivity(value: number);
  56822. get sensitivity(): number;
  56823. /**
  56824. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  56825. * @param mesh Axis gizmo mesh
  56826. * @param cache Gizmo axis definition used for reactive gizmo UI
  56827. */
  56828. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  56829. /**
  56830. * Disposes of the gizmo
  56831. */
  56832. dispose(): void;
  56833. }
  56834. }
  56835. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  56836. import { Observable } from "babylonjs/Misc/observable";
  56837. import { Nullable } from "babylonjs/types";
  56838. import { Vector3 } from "babylonjs/Maths/math.vector";
  56839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56840. import { Mesh } from "babylonjs/Meshes/mesh";
  56841. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56842. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56843. import { Color3 } from "babylonjs/Maths/math.color";
  56844. import "babylonjs/Meshes/Builders/boxBuilder";
  56845. /**
  56846. * Bounding box gizmo
  56847. */
  56848. export class BoundingBoxGizmo extends Gizmo {
  56849. private _lineBoundingBox;
  56850. private _rotateSpheresParent;
  56851. private _scaleBoxesParent;
  56852. private _boundingDimensions;
  56853. private _renderObserver;
  56854. private _pointerObserver;
  56855. private _scaleDragSpeed;
  56856. private _tmpQuaternion;
  56857. private _tmpVector;
  56858. private _tmpRotationMatrix;
  56859. /**
  56860. * 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)
  56861. */
  56862. ignoreChildren: boolean;
  56863. /**
  56864. * 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)
  56865. */
  56866. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56867. /**
  56868. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56869. */
  56870. rotationSphereSize: number;
  56871. /**
  56872. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56873. */
  56874. scaleBoxSize: number;
  56875. /**
  56876. * 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)
  56877. */
  56878. fixedDragMeshScreenSize: boolean;
  56879. /**
  56880. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56881. */
  56882. fixedDragMeshScreenSizeDistanceFactor: number;
  56883. /**
  56884. * Fired when a rotation sphere or scale box is dragged
  56885. */
  56886. onDragStartObservable: Observable<{}>;
  56887. /**
  56888. * Fired when a scale box is dragged
  56889. */
  56890. onScaleBoxDragObservable: Observable<{}>;
  56891. /**
  56892. * Fired when a scale box drag is ended
  56893. */
  56894. onScaleBoxDragEndObservable: Observable<{}>;
  56895. /**
  56896. * Fired when a rotation sphere is dragged
  56897. */
  56898. onRotationSphereDragObservable: Observable<{}>;
  56899. /**
  56900. * Fired when a rotation sphere drag is ended
  56901. */
  56902. onRotationSphereDragEndObservable: Observable<{}>;
  56903. /**
  56904. * 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)
  56905. */
  56906. scalePivot: Nullable<Vector3>;
  56907. /**
  56908. * Mesh used as a pivot to rotate the attached node
  56909. */
  56910. private _anchorMesh;
  56911. private _existingMeshScale;
  56912. private _dragMesh;
  56913. private pointerDragBehavior;
  56914. private coloredMaterial;
  56915. private hoverColoredMaterial;
  56916. /**
  56917. * Sets the color of the bounding box gizmo
  56918. * @param color the color to set
  56919. */
  56920. setColor(color: Color3): void;
  56921. /**
  56922. * Creates an BoundingBoxGizmo
  56923. * @param gizmoLayer The utility layer the gizmo will be added to
  56924. * @param color The color of the gizmo
  56925. */
  56926. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56927. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  56928. private _selectNode;
  56929. /**
  56930. * Updates the bounding box information for the Gizmo
  56931. */
  56932. updateBoundingBox(): void;
  56933. private _updateRotationSpheres;
  56934. private _updateScaleBoxes;
  56935. /**
  56936. * Enables rotation on the specified axis and disables rotation on the others
  56937. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  56938. */
  56939. setEnabledRotationAxis(axis: string): void;
  56940. /**
  56941. * Enables/disables scaling
  56942. * @param enable if scaling should be enabled
  56943. * @param homogeneousScaling defines if scaling should only be homogeneous
  56944. */
  56945. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  56946. private _updateDummy;
  56947. /**
  56948. * Enables a pointer drag behavior on the bounding box of the gizmo
  56949. */
  56950. enableDragBehavior(): void;
  56951. /**
  56952. * Disposes of the gizmo
  56953. */
  56954. dispose(): void;
  56955. /**
  56956. * 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)
  56957. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56958. * @returns the bounding box mesh with the passed in mesh as a child
  56959. */
  56960. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56961. /**
  56962. * CustomMeshes are not supported by this gizmo
  56963. * @param mesh The mesh to replace the default mesh of the gizmo
  56964. */
  56965. setCustomMesh(mesh: Mesh): void;
  56966. }
  56967. }
  56968. declare module "babylonjs/Gizmos/gizmoManager" {
  56969. import { Observable } from "babylonjs/Misc/observable";
  56970. import { Nullable } from "babylonjs/types";
  56971. import { Scene, IDisposable } from "babylonjs/scene";
  56972. import { Node } from "babylonjs/node";
  56973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56974. import { Mesh } from "babylonjs/Meshes/mesh";
  56975. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56976. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  56977. import { GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  56978. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56979. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56980. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56981. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  56982. /**
  56983. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56984. */
  56985. export class GizmoManager implements IDisposable {
  56986. private scene;
  56987. /**
  56988. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56989. */
  56990. gizmos: {
  56991. positionGizmo: Nullable<PositionGizmo>;
  56992. rotationGizmo: Nullable<RotationGizmo>;
  56993. scaleGizmo: Nullable<ScaleGizmo>;
  56994. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56995. };
  56996. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56997. clearGizmoOnEmptyPointerEvent: boolean;
  56998. /** Fires an event when the manager is attached to a mesh */
  56999. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  57000. /** Fires an event when the manager is attached to a node */
  57001. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  57002. private _gizmosEnabled;
  57003. private _pointerObservers;
  57004. private _attachedMesh;
  57005. private _attachedNode;
  57006. private _boundingBoxColor;
  57007. private _defaultUtilityLayer;
  57008. private _defaultKeepDepthUtilityLayer;
  57009. private _thickness;
  57010. /** Node Caching for quick lookup */
  57011. private _gizmoAxisCache;
  57012. /**
  57013. * When bounding box gizmo is enabled, this can be used to track drag/end events
  57014. */
  57015. boundingBoxDragBehavior: SixDofDragBehavior;
  57016. /**
  57017. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  57018. */
  57019. attachableMeshes: Nullable<Array<AbstractMesh>>;
  57020. /**
  57021. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  57022. */
  57023. attachableNodes: Nullable<Array<Node>>;
  57024. /**
  57025. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  57026. */
  57027. usePointerToAttachGizmos: boolean;
  57028. /**
  57029. * Utility layer that the bounding box gizmo belongs to
  57030. */
  57031. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  57032. /**
  57033. * Utility layer that all gizmos besides bounding box belong to
  57034. */
  57035. get utilityLayer(): UtilityLayerRenderer;
  57036. /**
  57037. * True when the mouse pointer is hovering a gizmo mesh
  57038. */
  57039. get isHovered(): boolean;
  57040. /**
  57041. * Instatiates a gizmo manager
  57042. * @param scene the scene to overlay the gizmos on top of
  57043. * @param thickness display gizmo axis thickness
  57044. * @param utilityLayer the layer where gizmos are rendered
  57045. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  57046. */
  57047. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  57048. /**
  57049. * Subscribes to pointer down events, for attaching and detaching mesh
  57050. * @param scene The sceme layer the observer will be added to
  57051. */
  57052. private _attachToMeshPointerObserver;
  57053. /**
  57054. * Attaches a set of gizmos to the specified mesh
  57055. * @param mesh The mesh the gizmo's should be attached to
  57056. */
  57057. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57058. /**
  57059. * Attaches a set of gizmos to the specified node
  57060. * @param node The node the gizmo's should be attached to
  57061. */
  57062. attachToNode(node: Nullable<Node>): void;
  57063. /**
  57064. * If the position gizmo is enabled
  57065. */
  57066. set positionGizmoEnabled(value: boolean);
  57067. get positionGizmoEnabled(): boolean;
  57068. /**
  57069. * If the rotation gizmo is enabled
  57070. */
  57071. set rotationGizmoEnabled(value: boolean);
  57072. get rotationGizmoEnabled(): boolean;
  57073. /**
  57074. * If the scale gizmo is enabled
  57075. */
  57076. set scaleGizmoEnabled(value: boolean);
  57077. get scaleGizmoEnabled(): boolean;
  57078. /**
  57079. * If the boundingBox gizmo is enabled
  57080. */
  57081. set boundingBoxGizmoEnabled(value: boolean);
  57082. get boundingBoxGizmoEnabled(): boolean;
  57083. /**
  57084. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57085. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57086. */
  57087. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  57088. /**
  57089. * Disposes of the gizmo manager
  57090. */
  57091. dispose(): void;
  57092. }
  57093. }
  57094. declare module "babylonjs/Gizmos/positionGizmo" {
  57095. import { Observable } from "babylonjs/Misc/observable";
  57096. import { Nullable } from "babylonjs/types";
  57097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57098. import { Node } from "babylonjs/node";
  57099. import { Mesh } from "babylonjs/Meshes/mesh";
  57100. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  57101. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  57102. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  57103. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  57104. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  57105. /**
  57106. * Gizmo that enables dragging a mesh along 3 axis
  57107. */
  57108. export class PositionGizmo extends Gizmo {
  57109. /**
  57110. * Internal gizmo used for interactions on the x axis
  57111. */
  57112. xGizmo: AxisDragGizmo;
  57113. /**
  57114. * Internal gizmo used for interactions on the y axis
  57115. */
  57116. yGizmo: AxisDragGizmo;
  57117. /**
  57118. * Internal gizmo used for interactions on the z axis
  57119. */
  57120. zGizmo: AxisDragGizmo;
  57121. /**
  57122. * Internal gizmo used for interactions on the yz plane
  57123. */
  57124. xPlaneGizmo: PlaneDragGizmo;
  57125. /**
  57126. * Internal gizmo used for interactions on the xz plane
  57127. */
  57128. yPlaneGizmo: PlaneDragGizmo;
  57129. /**
  57130. * Internal gizmo used for interactions on the xy plane
  57131. */
  57132. zPlaneGizmo: PlaneDragGizmo;
  57133. /**
  57134. * private variables
  57135. */
  57136. private _meshAttached;
  57137. private _nodeAttached;
  57138. private _snapDistance;
  57139. private _observables;
  57140. /** Node Caching for quick lookup */
  57141. private _gizmoAxisCache;
  57142. /** Fires an event when any of it's sub gizmos are dragged */
  57143. onDragStartObservable: Observable<unknown>;
  57144. /** Fires an event when any of it's sub gizmos are released from dragging */
  57145. onDragEndObservable: Observable<unknown>;
  57146. /**
  57147. * If set to true, planar drag is enabled
  57148. */
  57149. private _planarGizmoEnabled;
  57150. get attachedMesh(): Nullable<AbstractMesh>;
  57151. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57152. get attachedNode(): Nullable<Node>;
  57153. set attachedNode(node: Nullable<Node>);
  57154. /**
  57155. * True when the mouse pointer is hovering a gizmo mesh
  57156. */
  57157. get isHovered(): boolean;
  57158. /**
  57159. * Creates a PositionGizmo
  57160. * @param gizmoLayer The utility layer the gizmo will be added to
  57161. @param thickness display gizmo axis thickness
  57162. */
  57163. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57164. /**
  57165. * If the planar drag gizmo is enabled
  57166. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  57167. */
  57168. set planarGizmoEnabled(value: boolean);
  57169. get planarGizmoEnabled(): boolean;
  57170. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57171. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57172. /**
  57173. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57174. */
  57175. set snapDistance(value: number);
  57176. get snapDistance(): number;
  57177. /**
  57178. * Ratio for the scale of the gizmo (Default: 1)
  57179. */
  57180. set scaleRatio(value: number);
  57181. get scaleRatio(): number;
  57182. /**
  57183. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57184. * @param mesh Axis gizmo mesh
  57185. * @param cache Gizmo axis definition used for reactive gizmo UI
  57186. */
  57187. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57188. /**
  57189. * Disposes of the gizmo
  57190. */
  57191. dispose(): void;
  57192. /**
  57193. * CustomMeshes are not supported by this gizmo
  57194. * @param mesh The mesh to replace the default mesh of the gizmo
  57195. */
  57196. setCustomMesh(mesh: Mesh): void;
  57197. }
  57198. }
  57199. declare module "babylonjs/Gizmos/axisDragGizmo" {
  57200. import { Observable } from "babylonjs/Misc/observable";
  57201. import { Nullable } from "babylonjs/types";
  57202. import { Vector3 } from "babylonjs/Maths/math.vector";
  57203. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57204. import { Node } from "babylonjs/node";
  57205. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  57206. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  57207. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  57208. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  57209. import { Scene } from "babylonjs/scene";
  57210. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  57211. import { Color3 } from "babylonjs/Maths/math.color";
  57212. /**
  57213. * Single axis drag gizmo
  57214. */
  57215. export class AxisDragGizmo extends Gizmo {
  57216. /**
  57217. * Drag behavior responsible for the gizmos dragging interactions
  57218. */
  57219. dragBehavior: PointerDragBehavior;
  57220. private _pointerObserver;
  57221. /**
  57222. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57223. */
  57224. snapDistance: number;
  57225. /**
  57226. * Event that fires each time the gizmo snaps to a new location.
  57227. * * snapDistance is the the change in distance
  57228. */
  57229. onSnapObservable: Observable<{
  57230. snapDistance: number;
  57231. }>;
  57232. private _isEnabled;
  57233. private _parent;
  57234. private _gizmoMesh;
  57235. private _coloredMaterial;
  57236. private _hoverMaterial;
  57237. private _disableMaterial;
  57238. private _dragging;
  57239. /** @hidden */
  57240. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  57241. /** @hidden */
  57242. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  57243. /**
  57244. * Creates an AxisDragGizmo
  57245. * @param gizmoLayer The utility layer the gizmo will be added to
  57246. * @param dragAxis The axis which the gizmo will be able to drag on
  57247. * @param color The color of the gizmo
  57248. * @param thickness display gizmo axis thickness
  57249. */
  57250. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  57251. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57252. /**
  57253. * If the gizmo is enabled
  57254. */
  57255. set isEnabled(value: boolean);
  57256. get isEnabled(): boolean;
  57257. /**
  57258. * Disposes of the gizmo
  57259. */
  57260. dispose(): void;
  57261. }
  57262. }
  57263. declare module "babylonjs/Debug/axesViewer" {
  57264. import { Vector3 } from "babylonjs/Maths/math.vector";
  57265. import { Nullable } from "babylonjs/types";
  57266. import { Scene } from "babylonjs/scene";
  57267. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57268. /**
  57269. * The Axes viewer will show 3 axes in a specific point in space
  57270. */
  57271. export class AxesViewer {
  57272. private _xAxis;
  57273. private _yAxis;
  57274. private _zAxis;
  57275. private _scaleLinesFactor;
  57276. private _instanced;
  57277. /**
  57278. * Gets the hosting scene
  57279. */
  57280. scene: Nullable<Scene>;
  57281. /**
  57282. * Gets or sets a number used to scale line length
  57283. */
  57284. scaleLines: number;
  57285. /** Gets the node hierarchy used to render x-axis */
  57286. get xAxis(): TransformNode;
  57287. /** Gets the node hierarchy used to render y-axis */
  57288. get yAxis(): TransformNode;
  57289. /** Gets the node hierarchy used to render z-axis */
  57290. get zAxis(): TransformNode;
  57291. /**
  57292. * Creates a new AxesViewer
  57293. * @param scene defines the hosting scene
  57294. * @param scaleLines defines a number used to scale line length (1 by default)
  57295. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  57296. * @param xAxis defines the node hierarchy used to render the x-axis
  57297. * @param yAxis defines the node hierarchy used to render the y-axis
  57298. * @param zAxis defines the node hierarchy used to render the z-axis
  57299. */
  57300. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  57301. /**
  57302. * Force the viewer to update
  57303. * @param position defines the position of the viewer
  57304. * @param xaxis defines the x axis of the viewer
  57305. * @param yaxis defines the y axis of the viewer
  57306. * @param zaxis defines the z axis of the viewer
  57307. */
  57308. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  57309. /**
  57310. * Creates an instance of this axes viewer.
  57311. * @returns a new axes viewer with instanced meshes
  57312. */
  57313. createInstance(): AxesViewer;
  57314. /** Releases resources */
  57315. dispose(): void;
  57316. private static _SetRenderingGroupId;
  57317. }
  57318. }
  57319. declare module "babylonjs/Debug/boneAxesViewer" {
  57320. import { Nullable } from "babylonjs/types";
  57321. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  57322. import { Vector3 } from "babylonjs/Maths/math.vector";
  57323. import { Mesh } from "babylonjs/Meshes/mesh";
  57324. import { Bone } from "babylonjs/Bones/bone";
  57325. import { Scene } from "babylonjs/scene";
  57326. /**
  57327. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  57328. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  57329. */
  57330. export class BoneAxesViewer extends AxesViewer {
  57331. /**
  57332. * Gets or sets the target mesh where to display the axes viewer
  57333. */
  57334. mesh: Nullable<Mesh>;
  57335. /**
  57336. * Gets or sets the target bone where to display the axes viewer
  57337. */
  57338. bone: Nullable<Bone>;
  57339. /** Gets current position */
  57340. pos: Vector3;
  57341. /** Gets direction of X axis */
  57342. xaxis: Vector3;
  57343. /** Gets direction of Y axis */
  57344. yaxis: Vector3;
  57345. /** Gets direction of Z axis */
  57346. zaxis: Vector3;
  57347. /**
  57348. * Creates a new BoneAxesViewer
  57349. * @param scene defines the hosting scene
  57350. * @param bone defines the target bone
  57351. * @param mesh defines the target mesh
  57352. * @param scaleLines defines a scaling factor for line length (1 by default)
  57353. */
  57354. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  57355. /**
  57356. * Force the viewer to update
  57357. */
  57358. update(): void;
  57359. /** Releases resources */
  57360. dispose(): void;
  57361. }
  57362. }
  57363. declare module "babylonjs/Debug/debugLayer" {
  57364. import { Scene } from "babylonjs/scene";
  57365. /**
  57366. * Interface used to define scene explorer extensibility option
  57367. */
  57368. export interface IExplorerExtensibilityOption {
  57369. /**
  57370. * Define the option label
  57371. */
  57372. label: string;
  57373. /**
  57374. * Defines the action to execute on click
  57375. */
  57376. action: (entity: any) => void;
  57377. }
  57378. /**
  57379. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  57380. */
  57381. export interface IExplorerExtensibilityGroup {
  57382. /**
  57383. * Defines a predicate to test if a given type mut be extended
  57384. */
  57385. predicate: (entity: any) => boolean;
  57386. /**
  57387. * Gets the list of options added to a type
  57388. */
  57389. entries: IExplorerExtensibilityOption[];
  57390. }
  57391. /**
  57392. * Interface used to define the options to use to create the Inspector
  57393. */
  57394. export interface IInspectorOptions {
  57395. /**
  57396. * Display in overlay mode (default: false)
  57397. */
  57398. overlay?: boolean;
  57399. /**
  57400. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  57401. */
  57402. globalRoot?: HTMLElement;
  57403. /**
  57404. * Display the Scene explorer
  57405. */
  57406. showExplorer?: boolean;
  57407. /**
  57408. * Display the property inspector
  57409. */
  57410. showInspector?: boolean;
  57411. /**
  57412. * Display in embed mode (both panes on the right)
  57413. */
  57414. embedMode?: boolean;
  57415. /**
  57416. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  57417. */
  57418. handleResize?: boolean;
  57419. /**
  57420. * Allow the panes to popup (default: true)
  57421. */
  57422. enablePopup?: boolean;
  57423. /**
  57424. * Allow the panes to be closed by users (default: true)
  57425. */
  57426. enableClose?: boolean;
  57427. /**
  57428. * Optional list of extensibility entries
  57429. */
  57430. explorerExtensibility?: IExplorerExtensibilityGroup[];
  57431. /**
  57432. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  57433. */
  57434. inspectorURL?: string;
  57435. /**
  57436. * Optional initial tab (default to DebugLayerTab.Properties)
  57437. */
  57438. initialTab?: DebugLayerTab;
  57439. }
  57440. module "babylonjs/scene" {
  57441. interface Scene {
  57442. /**
  57443. * @hidden
  57444. * Backing field
  57445. */
  57446. _debugLayer: DebugLayer;
  57447. /**
  57448. * Gets the debug layer (aka Inspector) associated with the scene
  57449. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57450. */
  57451. debugLayer: DebugLayer;
  57452. }
  57453. }
  57454. /**
  57455. * Enum of inspector action tab
  57456. */
  57457. export enum DebugLayerTab {
  57458. /**
  57459. * Properties tag (default)
  57460. */
  57461. Properties = 0,
  57462. /**
  57463. * Debug tab
  57464. */
  57465. Debug = 1,
  57466. /**
  57467. * Statistics tab
  57468. */
  57469. Statistics = 2,
  57470. /**
  57471. * Tools tab
  57472. */
  57473. Tools = 3,
  57474. /**
  57475. * Settings tab
  57476. */
  57477. Settings = 4
  57478. }
  57479. /**
  57480. * The debug layer (aka Inspector) is the go to tool in order to better understand
  57481. * what is happening in your scene
  57482. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57483. */
  57484. export class DebugLayer {
  57485. /**
  57486. * Define the url to get the inspector script from.
  57487. * By default it uses the babylonjs CDN.
  57488. * @ignoreNaming
  57489. */
  57490. static InspectorURL: string;
  57491. private _scene;
  57492. private BJSINSPECTOR;
  57493. private _onPropertyChangedObservable?;
  57494. /**
  57495. * Observable triggered when a property is changed through the inspector.
  57496. */
  57497. get onPropertyChangedObservable(): any;
  57498. /**
  57499. * Instantiates a new debug layer.
  57500. * The debug layer (aka Inspector) is the go to tool in order to better understand
  57501. * what is happening in your scene
  57502. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57503. * @param scene Defines the scene to inspect
  57504. */
  57505. constructor(scene: Scene);
  57506. /** Creates the inspector window. */
  57507. private _createInspector;
  57508. /**
  57509. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  57510. * @param entity defines the entity to select
  57511. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  57512. */
  57513. select(entity: any, lineContainerTitles?: string | string[]): void;
  57514. /** Get the inspector from bundle or global */
  57515. private _getGlobalInspector;
  57516. /**
  57517. * Get if the inspector is visible or not.
  57518. * @returns true if visible otherwise, false
  57519. */
  57520. isVisible(): boolean;
  57521. /**
  57522. * Hide the inspector and close its window.
  57523. */
  57524. hide(): void;
  57525. /**
  57526. * Update the scene in the inspector
  57527. */
  57528. setAsActiveScene(): void;
  57529. /**
  57530. * Launch the debugLayer.
  57531. * @param config Define the configuration of the inspector
  57532. * @return a promise fulfilled when the debug layer is visible
  57533. */
  57534. show(config?: IInspectorOptions): Promise<DebugLayer>;
  57535. }
  57536. }
  57537. declare module "babylonjs/Debug/physicsViewer" {
  57538. import { Nullable } from "babylonjs/types";
  57539. import { Scene } from "babylonjs/scene";
  57540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57541. import { Mesh } from "babylonjs/Meshes/mesh";
  57542. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57543. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57544. /**
  57545. * Used to show the physics impostor around the specific mesh
  57546. */
  57547. export class PhysicsViewer {
  57548. /** @hidden */
  57549. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  57550. /** @hidden */
  57551. protected _meshes: Array<Nullable<AbstractMesh>>;
  57552. /** @hidden */
  57553. protected _scene: Nullable<Scene>;
  57554. /** @hidden */
  57555. protected _numMeshes: number;
  57556. /** @hidden */
  57557. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  57558. private _renderFunction;
  57559. private _utilityLayer;
  57560. private _debugBoxMesh;
  57561. private _debugSphereMesh;
  57562. private _debugCylinderMesh;
  57563. private _debugMaterial;
  57564. private _debugMeshMeshes;
  57565. /**
  57566. * Creates a new PhysicsViewer
  57567. * @param scene defines the hosting scene
  57568. */
  57569. constructor(scene: Scene);
  57570. /** @hidden */
  57571. protected _updateDebugMeshes(): void;
  57572. /**
  57573. * Renders a specified physic impostor
  57574. * @param impostor defines the impostor to render
  57575. * @param targetMesh defines the mesh represented by the impostor
  57576. * @returns the new debug mesh used to render the impostor
  57577. */
  57578. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  57579. /**
  57580. * Hides a specified physic impostor
  57581. * @param impostor defines the impostor to hide
  57582. */
  57583. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  57584. private _getDebugMaterial;
  57585. private _getDebugBoxMesh;
  57586. private _getDebugSphereMesh;
  57587. private _getDebugCylinderMesh;
  57588. private _getDebugMeshMesh;
  57589. private _getDebugMesh;
  57590. /** Releases all resources */
  57591. dispose(): void;
  57592. }
  57593. }
  57594. declare module "babylonjs/Debug/rayHelper" {
  57595. import { Nullable } from "babylonjs/types";
  57596. import { Ray } from "babylonjs/Culling/ray";
  57597. import { Vector3 } from "babylonjs/Maths/math.vector";
  57598. import { Color3 } from "babylonjs/Maths/math.color";
  57599. import { Scene } from "babylonjs/scene";
  57600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57601. import "babylonjs/Meshes/Builders/linesBuilder";
  57602. /**
  57603. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  57604. * in order to better appreciate the issue one might have.
  57605. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  57606. */
  57607. export class RayHelper {
  57608. /**
  57609. * Defines the ray we are currently tryin to visualize.
  57610. */
  57611. ray: Nullable<Ray>;
  57612. private _renderPoints;
  57613. private _renderLine;
  57614. private _renderFunction;
  57615. private _scene;
  57616. private _onAfterRenderObserver;
  57617. private _onAfterStepObserver;
  57618. private _attachedToMesh;
  57619. private _meshSpaceDirection;
  57620. private _meshSpaceOrigin;
  57621. /**
  57622. * Helper function to create a colored helper in a scene in one line.
  57623. * @param ray Defines the ray we are currently tryin to visualize
  57624. * @param scene Defines the scene the ray is used in
  57625. * @param color Defines the color we want to see the ray in
  57626. * @returns The newly created ray helper.
  57627. */
  57628. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  57629. /**
  57630. * Instantiate a new ray helper.
  57631. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  57632. * in order to better appreciate the issue one might have.
  57633. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  57634. * @param ray Defines the ray we are currently tryin to visualize
  57635. */
  57636. constructor(ray: Ray);
  57637. /**
  57638. * Shows the ray we are willing to debug.
  57639. * @param scene Defines the scene the ray needs to be rendered in
  57640. * @param color Defines the color the ray needs to be rendered in
  57641. */
  57642. show(scene: Scene, color?: Color3): void;
  57643. /**
  57644. * Hides the ray we are debugging.
  57645. */
  57646. hide(): void;
  57647. private _render;
  57648. /**
  57649. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  57650. * @param mesh Defines the mesh we want the helper attached to
  57651. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  57652. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  57653. * @param length Defines the length of the ray
  57654. */
  57655. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  57656. /**
  57657. * Detach the ray helper from the mesh it has previously been attached to.
  57658. */
  57659. detachFromMesh(): void;
  57660. private _updateToMesh;
  57661. /**
  57662. * Dispose the helper and release its associated resources.
  57663. */
  57664. dispose(): void;
  57665. }
  57666. }
  57667. declare module "babylonjs/Debug/ISkeletonViewer" {
  57668. import { Skeleton } from "babylonjs/Bones/skeleton";
  57669. import { Color3 } from "babylonjs/Maths/math.color";
  57670. /**
  57671. * Defines the options associated with the creation of a SkeletonViewer.
  57672. */
  57673. export interface ISkeletonViewerOptions {
  57674. /** Should the system pause animations before building the Viewer? */
  57675. pauseAnimations: boolean;
  57676. /** Should the system return the skeleton to rest before building? */
  57677. returnToRest: boolean;
  57678. /** public Display Mode of the Viewer */
  57679. displayMode: number;
  57680. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  57681. displayOptions: ISkeletonViewerDisplayOptions;
  57682. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  57683. computeBonesUsingShaders: boolean;
  57684. /** Flag ignore non weighted bones */
  57685. useAllBones: boolean;
  57686. }
  57687. /**
  57688. * Defines how to display the various bone meshes for the viewer.
  57689. */
  57690. export interface ISkeletonViewerDisplayOptions {
  57691. /** How far down to start tapering the bone spurs */
  57692. midStep?: number;
  57693. /** How big is the midStep? */
  57694. midStepFactor?: number;
  57695. /** Base for the Sphere Size */
  57696. sphereBaseSize?: number;
  57697. /** The ratio of the sphere to the longest bone in units */
  57698. sphereScaleUnit?: number;
  57699. /** Ratio for the Sphere Size */
  57700. sphereFactor?: number;
  57701. /** Whether a spur should attach its far end to the child bone position */
  57702. spurFollowsChild?: boolean;
  57703. /** Whether to show local axes or not */
  57704. showLocalAxes?: boolean;
  57705. /** Length of each local axis */
  57706. localAxesSize?: number;
  57707. }
  57708. /**
  57709. * Defines the constructor options for the BoneWeight Shader.
  57710. */
  57711. export interface IBoneWeightShaderOptions {
  57712. /** Skeleton to Map */
  57713. skeleton: Skeleton;
  57714. /** Colors for Uninfluenced bones */
  57715. colorBase?: Color3;
  57716. /** Colors for 0.0-0.25 Weight bones */
  57717. colorZero?: Color3;
  57718. /** Color for 0.25-0.5 Weight Influence */
  57719. colorQuarter?: Color3;
  57720. /** Color for 0.5-0.75 Weight Influence */
  57721. colorHalf?: Color3;
  57722. /** Color for 0.75-1 Weight Influence */
  57723. colorFull?: Color3;
  57724. /** Color for Zero Weight Influence */
  57725. targetBoneIndex?: number;
  57726. }
  57727. /**
  57728. * Simple structure of the gradient steps for the Color Map.
  57729. */
  57730. export interface ISkeletonMapShaderColorMapKnot {
  57731. /** Color of the Knot */
  57732. color: Color3;
  57733. /** Location of the Knot */
  57734. location: number;
  57735. }
  57736. /**
  57737. * Defines the constructor options for the SkeletonMap Shader.
  57738. */
  57739. export interface ISkeletonMapShaderOptions {
  57740. /** Skeleton to Map */
  57741. skeleton: Skeleton;
  57742. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  57743. colorMap?: ISkeletonMapShaderColorMapKnot[];
  57744. }
  57745. }
  57746. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57747. import { Nullable } from "babylonjs/types";
  57748. import { Scene } from "babylonjs/scene";
  57749. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57750. import { Color4 } from "babylonjs/Maths/math.color";
  57751. import { Mesh } from "babylonjs/Meshes/mesh";
  57752. /**
  57753. * Class containing static functions to help procedurally build meshes
  57754. */
  57755. export class RibbonBuilder {
  57756. /**
  57757. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57758. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57759. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57760. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57761. * * 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
  57762. * * 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
  57763. * * 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
  57764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57766. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57767. * * 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
  57768. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57769. * * 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
  57770. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57772. * @param name defines the name of the mesh
  57773. * @param options defines the options used to create the mesh
  57774. * @param scene defines the hosting scene
  57775. * @returns the ribbon mesh
  57776. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57777. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57778. */
  57779. static CreateRibbon(name: string, options: {
  57780. pathArray: Vector3[][];
  57781. closeArray?: boolean;
  57782. closePath?: boolean;
  57783. offset?: number;
  57784. updatable?: boolean;
  57785. sideOrientation?: number;
  57786. frontUVs?: Vector4;
  57787. backUVs?: Vector4;
  57788. instance?: Mesh;
  57789. invertUV?: boolean;
  57790. uvs?: Vector2[];
  57791. colors?: Color4[];
  57792. }, scene?: Nullable<Scene>): Mesh;
  57793. }
  57794. }
  57795. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57796. import { Nullable } from "babylonjs/types";
  57797. import { Scene } from "babylonjs/scene";
  57798. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57799. import { Mesh } from "babylonjs/Meshes/mesh";
  57800. /**
  57801. * Class containing static functions to help procedurally build meshes
  57802. */
  57803. export class ShapeBuilder {
  57804. /**
  57805. * 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.
  57806. * * 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.
  57807. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57808. * * 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.
  57809. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57810. * * 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
  57811. * * 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
  57812. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57813. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57814. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57815. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57817. * @param name defines the name of the mesh
  57818. * @param options defines the options used to create the mesh
  57819. * @param scene defines the hosting scene
  57820. * @returns the extruded shape mesh
  57821. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57822. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57823. */
  57824. static ExtrudeShape(name: string, options: {
  57825. shape: Vector3[];
  57826. path: Vector3[];
  57827. scale?: number;
  57828. rotation?: number;
  57829. cap?: number;
  57830. updatable?: boolean;
  57831. sideOrientation?: number;
  57832. frontUVs?: Vector4;
  57833. backUVs?: Vector4;
  57834. instance?: Mesh;
  57835. invertUV?: boolean;
  57836. }, scene?: Nullable<Scene>): Mesh;
  57837. /**
  57838. * Creates an custom extruded shape mesh.
  57839. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57840. * * 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.
  57841. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57842. * * 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
  57843. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57844. * * 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
  57845. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57846. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57847. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57848. * * 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
  57849. * * 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
  57850. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57852. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57853. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57855. * @param name defines the name of the mesh
  57856. * @param options defines the options used to create the mesh
  57857. * @param scene defines the hosting scene
  57858. * @returns the custom extruded shape mesh
  57859. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57860. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57861. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57862. */
  57863. static ExtrudeShapeCustom(name: string, options: {
  57864. shape: Vector3[];
  57865. path: Vector3[];
  57866. scaleFunction?: any;
  57867. rotationFunction?: any;
  57868. ribbonCloseArray?: boolean;
  57869. ribbonClosePath?: boolean;
  57870. cap?: number;
  57871. updatable?: boolean;
  57872. sideOrientation?: number;
  57873. frontUVs?: Vector4;
  57874. backUVs?: Vector4;
  57875. instance?: Mesh;
  57876. invertUV?: boolean;
  57877. }, scene?: Nullable<Scene>): Mesh;
  57878. private static _ExtrudeShapeGeneric;
  57879. }
  57880. }
  57881. declare module "babylonjs/Debug/skeletonViewer" {
  57882. import { Color3 } from "babylonjs/Maths/math.color";
  57883. import { Scene } from "babylonjs/scene";
  57884. import { Nullable } from "babylonjs/types";
  57885. import { Skeleton } from "babylonjs/Bones/skeleton";
  57886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57887. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  57888. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  57889. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  57890. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  57891. /**
  57892. * Class used to render a debug view of a given skeleton
  57893. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  57894. */
  57895. export class SkeletonViewer {
  57896. /** defines the skeleton to render */
  57897. skeleton: Skeleton;
  57898. /** defines the mesh attached to the skeleton */
  57899. mesh: AbstractMesh;
  57900. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  57901. autoUpdateBonesMatrices: boolean;
  57902. /** defines the rendering group id to use with the viewer */
  57903. renderingGroupId: number;
  57904. /** is the options for the viewer */
  57905. options: Partial<ISkeletonViewerOptions>;
  57906. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  57907. static readonly DISPLAY_LINES: number;
  57908. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  57909. static readonly DISPLAY_SPHERES: number;
  57910. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  57911. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  57912. /** public static method to create a BoneWeight Shader
  57913. * @param options The constructor options
  57914. * @param scene The scene that the shader is scoped to
  57915. * @returns The created ShaderMaterial
  57916. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  57917. */
  57918. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  57919. /** public static method to create a BoneWeight Shader
  57920. * @param options The constructor options
  57921. * @param scene The scene that the shader is scoped to
  57922. * @returns The created ShaderMaterial
  57923. */
  57924. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  57925. /** private static method to create a BoneWeight Shader
  57926. * @param size The size of the buffer to create (usually the bone count)
  57927. * @param colorMap The gradient data to generate
  57928. * @param scene The scene that the shader is scoped to
  57929. * @returns an Array of floats from the color gradient values
  57930. */
  57931. private static _CreateBoneMapColorBuffer;
  57932. /** If SkeletonViewer scene scope. */
  57933. private _scene;
  57934. /** Gets or sets the color used to render the skeleton */
  57935. color: Color3;
  57936. /** Array of the points of the skeleton fo the line view. */
  57937. private _debugLines;
  57938. /** The SkeletonViewers Mesh. */
  57939. private _debugMesh;
  57940. /** The local axes Meshes. */
  57941. private _localAxes;
  57942. /** If SkeletonViewer is enabled. */
  57943. private _isEnabled;
  57944. /** If SkeletonViewer is ready. */
  57945. private _ready;
  57946. /** SkeletonViewer render observable. */
  57947. private _obs;
  57948. /** The Utility Layer to render the gizmos in. */
  57949. private _utilityLayer;
  57950. private _boneIndices;
  57951. /** Gets the Scene. */
  57952. get scene(): Scene;
  57953. /** Gets the utilityLayer. */
  57954. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  57955. /** Checks Ready Status. */
  57956. get isReady(): Boolean;
  57957. /** Sets Ready Status. */
  57958. set ready(value: boolean);
  57959. /** Gets the debugMesh */
  57960. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  57961. /** Sets the debugMesh */
  57962. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  57963. /** Gets the displayMode */
  57964. get displayMode(): number;
  57965. /** Sets the displayMode */
  57966. set displayMode(value: number);
  57967. /**
  57968. * Creates a new SkeletonViewer
  57969. * @param skeleton defines the skeleton to render
  57970. * @param mesh defines the mesh attached to the skeleton
  57971. * @param scene defines the hosting scene
  57972. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  57973. * @param renderingGroupId defines the rendering group id to use with the viewer
  57974. * @param options All of the extra constructor options for the SkeletonViewer
  57975. */
  57976. constructor(
  57977. /** defines the skeleton to render */
  57978. skeleton: Skeleton,
  57979. /** defines the mesh attached to the skeleton */
  57980. mesh: AbstractMesh,
  57981. /** The Scene scope*/
  57982. scene: Scene,
  57983. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  57984. autoUpdateBonesMatrices?: boolean,
  57985. /** defines the rendering group id to use with the viewer */
  57986. renderingGroupId?: number,
  57987. /** is the options for the viewer */
  57988. options?: Partial<ISkeletonViewerOptions>);
  57989. /** The Dynamic bindings for the update functions */
  57990. private _bindObs;
  57991. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  57992. update(): void;
  57993. /** Gets or sets a boolean indicating if the viewer is enabled */
  57994. set isEnabled(value: boolean);
  57995. get isEnabled(): boolean;
  57996. private _getBonePosition;
  57997. private _getLinesForBonesWithLength;
  57998. private _getLinesForBonesNoLength;
  57999. /** function to revert the mesh and scene back to the initial state. */
  58000. private _revert;
  58001. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  58002. private _getAbsoluteBindPoseToRef;
  58003. /** function to build and bind sphere joint points and spur bone representations. */
  58004. private _buildSpheresAndSpurs;
  58005. private _buildLocalAxes;
  58006. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  58007. private _displayLinesUpdate;
  58008. /** Changes the displayMode of the skeleton viewer
  58009. * @param mode The displayMode numerical value
  58010. */
  58011. changeDisplayMode(mode: number): void;
  58012. /** Sets a display option of the skeleton viewer
  58013. *
  58014. * | Option | Type | Default | Description |
  58015. * | ---------------- | ------- | ------- | ----------- |
  58016. * | 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`. |
  58017. * | 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`. |
  58018. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58019. * | 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`. |
  58020. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  58021. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  58022. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  58023. *
  58024. * @param option String of the option name
  58025. * @param value The numerical option value
  58026. */
  58027. changeDisplayOptions(option: string, value: number): void;
  58028. /** Release associated resources */
  58029. dispose(): void;
  58030. }
  58031. }
  58032. declare module "babylonjs/Debug/index" {
  58033. export * from "babylonjs/Debug/axesViewer";
  58034. export * from "babylonjs/Debug/boneAxesViewer";
  58035. export * from "babylonjs/Debug/debugLayer";
  58036. export * from "babylonjs/Debug/physicsViewer";
  58037. export * from "babylonjs/Debug/rayHelper";
  58038. export * from "babylonjs/Debug/skeletonViewer";
  58039. export * from "babylonjs/Debug/ISkeletonViewer";
  58040. }
  58041. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  58042. /**
  58043. * Enum for Device Types
  58044. */
  58045. export enum DeviceType {
  58046. /** Generic */
  58047. Generic = 0,
  58048. /** Keyboard */
  58049. Keyboard = 1,
  58050. /** Mouse */
  58051. Mouse = 2,
  58052. /** Touch Pointers */
  58053. Touch = 3,
  58054. /** PS4 Dual Shock */
  58055. DualShock = 4,
  58056. /** Xbox */
  58057. Xbox = 5,
  58058. /** Switch Controller */
  58059. Switch = 6
  58060. }
  58061. /**
  58062. * Enum for All Pointers (Touch/Mouse)
  58063. */
  58064. export enum PointerInput {
  58065. /** Horizontal Axis */
  58066. Horizontal = 0,
  58067. /** Vertical Axis */
  58068. Vertical = 1,
  58069. /** Left Click or Touch */
  58070. LeftClick = 2,
  58071. /** Middle Click */
  58072. MiddleClick = 3,
  58073. /** Right Click */
  58074. RightClick = 4,
  58075. /** Browser Back */
  58076. BrowserBack = 5,
  58077. /** Browser Forward */
  58078. BrowserForward = 6
  58079. }
  58080. /**
  58081. * Enum for Dual Shock Gamepad
  58082. */
  58083. export enum DualShockInput {
  58084. /** Cross */
  58085. Cross = 0,
  58086. /** Circle */
  58087. Circle = 1,
  58088. /** Square */
  58089. Square = 2,
  58090. /** Triangle */
  58091. Triangle = 3,
  58092. /** L1 */
  58093. L1 = 4,
  58094. /** R1 */
  58095. R1 = 5,
  58096. /** L2 */
  58097. L2 = 6,
  58098. /** R2 */
  58099. R2 = 7,
  58100. /** Share */
  58101. Share = 8,
  58102. /** Options */
  58103. Options = 9,
  58104. /** L3 */
  58105. L3 = 10,
  58106. /** R3 */
  58107. R3 = 11,
  58108. /** DPadUp */
  58109. DPadUp = 12,
  58110. /** DPadDown */
  58111. DPadDown = 13,
  58112. /** DPadLeft */
  58113. DPadLeft = 14,
  58114. /** DRight */
  58115. DPadRight = 15,
  58116. /** Home */
  58117. Home = 16,
  58118. /** TouchPad */
  58119. TouchPad = 17,
  58120. /** LStickXAxis */
  58121. LStickXAxis = 18,
  58122. /** LStickYAxis */
  58123. LStickYAxis = 19,
  58124. /** RStickXAxis */
  58125. RStickXAxis = 20,
  58126. /** RStickYAxis */
  58127. RStickYAxis = 21
  58128. }
  58129. /**
  58130. * Enum for Xbox Gamepad
  58131. */
  58132. export enum XboxInput {
  58133. /** A */
  58134. A = 0,
  58135. /** B */
  58136. B = 1,
  58137. /** X */
  58138. X = 2,
  58139. /** Y */
  58140. Y = 3,
  58141. /** LB */
  58142. LB = 4,
  58143. /** RB */
  58144. RB = 5,
  58145. /** LT */
  58146. LT = 6,
  58147. /** RT */
  58148. RT = 7,
  58149. /** Back */
  58150. Back = 8,
  58151. /** Start */
  58152. Start = 9,
  58153. /** LS */
  58154. LS = 10,
  58155. /** RS */
  58156. RS = 11,
  58157. /** DPadUp */
  58158. DPadUp = 12,
  58159. /** DPadDown */
  58160. DPadDown = 13,
  58161. /** DPadLeft */
  58162. DPadLeft = 14,
  58163. /** DRight */
  58164. DPadRight = 15,
  58165. /** Home */
  58166. Home = 16,
  58167. /** LStickXAxis */
  58168. LStickXAxis = 17,
  58169. /** LStickYAxis */
  58170. LStickYAxis = 18,
  58171. /** RStickXAxis */
  58172. RStickXAxis = 19,
  58173. /** RStickYAxis */
  58174. RStickYAxis = 20
  58175. }
  58176. /**
  58177. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  58178. */
  58179. export enum SwitchInput {
  58180. /** B */
  58181. B = 0,
  58182. /** A */
  58183. A = 1,
  58184. /** Y */
  58185. Y = 2,
  58186. /** X */
  58187. X = 3,
  58188. /** L */
  58189. L = 4,
  58190. /** R */
  58191. R = 5,
  58192. /** ZL */
  58193. ZL = 6,
  58194. /** ZR */
  58195. ZR = 7,
  58196. /** Minus */
  58197. Minus = 8,
  58198. /** Plus */
  58199. Plus = 9,
  58200. /** LS */
  58201. LS = 10,
  58202. /** RS */
  58203. RS = 11,
  58204. /** DPadUp */
  58205. DPadUp = 12,
  58206. /** DPadDown */
  58207. DPadDown = 13,
  58208. /** DPadLeft */
  58209. DPadLeft = 14,
  58210. /** DRight */
  58211. DPadRight = 15,
  58212. /** Home */
  58213. Home = 16,
  58214. /** Capture */
  58215. Capture = 17,
  58216. /** LStickXAxis */
  58217. LStickXAxis = 18,
  58218. /** LStickYAxis */
  58219. LStickYAxis = 19,
  58220. /** RStickXAxis */
  58221. RStickXAxis = 20,
  58222. /** RStickYAxis */
  58223. RStickYAxis = 21
  58224. }
  58225. }
  58226. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  58227. import { Engine } from "babylonjs/Engines/engine";
  58228. import { IDisposable } from "babylonjs/scene";
  58229. import { Nullable } from "babylonjs/types";
  58230. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58231. /**
  58232. * This class will take all inputs from Keyboard, Pointer, and
  58233. * any Gamepads and provide a polling system that all devices
  58234. * will use. This class assumes that there will only be one
  58235. * pointer device and one keyboard.
  58236. */
  58237. export class DeviceInputSystem implements IDisposable {
  58238. /**
  58239. * Returns onDeviceConnected callback property
  58240. * @returns Callback with function to execute when a device is connected
  58241. */
  58242. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  58243. /**
  58244. * Sets callback function when a device is connected and executes against all connected devices
  58245. * @param callback Function to execute when a device is connected
  58246. */
  58247. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  58248. /**
  58249. * Callback to be triggered when a device is disconnected
  58250. */
  58251. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  58252. /**
  58253. * Callback to be triggered when event driven input is updated
  58254. */
  58255. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  58256. private _inputs;
  58257. private _gamepads;
  58258. private _keyboardActive;
  58259. private _pointerActive;
  58260. private _elementToAttachTo;
  58261. private _keyboardDownEvent;
  58262. private _keyboardUpEvent;
  58263. private _pointerMoveEvent;
  58264. private _pointerDownEvent;
  58265. private _pointerUpEvent;
  58266. private _gamepadConnectedEvent;
  58267. private _gamepadDisconnectedEvent;
  58268. private _onDeviceConnected;
  58269. private static _MAX_KEYCODES;
  58270. private static _MAX_POINTER_INPUTS;
  58271. private constructor();
  58272. /**
  58273. * Creates a new DeviceInputSystem instance
  58274. * @param engine Engine to pull input element from
  58275. * @returns The new instance
  58276. */
  58277. static Create(engine: Engine): DeviceInputSystem;
  58278. /**
  58279. * Checks for current device input value, given an id and input index
  58280. * @param deviceName Id of connected device
  58281. * @param inputIndex Index of device input
  58282. * @returns Current value of input
  58283. */
  58284. /**
  58285. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  58286. * @param deviceType Enum specifiying device type
  58287. * @param deviceSlot "Slot" or index that device is referenced in
  58288. * @param inputIndex Id of input to be checked
  58289. * @returns Current value of input
  58290. */
  58291. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  58292. /**
  58293. * Dispose of all the eventlisteners
  58294. */
  58295. dispose(): void;
  58296. /**
  58297. * Checks for existing connections to devices and register them, if necessary
  58298. * Currently handles gamepads and mouse
  58299. */
  58300. private _checkForConnectedDevices;
  58301. /**
  58302. * Add a gamepad to the DeviceInputSystem
  58303. * @param gamepad A single DOM Gamepad object
  58304. */
  58305. private _addGamePad;
  58306. /**
  58307. * Add pointer device to DeviceInputSystem
  58308. * @param deviceType Type of Pointer to add
  58309. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  58310. * @param currentX Current X at point of adding
  58311. * @param currentY Current Y at point of adding
  58312. */
  58313. private _addPointerDevice;
  58314. /**
  58315. * Add device and inputs to device array
  58316. * @param deviceType Enum specifiying device type
  58317. * @param deviceSlot "Slot" or index that device is referenced in
  58318. * @param numberOfInputs Number of input entries to create for given device
  58319. */
  58320. private _registerDevice;
  58321. /**
  58322. * Given a specific device name, remove that device from the device map
  58323. * @param deviceType Enum specifiying device type
  58324. * @param deviceSlot "Slot" or index that device is referenced in
  58325. */
  58326. private _unregisterDevice;
  58327. /**
  58328. * Handle all actions that come from keyboard interaction
  58329. */
  58330. private _handleKeyActions;
  58331. /**
  58332. * Handle all actions that come from pointer interaction
  58333. */
  58334. private _handlePointerActions;
  58335. /**
  58336. * Handle all actions that come from gamepad interaction
  58337. */
  58338. private _handleGamepadActions;
  58339. /**
  58340. * Update all non-event based devices with each frame
  58341. * @param deviceType Enum specifiying device type
  58342. * @param deviceSlot "Slot" or index that device is referenced in
  58343. * @param inputIndex Id of input to be checked
  58344. */
  58345. private _updateDevice;
  58346. /**
  58347. * Gets DeviceType from the device name
  58348. * @param deviceName Name of Device from DeviceInputSystem
  58349. * @returns DeviceType enum value
  58350. */
  58351. private _getGamepadDeviceType;
  58352. }
  58353. }
  58354. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  58355. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58356. /**
  58357. * Type to handle enforcement of inputs
  58358. */
  58359. 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;
  58360. }
  58361. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  58362. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  58363. import { Engine } from "babylonjs/Engines/engine";
  58364. import { IDisposable } from "babylonjs/scene";
  58365. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58366. import { Nullable } from "babylonjs/types";
  58367. import { Observable } from "babylonjs/Misc/observable";
  58368. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  58369. /**
  58370. * Class that handles all input for a specific device
  58371. */
  58372. export class DeviceSource<T extends DeviceType> {
  58373. /** Type of device */
  58374. readonly deviceType: DeviceType;
  58375. /** "Slot" or index that device is referenced in */
  58376. readonly deviceSlot: number;
  58377. /**
  58378. * Observable to handle device input changes per device
  58379. */
  58380. readonly onInputChangedObservable: Observable<{
  58381. inputIndex: DeviceInput<T>;
  58382. previousState: Nullable<number>;
  58383. currentState: Nullable<number>;
  58384. }>;
  58385. private readonly _deviceInputSystem;
  58386. /**
  58387. * Default Constructor
  58388. * @param deviceInputSystem Reference to DeviceInputSystem
  58389. * @param deviceType Type of device
  58390. * @param deviceSlot "Slot" or index that device is referenced in
  58391. */
  58392. constructor(deviceInputSystem: DeviceInputSystem,
  58393. /** Type of device */
  58394. deviceType: DeviceType,
  58395. /** "Slot" or index that device is referenced in */
  58396. deviceSlot?: number);
  58397. /**
  58398. * Get input for specific input
  58399. * @param inputIndex index of specific input on device
  58400. * @returns Input value from DeviceInputSystem
  58401. */
  58402. getInput(inputIndex: DeviceInput<T>): number;
  58403. }
  58404. /**
  58405. * Class to keep track of devices
  58406. */
  58407. export class DeviceSourceManager implements IDisposable {
  58408. /**
  58409. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  58410. */
  58411. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  58412. /**
  58413. * Observable to be triggered when after a device is disconnected
  58414. */
  58415. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  58416. private readonly _devices;
  58417. private readonly _firstDevice;
  58418. private readonly _deviceInputSystem;
  58419. /**
  58420. * Default Constructor
  58421. * @param engine engine to pull input element from
  58422. */
  58423. constructor(engine: Engine);
  58424. /**
  58425. * Gets a DeviceSource, given a type and slot
  58426. * @param deviceType Enum specifying device type
  58427. * @param deviceSlot "Slot" or index that device is referenced in
  58428. * @returns DeviceSource object
  58429. */
  58430. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  58431. /**
  58432. * Gets an array of DeviceSource objects for a given device type
  58433. * @param deviceType Enum specifying device type
  58434. * @returns Array of DeviceSource objects
  58435. */
  58436. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  58437. /**
  58438. * Returns a read-only list of all available devices
  58439. * @returns Read-only array with active devices
  58440. */
  58441. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  58442. /**
  58443. * Dispose of DeviceInputSystem and other parts
  58444. */
  58445. dispose(): void;
  58446. /**
  58447. * Function to add device name to device list
  58448. * @param deviceType Enum specifying device type
  58449. * @param deviceSlot "Slot" or index that device is referenced in
  58450. */
  58451. private _addDevice;
  58452. /**
  58453. * Function to remove device name to device list
  58454. * @param deviceType Enum specifying device type
  58455. * @param deviceSlot "Slot" or index that device is referenced in
  58456. */
  58457. private _removeDevice;
  58458. /**
  58459. * Updates array storing first connected device of each type
  58460. * @param type Type of Device
  58461. */
  58462. private _updateFirstDevices;
  58463. }
  58464. }
  58465. declare module "babylonjs/DeviceInput/index" {
  58466. export * from "babylonjs/DeviceInput/deviceInputSystem";
  58467. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58468. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  58469. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  58470. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  58471. }
  58472. declare module "babylonjs/Engines/nullEngine" {
  58473. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  58474. import { Engine } from "babylonjs/Engines/engine";
  58475. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  58476. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  58477. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58478. import { Effect } from "babylonjs/Materials/effect";
  58479. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  58480. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  58481. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  58482. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  58483. /**
  58484. * Options to create the null engine
  58485. */
  58486. export class NullEngineOptions {
  58487. /**
  58488. * Render width (Default: 512)
  58489. */
  58490. renderWidth: number;
  58491. /**
  58492. * Render height (Default: 256)
  58493. */
  58494. renderHeight: number;
  58495. /**
  58496. * Texture size (Default: 512)
  58497. */
  58498. textureSize: number;
  58499. /**
  58500. * If delta time between frames should be constant
  58501. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58502. */
  58503. deterministicLockstep: boolean;
  58504. /**
  58505. * Maximum about of steps between frames (Default: 4)
  58506. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58507. */
  58508. lockstepMaxSteps: number;
  58509. /**
  58510. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  58511. */
  58512. useHighPrecisionMatrix?: boolean;
  58513. }
  58514. /**
  58515. * The null engine class provides support for headless version of babylon.js.
  58516. * This can be used in server side scenario or for testing purposes
  58517. */
  58518. export class NullEngine extends Engine {
  58519. private _options;
  58520. /**
  58521. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  58522. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58523. * @returns true if engine is in deterministic lock step mode
  58524. */
  58525. isDeterministicLockStep(): boolean;
  58526. /**
  58527. * Gets the max steps when engine is running in deterministic lock step
  58528. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58529. * @returns the max steps
  58530. */
  58531. getLockstepMaxSteps(): number;
  58532. /**
  58533. * Gets the current hardware scaling level.
  58534. * By default the hardware scaling level is computed from the window device ratio.
  58535. * 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.
  58536. * @returns a number indicating the current hardware scaling level
  58537. */
  58538. getHardwareScalingLevel(): number;
  58539. constructor(options?: NullEngineOptions);
  58540. /**
  58541. * Creates a vertex buffer
  58542. * @param vertices the data for the vertex buffer
  58543. * @returns the new WebGL static buffer
  58544. */
  58545. createVertexBuffer(vertices: FloatArray): DataBuffer;
  58546. /**
  58547. * Creates a new index buffer
  58548. * @param indices defines the content of the index buffer
  58549. * @param updatable defines if the index buffer must be updatable
  58550. * @returns a new webGL buffer
  58551. */
  58552. createIndexBuffer(indices: IndicesArray): DataBuffer;
  58553. /**
  58554. * Clear the current render buffer or the current render target (if any is set up)
  58555. * @param color defines the color to use
  58556. * @param backBuffer defines if the back buffer must be cleared
  58557. * @param depth defines if the depth buffer must be cleared
  58558. * @param stencil defines if the stencil buffer must be cleared
  58559. */
  58560. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  58561. /**
  58562. * Gets the current render width
  58563. * @param useScreen defines if screen size must be used (or the current render target if any)
  58564. * @returns a number defining the current render width
  58565. */
  58566. getRenderWidth(useScreen?: boolean): number;
  58567. /**
  58568. * Gets the current render height
  58569. * @param useScreen defines if screen size must be used (or the current render target if any)
  58570. * @returns a number defining the current render height
  58571. */
  58572. getRenderHeight(useScreen?: boolean): number;
  58573. /**
  58574. * Set the WebGL's viewport
  58575. * @param viewport defines the viewport element to be used
  58576. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  58577. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  58578. */
  58579. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  58580. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  58581. /**
  58582. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  58583. * @param pipelineContext defines the pipeline context to use
  58584. * @param uniformsNames defines the list of uniform names
  58585. * @returns an array of webGL uniform locations
  58586. */
  58587. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  58588. /**
  58589. * Gets the lsit of active attributes for a given webGL program
  58590. * @param pipelineContext defines the pipeline context to use
  58591. * @param attributesNames defines the list of attribute names to get
  58592. * @returns an array of indices indicating the offset of each attribute
  58593. */
  58594. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  58595. /**
  58596. * Binds an effect to the webGL context
  58597. * @param effect defines the effect to bind
  58598. */
  58599. bindSamplers(effect: Effect): void;
  58600. /**
  58601. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  58602. * @param effect defines the effect to activate
  58603. */
  58604. enableEffect(effect: Effect): void;
  58605. /**
  58606. * Set various states to the webGL context
  58607. * @param culling defines backface culling state
  58608. * @param zOffset defines the value to apply to zOffset (0 by default)
  58609. * @param force defines if states must be applied even if cache is up to date
  58610. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  58611. */
  58612. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  58613. /**
  58614. * Set the value of an uniform to an array of int32
  58615. * @param uniform defines the webGL uniform location where to store the value
  58616. * @param array defines the array of int32 to store
  58617. * @returns true if value was set
  58618. */
  58619. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58620. /**
  58621. * Set the value of an uniform to an array of int32 (stored as vec2)
  58622. * @param uniform defines the webGL uniform location where to store the value
  58623. * @param array defines the array of int32 to store
  58624. * @returns true if value was set
  58625. */
  58626. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58627. /**
  58628. * Set the value of an uniform to an array of int32 (stored as vec3)
  58629. * @param uniform defines the webGL uniform location where to store the value
  58630. * @param array defines the array of int32 to store
  58631. * @returns true if value was set
  58632. */
  58633. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58634. /**
  58635. * Set the value of an uniform to an array of int32 (stored as vec4)
  58636. * @param uniform defines the webGL uniform location where to store the value
  58637. * @param array defines the array of int32 to store
  58638. * @returns true if value was set
  58639. */
  58640. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58641. /**
  58642. * Set the value of an uniform to an array of float32
  58643. * @param uniform defines the webGL uniform location where to store the value
  58644. * @param array defines the array of float32 to store
  58645. * @returns true if value was set
  58646. */
  58647. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58648. /**
  58649. * Set the value of an uniform to an array of float32 (stored as vec2)
  58650. * @param uniform defines the webGL uniform location where to store the value
  58651. * @param array defines the array of float32 to store
  58652. * @returns true if value was set
  58653. */
  58654. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58655. /**
  58656. * Set the value of an uniform to an array of float32 (stored as vec3)
  58657. * @param uniform defines the webGL uniform location where to store the value
  58658. * @param array defines the array of float32 to store
  58659. * @returns true if value was set
  58660. */
  58661. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58662. /**
  58663. * Set the value of an uniform to an array of float32 (stored as vec4)
  58664. * @param uniform defines the webGL uniform location where to store the value
  58665. * @param array defines the array of float32 to store
  58666. * @returns true if value was set
  58667. */
  58668. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58669. /**
  58670. * Set the value of an uniform to an array of number
  58671. * @param uniform defines the webGL uniform location where to store the value
  58672. * @param array defines the array of number to store
  58673. * @returns true if value was set
  58674. */
  58675. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  58676. /**
  58677. * Set the value of an uniform to an array of number (stored as vec2)
  58678. * @param uniform defines the webGL uniform location where to store the value
  58679. * @param array defines the array of number to store
  58680. * @returns true if value was set
  58681. */
  58682. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  58683. /**
  58684. * Set the value of an uniform to an array of number (stored as vec3)
  58685. * @param uniform defines the webGL uniform location where to store the value
  58686. * @param array defines the array of number to store
  58687. * @returns true if value was set
  58688. */
  58689. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  58690. /**
  58691. * Set the value of an uniform to an array of number (stored as vec4)
  58692. * @param uniform defines the webGL uniform location where to store the value
  58693. * @param array defines the array of number to store
  58694. * @returns true if value was set
  58695. */
  58696. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  58697. /**
  58698. * Set the value of an uniform to an array of float32 (stored as matrices)
  58699. * @param uniform defines the webGL uniform location where to store the value
  58700. * @param matrices defines the array of float32 to store
  58701. * @returns true if value was set
  58702. */
  58703. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  58704. /**
  58705. * Set the value of an uniform to a matrix (3x3)
  58706. * @param uniform defines the webGL uniform location where to store the value
  58707. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  58708. * @returns true if value was set
  58709. */
  58710. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58711. /**
  58712. * Set the value of an uniform to a matrix (2x2)
  58713. * @param uniform defines the webGL uniform location where to store the value
  58714. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  58715. * @returns true if value was set
  58716. */
  58717. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58718. /**
  58719. * Set the value of an uniform to a number (float)
  58720. * @param uniform defines the webGL uniform location where to store the value
  58721. * @param value defines the float number to store
  58722. * @returns true if value was set
  58723. */
  58724. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  58725. /**
  58726. * Set the value of an uniform to a vec2
  58727. * @param uniform defines the webGL uniform location where to store the value
  58728. * @param x defines the 1st component of the value
  58729. * @param y defines the 2nd component of the value
  58730. * @returns true if value was set
  58731. */
  58732. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  58733. /**
  58734. * Set the value of an uniform to a vec3
  58735. * @param uniform defines the webGL uniform location where to store the value
  58736. * @param x defines the 1st component of the value
  58737. * @param y defines the 2nd component of the value
  58738. * @param z defines the 3rd component of the value
  58739. * @returns true if value was set
  58740. */
  58741. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  58742. /**
  58743. * Set the value of an uniform to a boolean
  58744. * @param uniform defines the webGL uniform location where to store the value
  58745. * @param bool defines the boolean to store
  58746. * @returns true if value was set
  58747. */
  58748. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  58749. /**
  58750. * Set the value of an uniform to a vec4
  58751. * @param uniform defines the webGL uniform location where to store the value
  58752. * @param x defines the 1st component of the value
  58753. * @param y defines the 2nd component of the value
  58754. * @param z defines the 3rd component of the value
  58755. * @param w defines the 4th component of the value
  58756. * @returns true if value was set
  58757. */
  58758. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  58759. /**
  58760. * Sets the current alpha mode
  58761. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  58762. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  58763. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58764. */
  58765. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  58766. /**
  58767. * Bind webGl buffers directly to the webGL context
  58768. * @param vertexBuffers defines the vertex buffer to bind
  58769. * @param indexBuffer defines the index buffer to bind
  58770. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  58771. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  58772. * @param effect defines the effect associated with the vertex buffer
  58773. */
  58774. bindBuffers(vertexBuffers: {
  58775. [key: string]: VertexBuffer;
  58776. }, indexBuffer: DataBuffer, effect: Effect): void;
  58777. /**
  58778. * Force the entire cache to be cleared
  58779. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  58780. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  58781. */
  58782. wipeCaches(bruteForce?: boolean): void;
  58783. /**
  58784. * Send a draw order
  58785. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  58786. * @param indexStart defines the starting index
  58787. * @param indexCount defines the number of index to draw
  58788. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58789. */
  58790. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  58791. /**
  58792. * Draw a list of indexed primitives
  58793. * @param fillMode defines the primitive to use
  58794. * @param indexStart defines the starting index
  58795. * @param indexCount defines the number of index to draw
  58796. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58797. */
  58798. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  58799. /**
  58800. * Draw a list of unindexed primitives
  58801. * @param fillMode defines the primitive to use
  58802. * @param verticesStart defines the index of first vertex to draw
  58803. * @param verticesCount defines the count of vertices to draw
  58804. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58805. */
  58806. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  58807. /** @hidden */
  58808. _createTexture(): WebGLTexture;
  58809. /** @hidden */
  58810. _releaseTexture(texture: InternalTexture): void;
  58811. /**
  58812. * Usually called from Texture.ts.
  58813. * Passed information to create a WebGLTexture
  58814. * @param urlArg defines a value which contains one of the following:
  58815. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  58816. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  58817. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  58818. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  58819. * @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)
  58820. * @param scene needed for loading to the correct scene
  58821. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  58822. * @param onLoad optional callback to be called upon successful completion
  58823. * @param onError optional callback to be called upon failure
  58824. * @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
  58825. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  58826. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  58827. * @param forcedExtension defines the extension to use to pick the right loader
  58828. * @param mimeType defines an optional mime type
  58829. * @returns a InternalTexture for assignment back into BABYLON.Texture
  58830. */
  58831. 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;
  58832. /**
  58833. * Creates a new render target texture
  58834. * @param size defines the size of the texture
  58835. * @param options defines the options used to create the texture
  58836. * @returns a new render target texture stored in an InternalTexture
  58837. */
  58838. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  58839. /**
  58840. * Update the sampling mode of a given texture
  58841. * @param samplingMode defines the required sampling mode
  58842. * @param texture defines the texture to update
  58843. */
  58844. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  58845. /**
  58846. * Binds the frame buffer to the specified texture.
  58847. * @param texture The texture to render to or null for the default canvas
  58848. * @param faceIndex The face of the texture to render to in case of cube texture
  58849. * @param requiredWidth The width of the target to render to
  58850. * @param requiredHeight The height of the target to render to
  58851. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  58852. * @param lodLevel defines le lod level to bind to the frame buffer
  58853. */
  58854. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  58855. /**
  58856. * Unbind the current render target texture from the webGL context
  58857. * @param texture defines the render target texture to unbind
  58858. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  58859. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  58860. */
  58861. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  58862. /**
  58863. * Creates a dynamic vertex buffer
  58864. * @param vertices the data for the dynamic vertex buffer
  58865. * @returns the new WebGL dynamic buffer
  58866. */
  58867. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  58868. /**
  58869. * Update the content of a dynamic texture
  58870. * @param texture defines the texture to update
  58871. * @param canvas defines the canvas containing the source
  58872. * @param invertY defines if data must be stored with Y axis inverted
  58873. * @param premulAlpha defines if alpha is stored as premultiplied
  58874. * @param format defines the format of the data
  58875. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  58876. */
  58877. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  58878. /**
  58879. * Gets a boolean indicating if all created effects are ready
  58880. * @returns true if all effects are ready
  58881. */
  58882. areAllEffectsReady(): boolean;
  58883. /**
  58884. * @hidden
  58885. * Get the current error code of the webGL context
  58886. * @returns the error code
  58887. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  58888. */
  58889. getError(): number;
  58890. /** @hidden */
  58891. _getUnpackAlignement(): number;
  58892. /** @hidden */
  58893. _unpackFlipY(value: boolean): void;
  58894. /**
  58895. * Update a dynamic index buffer
  58896. * @param indexBuffer defines the target index buffer
  58897. * @param indices defines the data to update
  58898. * @param offset defines the offset in the target index buffer where update should start
  58899. */
  58900. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  58901. /**
  58902. * Updates a dynamic vertex buffer.
  58903. * @param vertexBuffer the vertex buffer to update
  58904. * @param vertices the data used to update the vertex buffer
  58905. * @param byteOffset the byte offset of the data (optional)
  58906. * @param byteLength the byte length of the data (optional)
  58907. */
  58908. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  58909. /** @hidden */
  58910. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  58911. /** @hidden */
  58912. _bindTexture(channel: number, texture: InternalTexture): void;
  58913. protected _deleteBuffer(buffer: WebGLBuffer): void;
  58914. /**
  58915. * 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
  58916. */
  58917. releaseEffects(): void;
  58918. displayLoadingUI(): void;
  58919. hideLoadingUI(): void;
  58920. /** @hidden */
  58921. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58922. /** @hidden */
  58923. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58924. /** @hidden */
  58925. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58926. /** @hidden */
  58927. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  58928. }
  58929. }
  58930. declare module "babylonjs/Instrumentation/timeToken" {
  58931. import { Nullable } from "babylonjs/types";
  58932. /**
  58933. * @hidden
  58934. **/
  58935. export class _TimeToken {
  58936. _startTimeQuery: Nullable<WebGLQuery>;
  58937. _endTimeQuery: Nullable<WebGLQuery>;
  58938. _timeElapsedQuery: Nullable<WebGLQuery>;
  58939. _timeElapsedQueryEnded: boolean;
  58940. }
  58941. }
  58942. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  58943. import { Nullable, int } from "babylonjs/types";
  58944. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  58945. /** @hidden */
  58946. export class _OcclusionDataStorage {
  58947. /** @hidden */
  58948. occlusionInternalRetryCounter: number;
  58949. /** @hidden */
  58950. isOcclusionQueryInProgress: boolean;
  58951. /** @hidden */
  58952. isOccluded: boolean;
  58953. /** @hidden */
  58954. occlusionRetryCount: number;
  58955. /** @hidden */
  58956. occlusionType: number;
  58957. /** @hidden */
  58958. occlusionQueryAlgorithmType: number;
  58959. }
  58960. module "babylonjs/Engines/engine" {
  58961. interface Engine {
  58962. /**
  58963. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  58964. * @return the new query
  58965. */
  58966. createQuery(): WebGLQuery;
  58967. /**
  58968. * Delete and release a webGL query
  58969. * @param query defines the query to delete
  58970. * @return the current engine
  58971. */
  58972. deleteQuery(query: WebGLQuery): Engine;
  58973. /**
  58974. * Check if a given query has resolved and got its value
  58975. * @param query defines the query to check
  58976. * @returns true if the query got its value
  58977. */
  58978. isQueryResultAvailable(query: WebGLQuery): boolean;
  58979. /**
  58980. * Gets the value of a given query
  58981. * @param query defines the query to check
  58982. * @returns the value of the query
  58983. */
  58984. getQueryResult(query: WebGLQuery): number;
  58985. /**
  58986. * Initiates an occlusion query
  58987. * @param algorithmType defines the algorithm to use
  58988. * @param query defines the query to use
  58989. * @returns the current engine
  58990. * @see https://doc.babylonjs.com/features/occlusionquery
  58991. */
  58992. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  58993. /**
  58994. * Ends an occlusion query
  58995. * @see https://doc.babylonjs.com/features/occlusionquery
  58996. * @param algorithmType defines the algorithm to use
  58997. * @returns the current engine
  58998. */
  58999. endOcclusionQuery(algorithmType: number): Engine;
  59000. /**
  59001. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  59002. * Please note that only one query can be issued at a time
  59003. * @returns a time token used to track the time span
  59004. */
  59005. startTimeQuery(): Nullable<_TimeToken>;
  59006. /**
  59007. * Ends a time query
  59008. * @param token defines the token used to measure the time span
  59009. * @returns the time spent (in ns)
  59010. */
  59011. endTimeQuery(token: _TimeToken): int;
  59012. /** @hidden */
  59013. _currentNonTimestampToken: Nullable<_TimeToken>;
  59014. /** @hidden */
  59015. _createTimeQuery(): WebGLQuery;
  59016. /** @hidden */
  59017. _deleteTimeQuery(query: WebGLQuery): void;
  59018. /** @hidden */
  59019. _getGlAlgorithmType(algorithmType: number): number;
  59020. /** @hidden */
  59021. _getTimeQueryResult(query: WebGLQuery): any;
  59022. /** @hidden */
  59023. _getTimeQueryAvailability(query: WebGLQuery): any;
  59024. }
  59025. }
  59026. module "babylonjs/Meshes/abstractMesh" {
  59027. interface AbstractMesh {
  59028. /**
  59029. * Backing filed
  59030. * @hidden
  59031. */
  59032. __occlusionDataStorage: _OcclusionDataStorage;
  59033. /**
  59034. * Access property
  59035. * @hidden
  59036. */
  59037. _occlusionDataStorage: _OcclusionDataStorage;
  59038. /**
  59039. * 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.
  59040. * The default value is -1 which means don't break the query and wait till the result
  59041. * @see https://doc.babylonjs.com/features/occlusionquery
  59042. */
  59043. occlusionRetryCount: number;
  59044. /**
  59045. * 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:
  59046. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  59047. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  59048. * * 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.
  59049. * @see https://doc.babylonjs.com/features/occlusionquery
  59050. */
  59051. occlusionType: number;
  59052. /**
  59053. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  59054. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  59055. * * 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.
  59056. * @see https://doc.babylonjs.com/features/occlusionquery
  59057. */
  59058. occlusionQueryAlgorithmType: number;
  59059. /**
  59060. * 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
  59061. * @see https://doc.babylonjs.com/features/occlusionquery
  59062. */
  59063. isOccluded: boolean;
  59064. /**
  59065. * Flag to check the progress status of the query
  59066. * @see https://doc.babylonjs.com/features/occlusionquery
  59067. */
  59068. isOcclusionQueryInProgress: boolean;
  59069. }
  59070. }
  59071. }
  59072. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  59073. import { Nullable } from "babylonjs/types";
  59074. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  59075. /** @hidden */
  59076. export var _forceTransformFeedbackToBundle: boolean;
  59077. module "babylonjs/Engines/engine" {
  59078. interface Engine {
  59079. /**
  59080. * Creates a webGL transform feedback object
  59081. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  59082. * @returns the webGL transform feedback object
  59083. */
  59084. createTransformFeedback(): WebGLTransformFeedback;
  59085. /**
  59086. * Delete a webGL transform feedback object
  59087. * @param value defines the webGL transform feedback object to delete
  59088. */
  59089. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  59090. /**
  59091. * Bind a webGL transform feedback object to the webgl context
  59092. * @param value defines the webGL transform feedback object to bind
  59093. */
  59094. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  59095. /**
  59096. * Begins a transform feedback operation
  59097. * @param usePoints defines if points or triangles must be used
  59098. */
  59099. beginTransformFeedback(usePoints: boolean): void;
  59100. /**
  59101. * Ends a transform feedback operation
  59102. */
  59103. endTransformFeedback(): void;
  59104. /**
  59105. * Specify the varyings to use with transform feedback
  59106. * @param program defines the associated webGL program
  59107. * @param value defines the list of strings representing the varying names
  59108. */
  59109. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  59110. /**
  59111. * Bind a webGL buffer for a transform feedback operation
  59112. * @param value defines the webGL buffer to bind
  59113. */
  59114. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  59115. }
  59116. }
  59117. }
  59118. declare module "babylonjs/Engines/Extensions/engine.views" {
  59119. import { Camera } from "babylonjs/Cameras/camera";
  59120. import { Nullable } from "babylonjs/types";
  59121. /**
  59122. * Class used to define an additional view for the engine
  59123. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59124. */
  59125. export class EngineView {
  59126. /** Defines the canvas where to render the view */
  59127. target: HTMLCanvasElement;
  59128. /** Defines an optional camera used to render the view (will use active camera else) */
  59129. camera?: Camera;
  59130. }
  59131. module "babylonjs/Engines/engine" {
  59132. interface Engine {
  59133. /**
  59134. * Gets or sets the HTML element to use for attaching events
  59135. */
  59136. inputElement: Nullable<HTMLElement>;
  59137. /**
  59138. * Gets the current engine view
  59139. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59140. */
  59141. activeView: Nullable<EngineView>;
  59142. /** Gets or sets the list of views */
  59143. views: EngineView[];
  59144. /**
  59145. * Register a new child canvas
  59146. * @param canvas defines the canvas to register
  59147. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  59148. * @returns the associated view
  59149. */
  59150. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  59151. /**
  59152. * Remove a registered child canvas
  59153. * @param canvas defines the canvas to remove
  59154. * @returns the current engine
  59155. */
  59156. unRegisterView(canvas: HTMLCanvasElement): Engine;
  59157. }
  59158. }
  59159. }
  59160. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  59161. import { Nullable } from "babylonjs/types";
  59162. module "babylonjs/Engines/engine" {
  59163. interface Engine {
  59164. /** @hidden */
  59165. _excludedCompressedTextures: string[];
  59166. /** @hidden */
  59167. _textureFormatInUse: string;
  59168. /**
  59169. * Gets the list of texture formats supported
  59170. */
  59171. readonly texturesSupported: Array<string>;
  59172. /**
  59173. * Gets the texture format in use
  59174. */
  59175. readonly textureFormatInUse: Nullable<string>;
  59176. /**
  59177. * Set the compressed texture extensions or file names to skip.
  59178. *
  59179. * @param skippedFiles defines the list of those texture files you want to skip
  59180. * Example: [".dds", ".env", "myfile.png"]
  59181. */
  59182. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  59183. /**
  59184. * Set the compressed texture format to use, based on the formats you have, and the formats
  59185. * supported by the hardware / browser.
  59186. *
  59187. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  59188. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  59189. * to API arguments needed to compressed textures. This puts the burden on the container
  59190. * generator to house the arcane code for determining these for current & future formats.
  59191. *
  59192. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59193. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59194. *
  59195. * Note: The result of this call is not taken into account when a texture is base64.
  59196. *
  59197. * @param formatsAvailable defines the list of those format families you have created
  59198. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  59199. *
  59200. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  59201. * @returns The extension selected.
  59202. */
  59203. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  59204. }
  59205. }
  59206. }
  59207. declare module "babylonjs/Engines/Extensions/index" {
  59208. export * from "babylonjs/Engines/Extensions/engine.alpha";
  59209. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  59210. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  59211. export * from "babylonjs/Engines/Extensions/engine.multiview";
  59212. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  59213. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59214. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  59215. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  59216. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  59217. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  59218. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  59219. export * from "babylonjs/Engines/Extensions/engine.webVR";
  59220. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  59221. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  59222. export * from "babylonjs/Engines/Extensions/engine.views";
  59223. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  59224. import "babylonjs/Engines/Extensions/engine.textureSelector";
  59225. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  59226. }
  59227. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  59228. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59229. /** @hidden */
  59230. export var rgbdEncodePixelShader: {
  59231. name: string;
  59232. shader: string;
  59233. };
  59234. }
  59235. declare module "babylonjs/Misc/environmentTextureTools" {
  59236. import { Nullable } from "babylonjs/types";
  59237. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59238. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59239. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59240. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  59241. import "babylonjs/Engines/Extensions/engine.readTexture";
  59242. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  59243. import "babylonjs/Shaders/rgbdEncode.fragment";
  59244. import "babylonjs/Shaders/rgbdDecode.fragment";
  59245. /**
  59246. * Raw texture data and descriptor sufficient for WebGL texture upload
  59247. */
  59248. export interface EnvironmentTextureInfo {
  59249. /**
  59250. * Version of the environment map
  59251. */
  59252. version: number;
  59253. /**
  59254. * Width of image
  59255. */
  59256. width: number;
  59257. /**
  59258. * Irradiance information stored in the file.
  59259. */
  59260. irradiance: any;
  59261. /**
  59262. * Specular information stored in the file.
  59263. */
  59264. specular: any;
  59265. }
  59266. /**
  59267. * Defines One Image in the file. It requires only the position in the file
  59268. * as well as the length.
  59269. */
  59270. interface BufferImageData {
  59271. /**
  59272. * Length of the image data.
  59273. */
  59274. length: number;
  59275. /**
  59276. * Position of the data from the null terminator delimiting the end of the JSON.
  59277. */
  59278. position: number;
  59279. }
  59280. /**
  59281. * Defines the specular data enclosed in the file.
  59282. * This corresponds to the version 1 of the data.
  59283. */
  59284. export interface EnvironmentTextureSpecularInfoV1 {
  59285. /**
  59286. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  59287. */
  59288. specularDataPosition?: number;
  59289. /**
  59290. * This contains all the images data needed to reconstruct the cubemap.
  59291. */
  59292. mipmaps: Array<BufferImageData>;
  59293. /**
  59294. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  59295. */
  59296. lodGenerationScale: number;
  59297. }
  59298. /**
  59299. * Sets of helpers addressing the serialization and deserialization of environment texture
  59300. * stored in a BabylonJS env file.
  59301. * Those files are usually stored as .env files.
  59302. */
  59303. export class EnvironmentTextureTools {
  59304. /**
  59305. * Magic number identifying the env file.
  59306. */
  59307. private static _MagicBytes;
  59308. /**
  59309. * Gets the environment info from an env file.
  59310. * @param data The array buffer containing the .env bytes.
  59311. * @returns the environment file info (the json header) if successfully parsed.
  59312. */
  59313. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  59314. /**
  59315. * Creates an environment texture from a loaded cube texture.
  59316. * @param texture defines the cube texture to convert in env file
  59317. * @return a promise containing the environment data if succesfull.
  59318. */
  59319. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  59320. /**
  59321. * Creates a JSON representation of the spherical data.
  59322. * @param texture defines the texture containing the polynomials
  59323. * @return the JSON representation of the spherical info
  59324. */
  59325. private static _CreateEnvTextureIrradiance;
  59326. /**
  59327. * Creates the ArrayBufferViews used for initializing environment texture image data.
  59328. * @param data the image data
  59329. * @param info parameters that determine what views will be created for accessing the underlying buffer
  59330. * @return the views described by info providing access to the underlying buffer
  59331. */
  59332. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  59333. /**
  59334. * Uploads the texture info contained in the env file to the GPU.
  59335. * @param texture defines the internal texture to upload to
  59336. * @param data defines the data to load
  59337. * @param info defines the texture info retrieved through the GetEnvInfo method
  59338. * @returns a promise
  59339. */
  59340. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  59341. private static _OnImageReadyAsync;
  59342. /**
  59343. * Uploads the levels of image data to the GPU.
  59344. * @param texture defines the internal texture to upload to
  59345. * @param imageData defines the array buffer views of image data [mipmap][face]
  59346. * @returns a promise
  59347. */
  59348. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  59349. /**
  59350. * Uploads spherical polynomials information to the texture.
  59351. * @param texture defines the texture we are trying to upload the information to
  59352. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  59353. */
  59354. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  59355. /** @hidden */
  59356. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59357. }
  59358. }
  59359. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  59360. /**
  59361. * Class used to inline functions in shader code
  59362. */
  59363. export class ShaderCodeInliner {
  59364. private static readonly _RegexpFindFunctionNameAndType;
  59365. private _sourceCode;
  59366. private _functionDescr;
  59367. private _numMaxIterations;
  59368. /** Gets or sets the token used to mark the functions to inline */
  59369. inlineToken: string;
  59370. /** Gets or sets the debug mode */
  59371. debug: boolean;
  59372. /** Gets the code after the inlining process */
  59373. get code(): string;
  59374. /**
  59375. * Initializes the inliner
  59376. * @param sourceCode shader code source to inline
  59377. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  59378. */
  59379. constructor(sourceCode: string, numMaxIterations?: number);
  59380. /**
  59381. * Start the processing of the shader code
  59382. */
  59383. processCode(): void;
  59384. private _collectFunctions;
  59385. private _processInlining;
  59386. private _extractBetweenMarkers;
  59387. private _skipWhitespaces;
  59388. private _removeComments;
  59389. private _replaceFunctionCallsByCode;
  59390. private _findBackward;
  59391. private _escapeRegExp;
  59392. private _replaceNames;
  59393. }
  59394. }
  59395. declare module "babylonjs/Engines/nativeEngine" {
  59396. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  59397. import { Engine } from "babylonjs/Engines/engine";
  59398. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  59399. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59400. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59401. import { Effect } from "babylonjs/Materials/effect";
  59402. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  59403. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  59404. import { IColor4Like } from "babylonjs/Maths/math.like";
  59405. import { Scene } from "babylonjs/scene";
  59406. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  59407. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  59408. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  59409. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  59410. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  59411. /**
  59412. * Container for accessors for natively-stored mesh data buffers.
  59413. */
  59414. class NativeDataBuffer extends DataBuffer {
  59415. /**
  59416. * Accessor value used to identify/retrieve a natively-stored index buffer.
  59417. */
  59418. nativeIndexBuffer?: any;
  59419. /**
  59420. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  59421. */
  59422. nativeVertexBuffer?: any;
  59423. }
  59424. /** @hidden */
  59425. class NativeTexture extends InternalTexture {
  59426. getInternalTexture(): InternalTexture;
  59427. getViewCount(): number;
  59428. }
  59429. /** @hidden */
  59430. export class NativeEngine extends Engine {
  59431. private readonly _native;
  59432. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  59433. private readonly INVALID_HANDLE;
  59434. private _boundBuffersVertexArray;
  59435. private _currentDepthTest;
  59436. getHardwareScalingLevel(): number;
  59437. constructor();
  59438. dispose(): void;
  59439. /**
  59440. * Can be used to override the current requestAnimationFrame requester.
  59441. * @hidden
  59442. */
  59443. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  59444. /**
  59445. * Override default engine behavior.
  59446. * @param color
  59447. * @param backBuffer
  59448. * @param depth
  59449. * @param stencil
  59450. */
  59451. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  59452. /**
  59453. * Gets host document
  59454. * @returns the host document object
  59455. */
  59456. getHostDocument(): Nullable<Document>;
  59457. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59458. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  59459. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  59460. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  59461. [key: string]: VertexBuffer;
  59462. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59463. bindBuffers(vertexBuffers: {
  59464. [key: string]: VertexBuffer;
  59465. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59466. recordVertexArrayObject(vertexBuffers: {
  59467. [key: string]: VertexBuffer;
  59468. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  59469. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59470. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59471. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59472. /**
  59473. * Draw a list of indexed primitives
  59474. * @param fillMode defines the primitive to use
  59475. * @param indexStart defines the starting index
  59476. * @param indexCount defines the number of index to draw
  59477. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59478. */
  59479. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59480. /**
  59481. * Draw a list of unindexed primitives
  59482. * @param fillMode defines the primitive to use
  59483. * @param verticesStart defines the index of first vertex to draw
  59484. * @param verticesCount defines the count of vertices to draw
  59485. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59486. */
  59487. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59488. createPipelineContext(): IPipelineContext;
  59489. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  59490. /** @hidden */
  59491. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  59492. /** @hidden */
  59493. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  59494. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59495. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59496. protected _setProgram(program: WebGLProgram): void;
  59497. _releaseEffect(effect: Effect): void;
  59498. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  59499. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  59500. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  59501. bindSamplers(effect: Effect): void;
  59502. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  59503. getRenderWidth(useScreen?: boolean): number;
  59504. getRenderHeight(useScreen?: boolean): number;
  59505. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  59506. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  59507. /**
  59508. * Set the z offset to apply to current rendering
  59509. * @param value defines the offset to apply
  59510. */
  59511. setZOffset(value: number): void;
  59512. /**
  59513. * Gets the current value of the zOffset
  59514. * @returns the current zOffset state
  59515. */
  59516. getZOffset(): number;
  59517. /**
  59518. * Enable or disable depth buffering
  59519. * @param enable defines the state to set
  59520. */
  59521. setDepthBuffer(enable: boolean): void;
  59522. /**
  59523. * Gets a boolean indicating if depth writing is enabled
  59524. * @returns the current depth writing state
  59525. */
  59526. getDepthWrite(): boolean;
  59527. setDepthFunctionToGreater(): void;
  59528. setDepthFunctionToGreaterOrEqual(): void;
  59529. setDepthFunctionToLess(): void;
  59530. setDepthFunctionToLessOrEqual(): void;
  59531. /**
  59532. * Enable or disable depth writing
  59533. * @param enable defines the state to set
  59534. */
  59535. setDepthWrite(enable: boolean): void;
  59536. /**
  59537. * Enable or disable color writing
  59538. * @param enable defines the state to set
  59539. */
  59540. setColorWrite(enable: boolean): void;
  59541. /**
  59542. * Gets a boolean indicating if color writing is enabled
  59543. * @returns the current color writing state
  59544. */
  59545. getColorWrite(): boolean;
  59546. /**
  59547. * Sets alpha constants used by some alpha blending modes
  59548. * @param r defines the red component
  59549. * @param g defines the green component
  59550. * @param b defines the blue component
  59551. * @param a defines the alpha component
  59552. */
  59553. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  59554. /**
  59555. * Sets the current alpha mode
  59556. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  59557. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59558. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59559. */
  59560. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59561. /**
  59562. * Gets the current alpha mode
  59563. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59564. * @returns the current alpha mode
  59565. */
  59566. getAlphaMode(): number;
  59567. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  59568. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59569. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59570. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59571. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59572. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59573. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59574. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59575. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59576. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59577. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59578. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59579. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59580. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59581. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59582. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59583. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59584. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59585. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59586. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59587. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  59588. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  59589. wipeCaches(bruteForce?: boolean): void;
  59590. _createTexture(): WebGLTexture;
  59591. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  59592. /**
  59593. * Update the content of a dynamic texture
  59594. * @param texture defines the texture to update
  59595. * @param canvas defines the canvas containing the source
  59596. * @param invertY defines if data must be stored with Y axis inverted
  59597. * @param premulAlpha defines if alpha is stored as premultiplied
  59598. * @param format defines the format of the data
  59599. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  59600. */
  59601. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  59602. /**
  59603. * Usually called from Texture.ts.
  59604. * Passed information to create a WebGLTexture
  59605. * @param url defines a value which contains one of the following:
  59606. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59607. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59608. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59609. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59610. * @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)
  59611. * @param scene needed for loading to the correct scene
  59612. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59613. * @param onLoad optional callback to be called upon successful completion
  59614. * @param onError optional callback to be called upon failure
  59615. * @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
  59616. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59617. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59618. * @param forcedExtension defines the extension to use to pick the right loader
  59619. * @param mimeType defines an optional mime type
  59620. * @param loaderOptions options to be passed to the loader
  59621. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59622. */
  59623. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  59624. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  59625. _releaseFramebufferObjects(texture: InternalTexture): void;
  59626. /**
  59627. * Creates a cube texture
  59628. * @param rootUrl defines the url where the files to load is located
  59629. * @param scene defines the current scene
  59630. * @param files defines the list of files to load (1 per face)
  59631. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  59632. * @param onLoad defines an optional callback raised when the texture is loaded
  59633. * @param onError defines an optional callback raised if there is an issue to load the texture
  59634. * @param format defines the format of the data
  59635. * @param forcedExtension defines the extension to use to pick the right loader
  59636. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  59637. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59638. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59639. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  59640. * @returns the cube texture as an InternalTexture
  59641. */
  59642. 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;
  59643. createRenderTargetTexture(size: number | {
  59644. width: number;
  59645. height: number;
  59646. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  59647. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59648. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  59649. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  59650. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  59651. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  59652. /**
  59653. * Updates a dynamic vertex buffer.
  59654. * @param vertexBuffer the vertex buffer to update
  59655. * @param data the data used to update the vertex buffer
  59656. * @param byteOffset the byte offset of the data (optional)
  59657. * @param byteLength the byte length of the data (optional)
  59658. */
  59659. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  59660. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  59661. private _updateAnisotropicLevel;
  59662. private _getAddressMode;
  59663. /** @hidden */
  59664. _bindTexture(channel: number, texture: InternalTexture): void;
  59665. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  59666. releaseEffects(): void;
  59667. /** @hidden */
  59668. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59669. /** @hidden */
  59670. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59671. /** @hidden */
  59672. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59673. /** @hidden */
  59674. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59675. private _getNativeSamplingMode;
  59676. private _getNativeTextureFormat;
  59677. private _getNativeAlphaMode;
  59678. private _getNativeAttribType;
  59679. }
  59680. }
  59681. declare module "babylonjs/Engines/index" {
  59682. export * from "babylonjs/Engines/constants";
  59683. export * from "babylonjs/Engines/engineCapabilities";
  59684. export * from "babylonjs/Engines/instancingAttributeInfo";
  59685. export * from "babylonjs/Engines/thinEngine";
  59686. export * from "babylonjs/Engines/engine";
  59687. export * from "babylonjs/Engines/engineStore";
  59688. export * from "babylonjs/Engines/nullEngine";
  59689. export * from "babylonjs/Engines/Extensions/index";
  59690. export * from "babylonjs/Engines/IPipelineContext";
  59691. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  59692. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  59693. export * from "babylonjs/Engines/nativeEngine";
  59694. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  59695. export * from "babylonjs/Engines/performanceConfigurator";
  59696. }
  59697. declare module "babylonjs/Events/clipboardEvents" {
  59698. /**
  59699. * Gather the list of clipboard event types as constants.
  59700. */
  59701. export class ClipboardEventTypes {
  59702. /**
  59703. * The clipboard event is fired when a copy command is active (pressed).
  59704. */
  59705. static readonly COPY: number;
  59706. /**
  59707. * The clipboard event is fired when a cut command is active (pressed).
  59708. */
  59709. static readonly CUT: number;
  59710. /**
  59711. * The clipboard event is fired when a paste command is active (pressed).
  59712. */
  59713. static readonly PASTE: number;
  59714. }
  59715. /**
  59716. * This class is used to store clipboard related info for the onClipboardObservable event.
  59717. */
  59718. export class ClipboardInfo {
  59719. /**
  59720. * Defines the type of event (BABYLON.ClipboardEventTypes)
  59721. */
  59722. type: number;
  59723. /**
  59724. * Defines the related dom event
  59725. */
  59726. event: ClipboardEvent;
  59727. /**
  59728. *Creates an instance of ClipboardInfo.
  59729. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  59730. * @param event Defines the related dom event
  59731. */
  59732. constructor(
  59733. /**
  59734. * Defines the type of event (BABYLON.ClipboardEventTypes)
  59735. */
  59736. type: number,
  59737. /**
  59738. * Defines the related dom event
  59739. */
  59740. event: ClipboardEvent);
  59741. /**
  59742. * Get the clipboard event's type from the keycode.
  59743. * @param keyCode Defines the keyCode for the current keyboard event.
  59744. * @return {number}
  59745. */
  59746. static GetTypeFromCharacter(keyCode: number): number;
  59747. }
  59748. }
  59749. declare module "babylonjs/Events/index" {
  59750. export * from "babylonjs/Events/keyboardEvents";
  59751. export * from "babylonjs/Events/pointerEvents";
  59752. export * from "babylonjs/Events/clipboardEvents";
  59753. }
  59754. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  59755. import { Scene } from "babylonjs/scene";
  59756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59757. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59758. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59759. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59760. /**
  59761. * Google Daydream controller
  59762. */
  59763. export class DaydreamController extends WebVRController {
  59764. /**
  59765. * Base Url for the controller model.
  59766. */
  59767. static MODEL_BASE_URL: string;
  59768. /**
  59769. * File name for the controller model.
  59770. */
  59771. static MODEL_FILENAME: string;
  59772. /**
  59773. * Gamepad Id prefix used to identify Daydream Controller.
  59774. */
  59775. static readonly GAMEPAD_ID_PREFIX: string;
  59776. /**
  59777. * Creates a new DaydreamController from a gamepad
  59778. * @param vrGamepad the gamepad that the controller should be created from
  59779. */
  59780. constructor(vrGamepad: any);
  59781. /**
  59782. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59783. * @param scene scene in which to add meshes
  59784. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59785. */
  59786. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59787. /**
  59788. * Called once for each button that changed state since the last frame
  59789. * @param buttonIdx Which button index changed
  59790. * @param state New state of the button
  59791. * @param changes Which properties on the state changed since last frame
  59792. */
  59793. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59794. }
  59795. }
  59796. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  59797. import { Scene } from "babylonjs/scene";
  59798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59799. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59800. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59801. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59802. /**
  59803. * Gear VR Controller
  59804. */
  59805. export class GearVRController extends WebVRController {
  59806. /**
  59807. * Base Url for the controller model.
  59808. */
  59809. static MODEL_BASE_URL: string;
  59810. /**
  59811. * File name for the controller model.
  59812. */
  59813. static MODEL_FILENAME: string;
  59814. /**
  59815. * Gamepad Id prefix used to identify this controller.
  59816. */
  59817. static readonly GAMEPAD_ID_PREFIX: string;
  59818. private readonly _buttonIndexToObservableNameMap;
  59819. /**
  59820. * Creates a new GearVRController from a gamepad
  59821. * @param vrGamepad the gamepad that the controller should be created from
  59822. */
  59823. constructor(vrGamepad: any);
  59824. /**
  59825. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59826. * @param scene scene in which to add meshes
  59827. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59828. */
  59829. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59830. /**
  59831. * Called once for each button that changed state since the last frame
  59832. * @param buttonIdx Which button index changed
  59833. * @param state New state of the button
  59834. * @param changes Which properties on the state changed since last frame
  59835. */
  59836. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59837. }
  59838. }
  59839. declare module "babylonjs/Gamepads/Controllers/genericController" {
  59840. import { Scene } from "babylonjs/scene";
  59841. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59842. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59843. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59844. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59845. /**
  59846. * Generic Controller
  59847. */
  59848. export class GenericController extends WebVRController {
  59849. /**
  59850. * Base Url for the controller model.
  59851. */
  59852. static readonly MODEL_BASE_URL: string;
  59853. /**
  59854. * File name for the controller model.
  59855. */
  59856. static readonly MODEL_FILENAME: string;
  59857. /**
  59858. * Creates a new GenericController from a gamepad
  59859. * @param vrGamepad the gamepad that the controller should be created from
  59860. */
  59861. constructor(vrGamepad: any);
  59862. /**
  59863. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59864. * @param scene scene in which to add meshes
  59865. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59866. */
  59867. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59868. /**
  59869. * Called once for each button that changed state since the last frame
  59870. * @param buttonIdx Which button index changed
  59871. * @param state New state of the button
  59872. * @param changes Which properties on the state changed since last frame
  59873. */
  59874. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59875. }
  59876. }
  59877. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  59878. import { Observable } from "babylonjs/Misc/observable";
  59879. import { Scene } from "babylonjs/scene";
  59880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59881. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59882. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59883. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59884. /**
  59885. * Oculus Touch Controller
  59886. */
  59887. export class OculusTouchController extends WebVRController {
  59888. /**
  59889. * Base Url for the controller model.
  59890. */
  59891. static MODEL_BASE_URL: string;
  59892. /**
  59893. * File name for the left controller model.
  59894. */
  59895. static MODEL_LEFT_FILENAME: string;
  59896. /**
  59897. * File name for the right controller model.
  59898. */
  59899. static MODEL_RIGHT_FILENAME: string;
  59900. /**
  59901. * Base Url for the Quest controller model.
  59902. */
  59903. static QUEST_MODEL_BASE_URL: string;
  59904. /**
  59905. * @hidden
  59906. * If the controllers are running on a device that needs the updated Quest controller models
  59907. */
  59908. static _IsQuest: boolean;
  59909. /**
  59910. * Fired when the secondary trigger on this controller is modified
  59911. */
  59912. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  59913. /**
  59914. * Fired when the thumb rest on this controller is modified
  59915. */
  59916. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  59917. /**
  59918. * Creates a new OculusTouchController from a gamepad
  59919. * @param vrGamepad the gamepad that the controller should be created from
  59920. */
  59921. constructor(vrGamepad: any);
  59922. /**
  59923. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59924. * @param scene scene in which to add meshes
  59925. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59926. */
  59927. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59928. /**
  59929. * Fired when the A button on this controller is modified
  59930. */
  59931. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59932. /**
  59933. * Fired when the B button on this controller is modified
  59934. */
  59935. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59936. /**
  59937. * Fired when the X button on this controller is modified
  59938. */
  59939. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59940. /**
  59941. * Fired when the Y button on this controller is modified
  59942. */
  59943. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59944. /**
  59945. * Called once for each button that changed state since the last frame
  59946. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  59947. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  59948. * 2) secondary trigger (same)
  59949. * 3) A (right) X (left), touch, pressed = value
  59950. * 4) B / Y
  59951. * 5) thumb rest
  59952. * @param buttonIdx Which button index changed
  59953. * @param state New state of the button
  59954. * @param changes Which properties on the state changed since last frame
  59955. */
  59956. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59957. }
  59958. }
  59959. declare module "babylonjs/Gamepads/Controllers/viveController" {
  59960. import { Scene } from "babylonjs/scene";
  59961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59962. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59963. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59964. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59965. import { Observable } from "babylonjs/Misc/observable";
  59966. /**
  59967. * Vive Controller
  59968. */
  59969. export class ViveController extends WebVRController {
  59970. /**
  59971. * Base Url for the controller model.
  59972. */
  59973. static MODEL_BASE_URL: string;
  59974. /**
  59975. * File name for the controller model.
  59976. */
  59977. static MODEL_FILENAME: string;
  59978. /**
  59979. * Creates a new ViveController from a gamepad
  59980. * @param vrGamepad the gamepad that the controller should be created from
  59981. */
  59982. constructor(vrGamepad: any);
  59983. /**
  59984. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59985. * @param scene scene in which to add meshes
  59986. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59987. */
  59988. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59989. /**
  59990. * Fired when the left button on this controller is modified
  59991. */
  59992. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59993. /**
  59994. * Fired when the right button on this controller is modified
  59995. */
  59996. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59997. /**
  59998. * Fired when the menu button on this controller is modified
  59999. */
  60000. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60001. /**
  60002. * Called once for each button that changed state since the last frame
  60003. * Vive mapping:
  60004. * 0: touchpad
  60005. * 1: trigger
  60006. * 2: left AND right buttons
  60007. * 3: menu button
  60008. * @param buttonIdx Which button index changed
  60009. * @param state New state of the button
  60010. * @param changes Which properties on the state changed since last frame
  60011. */
  60012. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60013. }
  60014. }
  60015. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  60016. import { Observable } from "babylonjs/Misc/observable";
  60017. import { Scene } from "babylonjs/scene";
  60018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60019. import { Ray } from "babylonjs/Culling/ray";
  60020. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  60021. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  60022. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  60023. /**
  60024. * Defines the WindowsMotionController object that the state of the windows motion controller
  60025. */
  60026. export class WindowsMotionController extends WebVRController {
  60027. /**
  60028. * The base url used to load the left and right controller models
  60029. */
  60030. static MODEL_BASE_URL: string;
  60031. /**
  60032. * The name of the left controller model file
  60033. */
  60034. static MODEL_LEFT_FILENAME: string;
  60035. /**
  60036. * The name of the right controller model file
  60037. */
  60038. static MODEL_RIGHT_FILENAME: string;
  60039. /**
  60040. * The controller name prefix for this controller type
  60041. */
  60042. static readonly GAMEPAD_ID_PREFIX: string;
  60043. /**
  60044. * The controller id pattern for this controller type
  60045. */
  60046. private static readonly GAMEPAD_ID_PATTERN;
  60047. private _loadedMeshInfo;
  60048. protected readonly _mapping: {
  60049. buttons: string[];
  60050. buttonMeshNames: {
  60051. trigger: string;
  60052. menu: string;
  60053. grip: string;
  60054. thumbstick: string;
  60055. trackpad: string;
  60056. };
  60057. buttonObservableNames: {
  60058. trigger: string;
  60059. menu: string;
  60060. grip: string;
  60061. thumbstick: string;
  60062. trackpad: string;
  60063. };
  60064. axisMeshNames: string[];
  60065. pointingPoseMeshName: string;
  60066. };
  60067. /**
  60068. * Fired when the trackpad on this controller is clicked
  60069. */
  60070. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60071. /**
  60072. * Fired when the trackpad on this controller is modified
  60073. */
  60074. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60075. /**
  60076. * The current x and y values of this controller's trackpad
  60077. */
  60078. trackpad: StickValues;
  60079. /**
  60080. * Creates a new WindowsMotionController from a gamepad
  60081. * @param vrGamepad the gamepad that the controller should be created from
  60082. */
  60083. constructor(vrGamepad: any);
  60084. /**
  60085. * Fired when the trigger on this controller is modified
  60086. */
  60087. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60088. /**
  60089. * Fired when the menu button on this controller is modified
  60090. */
  60091. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60092. /**
  60093. * Fired when the grip button on this controller is modified
  60094. */
  60095. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60096. /**
  60097. * Fired when the thumbstick button on this controller is modified
  60098. */
  60099. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60100. /**
  60101. * Fired when the touchpad button on this controller is modified
  60102. */
  60103. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60104. /**
  60105. * Fired when the touchpad values on this controller are modified
  60106. */
  60107. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  60108. protected _updateTrackpad(): void;
  60109. /**
  60110. * Called once per frame by the engine.
  60111. */
  60112. update(): void;
  60113. /**
  60114. * Called once for each button that changed state since the last frame
  60115. * @param buttonIdx Which button index changed
  60116. * @param state New state of the button
  60117. * @param changes Which properties on the state changed since last frame
  60118. */
  60119. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60120. /**
  60121. * Moves the buttons on the controller mesh based on their current state
  60122. * @param buttonName the name of the button to move
  60123. * @param buttonValue the value of the button which determines the buttons new position
  60124. */
  60125. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  60126. /**
  60127. * Moves the axis on the controller mesh based on its current state
  60128. * @param axis the index of the axis
  60129. * @param axisValue the value of the axis which determines the meshes new position
  60130. * @hidden
  60131. */
  60132. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  60133. /**
  60134. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60135. * @param scene scene in which to add meshes
  60136. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60137. */
  60138. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  60139. /**
  60140. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  60141. * can be transformed by button presses and axes values, based on this._mapping.
  60142. *
  60143. * @param scene scene in which the meshes exist
  60144. * @param meshes list of meshes that make up the controller model to process
  60145. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  60146. */
  60147. private processModel;
  60148. private createMeshInfo;
  60149. /**
  60150. * Gets the ray of the controller in the direction the controller is pointing
  60151. * @param length the length the resulting ray should be
  60152. * @returns a ray in the direction the controller is pointing
  60153. */
  60154. getForwardRay(length?: number): Ray;
  60155. /**
  60156. * Disposes of the controller
  60157. */
  60158. dispose(): void;
  60159. }
  60160. /**
  60161. * This class represents a new windows motion controller in XR.
  60162. */
  60163. export class XRWindowsMotionController extends WindowsMotionController {
  60164. /**
  60165. * Changing the original WIndowsMotionController mapping to fir the new mapping
  60166. */
  60167. protected readonly _mapping: {
  60168. buttons: string[];
  60169. buttonMeshNames: {
  60170. trigger: string;
  60171. menu: string;
  60172. grip: string;
  60173. thumbstick: string;
  60174. trackpad: string;
  60175. };
  60176. buttonObservableNames: {
  60177. trigger: string;
  60178. menu: string;
  60179. grip: string;
  60180. thumbstick: string;
  60181. trackpad: string;
  60182. };
  60183. axisMeshNames: string[];
  60184. pointingPoseMeshName: string;
  60185. };
  60186. /**
  60187. * Construct a new XR-Based windows motion controller
  60188. *
  60189. * @param gamepadInfo the gamepad object from the browser
  60190. */
  60191. constructor(gamepadInfo: any);
  60192. /**
  60193. * holds the thumbstick values (X,Y)
  60194. */
  60195. thumbstickValues: StickValues;
  60196. /**
  60197. * Fired when the thumbstick on this controller is clicked
  60198. */
  60199. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  60200. /**
  60201. * Fired when the thumbstick on this controller is modified
  60202. */
  60203. onThumbstickValuesChangedObservable: Observable<StickValues>;
  60204. /**
  60205. * Fired when the touchpad button on this controller is modified
  60206. */
  60207. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60208. /**
  60209. * Fired when the touchpad values on this controller are modified
  60210. */
  60211. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60212. /**
  60213. * Fired when the thumbstick button on this controller is modified
  60214. * here to prevent breaking changes
  60215. */
  60216. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60217. /**
  60218. * updating the thumbstick(!) and not the trackpad.
  60219. * This is named this way due to the difference between WebVR and XR and to avoid
  60220. * changing the parent class.
  60221. */
  60222. protected _updateTrackpad(): void;
  60223. /**
  60224. * Disposes the class with joy
  60225. */
  60226. dispose(): void;
  60227. }
  60228. }
  60229. declare module "babylonjs/Gamepads/Controllers/index" {
  60230. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  60231. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  60232. export * from "babylonjs/Gamepads/Controllers/genericController";
  60233. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  60234. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  60235. export * from "babylonjs/Gamepads/Controllers/viveController";
  60236. export * from "babylonjs/Gamepads/Controllers/webVRController";
  60237. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  60238. }
  60239. declare module "babylonjs/Gamepads/index" {
  60240. export * from "babylonjs/Gamepads/Controllers/index";
  60241. export * from "babylonjs/Gamepads/gamepad";
  60242. export * from "babylonjs/Gamepads/gamepadManager";
  60243. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  60244. export * from "babylonjs/Gamepads/xboxGamepad";
  60245. export * from "babylonjs/Gamepads/dualShockGamepad";
  60246. }
  60247. declare module "babylonjs/Lights/directionalLight" {
  60248. import { Camera } from "babylonjs/Cameras/camera";
  60249. import { Scene } from "babylonjs/scene";
  60250. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60252. import { Light } from "babylonjs/Lights/light";
  60253. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  60254. import { Effect } from "babylonjs/Materials/effect";
  60255. /**
  60256. * A directional light is defined by a direction (what a surprise!).
  60257. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  60258. * 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.
  60259. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60260. */
  60261. export class DirectionalLight extends ShadowLight {
  60262. private _shadowFrustumSize;
  60263. /**
  60264. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  60265. */
  60266. get shadowFrustumSize(): number;
  60267. /**
  60268. * Specifies a fix frustum size for the shadow generation.
  60269. */
  60270. set shadowFrustumSize(value: number);
  60271. private _shadowOrthoScale;
  60272. /**
  60273. * Gets the shadow projection scale against the optimal computed one.
  60274. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60275. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60276. */
  60277. get shadowOrthoScale(): number;
  60278. /**
  60279. * Sets the shadow projection scale against the optimal computed one.
  60280. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60281. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60282. */
  60283. set shadowOrthoScale(value: number);
  60284. /**
  60285. * Automatically compute the projection matrix to best fit (including all the casters)
  60286. * on each frame.
  60287. */
  60288. autoUpdateExtends: boolean;
  60289. /**
  60290. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  60291. * on each frame. autoUpdateExtends must be set to true for this to work
  60292. */
  60293. autoCalcShadowZBounds: boolean;
  60294. private _orthoLeft;
  60295. private _orthoRight;
  60296. private _orthoTop;
  60297. private _orthoBottom;
  60298. /**
  60299. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  60300. * The directional light is emitted from everywhere in the given direction.
  60301. * It can cast shadows.
  60302. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60303. * @param name The friendly name of the light
  60304. * @param direction The direction of the light
  60305. * @param scene The scene the light belongs to
  60306. */
  60307. constructor(name: string, direction: Vector3, scene: Scene);
  60308. /**
  60309. * Returns the string "DirectionalLight".
  60310. * @return The class name
  60311. */
  60312. getClassName(): string;
  60313. /**
  60314. * Returns the integer 1.
  60315. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60316. */
  60317. getTypeID(): number;
  60318. /**
  60319. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  60320. * Returns the DirectionalLight Shadow projection matrix.
  60321. */
  60322. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60323. /**
  60324. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  60325. * Returns the DirectionalLight Shadow projection matrix.
  60326. */
  60327. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  60328. /**
  60329. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  60330. * Returns the DirectionalLight Shadow projection matrix.
  60331. */
  60332. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60333. protected _buildUniformLayout(): void;
  60334. /**
  60335. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  60336. * @param effect The effect to update
  60337. * @param lightIndex The index of the light in the effect to update
  60338. * @returns The directional light
  60339. */
  60340. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  60341. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  60342. /**
  60343. * Gets the minZ used for shadow according to both the scene and the light.
  60344. *
  60345. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60346. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60347. * @param activeCamera The camera we are returning the min for
  60348. * @returns the depth min z
  60349. */
  60350. getDepthMinZ(activeCamera: Camera): number;
  60351. /**
  60352. * Gets the maxZ used for shadow according to both the scene and the light.
  60353. *
  60354. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60355. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60356. * @param activeCamera The camera we are returning the max for
  60357. * @returns the depth max z
  60358. */
  60359. getDepthMaxZ(activeCamera: Camera): number;
  60360. /**
  60361. * Prepares the list of defines specific to the light type.
  60362. * @param defines the list of defines
  60363. * @param lightIndex defines the index of the light for the effect
  60364. */
  60365. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60366. }
  60367. }
  60368. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  60369. import { Mesh } from "babylonjs/Meshes/mesh";
  60370. /**
  60371. * Class containing static functions to help procedurally build meshes
  60372. */
  60373. export class HemisphereBuilder {
  60374. /**
  60375. * Creates a hemisphere mesh
  60376. * @param name defines the name of the mesh
  60377. * @param options defines the options used to create the mesh
  60378. * @param scene defines the hosting scene
  60379. * @returns the hemisphere mesh
  60380. */
  60381. static CreateHemisphere(name: string, options: {
  60382. segments?: number;
  60383. diameter?: number;
  60384. sideOrientation?: number;
  60385. }, scene: any): Mesh;
  60386. }
  60387. }
  60388. declare module "babylonjs/Lights/spotLight" {
  60389. import { Nullable } from "babylonjs/types";
  60390. import { Scene } from "babylonjs/scene";
  60391. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60393. import { Effect } from "babylonjs/Materials/effect";
  60394. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60395. import { Light } from "babylonjs/Lights/light";
  60396. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  60397. /**
  60398. * A spot light is defined by a position, a direction, an angle, and an exponent.
  60399. * These values define a cone of light starting from the position, emitting toward the direction.
  60400. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  60401. * and the exponent defines the speed of the decay of the light with distance (reach).
  60402. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60403. */
  60404. export class SpotLight extends ShadowLight {
  60405. private _angle;
  60406. private _innerAngle;
  60407. private _cosHalfAngle;
  60408. private _lightAngleScale;
  60409. private _lightAngleOffset;
  60410. /**
  60411. * Gets the cone angle of the spot light in Radians.
  60412. */
  60413. get angle(): number;
  60414. /**
  60415. * Sets the cone angle of the spot light in Radians.
  60416. */
  60417. set angle(value: number);
  60418. /**
  60419. * Only used in gltf falloff mode, this defines the angle where
  60420. * the directional falloff will start before cutting at angle which could be seen
  60421. * as outer angle.
  60422. */
  60423. get innerAngle(): number;
  60424. /**
  60425. * Only used in gltf falloff mode, this defines the angle where
  60426. * the directional falloff will start before cutting at angle which could be seen
  60427. * as outer angle.
  60428. */
  60429. set innerAngle(value: number);
  60430. private _shadowAngleScale;
  60431. /**
  60432. * Allows scaling the angle of the light for shadow generation only.
  60433. */
  60434. get shadowAngleScale(): number;
  60435. /**
  60436. * Allows scaling the angle of the light for shadow generation only.
  60437. */
  60438. set shadowAngleScale(value: number);
  60439. /**
  60440. * The light decay speed with the distance from the emission spot.
  60441. */
  60442. exponent: number;
  60443. private _projectionTextureMatrix;
  60444. /**
  60445. * Allows reading the projecton texture
  60446. */
  60447. get projectionTextureMatrix(): Matrix;
  60448. protected _projectionTextureLightNear: number;
  60449. /**
  60450. * Gets the near clip of the Spotlight for texture projection.
  60451. */
  60452. get projectionTextureLightNear(): number;
  60453. /**
  60454. * Sets the near clip of the Spotlight for texture projection.
  60455. */
  60456. set projectionTextureLightNear(value: number);
  60457. protected _projectionTextureLightFar: number;
  60458. /**
  60459. * Gets the far clip of the Spotlight for texture projection.
  60460. */
  60461. get projectionTextureLightFar(): number;
  60462. /**
  60463. * Sets the far clip of the Spotlight for texture projection.
  60464. */
  60465. set projectionTextureLightFar(value: number);
  60466. protected _projectionTextureUpDirection: Vector3;
  60467. /**
  60468. * Gets the Up vector of the Spotlight for texture projection.
  60469. */
  60470. get projectionTextureUpDirection(): Vector3;
  60471. /**
  60472. * Sets the Up vector of the Spotlight for texture projection.
  60473. */
  60474. set projectionTextureUpDirection(value: Vector3);
  60475. private _projectionTexture;
  60476. /**
  60477. * Gets the projection texture of the light.
  60478. */
  60479. get projectionTexture(): Nullable<BaseTexture>;
  60480. /**
  60481. * Sets the projection texture of the light.
  60482. */
  60483. set projectionTexture(value: Nullable<BaseTexture>);
  60484. private static _IsProceduralTexture;
  60485. private static _IsTexture;
  60486. private _projectionTextureViewLightDirty;
  60487. private _projectionTextureProjectionLightDirty;
  60488. private _projectionTextureDirty;
  60489. private _projectionTextureViewTargetVector;
  60490. private _projectionTextureViewLightMatrix;
  60491. private _projectionTextureProjectionLightMatrix;
  60492. private _projectionTextureScalingMatrix;
  60493. /**
  60494. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  60495. * It can cast shadows.
  60496. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60497. * @param name The light friendly name
  60498. * @param position The position of the spot light in the scene
  60499. * @param direction The direction of the light in the scene
  60500. * @param angle The cone angle of the light in Radians
  60501. * @param exponent The light decay speed with the distance from the emission spot
  60502. * @param scene The scene the lights belongs to
  60503. */
  60504. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  60505. /**
  60506. * Returns the string "SpotLight".
  60507. * @returns the class name
  60508. */
  60509. getClassName(): string;
  60510. /**
  60511. * Returns the integer 2.
  60512. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60513. */
  60514. getTypeID(): number;
  60515. /**
  60516. * Overrides the direction setter to recompute the projection texture view light Matrix.
  60517. */
  60518. protected _setDirection(value: Vector3): void;
  60519. /**
  60520. * Overrides the position setter to recompute the projection texture view light Matrix.
  60521. */
  60522. protected _setPosition(value: Vector3): void;
  60523. /**
  60524. * 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.
  60525. * Returns the SpotLight.
  60526. */
  60527. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60528. protected _computeProjectionTextureViewLightMatrix(): void;
  60529. protected _computeProjectionTextureProjectionLightMatrix(): void;
  60530. /**
  60531. * Main function for light texture projection matrix computing.
  60532. */
  60533. protected _computeProjectionTextureMatrix(): void;
  60534. protected _buildUniformLayout(): void;
  60535. private _computeAngleValues;
  60536. /**
  60537. * Sets the passed Effect "effect" with the Light textures.
  60538. * @param effect The effect to update
  60539. * @param lightIndex The index of the light in the effect to update
  60540. * @returns The light
  60541. */
  60542. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  60543. /**
  60544. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  60545. * @param effect The effect to update
  60546. * @param lightIndex The index of the light in the effect to update
  60547. * @returns The spot light
  60548. */
  60549. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  60550. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60551. /**
  60552. * Disposes the light and the associated resources.
  60553. */
  60554. dispose(): void;
  60555. /**
  60556. * Prepares the list of defines specific to the light type.
  60557. * @param defines the list of defines
  60558. * @param lightIndex defines the index of the light for the effect
  60559. */
  60560. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60561. }
  60562. }
  60563. declare module "babylonjs/Gizmos/lightGizmo" {
  60564. import { Nullable } from "babylonjs/types";
  60565. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60566. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60567. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60568. import { Light } from "babylonjs/Lights/light";
  60569. import { Observable } from "babylonjs/Misc/observable";
  60570. /**
  60571. * Gizmo that enables viewing a light
  60572. */
  60573. export class LightGizmo extends Gizmo {
  60574. private _lightMesh;
  60575. private _material;
  60576. private _cachedPosition;
  60577. private _cachedForward;
  60578. private _attachedMeshParent;
  60579. private _pointerObserver;
  60580. /**
  60581. * Event that fires each time the gizmo is clicked
  60582. */
  60583. onClickedObservable: Observable<Light>;
  60584. /**
  60585. * Creates a LightGizmo
  60586. * @param gizmoLayer The utility layer the gizmo will be added to
  60587. */
  60588. constructor(gizmoLayer?: UtilityLayerRenderer);
  60589. private _light;
  60590. /**
  60591. * The light that the gizmo is attached to
  60592. */
  60593. set light(light: Nullable<Light>);
  60594. get light(): Nullable<Light>;
  60595. /**
  60596. * Gets the material used to render the light gizmo
  60597. */
  60598. get material(): StandardMaterial;
  60599. /**
  60600. * @hidden
  60601. * Updates the gizmo to match the attached mesh's position/rotation
  60602. */
  60603. protected _update(): void;
  60604. private static _Scale;
  60605. /**
  60606. * Creates the lines for a light mesh
  60607. */
  60608. private static _CreateLightLines;
  60609. /**
  60610. * Disposes of the light gizmo
  60611. */
  60612. dispose(): void;
  60613. private static _CreateHemisphericLightMesh;
  60614. private static _CreatePointLightMesh;
  60615. private static _CreateSpotLightMesh;
  60616. private static _CreateDirectionalLightMesh;
  60617. }
  60618. }
  60619. declare module "babylonjs/Gizmos/cameraGizmo" {
  60620. import { Nullable } from "babylonjs/types";
  60621. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60622. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60623. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60624. import { Camera } from "babylonjs/Cameras/camera";
  60625. import { Observable } from "babylonjs/Misc/observable";
  60626. /**
  60627. * Gizmo that enables viewing a camera
  60628. */
  60629. export class CameraGizmo extends Gizmo {
  60630. private _cameraMesh;
  60631. private _cameraLinesMesh;
  60632. private _material;
  60633. private _pointerObserver;
  60634. /**
  60635. * Event that fires each time the gizmo is clicked
  60636. */
  60637. onClickedObservable: Observable<Camera>;
  60638. /**
  60639. * Creates a CameraGizmo
  60640. * @param gizmoLayer The utility layer the gizmo will be added to
  60641. */
  60642. constructor(gizmoLayer?: UtilityLayerRenderer);
  60643. private _camera;
  60644. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  60645. get displayFrustum(): boolean;
  60646. set displayFrustum(value: boolean);
  60647. /**
  60648. * The camera that the gizmo is attached to
  60649. */
  60650. set camera(camera: Nullable<Camera>);
  60651. get camera(): Nullable<Camera>;
  60652. /**
  60653. * Gets the material used to render the camera gizmo
  60654. */
  60655. get material(): StandardMaterial;
  60656. /**
  60657. * @hidden
  60658. * Updates the gizmo to match the attached mesh's position/rotation
  60659. */
  60660. protected _update(): void;
  60661. private static _Scale;
  60662. private _invProjection;
  60663. /**
  60664. * Disposes of the camera gizmo
  60665. */
  60666. dispose(): void;
  60667. private static _CreateCameraMesh;
  60668. private static _CreateCameraFrustum;
  60669. }
  60670. }
  60671. declare module "babylonjs/Gizmos/index" {
  60672. export * from "babylonjs/Gizmos/axisDragGizmo";
  60673. export * from "babylonjs/Gizmos/axisScaleGizmo";
  60674. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  60675. export * from "babylonjs/Gizmos/gizmo";
  60676. export * from "babylonjs/Gizmos/gizmoManager";
  60677. export * from "babylonjs/Gizmos/planeRotationGizmo";
  60678. export * from "babylonjs/Gizmos/positionGizmo";
  60679. export * from "babylonjs/Gizmos/rotationGizmo";
  60680. export * from "babylonjs/Gizmos/scaleGizmo";
  60681. export * from "babylonjs/Gizmos/lightGizmo";
  60682. export * from "babylonjs/Gizmos/cameraGizmo";
  60683. export * from "babylonjs/Gizmos/planeDragGizmo";
  60684. }
  60685. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  60686. /** @hidden */
  60687. export var backgroundFragmentDeclaration: {
  60688. name: string;
  60689. shader: string;
  60690. };
  60691. }
  60692. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  60693. /** @hidden */
  60694. export var backgroundUboDeclaration: {
  60695. name: string;
  60696. shader: string;
  60697. };
  60698. }
  60699. declare module "babylonjs/Shaders/background.fragment" {
  60700. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  60701. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  60702. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  60703. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60704. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60705. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60706. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60707. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  60708. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  60709. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60710. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  60711. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  60712. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60713. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  60714. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  60715. /** @hidden */
  60716. export var backgroundPixelShader: {
  60717. name: string;
  60718. shader: string;
  60719. };
  60720. }
  60721. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  60722. /** @hidden */
  60723. export var backgroundVertexDeclaration: {
  60724. name: string;
  60725. shader: string;
  60726. };
  60727. }
  60728. declare module "babylonjs/Shaders/background.vertex" {
  60729. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  60730. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  60731. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60732. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60733. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60734. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  60735. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  60736. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60737. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60738. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60739. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60740. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60741. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  60742. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  60743. /** @hidden */
  60744. export var backgroundVertexShader: {
  60745. name: string;
  60746. shader: string;
  60747. };
  60748. }
  60749. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  60750. import { Nullable, int, float } from "babylonjs/types";
  60751. import { Scene } from "babylonjs/scene";
  60752. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60753. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60755. import { Mesh } from "babylonjs/Meshes/mesh";
  60756. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  60757. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  60758. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  60759. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60760. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  60761. import { Color3 } from "babylonjs/Maths/math.color";
  60762. import "babylonjs/Shaders/background.fragment";
  60763. import "babylonjs/Shaders/background.vertex";
  60764. /**
  60765. * Background material used to create an efficient environement around your scene.
  60766. */
  60767. export class BackgroundMaterial extends PushMaterial {
  60768. /**
  60769. * Standard reflectance value at parallel view angle.
  60770. */
  60771. static StandardReflectance0: number;
  60772. /**
  60773. * Standard reflectance value at grazing angle.
  60774. */
  60775. static StandardReflectance90: number;
  60776. protected _primaryColor: Color3;
  60777. /**
  60778. * Key light Color (multiply against the environement texture)
  60779. */
  60780. primaryColor: Color3;
  60781. protected __perceptualColor: Nullable<Color3>;
  60782. /**
  60783. * Experimental Internal Use Only.
  60784. *
  60785. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  60786. * This acts as a helper to set the primary color to a more "human friendly" value.
  60787. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  60788. * output color as close as possible from the chosen value.
  60789. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  60790. * part of lighting setup.)
  60791. */
  60792. get _perceptualColor(): Nullable<Color3>;
  60793. set _perceptualColor(value: Nullable<Color3>);
  60794. protected _primaryColorShadowLevel: float;
  60795. /**
  60796. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  60797. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  60798. */
  60799. get primaryColorShadowLevel(): float;
  60800. set primaryColorShadowLevel(value: float);
  60801. protected _primaryColorHighlightLevel: float;
  60802. /**
  60803. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  60804. * The primary color is used at the level chosen to define what the white area would look.
  60805. */
  60806. get primaryColorHighlightLevel(): float;
  60807. set primaryColorHighlightLevel(value: float);
  60808. protected _reflectionTexture: Nullable<BaseTexture>;
  60809. /**
  60810. * Reflection Texture used in the material.
  60811. * Should be author in a specific way for the best result (refer to the documentation).
  60812. */
  60813. reflectionTexture: Nullable<BaseTexture>;
  60814. protected _reflectionBlur: float;
  60815. /**
  60816. * Reflection Texture level of blur.
  60817. *
  60818. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  60819. * texture twice.
  60820. */
  60821. reflectionBlur: float;
  60822. protected _diffuseTexture: Nullable<BaseTexture>;
  60823. /**
  60824. * Diffuse Texture used in the material.
  60825. * Should be author in a specific way for the best result (refer to the documentation).
  60826. */
  60827. diffuseTexture: Nullable<BaseTexture>;
  60828. protected _shadowLights: Nullable<IShadowLight[]>;
  60829. /**
  60830. * Specify the list of lights casting shadow on the material.
  60831. * All scene shadow lights will be included if null.
  60832. */
  60833. shadowLights: Nullable<IShadowLight[]>;
  60834. protected _shadowLevel: float;
  60835. /**
  60836. * Helps adjusting the shadow to a softer level if required.
  60837. * 0 means black shadows and 1 means no shadows.
  60838. */
  60839. shadowLevel: float;
  60840. protected _sceneCenter: Vector3;
  60841. /**
  60842. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  60843. * It is usually zero but might be interesting to modify according to your setup.
  60844. */
  60845. sceneCenter: Vector3;
  60846. protected _opacityFresnel: boolean;
  60847. /**
  60848. * This helps specifying that the material is falling off to the sky box at grazing angle.
  60849. * This helps ensuring a nice transition when the camera goes under the ground.
  60850. */
  60851. opacityFresnel: boolean;
  60852. protected _reflectionFresnel: boolean;
  60853. /**
  60854. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  60855. * This helps adding a mirror texture on the ground.
  60856. */
  60857. reflectionFresnel: boolean;
  60858. protected _reflectionFalloffDistance: number;
  60859. /**
  60860. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  60861. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  60862. */
  60863. reflectionFalloffDistance: number;
  60864. protected _reflectionAmount: number;
  60865. /**
  60866. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  60867. */
  60868. reflectionAmount: number;
  60869. protected _reflectionReflectance0: number;
  60870. /**
  60871. * This specifies the weight of the reflection at grazing angle.
  60872. */
  60873. reflectionReflectance0: number;
  60874. protected _reflectionReflectance90: number;
  60875. /**
  60876. * This specifies the weight of the reflection at a perpendicular point of view.
  60877. */
  60878. reflectionReflectance90: number;
  60879. /**
  60880. * Sets the reflection reflectance fresnel values according to the default standard
  60881. * empirically know to work well :-)
  60882. */
  60883. set reflectionStandardFresnelWeight(value: number);
  60884. protected _useRGBColor: boolean;
  60885. /**
  60886. * Helps to directly use the maps channels instead of their level.
  60887. */
  60888. useRGBColor: boolean;
  60889. protected _enableNoise: boolean;
  60890. /**
  60891. * This helps reducing the banding effect that could occur on the background.
  60892. */
  60893. enableNoise: boolean;
  60894. /**
  60895. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60896. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  60897. * Recommended to be keep at 1.0 except for special cases.
  60898. */
  60899. get fovMultiplier(): number;
  60900. set fovMultiplier(value: number);
  60901. private _fovMultiplier;
  60902. /**
  60903. * Enable the FOV adjustment feature controlled by fovMultiplier.
  60904. */
  60905. useEquirectangularFOV: boolean;
  60906. private _maxSimultaneousLights;
  60907. /**
  60908. * Number of Simultaneous lights allowed on the material.
  60909. */
  60910. maxSimultaneousLights: int;
  60911. private _shadowOnly;
  60912. /**
  60913. * Make the material only render shadows
  60914. */
  60915. shadowOnly: boolean;
  60916. /**
  60917. * Default configuration related to image processing available in the Background Material.
  60918. */
  60919. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60920. /**
  60921. * Keep track of the image processing observer to allow dispose and replace.
  60922. */
  60923. private _imageProcessingObserver;
  60924. /**
  60925. * Attaches a new image processing configuration to the PBR Material.
  60926. * @param configuration (if null the scene configuration will be use)
  60927. */
  60928. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60929. /**
  60930. * Gets the image processing configuration used either in this material.
  60931. */
  60932. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  60933. /**
  60934. * Sets the Default image processing configuration used either in the this material.
  60935. *
  60936. * If sets to null, the scene one is in use.
  60937. */
  60938. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  60939. /**
  60940. * Gets wether the color curves effect is enabled.
  60941. */
  60942. get cameraColorCurvesEnabled(): boolean;
  60943. /**
  60944. * Sets wether the color curves effect is enabled.
  60945. */
  60946. set cameraColorCurvesEnabled(value: boolean);
  60947. /**
  60948. * Gets wether the color grading effect is enabled.
  60949. */
  60950. get cameraColorGradingEnabled(): boolean;
  60951. /**
  60952. * Gets wether the color grading effect is enabled.
  60953. */
  60954. set cameraColorGradingEnabled(value: boolean);
  60955. /**
  60956. * Gets wether tonemapping is enabled or not.
  60957. */
  60958. get cameraToneMappingEnabled(): boolean;
  60959. /**
  60960. * Sets wether tonemapping is enabled or not
  60961. */
  60962. set cameraToneMappingEnabled(value: boolean);
  60963. /**
  60964. * The camera exposure used on this material.
  60965. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60966. * This corresponds to a photographic exposure.
  60967. */
  60968. get cameraExposure(): float;
  60969. /**
  60970. * The camera exposure used on this material.
  60971. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60972. * This corresponds to a photographic exposure.
  60973. */
  60974. set cameraExposure(value: float);
  60975. /**
  60976. * Gets The camera contrast used on this material.
  60977. */
  60978. get cameraContrast(): float;
  60979. /**
  60980. * Sets The camera contrast used on this material.
  60981. */
  60982. set cameraContrast(value: float);
  60983. /**
  60984. * Gets the Color Grading 2D Lookup Texture.
  60985. */
  60986. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60987. /**
  60988. * Sets the Color Grading 2D Lookup Texture.
  60989. */
  60990. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60991. /**
  60992. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60993. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60994. * 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;
  60995. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60996. */
  60997. get cameraColorCurves(): Nullable<ColorCurves>;
  60998. /**
  60999. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61000. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61001. * 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;
  61002. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61003. */
  61004. set cameraColorCurves(value: Nullable<ColorCurves>);
  61005. /**
  61006. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  61007. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  61008. */
  61009. switchToBGR: boolean;
  61010. private _renderTargets;
  61011. private _reflectionControls;
  61012. private _white;
  61013. private _primaryShadowColor;
  61014. private _primaryHighlightColor;
  61015. /**
  61016. * Instantiates a Background Material in the given scene
  61017. * @param name The friendly name of the material
  61018. * @param scene The scene to add the material to
  61019. */
  61020. constructor(name: string, scene: Scene);
  61021. /**
  61022. * Gets a boolean indicating that current material needs to register RTT
  61023. */
  61024. get hasRenderTargetTextures(): boolean;
  61025. /**
  61026. * The entire material has been created in order to prevent overdraw.
  61027. * @returns false
  61028. */
  61029. needAlphaTesting(): boolean;
  61030. /**
  61031. * The entire material has been created in order to prevent overdraw.
  61032. * @returns true if blending is enable
  61033. */
  61034. needAlphaBlending(): boolean;
  61035. /**
  61036. * Checks wether the material is ready to be rendered for a given mesh.
  61037. * @param mesh The mesh to render
  61038. * @param subMesh The submesh to check against
  61039. * @param useInstances Specify wether or not the material is used with instances
  61040. * @returns true if all the dependencies are ready (Textures, Effects...)
  61041. */
  61042. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61043. /**
  61044. * Compute the primary color according to the chosen perceptual color.
  61045. */
  61046. private _computePrimaryColorFromPerceptualColor;
  61047. /**
  61048. * Compute the highlights and shadow colors according to their chosen levels.
  61049. */
  61050. private _computePrimaryColors;
  61051. /**
  61052. * Build the uniform buffer used in the material.
  61053. */
  61054. buildUniformLayout(): void;
  61055. /**
  61056. * Unbind the material.
  61057. */
  61058. unbind(): void;
  61059. /**
  61060. * Bind only the world matrix to the material.
  61061. * @param world The world matrix to bind.
  61062. */
  61063. bindOnlyWorldMatrix(world: Matrix): void;
  61064. /**
  61065. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  61066. * @param world The world matrix to bind.
  61067. * @param subMesh The submesh to bind for.
  61068. */
  61069. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61070. /**
  61071. * Checks to see if a texture is used in the material.
  61072. * @param texture - Base texture to use.
  61073. * @returns - Boolean specifying if a texture is used in the material.
  61074. */
  61075. hasTexture(texture: BaseTexture): boolean;
  61076. /**
  61077. * Dispose the material.
  61078. * @param forceDisposeEffect Force disposal of the associated effect.
  61079. * @param forceDisposeTextures Force disposal of the associated textures.
  61080. */
  61081. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  61082. /**
  61083. * Clones the material.
  61084. * @param name The cloned name.
  61085. * @returns The cloned material.
  61086. */
  61087. clone(name: string): BackgroundMaterial;
  61088. /**
  61089. * Serializes the current material to its JSON representation.
  61090. * @returns The JSON representation.
  61091. */
  61092. serialize(): any;
  61093. /**
  61094. * Gets the class name of the material
  61095. * @returns "BackgroundMaterial"
  61096. */
  61097. getClassName(): string;
  61098. /**
  61099. * Parse a JSON input to create back a background material.
  61100. * @param source The JSON data to parse
  61101. * @param scene The scene to create the parsed material in
  61102. * @param rootUrl The root url of the assets the material depends upon
  61103. * @returns the instantiated BackgroundMaterial.
  61104. */
  61105. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  61106. }
  61107. }
  61108. declare module "babylonjs/Helpers/environmentHelper" {
  61109. import { Observable } from "babylonjs/Misc/observable";
  61110. import { Nullable } from "babylonjs/types";
  61111. import { Scene } from "babylonjs/scene";
  61112. import { Vector3 } from "babylonjs/Maths/math.vector";
  61113. import { Color3 } from "babylonjs/Maths/math.color";
  61114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61115. import { Mesh } from "babylonjs/Meshes/mesh";
  61116. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61117. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  61118. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  61119. import "babylonjs/Meshes/Builders/planeBuilder";
  61120. import "babylonjs/Meshes/Builders/boxBuilder";
  61121. /**
  61122. * Represents the different options available during the creation of
  61123. * a Environment helper.
  61124. *
  61125. * This can control the default ground, skybox and image processing setup of your scene.
  61126. */
  61127. export interface IEnvironmentHelperOptions {
  61128. /**
  61129. * Specifies whether or not to create a ground.
  61130. * True by default.
  61131. */
  61132. createGround: boolean;
  61133. /**
  61134. * Specifies the ground size.
  61135. * 15 by default.
  61136. */
  61137. groundSize: number;
  61138. /**
  61139. * The texture used on the ground for the main color.
  61140. * Comes from the BabylonJS CDN by default.
  61141. *
  61142. * Remarks: Can be either a texture or a url.
  61143. */
  61144. groundTexture: string | BaseTexture;
  61145. /**
  61146. * The color mixed in the ground texture by default.
  61147. * BabylonJS clearColor by default.
  61148. */
  61149. groundColor: Color3;
  61150. /**
  61151. * Specifies the ground opacity.
  61152. * 1 by default.
  61153. */
  61154. groundOpacity: number;
  61155. /**
  61156. * Enables the ground to receive shadows.
  61157. * True by default.
  61158. */
  61159. enableGroundShadow: boolean;
  61160. /**
  61161. * Helps preventing the shadow to be fully black on the ground.
  61162. * 0.5 by default.
  61163. */
  61164. groundShadowLevel: number;
  61165. /**
  61166. * Creates a mirror texture attach to the ground.
  61167. * false by default.
  61168. */
  61169. enableGroundMirror: boolean;
  61170. /**
  61171. * Specifies the ground mirror size ratio.
  61172. * 0.3 by default as the default kernel is 64.
  61173. */
  61174. groundMirrorSizeRatio: number;
  61175. /**
  61176. * Specifies the ground mirror blur kernel size.
  61177. * 64 by default.
  61178. */
  61179. groundMirrorBlurKernel: number;
  61180. /**
  61181. * Specifies the ground mirror visibility amount.
  61182. * 1 by default
  61183. */
  61184. groundMirrorAmount: number;
  61185. /**
  61186. * Specifies the ground mirror reflectance weight.
  61187. * This uses the standard weight of the background material to setup the fresnel effect
  61188. * of the mirror.
  61189. * 1 by default.
  61190. */
  61191. groundMirrorFresnelWeight: number;
  61192. /**
  61193. * Specifies the ground mirror Falloff distance.
  61194. * This can helps reducing the size of the reflection.
  61195. * 0 by Default.
  61196. */
  61197. groundMirrorFallOffDistance: number;
  61198. /**
  61199. * Specifies the ground mirror texture type.
  61200. * Unsigned Int by Default.
  61201. */
  61202. groundMirrorTextureType: number;
  61203. /**
  61204. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  61205. * the shown objects.
  61206. */
  61207. groundYBias: number;
  61208. /**
  61209. * Specifies whether or not to create a skybox.
  61210. * True by default.
  61211. */
  61212. createSkybox: boolean;
  61213. /**
  61214. * Specifies the skybox size.
  61215. * 20 by default.
  61216. */
  61217. skyboxSize: number;
  61218. /**
  61219. * The texture used on the skybox for the main color.
  61220. * Comes from the BabylonJS CDN by default.
  61221. *
  61222. * Remarks: Can be either a texture or a url.
  61223. */
  61224. skyboxTexture: string | BaseTexture;
  61225. /**
  61226. * The color mixed in the skybox texture by default.
  61227. * BabylonJS clearColor by default.
  61228. */
  61229. skyboxColor: Color3;
  61230. /**
  61231. * The background rotation around the Y axis of the scene.
  61232. * This helps aligning the key lights of your scene with the background.
  61233. * 0 by default.
  61234. */
  61235. backgroundYRotation: number;
  61236. /**
  61237. * Compute automatically the size of the elements to best fit with the scene.
  61238. */
  61239. sizeAuto: boolean;
  61240. /**
  61241. * Default position of the rootMesh if autoSize is not true.
  61242. */
  61243. rootPosition: Vector3;
  61244. /**
  61245. * Sets up the image processing in the scene.
  61246. * true by default.
  61247. */
  61248. setupImageProcessing: boolean;
  61249. /**
  61250. * The texture used as your environment texture in the scene.
  61251. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  61252. *
  61253. * Remarks: Can be either a texture or a url.
  61254. */
  61255. environmentTexture: string | BaseTexture;
  61256. /**
  61257. * The value of the exposure to apply to the scene.
  61258. * 0.6 by default if setupImageProcessing is true.
  61259. */
  61260. cameraExposure: number;
  61261. /**
  61262. * The value of the contrast to apply to the scene.
  61263. * 1.6 by default if setupImageProcessing is true.
  61264. */
  61265. cameraContrast: number;
  61266. /**
  61267. * Specifies whether or not tonemapping should be enabled in the scene.
  61268. * true by default if setupImageProcessing is true.
  61269. */
  61270. toneMappingEnabled: boolean;
  61271. }
  61272. /**
  61273. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  61274. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  61275. * It also helps with the default setup of your imageProcessing configuration.
  61276. */
  61277. export class EnvironmentHelper {
  61278. /**
  61279. * Default ground texture URL.
  61280. */
  61281. private static _groundTextureCDNUrl;
  61282. /**
  61283. * Default skybox texture URL.
  61284. */
  61285. private static _skyboxTextureCDNUrl;
  61286. /**
  61287. * Default environment texture URL.
  61288. */
  61289. private static _environmentTextureCDNUrl;
  61290. /**
  61291. * Creates the default options for the helper.
  61292. */
  61293. private static _getDefaultOptions;
  61294. private _rootMesh;
  61295. /**
  61296. * Gets the root mesh created by the helper.
  61297. */
  61298. get rootMesh(): Mesh;
  61299. private _skybox;
  61300. /**
  61301. * Gets the skybox created by the helper.
  61302. */
  61303. get skybox(): Nullable<Mesh>;
  61304. private _skyboxTexture;
  61305. /**
  61306. * Gets the skybox texture created by the helper.
  61307. */
  61308. get skyboxTexture(): Nullable<BaseTexture>;
  61309. private _skyboxMaterial;
  61310. /**
  61311. * Gets the skybox material created by the helper.
  61312. */
  61313. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  61314. private _ground;
  61315. /**
  61316. * Gets the ground mesh created by the helper.
  61317. */
  61318. get ground(): Nullable<Mesh>;
  61319. private _groundTexture;
  61320. /**
  61321. * Gets the ground texture created by the helper.
  61322. */
  61323. get groundTexture(): Nullable<BaseTexture>;
  61324. private _groundMirror;
  61325. /**
  61326. * Gets the ground mirror created by the helper.
  61327. */
  61328. get groundMirror(): Nullable<MirrorTexture>;
  61329. /**
  61330. * Gets the ground mirror render list to helps pushing the meshes
  61331. * you wish in the ground reflection.
  61332. */
  61333. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  61334. private _groundMaterial;
  61335. /**
  61336. * Gets the ground material created by the helper.
  61337. */
  61338. get groundMaterial(): Nullable<BackgroundMaterial>;
  61339. /**
  61340. * Stores the creation options.
  61341. */
  61342. private readonly _scene;
  61343. private _options;
  61344. /**
  61345. * This observable will be notified with any error during the creation of the environment,
  61346. * mainly texture creation errors.
  61347. */
  61348. onErrorObservable: Observable<{
  61349. message?: string;
  61350. exception?: any;
  61351. }>;
  61352. /**
  61353. * constructor
  61354. * @param options Defines the options we want to customize the helper
  61355. * @param scene The scene to add the material to
  61356. */
  61357. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  61358. /**
  61359. * Updates the background according to the new options
  61360. * @param options
  61361. */
  61362. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  61363. /**
  61364. * Sets the primary color of all the available elements.
  61365. * @param color the main color to affect to the ground and the background
  61366. */
  61367. setMainColor(color: Color3): void;
  61368. /**
  61369. * Setup the image processing according to the specified options.
  61370. */
  61371. private _setupImageProcessing;
  61372. /**
  61373. * Setup the environment texture according to the specified options.
  61374. */
  61375. private _setupEnvironmentTexture;
  61376. /**
  61377. * Setup the background according to the specified options.
  61378. */
  61379. private _setupBackground;
  61380. /**
  61381. * Get the scene sizes according to the setup.
  61382. */
  61383. private _getSceneSize;
  61384. /**
  61385. * Setup the ground according to the specified options.
  61386. */
  61387. private _setupGround;
  61388. /**
  61389. * Setup the ground material according to the specified options.
  61390. */
  61391. private _setupGroundMaterial;
  61392. /**
  61393. * Setup the ground diffuse texture according to the specified options.
  61394. */
  61395. private _setupGroundDiffuseTexture;
  61396. /**
  61397. * Setup the ground mirror texture according to the specified options.
  61398. */
  61399. private _setupGroundMirrorTexture;
  61400. /**
  61401. * Setup the ground to receive the mirror texture.
  61402. */
  61403. private _setupMirrorInGroundMaterial;
  61404. /**
  61405. * Setup the skybox according to the specified options.
  61406. */
  61407. private _setupSkybox;
  61408. /**
  61409. * Setup the skybox material according to the specified options.
  61410. */
  61411. private _setupSkyboxMaterial;
  61412. /**
  61413. * Setup the skybox reflection texture according to the specified options.
  61414. */
  61415. private _setupSkyboxReflectionTexture;
  61416. private _errorHandler;
  61417. /**
  61418. * Dispose all the elements created by the Helper.
  61419. */
  61420. dispose(): void;
  61421. }
  61422. }
  61423. declare module "babylonjs/Helpers/textureDome" {
  61424. import { Scene } from "babylonjs/scene";
  61425. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61426. import { Mesh } from "babylonjs/Meshes/mesh";
  61427. import { Texture } from "babylonjs/Materials/Textures/texture";
  61428. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  61429. import "babylonjs/Meshes/Builders/sphereBuilder";
  61430. import { Nullable } from "babylonjs/types";
  61431. import { Observable } from "babylonjs/Misc/observable";
  61432. /**
  61433. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  61434. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  61435. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61436. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61437. */
  61438. export abstract class TextureDome<T extends Texture> extends TransformNode {
  61439. protected onError: Nullable<(message?: string, exception?: any) => void>;
  61440. /**
  61441. * Define the source as a Monoscopic panoramic 360/180.
  61442. */
  61443. static readonly MODE_MONOSCOPIC: number;
  61444. /**
  61445. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  61446. */
  61447. static readonly MODE_TOPBOTTOM: number;
  61448. /**
  61449. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  61450. */
  61451. static readonly MODE_SIDEBYSIDE: number;
  61452. private _halfDome;
  61453. private _crossEye;
  61454. protected _useDirectMapping: boolean;
  61455. /**
  61456. * The texture being displayed on the sphere
  61457. */
  61458. protected _texture: T;
  61459. /**
  61460. * Gets the texture being displayed on the sphere
  61461. */
  61462. get texture(): T;
  61463. /**
  61464. * Sets the texture being displayed on the sphere
  61465. */
  61466. set texture(newTexture: T);
  61467. /**
  61468. * The skybox material
  61469. */
  61470. protected _material: BackgroundMaterial;
  61471. /**
  61472. * The surface used for the dome
  61473. */
  61474. protected _mesh: Mesh;
  61475. /**
  61476. * Gets the mesh used for the dome.
  61477. */
  61478. get mesh(): Mesh;
  61479. /**
  61480. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  61481. */
  61482. private _halfDomeMask;
  61483. /**
  61484. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61485. * Also see the options.resolution property.
  61486. */
  61487. get fovMultiplier(): number;
  61488. set fovMultiplier(value: number);
  61489. protected _textureMode: number;
  61490. /**
  61491. * Gets or set the current texture mode for the texture. It can be:
  61492. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61493. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61494. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61495. */
  61496. get textureMode(): number;
  61497. /**
  61498. * Sets the current texture mode for the texture. It can be:
  61499. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61500. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61501. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61502. */
  61503. set textureMode(value: number);
  61504. /**
  61505. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  61506. */
  61507. get halfDome(): boolean;
  61508. /**
  61509. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  61510. */
  61511. set halfDome(enabled: boolean);
  61512. /**
  61513. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  61514. */
  61515. set crossEye(enabled: boolean);
  61516. /**
  61517. * Is it a cross-eye texture?
  61518. */
  61519. get crossEye(): boolean;
  61520. /**
  61521. * The background material of this dome.
  61522. */
  61523. get material(): BackgroundMaterial;
  61524. /**
  61525. * Oberserver used in Stereoscopic VR Mode.
  61526. */
  61527. private _onBeforeCameraRenderObserver;
  61528. /**
  61529. * Observable raised when an error occured while loading the 360 image
  61530. */
  61531. onLoadErrorObservable: Observable<string>;
  61532. /**
  61533. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  61534. * @param name Element's name, child elements will append suffixes for their own names.
  61535. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  61536. * @param options An object containing optional or exposed sub element properties
  61537. */
  61538. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  61539. resolution?: number;
  61540. clickToPlay?: boolean;
  61541. autoPlay?: boolean;
  61542. loop?: boolean;
  61543. size?: number;
  61544. poster?: string;
  61545. faceForward?: boolean;
  61546. useDirectMapping?: boolean;
  61547. halfDomeMode?: boolean;
  61548. crossEyeMode?: boolean;
  61549. generateMipMaps?: boolean;
  61550. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  61551. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  61552. protected _changeTextureMode(value: number): void;
  61553. /**
  61554. * Releases resources associated with this node.
  61555. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  61556. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  61557. */
  61558. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  61559. }
  61560. }
  61561. declare module "babylonjs/Helpers/photoDome" {
  61562. import { Scene } from "babylonjs/scene";
  61563. import { Texture } from "babylonjs/Materials/Textures/texture";
  61564. import { TextureDome } from "babylonjs/Helpers/textureDome";
  61565. /**
  61566. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  61567. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  61568. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61569. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61570. */
  61571. export class PhotoDome extends TextureDome<Texture> {
  61572. /**
  61573. * Define the image as a Monoscopic panoramic 360 image.
  61574. */
  61575. static readonly MODE_MONOSCOPIC: number;
  61576. /**
  61577. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  61578. */
  61579. static readonly MODE_TOPBOTTOM: number;
  61580. /**
  61581. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  61582. */
  61583. static readonly MODE_SIDEBYSIDE: number;
  61584. /**
  61585. * Gets or sets the texture being displayed on the sphere
  61586. */
  61587. get photoTexture(): Texture;
  61588. /**
  61589. * sets the texture being displayed on the sphere
  61590. */
  61591. set photoTexture(value: Texture);
  61592. /**
  61593. * Gets the current video mode for the video. It can be:
  61594. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61595. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61596. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61597. */
  61598. get imageMode(): number;
  61599. /**
  61600. * Sets the current video mode for the video. It can be:
  61601. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61602. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61603. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61604. */
  61605. set imageMode(value: number);
  61606. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  61607. }
  61608. }
  61609. declare module "babylonjs/Misc/dds" {
  61610. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  61611. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61612. import { Nullable } from "babylonjs/types";
  61613. import { Scene } from "babylonjs/scene";
  61614. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  61615. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61616. /**
  61617. * Direct draw surface info
  61618. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  61619. */
  61620. export interface DDSInfo {
  61621. /**
  61622. * Width of the texture
  61623. */
  61624. width: number;
  61625. /**
  61626. * Width of the texture
  61627. */
  61628. height: number;
  61629. /**
  61630. * Number of Mipmaps for the texture
  61631. * @see https://en.wikipedia.org/wiki/Mipmap
  61632. */
  61633. mipmapCount: number;
  61634. /**
  61635. * If the textures format is a known fourCC format
  61636. * @see https://www.fourcc.org/
  61637. */
  61638. isFourCC: boolean;
  61639. /**
  61640. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  61641. */
  61642. isRGB: boolean;
  61643. /**
  61644. * If the texture is a lumincance format
  61645. */
  61646. isLuminance: boolean;
  61647. /**
  61648. * If this is a cube texture
  61649. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  61650. */
  61651. isCube: boolean;
  61652. /**
  61653. * If the texture is a compressed format eg. FOURCC_DXT1
  61654. */
  61655. isCompressed: boolean;
  61656. /**
  61657. * The dxgiFormat of the texture
  61658. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  61659. */
  61660. dxgiFormat: number;
  61661. /**
  61662. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  61663. */
  61664. textureType: number;
  61665. /**
  61666. * Sphericle polynomial created for the dds texture
  61667. */
  61668. sphericalPolynomial?: SphericalPolynomial;
  61669. }
  61670. /**
  61671. * Class used to provide DDS decompression tools
  61672. */
  61673. export class DDSTools {
  61674. /**
  61675. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  61676. */
  61677. static StoreLODInAlphaChannel: boolean;
  61678. /**
  61679. * Gets DDS information from an array buffer
  61680. * @param data defines the array buffer view to read data from
  61681. * @returns the DDS information
  61682. */
  61683. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  61684. private static _FloatView;
  61685. private static _Int32View;
  61686. private static _ToHalfFloat;
  61687. private static _FromHalfFloat;
  61688. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  61689. private static _GetHalfFloatRGBAArrayBuffer;
  61690. private static _GetFloatRGBAArrayBuffer;
  61691. private static _GetFloatAsUIntRGBAArrayBuffer;
  61692. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  61693. private static _GetRGBAArrayBuffer;
  61694. private static _ExtractLongWordOrder;
  61695. private static _GetRGBArrayBuffer;
  61696. private static _GetLuminanceArrayBuffer;
  61697. /**
  61698. * Uploads DDS Levels to a Babylon Texture
  61699. * @hidden
  61700. */
  61701. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  61702. }
  61703. module "babylonjs/Engines/thinEngine" {
  61704. interface ThinEngine {
  61705. /**
  61706. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  61707. * @param rootUrl defines the url where the file to load is located
  61708. * @param scene defines the current scene
  61709. * @param lodScale defines scale to apply to the mip map selection
  61710. * @param lodOffset defines offset to apply to the mip map selection
  61711. * @param onLoad defines an optional callback raised when the texture is loaded
  61712. * @param onError defines an optional callback raised if there is an issue to load the texture
  61713. * @param format defines the format of the data
  61714. * @param forcedExtension defines the extension to use to pick the right loader
  61715. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  61716. * @returns the cube texture as an InternalTexture
  61717. */
  61718. 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;
  61719. }
  61720. }
  61721. }
  61722. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  61723. import { Nullable } from "babylonjs/types";
  61724. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61725. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61726. /**
  61727. * Implementation of the DDS Texture Loader.
  61728. * @hidden
  61729. */
  61730. export class _DDSTextureLoader implements IInternalTextureLoader {
  61731. /**
  61732. * Defines wether the loader supports cascade loading the different faces.
  61733. */
  61734. readonly supportCascades: boolean;
  61735. /**
  61736. * This returns if the loader support the current file information.
  61737. * @param extension defines the file extension of the file being loaded
  61738. * @returns true if the loader can load the specified file
  61739. */
  61740. canLoad(extension: string): boolean;
  61741. /**
  61742. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61743. * @param data contains the texture data
  61744. * @param texture defines the BabylonJS internal texture
  61745. * @param createPolynomials will be true if polynomials have been requested
  61746. * @param onLoad defines the callback to trigger once the texture is ready
  61747. * @param onError defines the callback to trigger in case of error
  61748. */
  61749. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61750. /**
  61751. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61752. * @param data contains the texture data
  61753. * @param texture defines the BabylonJS internal texture
  61754. * @param callback defines the method to call once ready to upload
  61755. */
  61756. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61757. }
  61758. }
  61759. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  61760. import { Nullable } from "babylonjs/types";
  61761. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61762. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61763. /**
  61764. * Implementation of the ENV Texture Loader.
  61765. * @hidden
  61766. */
  61767. export class _ENVTextureLoader implements IInternalTextureLoader {
  61768. /**
  61769. * Defines wether the loader supports cascade loading the different faces.
  61770. */
  61771. readonly supportCascades: boolean;
  61772. /**
  61773. * This returns if the loader support the current file information.
  61774. * @param extension defines the file extension of the file being loaded
  61775. * @returns true if the loader can load the specified file
  61776. */
  61777. canLoad(extension: string): boolean;
  61778. /**
  61779. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61780. * @param data contains the texture data
  61781. * @param texture defines the BabylonJS internal texture
  61782. * @param createPolynomials will be true if polynomials have been requested
  61783. * @param onLoad defines the callback to trigger once the texture is ready
  61784. * @param onError defines the callback to trigger in case of error
  61785. */
  61786. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61787. /**
  61788. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61789. * @param data contains the texture data
  61790. * @param texture defines the BabylonJS internal texture
  61791. * @param callback defines the method to call once ready to upload
  61792. */
  61793. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61794. }
  61795. }
  61796. declare module "babylonjs/Misc/khronosTextureContainer" {
  61797. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61798. /**
  61799. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  61800. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  61801. */
  61802. export class KhronosTextureContainer {
  61803. /** contents of the KTX container file */
  61804. data: ArrayBufferView;
  61805. private static HEADER_LEN;
  61806. private static COMPRESSED_2D;
  61807. private static COMPRESSED_3D;
  61808. private static TEX_2D;
  61809. private static TEX_3D;
  61810. /**
  61811. * Gets the openGL type
  61812. */
  61813. glType: number;
  61814. /**
  61815. * Gets the openGL type size
  61816. */
  61817. glTypeSize: number;
  61818. /**
  61819. * Gets the openGL format
  61820. */
  61821. glFormat: number;
  61822. /**
  61823. * Gets the openGL internal format
  61824. */
  61825. glInternalFormat: number;
  61826. /**
  61827. * Gets the base internal format
  61828. */
  61829. glBaseInternalFormat: number;
  61830. /**
  61831. * Gets image width in pixel
  61832. */
  61833. pixelWidth: number;
  61834. /**
  61835. * Gets image height in pixel
  61836. */
  61837. pixelHeight: number;
  61838. /**
  61839. * Gets image depth in pixels
  61840. */
  61841. pixelDepth: number;
  61842. /**
  61843. * Gets the number of array elements
  61844. */
  61845. numberOfArrayElements: number;
  61846. /**
  61847. * Gets the number of faces
  61848. */
  61849. numberOfFaces: number;
  61850. /**
  61851. * Gets the number of mipmap levels
  61852. */
  61853. numberOfMipmapLevels: number;
  61854. /**
  61855. * Gets the bytes of key value data
  61856. */
  61857. bytesOfKeyValueData: number;
  61858. /**
  61859. * Gets the load type
  61860. */
  61861. loadType: number;
  61862. /**
  61863. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  61864. */
  61865. isInvalid: boolean;
  61866. /**
  61867. * Creates a new KhronosTextureContainer
  61868. * @param data contents of the KTX container file
  61869. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  61870. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  61871. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  61872. */
  61873. constructor(
  61874. /** contents of the KTX container file */
  61875. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  61876. /**
  61877. * Uploads KTX content to a Babylon Texture.
  61878. * It is assumed that the texture has already been created & is currently bound
  61879. * @hidden
  61880. */
  61881. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  61882. private _upload2DCompressedLevels;
  61883. /**
  61884. * Checks if the given data starts with a KTX file identifier.
  61885. * @param data the data to check
  61886. * @returns true if the data is a KTX file or false otherwise
  61887. */
  61888. static IsValid(data: ArrayBufferView): boolean;
  61889. }
  61890. }
  61891. declare module "babylonjs/Misc/workerPool" {
  61892. import { IDisposable } from "babylonjs/scene";
  61893. /**
  61894. * Helper class to push actions to a pool of workers.
  61895. */
  61896. export class WorkerPool implements IDisposable {
  61897. private _workerInfos;
  61898. private _pendingActions;
  61899. /**
  61900. * Constructor
  61901. * @param workers Array of workers to use for actions
  61902. */
  61903. constructor(workers: Array<Worker>);
  61904. /**
  61905. * Terminates all workers and clears any pending actions.
  61906. */
  61907. dispose(): void;
  61908. /**
  61909. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61910. * pended until a worker has completed its action.
  61911. * @param action The action to perform. Call onComplete when the action is complete.
  61912. */
  61913. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61914. private _execute;
  61915. }
  61916. }
  61917. declare module "babylonjs/Misc/khronosTextureContainer2" {
  61918. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61919. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61920. /**
  61921. * Class for loading KTX2 files
  61922. */
  61923. export class KhronosTextureContainer2 {
  61924. private static _WorkerPoolPromise?;
  61925. private static _Initialized;
  61926. private static _Ktx2Decoder;
  61927. /**
  61928. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  61929. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  61930. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  61931. * Urls you can change:
  61932. * URLConfig.jsDecoderModule
  61933. * URLConfig.wasmUASTCToASTC
  61934. * URLConfig.wasmUASTCToBC7
  61935. * URLConfig.wasmUASTCToRGBA_UNORM
  61936. * URLConfig.wasmUASTCToRGBA_SRGB
  61937. * URLConfig.jsMSCTranscoder
  61938. * URLConfig.wasmMSCTranscoder
  61939. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  61940. */
  61941. static URLConfig: {
  61942. jsDecoderModule: string;
  61943. wasmUASTCToASTC: null;
  61944. wasmUASTCToBC7: null;
  61945. wasmUASTCToRGBA_UNORM: null;
  61946. wasmUASTCToRGBA_SRGB: null;
  61947. jsMSCTranscoder: null;
  61948. wasmMSCTranscoder: null;
  61949. };
  61950. /**
  61951. * Default number of workers used to handle data decoding
  61952. */
  61953. static DefaultNumWorkers: number;
  61954. private static GetDefaultNumWorkers;
  61955. private _engine;
  61956. private static _CreateWorkerPool;
  61957. /**
  61958. * Constructor
  61959. * @param engine The engine to use
  61960. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61961. */
  61962. constructor(engine: ThinEngine, numWorkers?: number);
  61963. /** @hidden */
  61964. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  61965. /**
  61966. * Stop all async operations and release resources.
  61967. */
  61968. dispose(): void;
  61969. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  61970. /**
  61971. * Checks if the given data starts with a KTX2 file identifier.
  61972. * @param data the data to check
  61973. * @returns true if the data is a KTX2 file or false otherwise
  61974. */
  61975. static IsValid(data: ArrayBufferView): boolean;
  61976. }
  61977. }
  61978. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  61979. import { Nullable } from "babylonjs/types";
  61980. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61981. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61982. /**
  61983. * Implementation of the KTX Texture Loader.
  61984. * @hidden
  61985. */
  61986. export class _KTXTextureLoader implements IInternalTextureLoader {
  61987. /**
  61988. * Defines wether the loader supports cascade loading the different faces.
  61989. */
  61990. readonly supportCascades: boolean;
  61991. /**
  61992. * This returns if the loader support the current file information.
  61993. * @param extension defines the file extension of the file being loaded
  61994. * @param mimeType defines the optional mime type of the file being loaded
  61995. * @returns true if the loader can load the specified file
  61996. */
  61997. canLoad(extension: string, mimeType?: string): boolean;
  61998. /**
  61999. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62000. * @param data contains the texture data
  62001. * @param texture defines the BabylonJS internal texture
  62002. * @param createPolynomials will be true if polynomials have been requested
  62003. * @param onLoad defines the callback to trigger once the texture is ready
  62004. * @param onError defines the callback to trigger in case of error
  62005. */
  62006. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62007. /**
  62008. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62009. * @param data contains the texture data
  62010. * @param texture defines the BabylonJS internal texture
  62011. * @param callback defines the method to call once ready to upload
  62012. */
  62013. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  62014. }
  62015. }
  62016. declare module "babylonjs/Helpers/sceneHelpers" {
  62017. import { Nullable } from "babylonjs/types";
  62018. import { Mesh } from "babylonjs/Meshes/mesh";
  62019. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62020. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  62021. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  62022. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  62023. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  62024. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  62025. import "babylonjs/Meshes/Builders/boxBuilder";
  62026. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  62027. /** @hidden */
  62028. export var _forceSceneHelpersToBundle: boolean;
  62029. module "babylonjs/scene" {
  62030. interface Scene {
  62031. /**
  62032. * Creates a default light for the scene.
  62033. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  62034. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  62035. */
  62036. createDefaultLight(replace?: boolean): void;
  62037. /**
  62038. * Creates a default camera for the scene.
  62039. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  62040. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62041. * @param replace has default false, when true replaces the active camera in the scene
  62042. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  62043. */
  62044. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62045. /**
  62046. * Creates a default camera and a default light.
  62047. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  62048. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62049. * @param replace has the default false, when true replaces the active camera/light in the scene
  62050. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  62051. */
  62052. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62053. /**
  62054. * Creates a new sky box
  62055. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  62056. * @param environmentTexture defines the texture to use as environment texture
  62057. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  62058. * @param scale defines the overall scale of the skybox
  62059. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  62060. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  62061. * @returns a new mesh holding the sky box
  62062. */
  62063. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  62064. /**
  62065. * Creates a new environment
  62066. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  62067. * @param options defines the options you can use to configure the environment
  62068. * @returns the new EnvironmentHelper
  62069. */
  62070. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  62071. /**
  62072. * Creates a new VREXperienceHelper
  62073. * @see https://doc.babylonjs.com/how_to/webvr_helper
  62074. * @param webVROptions defines the options used to create the new VREXperienceHelper
  62075. * @returns a new VREXperienceHelper
  62076. */
  62077. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  62078. /**
  62079. * Creates a new WebXRDefaultExperience
  62080. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  62081. * @param options experience options
  62082. * @returns a promise for a new WebXRDefaultExperience
  62083. */
  62084. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  62085. }
  62086. }
  62087. }
  62088. declare module "babylonjs/Helpers/videoDome" {
  62089. import { Scene } from "babylonjs/scene";
  62090. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  62091. import { TextureDome } from "babylonjs/Helpers/textureDome";
  62092. /**
  62093. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  62094. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  62095. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  62096. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62097. */
  62098. export class VideoDome extends TextureDome<VideoTexture> {
  62099. /**
  62100. * Define the video source as a Monoscopic panoramic 360 video.
  62101. */
  62102. static readonly MODE_MONOSCOPIC: number;
  62103. /**
  62104. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  62105. */
  62106. static readonly MODE_TOPBOTTOM: number;
  62107. /**
  62108. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  62109. */
  62110. static readonly MODE_SIDEBYSIDE: number;
  62111. /**
  62112. * Get the video texture associated with this video dome
  62113. */
  62114. get videoTexture(): VideoTexture;
  62115. /**
  62116. * Get the video mode of this dome
  62117. */
  62118. get videoMode(): number;
  62119. /**
  62120. * Set the video mode of this dome.
  62121. * @see textureMode
  62122. */
  62123. set videoMode(value: number);
  62124. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  62125. }
  62126. }
  62127. declare module "babylonjs/Helpers/index" {
  62128. export * from "babylonjs/Helpers/environmentHelper";
  62129. export * from "babylonjs/Helpers/photoDome";
  62130. export * from "babylonjs/Helpers/sceneHelpers";
  62131. export * from "babylonjs/Helpers/videoDome";
  62132. }
  62133. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  62134. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  62135. import { IDisposable } from "babylonjs/scene";
  62136. import { Engine } from "babylonjs/Engines/engine";
  62137. /**
  62138. * This class can be used to get instrumentation data from a Babylon engine
  62139. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62140. */
  62141. export class EngineInstrumentation implements IDisposable {
  62142. /**
  62143. * Define the instrumented engine.
  62144. */
  62145. engine: Engine;
  62146. private _captureGPUFrameTime;
  62147. private _gpuFrameTimeToken;
  62148. private _gpuFrameTime;
  62149. private _captureShaderCompilationTime;
  62150. private _shaderCompilationTime;
  62151. private _onBeginFrameObserver;
  62152. private _onEndFrameObserver;
  62153. private _onBeforeShaderCompilationObserver;
  62154. private _onAfterShaderCompilationObserver;
  62155. /**
  62156. * Gets the perf counter used for GPU frame time
  62157. */
  62158. get gpuFrameTimeCounter(): PerfCounter;
  62159. /**
  62160. * Gets the GPU frame time capture status
  62161. */
  62162. get captureGPUFrameTime(): boolean;
  62163. /**
  62164. * Enable or disable the GPU frame time capture
  62165. */
  62166. set captureGPUFrameTime(value: boolean);
  62167. /**
  62168. * Gets the perf counter used for shader compilation time
  62169. */
  62170. get shaderCompilationTimeCounter(): PerfCounter;
  62171. /**
  62172. * Gets the shader compilation time capture status
  62173. */
  62174. get captureShaderCompilationTime(): boolean;
  62175. /**
  62176. * Enable or disable the shader compilation time capture
  62177. */
  62178. set captureShaderCompilationTime(value: boolean);
  62179. /**
  62180. * Instantiates a new engine instrumentation.
  62181. * This class can be used to get instrumentation data from a Babylon engine
  62182. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62183. * @param engine Defines the engine to instrument
  62184. */
  62185. constructor(
  62186. /**
  62187. * Define the instrumented engine.
  62188. */
  62189. engine: Engine);
  62190. /**
  62191. * Dispose and release associated resources.
  62192. */
  62193. dispose(): void;
  62194. }
  62195. }
  62196. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  62197. import { Scene, IDisposable } from "babylonjs/scene";
  62198. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  62199. /**
  62200. * This class can be used to get instrumentation data from a Babylon engine
  62201. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62202. */
  62203. export class SceneInstrumentation implements IDisposable {
  62204. /**
  62205. * Defines the scene to instrument
  62206. */
  62207. scene: Scene;
  62208. private _captureActiveMeshesEvaluationTime;
  62209. private _activeMeshesEvaluationTime;
  62210. private _captureRenderTargetsRenderTime;
  62211. private _renderTargetsRenderTime;
  62212. private _captureFrameTime;
  62213. private _frameTime;
  62214. private _captureRenderTime;
  62215. private _renderTime;
  62216. private _captureInterFrameTime;
  62217. private _interFrameTime;
  62218. private _captureParticlesRenderTime;
  62219. private _particlesRenderTime;
  62220. private _captureSpritesRenderTime;
  62221. private _spritesRenderTime;
  62222. private _capturePhysicsTime;
  62223. private _physicsTime;
  62224. private _captureAnimationsTime;
  62225. private _animationsTime;
  62226. private _captureCameraRenderTime;
  62227. private _cameraRenderTime;
  62228. private _onBeforeActiveMeshesEvaluationObserver;
  62229. private _onAfterActiveMeshesEvaluationObserver;
  62230. private _onBeforeRenderTargetsRenderObserver;
  62231. private _onAfterRenderTargetsRenderObserver;
  62232. private _onAfterRenderObserver;
  62233. private _onBeforeDrawPhaseObserver;
  62234. private _onAfterDrawPhaseObserver;
  62235. private _onBeforeAnimationsObserver;
  62236. private _onBeforeParticlesRenderingObserver;
  62237. private _onAfterParticlesRenderingObserver;
  62238. private _onBeforeSpritesRenderingObserver;
  62239. private _onAfterSpritesRenderingObserver;
  62240. private _onBeforePhysicsObserver;
  62241. private _onAfterPhysicsObserver;
  62242. private _onAfterAnimationsObserver;
  62243. private _onBeforeCameraRenderObserver;
  62244. private _onAfterCameraRenderObserver;
  62245. /**
  62246. * Gets the perf counter used for active meshes evaluation time
  62247. */
  62248. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  62249. /**
  62250. * Gets the active meshes evaluation time capture status
  62251. */
  62252. get captureActiveMeshesEvaluationTime(): boolean;
  62253. /**
  62254. * Enable or disable the active meshes evaluation time capture
  62255. */
  62256. set captureActiveMeshesEvaluationTime(value: boolean);
  62257. /**
  62258. * Gets the perf counter used for render targets render time
  62259. */
  62260. get renderTargetsRenderTimeCounter(): PerfCounter;
  62261. /**
  62262. * Gets the render targets render time capture status
  62263. */
  62264. get captureRenderTargetsRenderTime(): boolean;
  62265. /**
  62266. * Enable or disable the render targets render time capture
  62267. */
  62268. set captureRenderTargetsRenderTime(value: boolean);
  62269. /**
  62270. * Gets the perf counter used for particles render time
  62271. */
  62272. get particlesRenderTimeCounter(): PerfCounter;
  62273. /**
  62274. * Gets the particles render time capture status
  62275. */
  62276. get captureParticlesRenderTime(): boolean;
  62277. /**
  62278. * Enable or disable the particles render time capture
  62279. */
  62280. set captureParticlesRenderTime(value: boolean);
  62281. /**
  62282. * Gets the perf counter used for sprites render time
  62283. */
  62284. get spritesRenderTimeCounter(): PerfCounter;
  62285. /**
  62286. * Gets the sprites render time capture status
  62287. */
  62288. get captureSpritesRenderTime(): boolean;
  62289. /**
  62290. * Enable or disable the sprites render time capture
  62291. */
  62292. set captureSpritesRenderTime(value: boolean);
  62293. /**
  62294. * Gets the perf counter used for physics time
  62295. */
  62296. get physicsTimeCounter(): PerfCounter;
  62297. /**
  62298. * Gets the physics time capture status
  62299. */
  62300. get capturePhysicsTime(): boolean;
  62301. /**
  62302. * Enable or disable the physics time capture
  62303. */
  62304. set capturePhysicsTime(value: boolean);
  62305. /**
  62306. * Gets the perf counter used for animations time
  62307. */
  62308. get animationsTimeCounter(): PerfCounter;
  62309. /**
  62310. * Gets the animations time capture status
  62311. */
  62312. get captureAnimationsTime(): boolean;
  62313. /**
  62314. * Enable or disable the animations time capture
  62315. */
  62316. set captureAnimationsTime(value: boolean);
  62317. /**
  62318. * Gets the perf counter used for frame time capture
  62319. */
  62320. get frameTimeCounter(): PerfCounter;
  62321. /**
  62322. * Gets the frame time capture status
  62323. */
  62324. get captureFrameTime(): boolean;
  62325. /**
  62326. * Enable or disable the frame time capture
  62327. */
  62328. set captureFrameTime(value: boolean);
  62329. /**
  62330. * Gets the perf counter used for inter-frames time capture
  62331. */
  62332. get interFrameTimeCounter(): PerfCounter;
  62333. /**
  62334. * Gets the inter-frames time capture status
  62335. */
  62336. get captureInterFrameTime(): boolean;
  62337. /**
  62338. * Enable or disable the inter-frames time capture
  62339. */
  62340. set captureInterFrameTime(value: boolean);
  62341. /**
  62342. * Gets the perf counter used for render time capture
  62343. */
  62344. get renderTimeCounter(): PerfCounter;
  62345. /**
  62346. * Gets the render time capture status
  62347. */
  62348. get captureRenderTime(): boolean;
  62349. /**
  62350. * Enable or disable the render time capture
  62351. */
  62352. set captureRenderTime(value: boolean);
  62353. /**
  62354. * Gets the perf counter used for camera render time capture
  62355. */
  62356. get cameraRenderTimeCounter(): PerfCounter;
  62357. /**
  62358. * Gets the camera render time capture status
  62359. */
  62360. get captureCameraRenderTime(): boolean;
  62361. /**
  62362. * Enable or disable the camera render time capture
  62363. */
  62364. set captureCameraRenderTime(value: boolean);
  62365. /**
  62366. * Gets the perf counter used for draw calls
  62367. */
  62368. get drawCallsCounter(): PerfCounter;
  62369. /**
  62370. * Instantiates a new scene instrumentation.
  62371. * This class can be used to get instrumentation data from a Babylon engine
  62372. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62373. * @param scene Defines the scene to instrument
  62374. */
  62375. constructor(
  62376. /**
  62377. * Defines the scene to instrument
  62378. */
  62379. scene: Scene);
  62380. /**
  62381. * Dispose and release associated resources.
  62382. */
  62383. dispose(): void;
  62384. }
  62385. }
  62386. declare module "babylonjs/Instrumentation/index" {
  62387. export * from "babylonjs/Instrumentation/engineInstrumentation";
  62388. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  62389. export * from "babylonjs/Instrumentation/timeToken";
  62390. }
  62391. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  62392. /** @hidden */
  62393. export var glowMapGenerationPixelShader: {
  62394. name: string;
  62395. shader: string;
  62396. };
  62397. }
  62398. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  62399. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62400. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62401. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62402. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62403. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62404. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62405. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62406. /** @hidden */
  62407. export var glowMapGenerationVertexShader: {
  62408. name: string;
  62409. shader: string;
  62410. };
  62411. }
  62412. declare module "babylonjs/Layers/effectLayer" {
  62413. import { Observable } from "babylonjs/Misc/observable";
  62414. import { Nullable } from "babylonjs/types";
  62415. import { Camera } from "babylonjs/Cameras/camera";
  62416. import { Scene } from "babylonjs/scene";
  62417. import { ISize } from "babylonjs/Maths/math.size";
  62418. import { Color4 } from "babylonjs/Maths/math.color";
  62419. import { Engine } from "babylonjs/Engines/engine";
  62420. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62422. import { Mesh } from "babylonjs/Meshes/mesh";
  62423. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62424. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62425. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62426. import { Effect } from "babylonjs/Materials/effect";
  62427. import { Material } from "babylonjs/Materials/material";
  62428. import "babylonjs/Shaders/glowMapGeneration.fragment";
  62429. import "babylonjs/Shaders/glowMapGeneration.vertex";
  62430. /**
  62431. * Effect layer options. This helps customizing the behaviour
  62432. * of the effect layer.
  62433. */
  62434. export interface IEffectLayerOptions {
  62435. /**
  62436. * Multiplication factor apply to the canvas size to compute the render target size
  62437. * used to generated the objects (the smaller the faster).
  62438. */
  62439. mainTextureRatio: number;
  62440. /**
  62441. * Enforces a fixed size texture to ensure effect stability across devices.
  62442. */
  62443. mainTextureFixedSize?: number;
  62444. /**
  62445. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  62446. */
  62447. alphaBlendingMode: number;
  62448. /**
  62449. * The camera attached to the layer.
  62450. */
  62451. camera: Nullable<Camera>;
  62452. /**
  62453. * The rendering group to draw the layer in.
  62454. */
  62455. renderingGroupId: number;
  62456. }
  62457. /**
  62458. * The effect layer Helps adding post process effect blended with the main pass.
  62459. *
  62460. * This can be for instance use to generate glow or higlight effects on the scene.
  62461. *
  62462. * The effect layer class can not be used directly and is intented to inherited from to be
  62463. * customized per effects.
  62464. */
  62465. export abstract class EffectLayer {
  62466. private _vertexBuffers;
  62467. private _indexBuffer;
  62468. private _cachedDefines;
  62469. private _effectLayerMapGenerationEffect;
  62470. private _effectLayerOptions;
  62471. private _mergeEffect;
  62472. protected _scene: Scene;
  62473. protected _engine: Engine;
  62474. protected _maxSize: number;
  62475. protected _mainTextureDesiredSize: ISize;
  62476. protected _mainTexture: RenderTargetTexture;
  62477. protected _shouldRender: boolean;
  62478. protected _postProcesses: PostProcess[];
  62479. protected _textures: BaseTexture[];
  62480. protected _emissiveTextureAndColor: {
  62481. texture: Nullable<BaseTexture>;
  62482. color: Color4;
  62483. };
  62484. /**
  62485. * The name of the layer
  62486. */
  62487. name: string;
  62488. /**
  62489. * The clear color of the texture used to generate the glow map.
  62490. */
  62491. neutralColor: Color4;
  62492. /**
  62493. * Specifies whether the highlight layer is enabled or not.
  62494. */
  62495. isEnabled: boolean;
  62496. /**
  62497. * Gets the camera attached to the layer.
  62498. */
  62499. get camera(): Nullable<Camera>;
  62500. /**
  62501. * Gets the rendering group id the layer should render in.
  62502. */
  62503. get renderingGroupId(): number;
  62504. set renderingGroupId(renderingGroupId: number);
  62505. /**
  62506. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  62507. */
  62508. disableBoundingBoxesFromEffectLayer: boolean;
  62509. /**
  62510. * An event triggered when the effect layer has been disposed.
  62511. */
  62512. onDisposeObservable: Observable<EffectLayer>;
  62513. /**
  62514. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  62515. */
  62516. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  62517. /**
  62518. * An event triggered when the generated texture is being merged in the scene.
  62519. */
  62520. onBeforeComposeObservable: Observable<EffectLayer>;
  62521. /**
  62522. * An event triggered when the mesh is rendered into the effect render target.
  62523. */
  62524. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  62525. /**
  62526. * An event triggered after the mesh has been rendered into the effect render target.
  62527. */
  62528. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  62529. /**
  62530. * An event triggered when the generated texture has been merged in the scene.
  62531. */
  62532. onAfterComposeObservable: Observable<EffectLayer>;
  62533. /**
  62534. * An event triggered when the efffect layer changes its size.
  62535. */
  62536. onSizeChangedObservable: Observable<EffectLayer>;
  62537. /** @hidden */
  62538. static _SceneComponentInitialization: (scene: Scene) => void;
  62539. /**
  62540. * Instantiates a new effect Layer and references it in the scene.
  62541. * @param name The name of the layer
  62542. * @param scene The scene to use the layer in
  62543. */
  62544. constructor(
  62545. /** The Friendly of the effect in the scene */
  62546. name: string, scene: Scene);
  62547. /**
  62548. * Get the effect name of the layer.
  62549. * @return The effect name
  62550. */
  62551. abstract getEffectName(): string;
  62552. /**
  62553. * Checks for the readiness of the element composing the layer.
  62554. * @param subMesh the mesh to check for
  62555. * @param useInstances specify whether or not to use instances to render the mesh
  62556. * @return true if ready otherwise, false
  62557. */
  62558. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62559. /**
  62560. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62561. * @returns true if the effect requires stencil during the main canvas render pass.
  62562. */
  62563. abstract needStencil(): boolean;
  62564. /**
  62565. * Create the merge effect. This is the shader use to blit the information back
  62566. * to the main canvas at the end of the scene rendering.
  62567. * @returns The effect containing the shader used to merge the effect on the main canvas
  62568. */
  62569. protected abstract _createMergeEffect(): Effect;
  62570. /**
  62571. * Creates the render target textures and post processes used in the effect layer.
  62572. */
  62573. protected abstract _createTextureAndPostProcesses(): void;
  62574. /**
  62575. * Implementation specific of rendering the generating effect on the main canvas.
  62576. * @param effect The effect used to render through
  62577. */
  62578. protected abstract _internalRender(effect: Effect): void;
  62579. /**
  62580. * Sets the required values for both the emissive texture and and the main color.
  62581. */
  62582. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62583. /**
  62584. * Free any resources and references associated to a mesh.
  62585. * Internal use
  62586. * @param mesh The mesh to free.
  62587. */
  62588. abstract _disposeMesh(mesh: Mesh): void;
  62589. /**
  62590. * Serializes this layer (Glow or Highlight for example)
  62591. * @returns a serialized layer object
  62592. */
  62593. abstract serialize?(): any;
  62594. /**
  62595. * Initializes the effect layer with the required options.
  62596. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  62597. */
  62598. protected _init(options: Partial<IEffectLayerOptions>): void;
  62599. /**
  62600. * Generates the index buffer of the full screen quad blending to the main canvas.
  62601. */
  62602. private _generateIndexBuffer;
  62603. /**
  62604. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  62605. */
  62606. private _generateVertexBuffer;
  62607. /**
  62608. * Sets the main texture desired size which is the closest power of two
  62609. * of the engine canvas size.
  62610. */
  62611. private _setMainTextureSize;
  62612. /**
  62613. * Creates the main texture for the effect layer.
  62614. */
  62615. protected _createMainTexture(): void;
  62616. /**
  62617. * Adds specific effects defines.
  62618. * @param defines The defines to add specifics to.
  62619. */
  62620. protected _addCustomEffectDefines(defines: string[]): void;
  62621. /**
  62622. * Checks for the readiness of the element composing the layer.
  62623. * @param subMesh the mesh to check for
  62624. * @param useInstances specify whether or not to use instances to render the mesh
  62625. * @param emissiveTexture the associated emissive texture used to generate the glow
  62626. * @return true if ready otherwise, false
  62627. */
  62628. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  62629. /**
  62630. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  62631. */
  62632. render(): void;
  62633. /**
  62634. * Determine if a given mesh will be used in the current effect.
  62635. * @param mesh mesh to test
  62636. * @returns true if the mesh will be used
  62637. */
  62638. hasMesh(mesh: AbstractMesh): boolean;
  62639. /**
  62640. * Returns true if the layer contains information to display, otherwise false.
  62641. * @returns true if the glow layer should be rendered
  62642. */
  62643. shouldRender(): boolean;
  62644. /**
  62645. * Returns true if the mesh should render, otherwise false.
  62646. * @param mesh The mesh to render
  62647. * @returns true if it should render otherwise false
  62648. */
  62649. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  62650. /**
  62651. * Returns true if the mesh can be rendered, otherwise false.
  62652. * @param mesh The mesh to render
  62653. * @param material The material used on the mesh
  62654. * @returns true if it can be rendered otherwise false
  62655. */
  62656. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62657. /**
  62658. * Returns true if the mesh should render, otherwise false.
  62659. * @param mesh The mesh to render
  62660. * @returns true if it should render otherwise false
  62661. */
  62662. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  62663. /**
  62664. * Renders the submesh passed in parameter to the generation map.
  62665. */
  62666. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  62667. /**
  62668. * Defines whether the current material of the mesh should be use to render the effect.
  62669. * @param mesh defines the current mesh to render
  62670. */
  62671. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62672. /**
  62673. * Rebuild the required buffers.
  62674. * @hidden Internal use only.
  62675. */
  62676. _rebuild(): void;
  62677. /**
  62678. * Dispose only the render target textures and post process.
  62679. */
  62680. private _disposeTextureAndPostProcesses;
  62681. /**
  62682. * Dispose the highlight layer and free resources.
  62683. */
  62684. dispose(): void;
  62685. /**
  62686. * Gets the class name of the effect layer
  62687. * @returns the string with the class name of the effect layer
  62688. */
  62689. getClassName(): string;
  62690. /**
  62691. * Creates an effect layer from parsed effect layer data
  62692. * @param parsedEffectLayer defines effect layer data
  62693. * @param scene defines the current scene
  62694. * @param rootUrl defines the root URL containing the effect layer information
  62695. * @returns a parsed effect Layer
  62696. */
  62697. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  62698. }
  62699. }
  62700. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  62701. import { Scene } from "babylonjs/scene";
  62702. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62703. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62704. import { AbstractScene } from "babylonjs/abstractScene";
  62705. module "babylonjs/abstractScene" {
  62706. interface AbstractScene {
  62707. /**
  62708. * The list of effect layers (highlights/glow) added to the scene
  62709. * @see https://doc.babylonjs.com/how_to/highlight_layer
  62710. * @see https://doc.babylonjs.com/how_to/glow_layer
  62711. */
  62712. effectLayers: Array<EffectLayer>;
  62713. /**
  62714. * Removes the given effect layer from this scene.
  62715. * @param toRemove defines the effect layer to remove
  62716. * @returns the index of the removed effect layer
  62717. */
  62718. removeEffectLayer(toRemove: EffectLayer): number;
  62719. /**
  62720. * Adds the given effect layer to this scene
  62721. * @param newEffectLayer defines the effect layer to add
  62722. */
  62723. addEffectLayer(newEffectLayer: EffectLayer): void;
  62724. }
  62725. }
  62726. /**
  62727. * Defines the layer scene component responsible to manage any effect layers
  62728. * in a given scene.
  62729. */
  62730. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  62731. /**
  62732. * The component name helpfull to identify the component in the list of scene components.
  62733. */
  62734. readonly name: string;
  62735. /**
  62736. * The scene the component belongs to.
  62737. */
  62738. scene: Scene;
  62739. private _engine;
  62740. private _renderEffects;
  62741. private _needStencil;
  62742. private _previousStencilState;
  62743. /**
  62744. * Creates a new instance of the component for the given scene
  62745. * @param scene Defines the scene to register the component in
  62746. */
  62747. constructor(scene: Scene);
  62748. /**
  62749. * Registers the component in a given scene
  62750. */
  62751. register(): void;
  62752. /**
  62753. * Rebuilds the elements related to this component in case of
  62754. * context lost for instance.
  62755. */
  62756. rebuild(): void;
  62757. /**
  62758. * Serializes the component data to the specified json object
  62759. * @param serializationObject The object to serialize to
  62760. */
  62761. serialize(serializationObject: any): void;
  62762. /**
  62763. * Adds all the elements from the container to the scene
  62764. * @param container the container holding the elements
  62765. */
  62766. addFromContainer(container: AbstractScene): void;
  62767. /**
  62768. * Removes all the elements in the container from the scene
  62769. * @param container contains the elements to remove
  62770. * @param dispose if the removed element should be disposed (default: false)
  62771. */
  62772. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62773. /**
  62774. * Disposes the component and the associated ressources.
  62775. */
  62776. dispose(): void;
  62777. private _isReadyForMesh;
  62778. private _renderMainTexture;
  62779. private _setStencil;
  62780. private _setStencilBack;
  62781. private _draw;
  62782. private _drawCamera;
  62783. private _drawRenderingGroup;
  62784. }
  62785. }
  62786. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  62787. /** @hidden */
  62788. export var glowMapMergePixelShader: {
  62789. name: string;
  62790. shader: string;
  62791. };
  62792. }
  62793. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  62794. /** @hidden */
  62795. export var glowMapMergeVertexShader: {
  62796. name: string;
  62797. shader: string;
  62798. };
  62799. }
  62800. declare module "babylonjs/Layers/glowLayer" {
  62801. import { Nullable } from "babylonjs/types";
  62802. import { Camera } from "babylonjs/Cameras/camera";
  62803. import { Scene } from "babylonjs/scene";
  62804. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62806. import { Mesh } from "babylonjs/Meshes/mesh";
  62807. import { Texture } from "babylonjs/Materials/Textures/texture";
  62808. import { Effect } from "babylonjs/Materials/effect";
  62809. import { Material } from "babylonjs/Materials/material";
  62810. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62811. import { Color4 } from "babylonjs/Maths/math.color";
  62812. import "babylonjs/Shaders/glowMapMerge.fragment";
  62813. import "babylonjs/Shaders/glowMapMerge.vertex";
  62814. import "babylonjs/Layers/effectLayerSceneComponent";
  62815. module "babylonjs/abstractScene" {
  62816. interface AbstractScene {
  62817. /**
  62818. * Return a the first highlight layer of the scene with a given name.
  62819. * @param name The name of the highlight layer to look for.
  62820. * @return The highlight layer if found otherwise null.
  62821. */
  62822. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  62823. }
  62824. }
  62825. /**
  62826. * Glow layer options. This helps customizing the behaviour
  62827. * of the glow layer.
  62828. */
  62829. export interface IGlowLayerOptions {
  62830. /**
  62831. * Multiplication factor apply to the canvas size to compute the render target size
  62832. * used to generated the glowing objects (the smaller the faster).
  62833. */
  62834. mainTextureRatio: number;
  62835. /**
  62836. * Enforces a fixed size texture to ensure resize independant blur.
  62837. */
  62838. mainTextureFixedSize?: number;
  62839. /**
  62840. * How big is the kernel of the blur texture.
  62841. */
  62842. blurKernelSize: number;
  62843. /**
  62844. * The camera attached to the layer.
  62845. */
  62846. camera: Nullable<Camera>;
  62847. /**
  62848. * Enable MSAA by chosing the number of samples.
  62849. */
  62850. mainTextureSamples?: number;
  62851. /**
  62852. * The rendering group to draw the layer in.
  62853. */
  62854. renderingGroupId: number;
  62855. }
  62856. /**
  62857. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  62858. *
  62859. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  62860. *
  62861. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  62862. */
  62863. export class GlowLayer extends EffectLayer {
  62864. /**
  62865. * Effect Name of the layer.
  62866. */
  62867. static readonly EffectName: string;
  62868. /**
  62869. * The default blur kernel size used for the glow.
  62870. */
  62871. static DefaultBlurKernelSize: number;
  62872. /**
  62873. * The default texture size ratio used for the glow.
  62874. */
  62875. static DefaultTextureRatio: number;
  62876. /**
  62877. * Sets the kernel size of the blur.
  62878. */
  62879. set blurKernelSize(value: number);
  62880. /**
  62881. * Gets the kernel size of the blur.
  62882. */
  62883. get blurKernelSize(): number;
  62884. /**
  62885. * Sets the glow intensity.
  62886. */
  62887. set intensity(value: number);
  62888. /**
  62889. * Gets the glow intensity.
  62890. */
  62891. get intensity(): number;
  62892. private _options;
  62893. private _intensity;
  62894. private _horizontalBlurPostprocess1;
  62895. private _verticalBlurPostprocess1;
  62896. private _horizontalBlurPostprocess2;
  62897. private _verticalBlurPostprocess2;
  62898. private _blurTexture1;
  62899. private _blurTexture2;
  62900. private _postProcesses1;
  62901. private _postProcesses2;
  62902. private _includedOnlyMeshes;
  62903. private _excludedMeshes;
  62904. private _meshesUsingTheirOwnMaterials;
  62905. /**
  62906. * Callback used to let the user override the color selection on a per mesh basis
  62907. */
  62908. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  62909. /**
  62910. * Callback used to let the user override the texture selection on a per mesh basis
  62911. */
  62912. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  62913. /**
  62914. * Instantiates a new glow Layer and references it to the scene.
  62915. * @param name The name of the layer
  62916. * @param scene The scene to use the layer in
  62917. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  62918. */
  62919. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  62920. /**
  62921. * Get the effect name of the layer.
  62922. * @return The effect name
  62923. */
  62924. getEffectName(): string;
  62925. /**
  62926. * Create the merge effect. This is the shader use to blit the information back
  62927. * to the main canvas at the end of the scene rendering.
  62928. */
  62929. protected _createMergeEffect(): Effect;
  62930. /**
  62931. * Creates the render target textures and post processes used in the glow layer.
  62932. */
  62933. protected _createTextureAndPostProcesses(): void;
  62934. /**
  62935. * Checks for the readiness of the element composing the layer.
  62936. * @param subMesh the mesh to check for
  62937. * @param useInstances specify wether or not to use instances to render the mesh
  62938. * @param emissiveTexture the associated emissive texture used to generate the glow
  62939. * @return true if ready otherwise, false
  62940. */
  62941. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62942. /**
  62943. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62944. */
  62945. needStencil(): boolean;
  62946. /**
  62947. * Returns true if the mesh can be rendered, otherwise false.
  62948. * @param mesh The mesh to render
  62949. * @param material The material used on the mesh
  62950. * @returns true if it can be rendered otherwise false
  62951. */
  62952. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62953. /**
  62954. * Implementation specific of rendering the generating effect on the main canvas.
  62955. * @param effect The effect used to render through
  62956. */
  62957. protected _internalRender(effect: Effect): void;
  62958. /**
  62959. * Sets the required values for both the emissive texture and and the main color.
  62960. */
  62961. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62962. /**
  62963. * Returns true if the mesh should render, otherwise false.
  62964. * @param mesh The mesh to render
  62965. * @returns true if it should render otherwise false
  62966. */
  62967. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62968. /**
  62969. * Adds specific effects defines.
  62970. * @param defines The defines to add specifics to.
  62971. */
  62972. protected _addCustomEffectDefines(defines: string[]): void;
  62973. /**
  62974. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  62975. * @param mesh The mesh to exclude from the glow layer
  62976. */
  62977. addExcludedMesh(mesh: Mesh): void;
  62978. /**
  62979. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  62980. * @param mesh The mesh to remove
  62981. */
  62982. removeExcludedMesh(mesh: Mesh): void;
  62983. /**
  62984. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  62985. * @param mesh The mesh to include in the glow layer
  62986. */
  62987. addIncludedOnlyMesh(mesh: Mesh): void;
  62988. /**
  62989. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  62990. * @param mesh The mesh to remove
  62991. */
  62992. removeIncludedOnlyMesh(mesh: Mesh): void;
  62993. /**
  62994. * Determine if a given mesh will be used in the glow layer
  62995. * @param mesh The mesh to test
  62996. * @returns true if the mesh will be highlighted by the current glow layer
  62997. */
  62998. hasMesh(mesh: AbstractMesh): boolean;
  62999. /**
  63000. * Defines whether the current material of the mesh should be use to render the effect.
  63001. * @param mesh defines the current mesh to render
  63002. */
  63003. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63004. /**
  63005. * Add a mesh to be rendered through its own material and not with emissive only.
  63006. * @param mesh The mesh for which we need to use its material
  63007. */
  63008. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  63009. /**
  63010. * Remove a mesh from being rendered through its own material and not with emissive only.
  63011. * @param mesh The mesh for which we need to not use its material
  63012. */
  63013. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  63014. /**
  63015. * Free any resources and references associated to a mesh.
  63016. * Internal use
  63017. * @param mesh The mesh to free.
  63018. * @hidden
  63019. */
  63020. _disposeMesh(mesh: Mesh): void;
  63021. /**
  63022. * Gets the class name of the effect layer
  63023. * @returns the string with the class name of the effect layer
  63024. */
  63025. getClassName(): string;
  63026. /**
  63027. * Serializes this glow layer
  63028. * @returns a serialized glow layer object
  63029. */
  63030. serialize(): any;
  63031. /**
  63032. * Creates a Glow Layer from parsed glow layer data
  63033. * @param parsedGlowLayer defines glow layer data
  63034. * @param scene defines the current scene
  63035. * @param rootUrl defines the root URL containing the glow layer information
  63036. * @returns a parsed Glow Layer
  63037. */
  63038. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  63039. }
  63040. }
  63041. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  63042. /** @hidden */
  63043. export var glowBlurPostProcessPixelShader: {
  63044. name: string;
  63045. shader: string;
  63046. };
  63047. }
  63048. declare module "babylonjs/Layers/highlightLayer" {
  63049. import { Observable } from "babylonjs/Misc/observable";
  63050. import { Nullable } from "babylonjs/types";
  63051. import { Camera } from "babylonjs/Cameras/camera";
  63052. import { Scene } from "babylonjs/scene";
  63053. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63055. import { Mesh } from "babylonjs/Meshes/mesh";
  63056. import { Effect } from "babylonjs/Materials/effect";
  63057. import { Material } from "babylonjs/Materials/material";
  63058. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  63059. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  63060. import "babylonjs/Shaders/glowMapMerge.fragment";
  63061. import "babylonjs/Shaders/glowMapMerge.vertex";
  63062. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  63063. module "babylonjs/abstractScene" {
  63064. interface AbstractScene {
  63065. /**
  63066. * Return a the first highlight layer of the scene with a given name.
  63067. * @param name The name of the highlight layer to look for.
  63068. * @return The highlight layer if found otherwise null.
  63069. */
  63070. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  63071. }
  63072. }
  63073. /**
  63074. * Highlight layer options. This helps customizing the behaviour
  63075. * of the highlight layer.
  63076. */
  63077. export interface IHighlightLayerOptions {
  63078. /**
  63079. * Multiplication factor apply to the canvas size to compute the render target size
  63080. * used to generated the glowing objects (the smaller the faster).
  63081. */
  63082. mainTextureRatio: number;
  63083. /**
  63084. * Enforces a fixed size texture to ensure resize independant blur.
  63085. */
  63086. mainTextureFixedSize?: number;
  63087. /**
  63088. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  63089. * of the picture to blur (the smaller the faster).
  63090. */
  63091. blurTextureSizeRatio: number;
  63092. /**
  63093. * How big in texel of the blur texture is the vertical blur.
  63094. */
  63095. blurVerticalSize: number;
  63096. /**
  63097. * How big in texel of the blur texture is the horizontal blur.
  63098. */
  63099. blurHorizontalSize: number;
  63100. /**
  63101. * Alpha blending mode used to apply the blur. Default is combine.
  63102. */
  63103. alphaBlendingMode: number;
  63104. /**
  63105. * The camera attached to the layer.
  63106. */
  63107. camera: Nullable<Camera>;
  63108. /**
  63109. * Should we display highlight as a solid stroke?
  63110. */
  63111. isStroke?: boolean;
  63112. /**
  63113. * The rendering group to draw the layer in.
  63114. */
  63115. renderingGroupId: number;
  63116. }
  63117. /**
  63118. * The highlight layer Helps adding a glow effect around a mesh.
  63119. *
  63120. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  63121. * glowy meshes to your scene.
  63122. *
  63123. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  63124. */
  63125. export class HighlightLayer extends EffectLayer {
  63126. name: string;
  63127. /**
  63128. * Effect Name of the highlight layer.
  63129. */
  63130. static readonly EffectName: string;
  63131. /**
  63132. * The neutral color used during the preparation of the glow effect.
  63133. * This is black by default as the blend operation is a blend operation.
  63134. */
  63135. static NeutralColor: Color4;
  63136. /**
  63137. * Stencil value used for glowing meshes.
  63138. */
  63139. static GlowingMeshStencilReference: number;
  63140. /**
  63141. * Stencil value used for the other meshes in the scene.
  63142. */
  63143. static NormalMeshStencilReference: number;
  63144. /**
  63145. * Specifies whether or not the inner glow is ACTIVE in the layer.
  63146. */
  63147. innerGlow: boolean;
  63148. /**
  63149. * Specifies whether or not the outer glow is ACTIVE in the layer.
  63150. */
  63151. outerGlow: boolean;
  63152. /**
  63153. * Specifies the horizontal size of the blur.
  63154. */
  63155. set blurHorizontalSize(value: number);
  63156. /**
  63157. * Specifies the vertical size of the blur.
  63158. */
  63159. set blurVerticalSize(value: number);
  63160. /**
  63161. * Gets the horizontal size of the blur.
  63162. */
  63163. get blurHorizontalSize(): number;
  63164. /**
  63165. * Gets the vertical size of the blur.
  63166. */
  63167. get blurVerticalSize(): number;
  63168. /**
  63169. * An event triggered when the highlight layer is being blurred.
  63170. */
  63171. onBeforeBlurObservable: Observable<HighlightLayer>;
  63172. /**
  63173. * An event triggered when the highlight layer has been blurred.
  63174. */
  63175. onAfterBlurObservable: Observable<HighlightLayer>;
  63176. private _instanceGlowingMeshStencilReference;
  63177. private _options;
  63178. private _downSamplePostprocess;
  63179. private _horizontalBlurPostprocess;
  63180. private _verticalBlurPostprocess;
  63181. private _blurTexture;
  63182. private _meshes;
  63183. private _excludedMeshes;
  63184. /**
  63185. * Instantiates a new highlight Layer and references it to the scene..
  63186. * @param name The name of the layer
  63187. * @param scene The scene to use the layer in
  63188. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  63189. */
  63190. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  63191. /**
  63192. * Get the effect name of the layer.
  63193. * @return The effect name
  63194. */
  63195. getEffectName(): string;
  63196. /**
  63197. * Create the merge effect. This is the shader use to blit the information back
  63198. * to the main canvas at the end of the scene rendering.
  63199. */
  63200. protected _createMergeEffect(): Effect;
  63201. /**
  63202. * Creates the render target textures and post processes used in the highlight layer.
  63203. */
  63204. protected _createTextureAndPostProcesses(): void;
  63205. /**
  63206. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  63207. */
  63208. needStencil(): boolean;
  63209. /**
  63210. * Checks for the readiness of the element composing the layer.
  63211. * @param subMesh the mesh to check for
  63212. * @param useInstances specify wether or not to use instances to render the mesh
  63213. * @param emissiveTexture the associated emissive texture used to generate the glow
  63214. * @return true if ready otherwise, false
  63215. */
  63216. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63217. /**
  63218. * Implementation specific of rendering the generating effect on the main canvas.
  63219. * @param effect The effect used to render through
  63220. */
  63221. protected _internalRender(effect: Effect): void;
  63222. /**
  63223. * Returns true if the layer contains information to display, otherwise false.
  63224. */
  63225. shouldRender(): boolean;
  63226. /**
  63227. * Returns true if the mesh should render, otherwise false.
  63228. * @param mesh The mesh to render
  63229. * @returns true if it should render otherwise false
  63230. */
  63231. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63232. /**
  63233. * Returns true if the mesh can be rendered, otherwise false.
  63234. * @param mesh The mesh to render
  63235. * @param material The material used on the mesh
  63236. * @returns true if it can be rendered otherwise false
  63237. */
  63238. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63239. /**
  63240. * Adds specific effects defines.
  63241. * @param defines The defines to add specifics to.
  63242. */
  63243. protected _addCustomEffectDefines(defines: string[]): void;
  63244. /**
  63245. * Sets the required values for both the emissive texture and and the main color.
  63246. */
  63247. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63248. /**
  63249. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  63250. * @param mesh The mesh to exclude from the highlight layer
  63251. */
  63252. addExcludedMesh(mesh: Mesh): void;
  63253. /**
  63254. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  63255. * @param mesh The mesh to highlight
  63256. */
  63257. removeExcludedMesh(mesh: Mesh): void;
  63258. /**
  63259. * Determine if a given mesh will be highlighted by the current HighlightLayer
  63260. * @param mesh mesh to test
  63261. * @returns true if the mesh will be highlighted by the current HighlightLayer
  63262. */
  63263. hasMesh(mesh: AbstractMesh): boolean;
  63264. /**
  63265. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  63266. * @param mesh The mesh to highlight
  63267. * @param color The color of the highlight
  63268. * @param glowEmissiveOnly Extract the glow from the emissive texture
  63269. */
  63270. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  63271. /**
  63272. * Remove a mesh from the highlight layer in order to make it stop glowing.
  63273. * @param mesh The mesh to highlight
  63274. */
  63275. removeMesh(mesh: Mesh): void;
  63276. /**
  63277. * Remove all the meshes currently referenced in the highlight layer
  63278. */
  63279. removeAllMeshes(): void;
  63280. /**
  63281. * Force the stencil to the normal expected value for none glowing parts
  63282. */
  63283. private _defaultStencilReference;
  63284. /**
  63285. * Free any resources and references associated to a mesh.
  63286. * Internal use
  63287. * @param mesh The mesh to free.
  63288. * @hidden
  63289. */
  63290. _disposeMesh(mesh: Mesh): void;
  63291. /**
  63292. * Dispose the highlight layer and free resources.
  63293. */
  63294. dispose(): void;
  63295. /**
  63296. * Gets the class name of the effect layer
  63297. * @returns the string with the class name of the effect layer
  63298. */
  63299. getClassName(): string;
  63300. /**
  63301. * Serializes this Highlight layer
  63302. * @returns a serialized Highlight layer object
  63303. */
  63304. serialize(): any;
  63305. /**
  63306. * Creates a Highlight layer from parsed Highlight layer data
  63307. * @param parsedHightlightLayer defines the Highlight layer data
  63308. * @param scene defines the current scene
  63309. * @param rootUrl defines the root URL containing the Highlight layer information
  63310. * @returns a parsed Highlight layer
  63311. */
  63312. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  63313. }
  63314. }
  63315. declare module "babylonjs/Layers/layerSceneComponent" {
  63316. import { Scene } from "babylonjs/scene";
  63317. import { ISceneComponent } from "babylonjs/sceneComponent";
  63318. import { Layer } from "babylonjs/Layers/layer";
  63319. import { AbstractScene } from "babylonjs/abstractScene";
  63320. module "babylonjs/abstractScene" {
  63321. interface AbstractScene {
  63322. /**
  63323. * The list of layers (background and foreground) of the scene
  63324. */
  63325. layers: Array<Layer>;
  63326. }
  63327. }
  63328. /**
  63329. * Defines the layer scene component responsible to manage any layers
  63330. * in a given scene.
  63331. */
  63332. export class LayerSceneComponent implements ISceneComponent {
  63333. /**
  63334. * The component name helpfull to identify the component in the list of scene components.
  63335. */
  63336. readonly name: string;
  63337. /**
  63338. * The scene the component belongs to.
  63339. */
  63340. scene: Scene;
  63341. private _engine;
  63342. /**
  63343. * Creates a new instance of the component for the given scene
  63344. * @param scene Defines the scene to register the component in
  63345. */
  63346. constructor(scene: Scene);
  63347. /**
  63348. * Registers the component in a given scene
  63349. */
  63350. register(): void;
  63351. /**
  63352. * Rebuilds the elements related to this component in case of
  63353. * context lost for instance.
  63354. */
  63355. rebuild(): void;
  63356. /**
  63357. * Disposes the component and the associated ressources.
  63358. */
  63359. dispose(): void;
  63360. private _draw;
  63361. private _drawCameraPredicate;
  63362. private _drawCameraBackground;
  63363. private _drawCameraForeground;
  63364. private _drawRenderTargetPredicate;
  63365. private _drawRenderTargetBackground;
  63366. private _drawRenderTargetForeground;
  63367. /**
  63368. * Adds all the elements from the container to the scene
  63369. * @param container the container holding the elements
  63370. */
  63371. addFromContainer(container: AbstractScene): void;
  63372. /**
  63373. * Removes all the elements in the container from the scene
  63374. * @param container contains the elements to remove
  63375. * @param dispose if the removed element should be disposed (default: false)
  63376. */
  63377. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63378. }
  63379. }
  63380. declare module "babylonjs/Shaders/layer.fragment" {
  63381. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63382. /** @hidden */
  63383. export var layerPixelShader: {
  63384. name: string;
  63385. shader: string;
  63386. };
  63387. }
  63388. declare module "babylonjs/Shaders/layer.vertex" {
  63389. /** @hidden */
  63390. export var layerVertexShader: {
  63391. name: string;
  63392. shader: string;
  63393. };
  63394. }
  63395. declare module "babylonjs/Layers/layer" {
  63396. import { Observable } from "babylonjs/Misc/observable";
  63397. import { Nullable } from "babylonjs/types";
  63398. import { Scene } from "babylonjs/scene";
  63399. import { Vector2 } from "babylonjs/Maths/math.vector";
  63400. import { Color4 } from "babylonjs/Maths/math.color";
  63401. import { Texture } from "babylonjs/Materials/Textures/texture";
  63402. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63403. import "babylonjs/Shaders/layer.fragment";
  63404. import "babylonjs/Shaders/layer.vertex";
  63405. /**
  63406. * This represents a full screen 2d layer.
  63407. * This can be useful to display a picture in the background of your scene for instance.
  63408. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63409. */
  63410. export class Layer {
  63411. /**
  63412. * Define the name of the layer.
  63413. */
  63414. name: string;
  63415. /**
  63416. * Define the texture the layer should display.
  63417. */
  63418. texture: Nullable<Texture>;
  63419. /**
  63420. * Is the layer in background or foreground.
  63421. */
  63422. isBackground: boolean;
  63423. /**
  63424. * Define the color of the layer (instead of texture).
  63425. */
  63426. color: Color4;
  63427. /**
  63428. * Define the scale of the layer in order to zoom in out of the texture.
  63429. */
  63430. scale: Vector2;
  63431. /**
  63432. * Define an offset for the layer in order to shift the texture.
  63433. */
  63434. offset: Vector2;
  63435. /**
  63436. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  63437. */
  63438. alphaBlendingMode: number;
  63439. /**
  63440. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  63441. * Alpha test will not mix with the background color in case of transparency.
  63442. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  63443. */
  63444. alphaTest: boolean;
  63445. /**
  63446. * Define a mask to restrict the layer to only some of the scene cameras.
  63447. */
  63448. layerMask: number;
  63449. /**
  63450. * Define the list of render target the layer is visible into.
  63451. */
  63452. renderTargetTextures: RenderTargetTexture[];
  63453. /**
  63454. * Define if the layer is only used in renderTarget or if it also
  63455. * renders in the main frame buffer of the canvas.
  63456. */
  63457. renderOnlyInRenderTargetTextures: boolean;
  63458. private _scene;
  63459. private _vertexBuffers;
  63460. private _indexBuffer;
  63461. private _effect;
  63462. private _previousDefines;
  63463. /**
  63464. * An event triggered when the layer is disposed.
  63465. */
  63466. onDisposeObservable: Observable<Layer>;
  63467. private _onDisposeObserver;
  63468. /**
  63469. * Back compatibility with callback before the onDisposeObservable existed.
  63470. * The set callback will be triggered when the layer has been disposed.
  63471. */
  63472. set onDispose(callback: () => void);
  63473. /**
  63474. * An event triggered before rendering the scene
  63475. */
  63476. onBeforeRenderObservable: Observable<Layer>;
  63477. private _onBeforeRenderObserver;
  63478. /**
  63479. * Back compatibility with callback before the onBeforeRenderObservable existed.
  63480. * The set callback will be triggered just before rendering the layer.
  63481. */
  63482. set onBeforeRender(callback: () => void);
  63483. /**
  63484. * An event triggered after rendering the scene
  63485. */
  63486. onAfterRenderObservable: Observable<Layer>;
  63487. private _onAfterRenderObserver;
  63488. /**
  63489. * Back compatibility with callback before the onAfterRenderObservable existed.
  63490. * The set callback will be triggered just after rendering the layer.
  63491. */
  63492. set onAfterRender(callback: () => void);
  63493. /**
  63494. * Instantiates a new layer.
  63495. * This represents a full screen 2d layer.
  63496. * This can be useful to display a picture in the background of your scene for instance.
  63497. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63498. * @param name Define the name of the layer in the scene
  63499. * @param imgUrl Define the url of the texture to display in the layer
  63500. * @param scene Define the scene the layer belongs to
  63501. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  63502. * @param color Defines a color for the layer
  63503. */
  63504. constructor(
  63505. /**
  63506. * Define the name of the layer.
  63507. */
  63508. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  63509. private _createIndexBuffer;
  63510. /** @hidden */
  63511. _rebuild(): void;
  63512. /**
  63513. * Renders the layer in the scene.
  63514. */
  63515. render(): void;
  63516. /**
  63517. * Disposes and releases the associated ressources.
  63518. */
  63519. dispose(): void;
  63520. }
  63521. }
  63522. declare module "babylonjs/Layers/index" {
  63523. export * from "babylonjs/Layers/effectLayer";
  63524. export * from "babylonjs/Layers/effectLayerSceneComponent";
  63525. export * from "babylonjs/Layers/glowLayer";
  63526. export * from "babylonjs/Layers/highlightLayer";
  63527. export * from "babylonjs/Layers/layer";
  63528. export * from "babylonjs/Layers/layerSceneComponent";
  63529. }
  63530. declare module "babylonjs/Shaders/lensFlare.fragment" {
  63531. /** @hidden */
  63532. export var lensFlarePixelShader: {
  63533. name: string;
  63534. shader: string;
  63535. };
  63536. }
  63537. declare module "babylonjs/Shaders/lensFlare.vertex" {
  63538. /** @hidden */
  63539. export var lensFlareVertexShader: {
  63540. name: string;
  63541. shader: string;
  63542. };
  63543. }
  63544. declare module "babylonjs/LensFlares/lensFlareSystem" {
  63545. import { Scene } from "babylonjs/scene";
  63546. import { Vector3 } from "babylonjs/Maths/math.vector";
  63547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63548. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  63549. import "babylonjs/Shaders/lensFlare.fragment";
  63550. import "babylonjs/Shaders/lensFlare.vertex";
  63551. import { Viewport } from "babylonjs/Maths/math.viewport";
  63552. /**
  63553. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63554. * It is usually composed of several `lensFlare`.
  63555. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63556. */
  63557. export class LensFlareSystem {
  63558. /**
  63559. * Define the name of the lens flare system
  63560. */
  63561. name: string;
  63562. /**
  63563. * List of lens flares used in this system.
  63564. */
  63565. lensFlares: LensFlare[];
  63566. /**
  63567. * Define a limit from the border the lens flare can be visible.
  63568. */
  63569. borderLimit: number;
  63570. /**
  63571. * Define a viewport border we do not want to see the lens flare in.
  63572. */
  63573. viewportBorder: number;
  63574. /**
  63575. * Define a predicate which could limit the list of meshes able to occlude the effect.
  63576. */
  63577. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  63578. /**
  63579. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  63580. */
  63581. layerMask: number;
  63582. /**
  63583. * Define the id of the lens flare system in the scene.
  63584. * (equal to name by default)
  63585. */
  63586. id: string;
  63587. private _scene;
  63588. private _emitter;
  63589. private _vertexBuffers;
  63590. private _indexBuffer;
  63591. private _effect;
  63592. private _positionX;
  63593. private _positionY;
  63594. private _isEnabled;
  63595. /** @hidden */
  63596. static _SceneComponentInitialization: (scene: Scene) => void;
  63597. /**
  63598. * Instantiates a lens flare system.
  63599. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63600. * It is usually composed of several `lensFlare`.
  63601. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63602. * @param name Define the name of the lens flare system in the scene
  63603. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  63604. * @param scene Define the scene the lens flare system belongs to
  63605. */
  63606. constructor(
  63607. /**
  63608. * Define the name of the lens flare system
  63609. */
  63610. name: string, emitter: any, scene: Scene);
  63611. /**
  63612. * Define if the lens flare system is enabled.
  63613. */
  63614. get isEnabled(): boolean;
  63615. set isEnabled(value: boolean);
  63616. /**
  63617. * Get the scene the effects belongs to.
  63618. * @returns the scene holding the lens flare system
  63619. */
  63620. getScene(): Scene;
  63621. /**
  63622. * Get the emitter of the lens flare system.
  63623. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63624. * @returns the emitter of the lens flare system
  63625. */
  63626. getEmitter(): any;
  63627. /**
  63628. * Set the emitter of the lens flare system.
  63629. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63630. * @param newEmitter Define the new emitter of the system
  63631. */
  63632. setEmitter(newEmitter: any): void;
  63633. /**
  63634. * Get the lens flare system emitter position.
  63635. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  63636. * @returns the position
  63637. */
  63638. getEmitterPosition(): Vector3;
  63639. /**
  63640. * @hidden
  63641. */
  63642. computeEffectivePosition(globalViewport: Viewport): boolean;
  63643. /** @hidden */
  63644. _isVisible(): boolean;
  63645. /**
  63646. * @hidden
  63647. */
  63648. render(): boolean;
  63649. /**
  63650. * Dispose and release the lens flare with its associated resources.
  63651. */
  63652. dispose(): void;
  63653. /**
  63654. * Parse a lens flare system from a JSON repressentation
  63655. * @param parsedLensFlareSystem Define the JSON to parse
  63656. * @param scene Define the scene the parsed system should be instantiated in
  63657. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  63658. * @returns the parsed system
  63659. */
  63660. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  63661. /**
  63662. * Serialize the current Lens Flare System into a JSON representation.
  63663. * @returns the serialized JSON
  63664. */
  63665. serialize(): any;
  63666. }
  63667. }
  63668. declare module "babylonjs/LensFlares/lensFlare" {
  63669. import { Nullable } from "babylonjs/types";
  63670. import { Color3 } from "babylonjs/Maths/math.color";
  63671. import { Texture } from "babylonjs/Materials/Textures/texture";
  63672. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  63673. /**
  63674. * This represents one of the lens effect in a `lensFlareSystem`.
  63675. * It controls one of the indiviual texture used in the effect.
  63676. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63677. */
  63678. export class LensFlare {
  63679. /**
  63680. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63681. */
  63682. size: number;
  63683. /**
  63684. * 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.
  63685. */
  63686. position: number;
  63687. /**
  63688. * Define the lens color.
  63689. */
  63690. color: Color3;
  63691. /**
  63692. * Define the lens texture.
  63693. */
  63694. texture: Nullable<Texture>;
  63695. /**
  63696. * Define the alpha mode to render this particular lens.
  63697. */
  63698. alphaMode: number;
  63699. private _system;
  63700. /**
  63701. * Creates a new Lens Flare.
  63702. * This represents one of the lens effect in a `lensFlareSystem`.
  63703. * It controls one of the indiviual texture used in the effect.
  63704. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63705. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  63706. * @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.
  63707. * @param color Define the lens color
  63708. * @param imgUrl Define the lens texture url
  63709. * @param system Define the `lensFlareSystem` this flare is part of
  63710. * @returns The newly created Lens Flare
  63711. */
  63712. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  63713. /**
  63714. * Instantiates a new Lens Flare.
  63715. * This represents one of the lens effect in a `lensFlareSystem`.
  63716. * It controls one of the indiviual texture used in the effect.
  63717. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63718. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  63719. * @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.
  63720. * @param color Define the lens color
  63721. * @param imgUrl Define the lens texture url
  63722. * @param system Define the `lensFlareSystem` this flare is part of
  63723. */
  63724. constructor(
  63725. /**
  63726. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63727. */
  63728. size: number,
  63729. /**
  63730. * 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.
  63731. */
  63732. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  63733. /**
  63734. * Dispose and release the lens flare with its associated resources.
  63735. */
  63736. dispose(): void;
  63737. }
  63738. }
  63739. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  63740. import { Nullable } from "babylonjs/types";
  63741. import { Scene } from "babylonjs/scene";
  63742. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63743. import { AbstractScene } from "babylonjs/abstractScene";
  63744. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  63745. module "babylonjs/abstractScene" {
  63746. interface AbstractScene {
  63747. /**
  63748. * The list of lens flare system added to the scene
  63749. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63750. */
  63751. lensFlareSystems: Array<LensFlareSystem>;
  63752. /**
  63753. * Removes the given lens flare system from this scene.
  63754. * @param toRemove The lens flare system to remove
  63755. * @returns The index of the removed lens flare system
  63756. */
  63757. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  63758. /**
  63759. * Adds the given lens flare system to this scene
  63760. * @param newLensFlareSystem The lens flare system to add
  63761. */
  63762. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  63763. /**
  63764. * Gets a lens flare system using its name
  63765. * @param name defines the name to look for
  63766. * @returns the lens flare system or null if not found
  63767. */
  63768. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  63769. /**
  63770. * Gets a lens flare system using its id
  63771. * @param id defines the id to look for
  63772. * @returns the lens flare system or null if not found
  63773. */
  63774. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  63775. }
  63776. }
  63777. /**
  63778. * Defines the lens flare scene component responsible to manage any lens flares
  63779. * in a given scene.
  63780. */
  63781. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  63782. /**
  63783. * The component name helpfull to identify the component in the list of scene components.
  63784. */
  63785. readonly name: string;
  63786. /**
  63787. * The scene the component belongs to.
  63788. */
  63789. scene: Scene;
  63790. /**
  63791. * Creates a new instance of the component for the given scene
  63792. * @param scene Defines the scene to register the component in
  63793. */
  63794. constructor(scene: Scene);
  63795. /**
  63796. * Registers the component in a given scene
  63797. */
  63798. register(): void;
  63799. /**
  63800. * Rebuilds the elements related to this component in case of
  63801. * context lost for instance.
  63802. */
  63803. rebuild(): void;
  63804. /**
  63805. * Adds all the elements from the container to the scene
  63806. * @param container the container holding the elements
  63807. */
  63808. addFromContainer(container: AbstractScene): void;
  63809. /**
  63810. * Removes all the elements in the container from the scene
  63811. * @param container contains the elements to remove
  63812. * @param dispose if the removed element should be disposed (default: false)
  63813. */
  63814. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63815. /**
  63816. * Serializes the component data to the specified json object
  63817. * @param serializationObject The object to serialize to
  63818. */
  63819. serialize(serializationObject: any): void;
  63820. /**
  63821. * Disposes the component and the associated ressources.
  63822. */
  63823. dispose(): void;
  63824. private _draw;
  63825. }
  63826. }
  63827. declare module "babylonjs/LensFlares/index" {
  63828. export * from "babylonjs/LensFlares/lensFlare";
  63829. export * from "babylonjs/LensFlares/lensFlareSystem";
  63830. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  63831. }
  63832. declare module "babylonjs/Shaders/depth.fragment" {
  63833. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63834. /** @hidden */
  63835. export var depthPixelShader: {
  63836. name: string;
  63837. shader: string;
  63838. };
  63839. }
  63840. declare module "babylonjs/Shaders/depth.vertex" {
  63841. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63842. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63843. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63844. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63845. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63846. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63847. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63848. /** @hidden */
  63849. export var depthVertexShader: {
  63850. name: string;
  63851. shader: string;
  63852. };
  63853. }
  63854. declare module "babylonjs/Rendering/depthRenderer" {
  63855. import { Nullable } from "babylonjs/types";
  63856. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63857. import { Scene } from "babylonjs/scene";
  63858. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63859. import { Camera } from "babylonjs/Cameras/camera";
  63860. import "babylonjs/Shaders/depth.fragment";
  63861. import "babylonjs/Shaders/depth.vertex";
  63862. /**
  63863. * This represents a depth renderer in Babylon.
  63864. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63865. */
  63866. export class DepthRenderer {
  63867. private _scene;
  63868. private _depthMap;
  63869. private _effect;
  63870. private readonly _storeNonLinearDepth;
  63871. private readonly _clearColor;
  63872. /** Get if the depth renderer is using packed depth or not */
  63873. readonly isPacked: boolean;
  63874. private _cachedDefines;
  63875. private _camera;
  63876. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  63877. enabled: boolean;
  63878. /**
  63879. * Specifiess that the depth renderer will only be used within
  63880. * the camera it is created for.
  63881. * This can help forcing its rendering during the camera processing.
  63882. */
  63883. useOnlyInActiveCamera: boolean;
  63884. /** @hidden */
  63885. static _SceneComponentInitialization: (scene: Scene) => void;
  63886. /**
  63887. * Instantiates a depth renderer
  63888. * @param scene The scene the renderer belongs to
  63889. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63890. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63891. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63892. */
  63893. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63894. /**
  63895. * Creates the depth rendering effect and checks if the effect is ready.
  63896. * @param subMesh The submesh to be used to render the depth map of
  63897. * @param useInstances If multiple world instances should be used
  63898. * @returns if the depth renderer is ready to render the depth map
  63899. */
  63900. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63901. /**
  63902. * Gets the texture which the depth map will be written to.
  63903. * @returns The depth map texture
  63904. */
  63905. getDepthMap(): RenderTargetTexture;
  63906. /**
  63907. * Disposes of the depth renderer.
  63908. */
  63909. dispose(): void;
  63910. }
  63911. }
  63912. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  63913. /** @hidden */
  63914. export var minmaxReduxPixelShader: {
  63915. name: string;
  63916. shader: string;
  63917. };
  63918. }
  63919. declare module "babylonjs/Misc/minMaxReducer" {
  63920. import { Nullable } from "babylonjs/types";
  63921. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63922. import { Camera } from "babylonjs/Cameras/camera";
  63923. import { Observer } from "babylonjs/Misc/observable";
  63924. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63925. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  63926. import { Observable } from "babylonjs/Misc/observable";
  63927. import "babylonjs/Shaders/minmaxRedux.fragment";
  63928. /**
  63929. * This class computes a min/max reduction from a texture: it means it computes the minimum
  63930. * and maximum values from all values of the texture.
  63931. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  63932. * The source values are read from the red channel of the texture.
  63933. */
  63934. export class MinMaxReducer {
  63935. /**
  63936. * Observable triggered when the computation has been performed
  63937. */
  63938. onAfterReductionPerformed: Observable<{
  63939. min: number;
  63940. max: number;
  63941. }>;
  63942. protected _camera: Camera;
  63943. protected _sourceTexture: Nullable<RenderTargetTexture>;
  63944. protected _reductionSteps: Nullable<Array<PostProcess>>;
  63945. protected _postProcessManager: PostProcessManager;
  63946. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  63947. protected _forceFullscreenViewport: boolean;
  63948. /**
  63949. * Creates a min/max reducer
  63950. * @param camera The camera to use for the post processes
  63951. */
  63952. constructor(camera: Camera);
  63953. /**
  63954. * Gets the texture used to read the values from.
  63955. */
  63956. get sourceTexture(): Nullable<RenderTargetTexture>;
  63957. /**
  63958. * Sets the source texture to read the values from.
  63959. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  63960. * because in such textures '1' value must not be taken into account to compute the maximum
  63961. * as this value is used to clear the texture.
  63962. * Note that the computation is not activated by calling this function, you must call activate() for that!
  63963. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  63964. * @param depthRedux Indicates if the texture is a depth texture or not
  63965. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  63966. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63967. */
  63968. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63969. /**
  63970. * Defines the refresh rate of the computation.
  63971. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63972. */
  63973. get refreshRate(): number;
  63974. set refreshRate(value: number);
  63975. protected _activated: boolean;
  63976. /**
  63977. * Gets the activation status of the reducer
  63978. */
  63979. get activated(): boolean;
  63980. /**
  63981. * Activates the reduction computation.
  63982. * When activated, the observers registered in onAfterReductionPerformed are
  63983. * called after the compuation is performed
  63984. */
  63985. activate(): void;
  63986. /**
  63987. * Deactivates the reduction computation.
  63988. */
  63989. deactivate(): void;
  63990. /**
  63991. * Disposes the min/max reducer
  63992. * @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.
  63993. */
  63994. dispose(disposeAll?: boolean): void;
  63995. }
  63996. }
  63997. declare module "babylonjs/Misc/depthReducer" {
  63998. import { Nullable } from "babylonjs/types";
  63999. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64000. import { Camera } from "babylonjs/Cameras/camera";
  64001. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64002. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  64003. /**
  64004. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  64005. */
  64006. export class DepthReducer extends MinMaxReducer {
  64007. private _depthRenderer;
  64008. private _depthRendererId;
  64009. /**
  64010. * Gets the depth renderer used for the computation.
  64011. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  64012. */
  64013. get depthRenderer(): Nullable<DepthRenderer>;
  64014. /**
  64015. * Creates a depth reducer
  64016. * @param camera The camera used to render the depth texture
  64017. */
  64018. constructor(camera: Camera);
  64019. /**
  64020. * Sets the depth renderer to use to generate the depth map
  64021. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  64022. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  64023. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64024. */
  64025. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  64026. /** @hidden */
  64027. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64028. /**
  64029. * Activates the reduction computation.
  64030. * When activated, the observers registered in onAfterReductionPerformed are
  64031. * called after the compuation is performed
  64032. */
  64033. activate(): void;
  64034. /**
  64035. * Deactivates the reduction computation.
  64036. */
  64037. deactivate(): void;
  64038. /**
  64039. * Disposes the depth reducer
  64040. * @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.
  64041. */
  64042. dispose(disposeAll?: boolean): void;
  64043. }
  64044. }
  64045. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  64046. import { Nullable } from "babylonjs/types";
  64047. import { Scene } from "babylonjs/scene";
  64048. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64049. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64051. import { Effect } from "babylonjs/Materials/effect";
  64052. import "babylonjs/Shaders/shadowMap.fragment";
  64053. import "babylonjs/Shaders/shadowMap.vertex";
  64054. import "babylonjs/Shaders/depthBoxBlur.fragment";
  64055. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  64056. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  64057. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  64058. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64059. /**
  64060. * A CSM implementation allowing casting shadows on large scenes.
  64061. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64062. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  64063. */
  64064. export class CascadedShadowGenerator extends ShadowGenerator {
  64065. private static readonly frustumCornersNDCSpace;
  64066. /**
  64067. * Name of the CSM class
  64068. */
  64069. static CLASSNAME: string;
  64070. /**
  64071. * Defines the default number of cascades used by the CSM.
  64072. */
  64073. static readonly DEFAULT_CASCADES_COUNT: number;
  64074. /**
  64075. * Defines the minimum number of cascades used by the CSM.
  64076. */
  64077. static readonly MIN_CASCADES_COUNT: number;
  64078. /**
  64079. * Defines the maximum number of cascades used by the CSM.
  64080. */
  64081. static readonly MAX_CASCADES_COUNT: number;
  64082. protected _validateFilter(filter: number): number;
  64083. /**
  64084. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  64085. */
  64086. penumbraDarkness: number;
  64087. private _numCascades;
  64088. /**
  64089. * Gets or set the number of cascades used by the CSM.
  64090. */
  64091. get numCascades(): number;
  64092. set numCascades(value: number);
  64093. /**
  64094. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  64095. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  64096. */
  64097. stabilizeCascades: boolean;
  64098. private _freezeShadowCastersBoundingInfo;
  64099. private _freezeShadowCastersBoundingInfoObservable;
  64100. /**
  64101. * Enables or disables the shadow casters bounding info computation.
  64102. * If your shadow casters don't move, you can disable this feature.
  64103. * If it is enabled, the bounding box computation is done every frame.
  64104. */
  64105. get freezeShadowCastersBoundingInfo(): boolean;
  64106. set freezeShadowCastersBoundingInfo(freeze: boolean);
  64107. private _scbiMin;
  64108. private _scbiMax;
  64109. protected _computeShadowCastersBoundingInfo(): void;
  64110. protected _shadowCastersBoundingInfo: BoundingInfo;
  64111. /**
  64112. * Gets or sets the shadow casters bounding info.
  64113. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  64114. * so that the system won't overwrite the bounds you provide
  64115. */
  64116. get shadowCastersBoundingInfo(): BoundingInfo;
  64117. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  64118. protected _breaksAreDirty: boolean;
  64119. protected _minDistance: number;
  64120. protected _maxDistance: number;
  64121. /**
  64122. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  64123. *
  64124. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  64125. * If you don't know these values, simply leave them to their defaults and don't call this function.
  64126. * @param min minimal distance for the breaks (default to 0.)
  64127. * @param max maximal distance for the breaks (default to 1.)
  64128. */
  64129. setMinMaxDistance(min: number, max: number): void;
  64130. /** Gets the minimal distance used in the cascade break computation */
  64131. get minDistance(): number;
  64132. /** Gets the maximal distance used in the cascade break computation */
  64133. get maxDistance(): number;
  64134. /**
  64135. * Gets the class name of that object
  64136. * @returns "CascadedShadowGenerator"
  64137. */
  64138. getClassName(): string;
  64139. private _cascadeMinExtents;
  64140. private _cascadeMaxExtents;
  64141. /**
  64142. * Gets a cascade minimum extents
  64143. * @param cascadeIndex index of the cascade
  64144. * @returns the minimum cascade extents
  64145. */
  64146. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  64147. /**
  64148. * Gets a cascade maximum extents
  64149. * @param cascadeIndex index of the cascade
  64150. * @returns the maximum cascade extents
  64151. */
  64152. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  64153. private _cascades;
  64154. private _currentLayer;
  64155. private _viewSpaceFrustumsZ;
  64156. private _viewMatrices;
  64157. private _projectionMatrices;
  64158. private _transformMatrices;
  64159. private _transformMatricesAsArray;
  64160. private _frustumLengths;
  64161. private _lightSizeUVCorrection;
  64162. private _depthCorrection;
  64163. private _frustumCornersWorldSpace;
  64164. private _frustumCenter;
  64165. private _shadowCameraPos;
  64166. private _shadowMaxZ;
  64167. /**
  64168. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  64169. * It defaults to camera.maxZ
  64170. */
  64171. get shadowMaxZ(): number;
  64172. /**
  64173. * Sets the shadow max z distance.
  64174. */
  64175. set shadowMaxZ(value: number);
  64176. protected _debug: boolean;
  64177. /**
  64178. * Gets or sets the debug flag.
  64179. * When enabled, the cascades are materialized by different colors on the screen.
  64180. */
  64181. get debug(): boolean;
  64182. set debug(dbg: boolean);
  64183. private _depthClamp;
  64184. /**
  64185. * Gets or sets the depth clamping value.
  64186. *
  64187. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  64188. * to account for the shadow casters far away.
  64189. *
  64190. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  64191. */
  64192. get depthClamp(): boolean;
  64193. set depthClamp(value: boolean);
  64194. private _cascadeBlendPercentage;
  64195. /**
  64196. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  64197. * It defaults to 0.1 (10% blending).
  64198. */
  64199. get cascadeBlendPercentage(): number;
  64200. set cascadeBlendPercentage(value: number);
  64201. private _lambda;
  64202. /**
  64203. * Gets or set the lambda parameter.
  64204. * This parameter is used to split the camera frustum and create the cascades.
  64205. * 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.
  64206. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  64207. */
  64208. get lambda(): number;
  64209. set lambda(value: number);
  64210. /**
  64211. * Gets the view matrix corresponding to a given cascade
  64212. * @param cascadeNum cascade to retrieve the view matrix from
  64213. * @returns the cascade view matrix
  64214. */
  64215. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  64216. /**
  64217. * Gets the projection matrix corresponding to a given cascade
  64218. * @param cascadeNum cascade to retrieve the projection matrix from
  64219. * @returns the cascade projection matrix
  64220. */
  64221. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  64222. /**
  64223. * Gets the transformation matrix corresponding to a given cascade
  64224. * @param cascadeNum cascade to retrieve the transformation matrix from
  64225. * @returns the cascade transformation matrix
  64226. */
  64227. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  64228. private _depthRenderer;
  64229. /**
  64230. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  64231. *
  64232. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  64233. *
  64234. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  64235. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  64236. * @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
  64237. */
  64238. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  64239. private _depthReducer;
  64240. private _autoCalcDepthBounds;
  64241. /**
  64242. * Gets or sets the autoCalcDepthBounds property.
  64243. *
  64244. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  64245. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  64246. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  64247. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  64248. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  64249. */
  64250. get autoCalcDepthBounds(): boolean;
  64251. set autoCalcDepthBounds(value: boolean);
  64252. /**
  64253. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  64254. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64255. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  64256. * for setting the refresh rate on the renderer yourself!
  64257. */
  64258. get autoCalcDepthBoundsRefreshRate(): number;
  64259. set autoCalcDepthBoundsRefreshRate(value: number);
  64260. /**
  64261. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  64262. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  64263. * you change the camera near/far planes!
  64264. */
  64265. splitFrustum(): void;
  64266. private _splitFrustum;
  64267. private _computeMatrices;
  64268. private _computeFrustumInWorldSpace;
  64269. private _computeCascadeFrustum;
  64270. /**
  64271. * Support test.
  64272. */
  64273. static get IsSupported(): boolean;
  64274. /** @hidden */
  64275. static _SceneComponentInitialization: (scene: Scene) => void;
  64276. /**
  64277. * Creates a Cascaded Shadow Generator object.
  64278. * A ShadowGenerator is the required tool to use the shadows.
  64279. * Each directional light casting shadows needs to use its own ShadowGenerator.
  64280. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64281. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  64282. * @param light The directional light object generating the shadows.
  64283. * @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.
  64284. */
  64285. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  64286. protected _initializeGenerator(): void;
  64287. protected _createTargetRenderTexture(): void;
  64288. protected _initializeShadowMap(): void;
  64289. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  64290. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  64291. /**
  64292. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  64293. * @param defines Defines of the material we want to update
  64294. * @param lightIndex Index of the light in the enabled light list of the material
  64295. */
  64296. prepareDefines(defines: any, lightIndex: number): void;
  64297. /**
  64298. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  64299. * defined in the generator but impacting the effect).
  64300. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  64301. * @param effect The effect we are binfing the information for
  64302. */
  64303. bindShadowLight(lightIndex: string, effect: Effect): void;
  64304. /**
  64305. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  64306. * (eq to view projection * shadow projection matrices)
  64307. * @returns The transform matrix used to create the shadow map
  64308. */
  64309. getTransformMatrix(): Matrix;
  64310. /**
  64311. * Disposes the ShadowGenerator.
  64312. * Returns nothing.
  64313. */
  64314. dispose(): void;
  64315. /**
  64316. * Serializes the shadow generator setup to a json object.
  64317. * @returns The serialized JSON object
  64318. */
  64319. serialize(): any;
  64320. /**
  64321. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  64322. * @param parsedShadowGenerator The JSON object to parse
  64323. * @param scene The scene to create the shadow map for
  64324. * @returns The parsed shadow generator
  64325. */
  64326. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  64327. }
  64328. }
  64329. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  64330. import { Scene } from "babylonjs/scene";
  64331. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  64332. import { AbstractScene } from "babylonjs/abstractScene";
  64333. /**
  64334. * Defines the shadow generator component responsible to manage any shadow generators
  64335. * in a given scene.
  64336. */
  64337. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  64338. /**
  64339. * The component name helpfull to identify the component in the list of scene components.
  64340. */
  64341. readonly name: string;
  64342. /**
  64343. * The scene the component belongs to.
  64344. */
  64345. scene: Scene;
  64346. /**
  64347. * Creates a new instance of the component for the given scene
  64348. * @param scene Defines the scene to register the component in
  64349. */
  64350. constructor(scene: Scene);
  64351. /**
  64352. * Registers the component in a given scene
  64353. */
  64354. register(): void;
  64355. /**
  64356. * Rebuilds the elements related to this component in case of
  64357. * context lost for instance.
  64358. */
  64359. rebuild(): void;
  64360. /**
  64361. * Serializes the component data to the specified json object
  64362. * @param serializationObject The object to serialize to
  64363. */
  64364. serialize(serializationObject: any): void;
  64365. /**
  64366. * Adds all the elements from the container to the scene
  64367. * @param container the container holding the elements
  64368. */
  64369. addFromContainer(container: AbstractScene): void;
  64370. /**
  64371. * Removes all the elements in the container from the scene
  64372. * @param container contains the elements to remove
  64373. * @param dispose if the removed element should be disposed (default: false)
  64374. */
  64375. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64376. /**
  64377. * Rebuilds the elements related to this component in case of
  64378. * context lost for instance.
  64379. */
  64380. dispose(): void;
  64381. private _gatherRenderTargets;
  64382. }
  64383. }
  64384. declare module "babylonjs/Lights/Shadows/index" {
  64385. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  64386. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  64387. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  64388. }
  64389. declare module "babylonjs/Lights/pointLight" {
  64390. import { Scene } from "babylonjs/scene";
  64391. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64393. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  64394. import { Effect } from "babylonjs/Materials/effect";
  64395. /**
  64396. * A point light is a light defined by an unique point in world space.
  64397. * The light is emitted in every direction from this point.
  64398. * A good example of a point light is a standard light bulb.
  64399. * Documentation: https://doc.babylonjs.com/babylon101/lights
  64400. */
  64401. export class PointLight extends ShadowLight {
  64402. private _shadowAngle;
  64403. /**
  64404. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64405. * This specifies what angle the shadow will use to be created.
  64406. *
  64407. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64408. */
  64409. get shadowAngle(): number;
  64410. /**
  64411. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64412. * This specifies what angle the shadow will use to be created.
  64413. *
  64414. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64415. */
  64416. set shadowAngle(value: number);
  64417. /**
  64418. * Gets the direction if it has been set.
  64419. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64420. */
  64421. get direction(): Vector3;
  64422. /**
  64423. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64424. */
  64425. set direction(value: Vector3);
  64426. /**
  64427. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  64428. * A PointLight emits the light in every direction.
  64429. * It can cast shadows.
  64430. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  64431. * ```javascript
  64432. * var pointLight = new PointLight("pl", camera.position, scene);
  64433. * ```
  64434. * Documentation : https://doc.babylonjs.com/babylon101/lights
  64435. * @param name The light friendly name
  64436. * @param position The position of the point light in the scene
  64437. * @param scene The scene the lights belongs to
  64438. */
  64439. constructor(name: string, position: Vector3, scene: Scene);
  64440. /**
  64441. * Returns the string "PointLight"
  64442. * @returns the class name
  64443. */
  64444. getClassName(): string;
  64445. /**
  64446. * Returns the integer 0.
  64447. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  64448. */
  64449. getTypeID(): number;
  64450. /**
  64451. * Specifies wether or not the shadowmap should be a cube texture.
  64452. * @returns true if the shadowmap needs to be a cube texture.
  64453. */
  64454. needCube(): boolean;
  64455. /**
  64456. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  64457. * @param faceIndex The index of the face we are computed the direction to generate shadow
  64458. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  64459. */
  64460. getShadowDirection(faceIndex?: number): Vector3;
  64461. /**
  64462. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  64463. * - fov = PI / 2
  64464. * - aspect ratio : 1.0
  64465. * - z-near and far equal to the active camera minZ and maxZ.
  64466. * Returns the PointLight.
  64467. */
  64468. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  64469. protected _buildUniformLayout(): void;
  64470. /**
  64471. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  64472. * @param effect The effect to update
  64473. * @param lightIndex The index of the light in the effect to update
  64474. * @returns The point light
  64475. */
  64476. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  64477. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  64478. /**
  64479. * Prepares the list of defines specific to the light type.
  64480. * @param defines the list of defines
  64481. * @param lightIndex defines the index of the light for the effect
  64482. */
  64483. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  64484. }
  64485. }
  64486. declare module "babylonjs/Lights/index" {
  64487. export * from "babylonjs/Lights/light";
  64488. export * from "babylonjs/Lights/shadowLight";
  64489. export * from "babylonjs/Lights/Shadows/index";
  64490. export * from "babylonjs/Lights/directionalLight";
  64491. export * from "babylonjs/Lights/hemisphericLight";
  64492. export * from "babylonjs/Lights/pointLight";
  64493. export * from "babylonjs/Lights/spotLight";
  64494. }
  64495. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  64496. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  64497. /**
  64498. * Header information of HDR texture files.
  64499. */
  64500. export interface HDRInfo {
  64501. /**
  64502. * The height of the texture in pixels.
  64503. */
  64504. height: number;
  64505. /**
  64506. * The width of the texture in pixels.
  64507. */
  64508. width: number;
  64509. /**
  64510. * The index of the beginning of the data in the binary file.
  64511. */
  64512. dataPosition: number;
  64513. }
  64514. /**
  64515. * This groups tools to convert HDR texture to native colors array.
  64516. */
  64517. export class HDRTools {
  64518. private static Ldexp;
  64519. private static Rgbe2float;
  64520. private static readStringLine;
  64521. /**
  64522. * Reads header information from an RGBE texture stored in a native array.
  64523. * More information on this format are available here:
  64524. * https://en.wikipedia.org/wiki/RGBE_image_format
  64525. *
  64526. * @param uint8array The binary file stored in native array.
  64527. * @return The header information.
  64528. */
  64529. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  64530. /**
  64531. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  64532. * This RGBE texture needs to store the information as a panorama.
  64533. *
  64534. * More information on this format are available here:
  64535. * https://en.wikipedia.org/wiki/RGBE_image_format
  64536. *
  64537. * @param buffer The binary file stored in an array buffer.
  64538. * @param size The expected size of the extracted cubemap.
  64539. * @return The Cube Map information.
  64540. */
  64541. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  64542. /**
  64543. * Returns the pixels data extracted from an RGBE texture.
  64544. * This pixels will be stored left to right up to down in the R G B order in one array.
  64545. *
  64546. * More information on this format are available here:
  64547. * https://en.wikipedia.org/wiki/RGBE_image_format
  64548. *
  64549. * @param uint8array The binary file stored in an array buffer.
  64550. * @param hdrInfo The header information of the file.
  64551. * @return The pixels data in RGB right to left up to down order.
  64552. */
  64553. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  64554. private static RGBE_ReadPixels_RLE;
  64555. private static RGBE_ReadPixels_NOT_RLE;
  64556. }
  64557. }
  64558. declare module "babylonjs/Materials/effectRenderer" {
  64559. import { Nullable } from "babylonjs/types";
  64560. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64561. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64562. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64563. import { Viewport } from "babylonjs/Maths/math.viewport";
  64564. import { Observable } from "babylonjs/Misc/observable";
  64565. import { Effect } from "babylonjs/Materials/effect";
  64566. import "babylonjs/Shaders/postprocess.vertex";
  64567. /**
  64568. * Effect Render Options
  64569. */
  64570. export interface IEffectRendererOptions {
  64571. /**
  64572. * Defines the vertices positions.
  64573. */
  64574. positions?: number[];
  64575. /**
  64576. * Defines the indices.
  64577. */
  64578. indices?: number[];
  64579. }
  64580. /**
  64581. * Helper class to render one or more effects.
  64582. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  64583. */
  64584. export class EffectRenderer {
  64585. private engine;
  64586. private static _DefaultOptions;
  64587. private _vertexBuffers;
  64588. private _indexBuffer;
  64589. private _fullscreenViewport;
  64590. /**
  64591. * Creates an effect renderer
  64592. * @param engine the engine to use for rendering
  64593. * @param options defines the options of the effect renderer
  64594. */
  64595. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  64596. /**
  64597. * Sets the current viewport in normalized coordinates 0-1
  64598. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  64599. */
  64600. setViewport(viewport?: Viewport): void;
  64601. /**
  64602. * Binds the embedded attributes buffer to the effect.
  64603. * @param effect Defines the effect to bind the attributes for
  64604. */
  64605. bindBuffers(effect: Effect): void;
  64606. /**
  64607. * Sets the current effect wrapper to use during draw.
  64608. * The effect needs to be ready before calling this api.
  64609. * This also sets the default full screen position attribute.
  64610. * @param effectWrapper Defines the effect to draw with
  64611. */
  64612. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  64613. /**
  64614. * Restores engine states
  64615. */
  64616. restoreStates(): void;
  64617. /**
  64618. * Draws a full screen quad.
  64619. */
  64620. draw(): void;
  64621. private isRenderTargetTexture;
  64622. /**
  64623. * renders one or more effects to a specified texture
  64624. * @param effectWrapper the effect to renderer
  64625. * @param outputTexture texture to draw to, if null it will render to the screen.
  64626. */
  64627. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  64628. /**
  64629. * Disposes of the effect renderer
  64630. */
  64631. dispose(): void;
  64632. }
  64633. /**
  64634. * Options to create an EffectWrapper
  64635. */
  64636. interface EffectWrapperCreationOptions {
  64637. /**
  64638. * Engine to use to create the effect
  64639. */
  64640. engine: ThinEngine;
  64641. /**
  64642. * Fragment shader for the effect
  64643. */
  64644. fragmentShader: string;
  64645. /**
  64646. * Use the shader store instead of direct source code
  64647. */
  64648. useShaderStore?: boolean;
  64649. /**
  64650. * Vertex shader for the effect
  64651. */
  64652. vertexShader?: string;
  64653. /**
  64654. * Attributes to use in the shader
  64655. */
  64656. attributeNames?: Array<string>;
  64657. /**
  64658. * Uniforms to use in the shader
  64659. */
  64660. uniformNames?: Array<string>;
  64661. /**
  64662. * Texture sampler names to use in the shader
  64663. */
  64664. samplerNames?: Array<string>;
  64665. /**
  64666. * Defines to use in the shader
  64667. */
  64668. defines?: Array<string>;
  64669. /**
  64670. * Callback when effect is compiled
  64671. */
  64672. onCompiled?: Nullable<(effect: Effect) => void>;
  64673. /**
  64674. * The friendly name of the effect displayed in Spector.
  64675. */
  64676. name?: string;
  64677. }
  64678. /**
  64679. * Wraps an effect to be used for rendering
  64680. */
  64681. export class EffectWrapper {
  64682. /**
  64683. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  64684. */
  64685. onApplyObservable: Observable<{}>;
  64686. /**
  64687. * The underlying effect
  64688. */
  64689. effect: Effect;
  64690. /**
  64691. * Creates an effect to be renderer
  64692. * @param creationOptions options to create the effect
  64693. */
  64694. constructor(creationOptions: EffectWrapperCreationOptions);
  64695. /**
  64696. * Disposes of the effect wrapper
  64697. */
  64698. dispose(): void;
  64699. }
  64700. }
  64701. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  64702. /** @hidden */
  64703. export var hdrFilteringVertexShader: {
  64704. name: string;
  64705. shader: string;
  64706. };
  64707. }
  64708. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  64709. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64710. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  64711. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  64712. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  64713. /** @hidden */
  64714. export var hdrFilteringPixelShader: {
  64715. name: string;
  64716. shader: string;
  64717. };
  64718. }
  64719. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  64720. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64721. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64722. import { Nullable } from "babylonjs/types";
  64723. import "babylonjs/Shaders/hdrFiltering.vertex";
  64724. import "babylonjs/Shaders/hdrFiltering.fragment";
  64725. /**
  64726. * Options for texture filtering
  64727. */
  64728. interface IHDRFilteringOptions {
  64729. /**
  64730. * Scales pixel intensity for the input HDR map.
  64731. */
  64732. hdrScale?: number;
  64733. /**
  64734. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  64735. */
  64736. quality?: number;
  64737. }
  64738. /**
  64739. * Filters HDR maps to get correct renderings of PBR reflections
  64740. */
  64741. export class HDRFiltering {
  64742. private _engine;
  64743. private _effectRenderer;
  64744. private _effectWrapper;
  64745. private _lodGenerationOffset;
  64746. private _lodGenerationScale;
  64747. /**
  64748. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  64749. * you care about baking speed.
  64750. */
  64751. quality: number;
  64752. /**
  64753. * Scales pixel intensity for the input HDR map.
  64754. */
  64755. hdrScale: number;
  64756. /**
  64757. * Instantiates HDR filter for reflection maps
  64758. *
  64759. * @param engine Thin engine
  64760. * @param options Options
  64761. */
  64762. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  64763. private _createRenderTarget;
  64764. private _prefilterInternal;
  64765. private _createEffect;
  64766. /**
  64767. * Get a value indicating if the filter is ready to be used
  64768. * @param texture Texture to filter
  64769. * @returns true if the filter is ready
  64770. */
  64771. isReady(texture: BaseTexture): boolean;
  64772. /**
  64773. * Prefilters a cube texture to have mipmap levels representing roughness values.
  64774. * Prefiltering will be invoked at the end of next rendering pass.
  64775. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  64776. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  64777. * @param texture Texture to filter
  64778. * @param onFinished Callback when filtering is done
  64779. * @return Promise called when prefiltering is done
  64780. */
  64781. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  64782. }
  64783. }
  64784. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  64785. import { Nullable } from "babylonjs/types";
  64786. import { Scene } from "babylonjs/scene";
  64787. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64788. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64789. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64790. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64791. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  64792. /**
  64793. * This represents a texture coming from an HDR input.
  64794. *
  64795. * The only supported format is currently panorama picture stored in RGBE format.
  64796. * Example of such files can be found on HDRLib: http://hdrlib.com/
  64797. */
  64798. export class HDRCubeTexture extends BaseTexture {
  64799. private static _facesMapping;
  64800. private _generateHarmonics;
  64801. private _noMipmap;
  64802. private _prefilterOnLoad;
  64803. private _textureMatrix;
  64804. private _size;
  64805. private _onLoad;
  64806. private _onError;
  64807. /**
  64808. * The texture URL.
  64809. */
  64810. url: string;
  64811. protected _isBlocking: boolean;
  64812. /**
  64813. * Sets wether or not the texture is blocking during loading.
  64814. */
  64815. set isBlocking(value: boolean);
  64816. /**
  64817. * Gets wether or not the texture is blocking during loading.
  64818. */
  64819. get isBlocking(): boolean;
  64820. protected _rotationY: number;
  64821. /**
  64822. * Sets texture matrix rotation angle around Y axis in radians.
  64823. */
  64824. set rotationY(value: number);
  64825. /**
  64826. * Gets texture matrix rotation angle around Y axis radians.
  64827. */
  64828. get rotationY(): number;
  64829. /**
  64830. * Gets or sets the center of the bounding box associated with the cube texture
  64831. * It must define where the camera used to render the texture was set
  64832. */
  64833. boundingBoxPosition: Vector3;
  64834. private _boundingBoxSize;
  64835. /**
  64836. * Gets or sets the size of the bounding box associated with the cube texture
  64837. * When defined, the cubemap will switch to local mode
  64838. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64839. * @example https://www.babylonjs-playground.com/#RNASML
  64840. */
  64841. set boundingBoxSize(value: Vector3);
  64842. get boundingBoxSize(): Vector3;
  64843. /**
  64844. * Instantiates an HDRTexture from the following parameters.
  64845. *
  64846. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64847. * @param sceneOrEngine The scene or engine the texture will be used in
  64848. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64849. * @param noMipmap Forces to not generate the mipmap if true
  64850. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64851. * @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)
  64852. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64853. */
  64854. 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>);
  64855. /**
  64856. * Get the current class name of the texture useful for serialization or dynamic coding.
  64857. * @returns "HDRCubeTexture"
  64858. */
  64859. getClassName(): string;
  64860. /**
  64861. * Occurs when the file is raw .hdr file.
  64862. */
  64863. private loadTexture;
  64864. clone(): HDRCubeTexture;
  64865. delayLoad(): void;
  64866. /**
  64867. * Get the texture reflection matrix used to rotate/transform the reflection.
  64868. * @returns the reflection matrix
  64869. */
  64870. getReflectionTextureMatrix(): Matrix;
  64871. /**
  64872. * Set the texture reflection matrix used to rotate/transform the reflection.
  64873. * @param value Define the reflection matrix to set
  64874. */
  64875. setReflectionTextureMatrix(value: Matrix): void;
  64876. /**
  64877. * Parses a JSON representation of an HDR Texture in order to create the texture
  64878. * @param parsedTexture Define the JSON representation
  64879. * @param scene Define the scene the texture should be created in
  64880. * @param rootUrl Define the root url in case we need to load relative dependencies
  64881. * @returns the newly created texture after parsing
  64882. */
  64883. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  64884. serialize(): any;
  64885. }
  64886. }
  64887. declare module "babylonjs/Physics/physicsEngine" {
  64888. import { Nullable } from "babylonjs/types";
  64889. import { Vector3 } from "babylonjs/Maths/math.vector";
  64890. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64891. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  64892. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  64893. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64894. /**
  64895. * Class used to control physics engine
  64896. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64897. */
  64898. export class PhysicsEngine implements IPhysicsEngine {
  64899. private _physicsPlugin;
  64900. /**
  64901. * Global value used to control the smallest number supported by the simulation
  64902. */
  64903. static Epsilon: number;
  64904. private _impostors;
  64905. private _joints;
  64906. private _subTimeStep;
  64907. /**
  64908. * Gets the gravity vector used by the simulation
  64909. */
  64910. gravity: Vector3;
  64911. /**
  64912. * Factory used to create the default physics plugin.
  64913. * @returns The default physics plugin
  64914. */
  64915. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  64916. /**
  64917. * Creates a new Physics Engine
  64918. * @param gravity defines the gravity vector used by the simulation
  64919. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64920. */
  64921. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64922. /**
  64923. * Sets the gravity vector used by the simulation
  64924. * @param gravity defines the gravity vector to use
  64925. */
  64926. setGravity(gravity: Vector3): void;
  64927. /**
  64928. * Set the time step of the physics engine.
  64929. * Default is 1/60.
  64930. * To slow it down, enter 1/600 for example.
  64931. * To speed it up, 1/30
  64932. * @param newTimeStep defines the new timestep to apply to this world.
  64933. */
  64934. setTimeStep(newTimeStep?: number): void;
  64935. /**
  64936. * Get the time step of the physics engine.
  64937. * @returns the current time step
  64938. */
  64939. getTimeStep(): number;
  64940. /**
  64941. * Set the sub time step of the physics engine.
  64942. * Default is 0 meaning there is no sub steps
  64943. * To increase physics resolution precision, set a small value (like 1 ms)
  64944. * @param subTimeStep defines the new sub timestep used for physics resolution.
  64945. */
  64946. setSubTimeStep(subTimeStep?: number): void;
  64947. /**
  64948. * Get the sub time step of the physics engine.
  64949. * @returns the current sub time step
  64950. */
  64951. getSubTimeStep(): number;
  64952. /**
  64953. * Release all resources
  64954. */
  64955. dispose(): void;
  64956. /**
  64957. * Gets the name of the current physics plugin
  64958. * @returns the name of the plugin
  64959. */
  64960. getPhysicsPluginName(): string;
  64961. /**
  64962. * Adding a new impostor for the impostor tracking.
  64963. * This will be done by the impostor itself.
  64964. * @param impostor the impostor to add
  64965. */
  64966. addImpostor(impostor: PhysicsImpostor): void;
  64967. /**
  64968. * Remove an impostor from the engine.
  64969. * This impostor and its mesh will not longer be updated by the physics engine.
  64970. * @param impostor the impostor to remove
  64971. */
  64972. removeImpostor(impostor: PhysicsImpostor): void;
  64973. /**
  64974. * Add a joint to the physics engine
  64975. * @param mainImpostor defines the main impostor to which the joint is added.
  64976. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  64977. * @param joint defines the joint that will connect both impostors.
  64978. */
  64979. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64980. /**
  64981. * Removes a joint from the simulation
  64982. * @param mainImpostor defines the impostor used with the joint
  64983. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  64984. * @param joint defines the joint to remove
  64985. */
  64986. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64987. /**
  64988. * Called by the scene. No need to call it.
  64989. * @param delta defines the timespam between frames
  64990. */
  64991. _step(delta: number): void;
  64992. /**
  64993. * Gets the current plugin used to run the simulation
  64994. * @returns current plugin
  64995. */
  64996. getPhysicsPlugin(): IPhysicsEnginePlugin;
  64997. /**
  64998. * Gets the list of physic impostors
  64999. * @returns an array of PhysicsImpostor
  65000. */
  65001. getImpostors(): Array<PhysicsImpostor>;
  65002. /**
  65003. * Gets the impostor for a physics enabled object
  65004. * @param object defines the object impersonated by the impostor
  65005. * @returns the PhysicsImpostor or null if not found
  65006. */
  65007. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  65008. /**
  65009. * Gets the impostor for a physics body object
  65010. * @param body defines physics body used by the impostor
  65011. * @returns the PhysicsImpostor or null if not found
  65012. */
  65013. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  65014. /**
  65015. * Does a raycast in the physics world
  65016. * @param from when should the ray start?
  65017. * @param to when should the ray end?
  65018. * @returns PhysicsRaycastResult
  65019. */
  65020. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65021. }
  65022. }
  65023. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  65024. import { Nullable } from "babylonjs/types";
  65025. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  65026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65027. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  65028. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  65029. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  65030. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  65031. /** @hidden */
  65032. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  65033. private _useDeltaForWorldStep;
  65034. world: any;
  65035. name: string;
  65036. private _physicsMaterials;
  65037. private _fixedTimeStep;
  65038. private _cannonRaycastResult;
  65039. private _raycastResult;
  65040. private _physicsBodysToRemoveAfterStep;
  65041. private _firstFrame;
  65042. BJSCANNON: any;
  65043. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  65044. setGravity(gravity: Vector3): void;
  65045. setTimeStep(timeStep: number): void;
  65046. getTimeStep(): number;
  65047. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65048. private _removeMarkedPhysicsBodiesFromWorld;
  65049. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65050. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65051. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65052. private _processChildMeshes;
  65053. removePhysicsBody(impostor: PhysicsImpostor): void;
  65054. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65055. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65056. private _addMaterial;
  65057. private _checkWithEpsilon;
  65058. private _createShape;
  65059. private _createHeightmap;
  65060. private _minus90X;
  65061. private _plus90X;
  65062. private _tmpPosition;
  65063. private _tmpDeltaPosition;
  65064. private _tmpUnityRotation;
  65065. private _updatePhysicsBodyTransformation;
  65066. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65067. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65068. isSupported(): boolean;
  65069. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65070. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65071. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65072. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65073. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65074. getBodyMass(impostor: PhysicsImpostor): number;
  65075. getBodyFriction(impostor: PhysicsImpostor): number;
  65076. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65077. getBodyRestitution(impostor: PhysicsImpostor): number;
  65078. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65079. sleepBody(impostor: PhysicsImpostor): void;
  65080. wakeUpBody(impostor: PhysicsImpostor): void;
  65081. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  65082. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65083. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65084. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65085. getRadius(impostor: PhysicsImpostor): number;
  65086. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65087. dispose(): void;
  65088. private _extendNamespace;
  65089. /**
  65090. * Does a raycast in the physics world
  65091. * @param from when should the ray start?
  65092. * @param to when should the ray end?
  65093. * @returns PhysicsRaycastResult
  65094. */
  65095. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65096. }
  65097. }
  65098. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  65099. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  65100. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  65101. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  65102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65103. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  65104. import { Nullable } from "babylonjs/types";
  65105. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  65106. /** @hidden */
  65107. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  65108. private _useDeltaForWorldStep;
  65109. world: any;
  65110. name: string;
  65111. BJSOIMO: any;
  65112. private _raycastResult;
  65113. private _fixedTimeStep;
  65114. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  65115. setGravity(gravity: Vector3): void;
  65116. setTimeStep(timeStep: number): void;
  65117. getTimeStep(): number;
  65118. private _tmpImpostorsArray;
  65119. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65120. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65121. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65122. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65123. private _tmpPositionVector;
  65124. removePhysicsBody(impostor: PhysicsImpostor): void;
  65125. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65126. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65127. isSupported(): boolean;
  65128. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65129. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65130. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65131. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65132. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65133. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65134. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65135. getBodyMass(impostor: PhysicsImpostor): number;
  65136. getBodyFriction(impostor: PhysicsImpostor): number;
  65137. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65138. getBodyRestitution(impostor: PhysicsImpostor): number;
  65139. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65140. sleepBody(impostor: PhysicsImpostor): void;
  65141. wakeUpBody(impostor: PhysicsImpostor): void;
  65142. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65143. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  65144. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  65145. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65146. getRadius(impostor: PhysicsImpostor): number;
  65147. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65148. dispose(): void;
  65149. /**
  65150. * Does a raycast in the physics world
  65151. * @param from when should the ray start?
  65152. * @param to when should the ray end?
  65153. * @returns PhysicsRaycastResult
  65154. */
  65155. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65156. }
  65157. }
  65158. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  65159. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  65160. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  65161. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  65162. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  65163. import { Nullable } from "babylonjs/types";
  65164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65165. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  65166. /**
  65167. * AmmoJS Physics plugin
  65168. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65169. * @see https://github.com/kripken/ammo.js/
  65170. */
  65171. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  65172. private _useDeltaForWorldStep;
  65173. /**
  65174. * Reference to the Ammo library
  65175. */
  65176. bjsAMMO: any;
  65177. /**
  65178. * Created ammoJS world which physics bodies are added to
  65179. */
  65180. world: any;
  65181. /**
  65182. * Name of the plugin
  65183. */
  65184. name: string;
  65185. private _timeStep;
  65186. private _fixedTimeStep;
  65187. private _maxSteps;
  65188. private _tmpQuaternion;
  65189. private _tmpAmmoTransform;
  65190. private _tmpAmmoQuaternion;
  65191. private _tmpAmmoConcreteContactResultCallback;
  65192. private _collisionConfiguration;
  65193. private _dispatcher;
  65194. private _overlappingPairCache;
  65195. private _solver;
  65196. private _softBodySolver;
  65197. private _tmpAmmoVectorA;
  65198. private _tmpAmmoVectorB;
  65199. private _tmpAmmoVectorC;
  65200. private _tmpAmmoVectorD;
  65201. private _tmpContactCallbackResult;
  65202. private _tmpAmmoVectorRCA;
  65203. private _tmpAmmoVectorRCB;
  65204. private _raycastResult;
  65205. private _tmpContactPoint;
  65206. private static readonly DISABLE_COLLISION_FLAG;
  65207. private static readonly KINEMATIC_FLAG;
  65208. private static readonly DISABLE_DEACTIVATION_FLAG;
  65209. /**
  65210. * Initializes the ammoJS plugin
  65211. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  65212. * @param ammoInjection can be used to inject your own ammo reference
  65213. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  65214. */
  65215. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  65216. /**
  65217. * Sets the gravity of the physics world (m/(s^2))
  65218. * @param gravity Gravity to set
  65219. */
  65220. setGravity(gravity: Vector3): void;
  65221. /**
  65222. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  65223. * @param timeStep timestep to use in seconds
  65224. */
  65225. setTimeStep(timeStep: number): void;
  65226. /**
  65227. * 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)
  65228. * @param fixedTimeStep fixedTimeStep to use in seconds
  65229. */
  65230. setFixedTimeStep(fixedTimeStep: number): void;
  65231. /**
  65232. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  65233. * @param maxSteps the maximum number of steps by the physics engine per frame
  65234. */
  65235. setMaxSteps(maxSteps: number): void;
  65236. /**
  65237. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  65238. * @returns the current timestep in seconds
  65239. */
  65240. getTimeStep(): number;
  65241. /**
  65242. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  65243. */
  65244. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  65245. private _isImpostorInContact;
  65246. private _isImpostorPairInContact;
  65247. private _stepSimulation;
  65248. /**
  65249. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  65250. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  65251. * After the step the babylon meshes are set to the position of the physics imposters
  65252. * @param delta amount of time to step forward
  65253. * @param impostors array of imposters to update before/after the step
  65254. */
  65255. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65256. /**
  65257. * Update babylon mesh to match physics world object
  65258. * @param impostor imposter to match
  65259. */
  65260. private _afterSoftStep;
  65261. /**
  65262. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65263. * @param impostor imposter to match
  65264. */
  65265. private _ropeStep;
  65266. /**
  65267. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65268. * @param impostor imposter to match
  65269. */
  65270. private _softbodyOrClothStep;
  65271. private _tmpMatrix;
  65272. /**
  65273. * Applies an impulse on the imposter
  65274. * @param impostor imposter to apply impulse to
  65275. * @param force amount of force to be applied to the imposter
  65276. * @param contactPoint the location to apply the impulse on the imposter
  65277. */
  65278. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65279. /**
  65280. * Applies a force on the imposter
  65281. * @param impostor imposter to apply force
  65282. * @param force amount of force to be applied to the imposter
  65283. * @param contactPoint the location to apply the force on the imposter
  65284. */
  65285. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65286. /**
  65287. * Creates a physics body using the plugin
  65288. * @param impostor the imposter to create the physics body on
  65289. */
  65290. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65291. /**
  65292. * Removes the physics body from the imposter and disposes of the body's memory
  65293. * @param impostor imposter to remove the physics body from
  65294. */
  65295. removePhysicsBody(impostor: PhysicsImpostor): void;
  65296. /**
  65297. * Generates a joint
  65298. * @param impostorJoint the imposter joint to create the joint with
  65299. */
  65300. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65301. /**
  65302. * Removes a joint
  65303. * @param impostorJoint the imposter joint to remove the joint from
  65304. */
  65305. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65306. private _addMeshVerts;
  65307. /**
  65308. * Initialise the soft body vertices to match its object's (mesh) vertices
  65309. * Softbody vertices (nodes) are in world space and to match this
  65310. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  65311. * @param impostor to create the softbody for
  65312. */
  65313. private _softVertexData;
  65314. /**
  65315. * Create an impostor's soft body
  65316. * @param impostor to create the softbody for
  65317. */
  65318. private _createSoftbody;
  65319. /**
  65320. * Create cloth for an impostor
  65321. * @param impostor to create the softbody for
  65322. */
  65323. private _createCloth;
  65324. /**
  65325. * Create rope for an impostor
  65326. * @param impostor to create the softbody for
  65327. */
  65328. private _createRope;
  65329. /**
  65330. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  65331. * @param impostor to create the custom physics shape for
  65332. */
  65333. private _createCustom;
  65334. private _addHullVerts;
  65335. private _createShape;
  65336. /**
  65337. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  65338. * @param impostor imposter containing the physics body and babylon object
  65339. */
  65340. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65341. /**
  65342. * Sets the babylon object's position/rotation from the physics body's position/rotation
  65343. * @param impostor imposter containing the physics body and babylon object
  65344. * @param newPosition new position
  65345. * @param newRotation new rotation
  65346. */
  65347. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65348. /**
  65349. * If this plugin is supported
  65350. * @returns true if its supported
  65351. */
  65352. isSupported(): boolean;
  65353. /**
  65354. * Sets the linear velocity of the physics body
  65355. * @param impostor imposter to set the velocity on
  65356. * @param velocity velocity to set
  65357. */
  65358. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65359. /**
  65360. * Sets the angular velocity of the physics body
  65361. * @param impostor imposter to set the velocity on
  65362. * @param velocity velocity to set
  65363. */
  65364. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65365. /**
  65366. * gets the linear velocity
  65367. * @param impostor imposter to get linear velocity from
  65368. * @returns linear velocity
  65369. */
  65370. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65371. /**
  65372. * gets the angular velocity
  65373. * @param impostor imposter to get angular velocity from
  65374. * @returns angular velocity
  65375. */
  65376. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65377. /**
  65378. * Sets the mass of physics body
  65379. * @param impostor imposter to set the mass on
  65380. * @param mass mass to set
  65381. */
  65382. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65383. /**
  65384. * Gets the mass of the physics body
  65385. * @param impostor imposter to get the mass from
  65386. * @returns mass
  65387. */
  65388. getBodyMass(impostor: PhysicsImpostor): number;
  65389. /**
  65390. * Gets friction of the impostor
  65391. * @param impostor impostor to get friction from
  65392. * @returns friction value
  65393. */
  65394. getBodyFriction(impostor: PhysicsImpostor): number;
  65395. /**
  65396. * Sets friction of the impostor
  65397. * @param impostor impostor to set friction on
  65398. * @param friction friction value
  65399. */
  65400. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65401. /**
  65402. * Gets restitution of the impostor
  65403. * @param impostor impostor to get restitution from
  65404. * @returns restitution value
  65405. */
  65406. getBodyRestitution(impostor: PhysicsImpostor): number;
  65407. /**
  65408. * Sets resitution of the impostor
  65409. * @param impostor impostor to set resitution on
  65410. * @param restitution resitution value
  65411. */
  65412. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65413. /**
  65414. * Gets pressure inside the impostor
  65415. * @param impostor impostor to get pressure from
  65416. * @returns pressure value
  65417. */
  65418. getBodyPressure(impostor: PhysicsImpostor): number;
  65419. /**
  65420. * Sets pressure inside a soft body impostor
  65421. * Cloth and rope must remain 0 pressure
  65422. * @param impostor impostor to set pressure on
  65423. * @param pressure pressure value
  65424. */
  65425. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  65426. /**
  65427. * Gets stiffness of the impostor
  65428. * @param impostor impostor to get stiffness from
  65429. * @returns pressure value
  65430. */
  65431. getBodyStiffness(impostor: PhysicsImpostor): number;
  65432. /**
  65433. * Sets stiffness of the impostor
  65434. * @param impostor impostor to set stiffness on
  65435. * @param stiffness stiffness value from 0 to 1
  65436. */
  65437. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  65438. /**
  65439. * Gets velocityIterations of the impostor
  65440. * @param impostor impostor to get velocity iterations from
  65441. * @returns velocityIterations value
  65442. */
  65443. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  65444. /**
  65445. * Sets velocityIterations of the impostor
  65446. * @param impostor impostor to set velocity iterations on
  65447. * @param velocityIterations velocityIterations value
  65448. */
  65449. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  65450. /**
  65451. * Gets positionIterations of the impostor
  65452. * @param impostor impostor to get position iterations from
  65453. * @returns positionIterations value
  65454. */
  65455. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  65456. /**
  65457. * Sets positionIterations of the impostor
  65458. * @param impostor impostor to set position on
  65459. * @param positionIterations positionIterations value
  65460. */
  65461. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  65462. /**
  65463. * Append an anchor to a cloth object
  65464. * @param impostor is the cloth impostor to add anchor to
  65465. * @param otherImpostor is the rigid impostor to anchor to
  65466. * @param width ratio across width from 0 to 1
  65467. * @param height ratio up height from 0 to 1
  65468. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  65469. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65470. */
  65471. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65472. /**
  65473. * Append an hook to a rope object
  65474. * @param impostor is the rope impostor to add hook to
  65475. * @param otherImpostor is the rigid impostor to hook to
  65476. * @param length ratio along the rope from 0 to 1
  65477. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  65478. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65479. */
  65480. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65481. /**
  65482. * Sleeps the physics body and stops it from being active
  65483. * @param impostor impostor to sleep
  65484. */
  65485. sleepBody(impostor: PhysicsImpostor): void;
  65486. /**
  65487. * Activates the physics body
  65488. * @param impostor impostor to activate
  65489. */
  65490. wakeUpBody(impostor: PhysicsImpostor): void;
  65491. /**
  65492. * Updates the distance parameters of the joint
  65493. * @param joint joint to update
  65494. * @param maxDistance maximum distance of the joint
  65495. * @param minDistance minimum distance of the joint
  65496. */
  65497. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65498. /**
  65499. * Sets a motor on the joint
  65500. * @param joint joint to set motor on
  65501. * @param speed speed of the motor
  65502. * @param maxForce maximum force of the motor
  65503. * @param motorIndex index of the motor
  65504. */
  65505. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65506. /**
  65507. * Sets the motors limit
  65508. * @param joint joint to set limit on
  65509. * @param upperLimit upper limit
  65510. * @param lowerLimit lower limit
  65511. */
  65512. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65513. /**
  65514. * Syncs the position and rotation of a mesh with the impostor
  65515. * @param mesh mesh to sync
  65516. * @param impostor impostor to update the mesh with
  65517. */
  65518. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65519. /**
  65520. * Gets the radius of the impostor
  65521. * @param impostor impostor to get radius from
  65522. * @returns the radius
  65523. */
  65524. getRadius(impostor: PhysicsImpostor): number;
  65525. /**
  65526. * Gets the box size of the impostor
  65527. * @param impostor impostor to get box size from
  65528. * @param result the resulting box size
  65529. */
  65530. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65531. /**
  65532. * Disposes of the impostor
  65533. */
  65534. dispose(): void;
  65535. /**
  65536. * Does a raycast in the physics world
  65537. * @param from when should the ray start?
  65538. * @param to when should the ray end?
  65539. * @returns PhysicsRaycastResult
  65540. */
  65541. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65542. }
  65543. }
  65544. declare module "babylonjs/Probes/reflectionProbe" {
  65545. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65546. import { Vector3 } from "babylonjs/Maths/math.vector";
  65547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65548. import { Nullable } from "babylonjs/types";
  65549. import { Scene } from "babylonjs/scene";
  65550. module "babylonjs/abstractScene" {
  65551. interface AbstractScene {
  65552. /**
  65553. * The list of reflection probes added to the scene
  65554. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65555. */
  65556. reflectionProbes: Array<ReflectionProbe>;
  65557. /**
  65558. * Removes the given reflection probe from this scene.
  65559. * @param toRemove The reflection probe to remove
  65560. * @returns The index of the removed reflection probe
  65561. */
  65562. removeReflectionProbe(toRemove: ReflectionProbe): number;
  65563. /**
  65564. * Adds the given reflection probe to this scene.
  65565. * @param newReflectionProbe The reflection probe to add
  65566. */
  65567. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  65568. }
  65569. }
  65570. /**
  65571. * Class used to generate realtime reflection / refraction cube textures
  65572. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65573. */
  65574. export class ReflectionProbe {
  65575. /** defines the name of the probe */
  65576. name: string;
  65577. private _scene;
  65578. private _renderTargetTexture;
  65579. private _projectionMatrix;
  65580. private _viewMatrix;
  65581. private _target;
  65582. private _add;
  65583. private _attachedMesh;
  65584. private _invertYAxis;
  65585. /** Gets or sets probe position (center of the cube map) */
  65586. position: Vector3;
  65587. /**
  65588. * Creates a new reflection probe
  65589. * @param name defines the name of the probe
  65590. * @param size defines the texture resolution (for each face)
  65591. * @param scene defines the hosting scene
  65592. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  65593. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  65594. */
  65595. constructor(
  65596. /** defines the name of the probe */
  65597. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  65598. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  65599. get samples(): number;
  65600. set samples(value: number);
  65601. /** Gets or sets the refresh rate to use (on every frame by default) */
  65602. get refreshRate(): number;
  65603. set refreshRate(value: number);
  65604. /**
  65605. * Gets the hosting scene
  65606. * @returns a Scene
  65607. */
  65608. getScene(): Scene;
  65609. /** Gets the internal CubeTexture used to render to */
  65610. get cubeTexture(): RenderTargetTexture;
  65611. /** Gets the list of meshes to render */
  65612. get renderList(): Nullable<AbstractMesh[]>;
  65613. /**
  65614. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  65615. * @param mesh defines the mesh to attach to
  65616. */
  65617. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  65618. /**
  65619. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  65620. * @param renderingGroupId The rendering group id corresponding to its index
  65621. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  65622. */
  65623. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  65624. /**
  65625. * Clean all associated resources
  65626. */
  65627. dispose(): void;
  65628. /**
  65629. * Converts the reflection probe information to a readable string for debug purpose.
  65630. * @param fullDetails Supports for multiple levels of logging within scene loading
  65631. * @returns the human readable reflection probe info
  65632. */
  65633. toString(fullDetails?: boolean): string;
  65634. /**
  65635. * Get the class name of the relfection probe.
  65636. * @returns "ReflectionProbe"
  65637. */
  65638. getClassName(): string;
  65639. /**
  65640. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  65641. * @returns The JSON representation of the texture
  65642. */
  65643. serialize(): any;
  65644. /**
  65645. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  65646. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  65647. * @param scene Define the scene the parsed reflection probe should be instantiated in
  65648. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  65649. * @returns The parsed reflection probe if successful
  65650. */
  65651. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  65652. }
  65653. }
  65654. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  65655. /** @hidden */
  65656. export var _BabylonLoaderRegistered: boolean;
  65657. /**
  65658. * Helps setting up some configuration for the babylon file loader.
  65659. */
  65660. export class BabylonFileLoaderConfiguration {
  65661. /**
  65662. * The loader does not allow injecting custom physix engine into the plugins.
  65663. * Unfortunately in ES6, we need to manually inject them into the plugin.
  65664. * So you could set this variable to your engine import to make it work.
  65665. */
  65666. static LoaderInjectedPhysicsEngine: any;
  65667. }
  65668. }
  65669. declare module "babylonjs/Loading/Plugins/index" {
  65670. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  65671. }
  65672. declare module "babylonjs/Loading/index" {
  65673. export * from "babylonjs/Loading/loadingScreen";
  65674. export * from "babylonjs/Loading/Plugins/index";
  65675. export * from "babylonjs/Loading/sceneLoader";
  65676. export * from "babylonjs/Loading/sceneLoaderFlags";
  65677. }
  65678. declare module "babylonjs/Materials/Background/index" {
  65679. export * from "babylonjs/Materials/Background/backgroundMaterial";
  65680. }
  65681. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  65682. import { Scene } from "babylonjs/scene";
  65683. import { Color3 } from "babylonjs/Maths/math.color";
  65684. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65685. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65686. /**
  65687. * The Physically based simple base material of BJS.
  65688. *
  65689. * This enables better naming and convention enforcements on top of the pbrMaterial.
  65690. * It is used as the base class for both the specGloss and metalRough conventions.
  65691. */
  65692. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  65693. /**
  65694. * Number of Simultaneous lights allowed on the material.
  65695. */
  65696. maxSimultaneousLights: number;
  65697. /**
  65698. * If sets to true, disables all the lights affecting the material.
  65699. */
  65700. disableLighting: boolean;
  65701. /**
  65702. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  65703. */
  65704. environmentTexture: BaseTexture;
  65705. /**
  65706. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  65707. */
  65708. invertNormalMapX: boolean;
  65709. /**
  65710. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  65711. */
  65712. invertNormalMapY: boolean;
  65713. /**
  65714. * Normal map used in the model.
  65715. */
  65716. normalTexture: BaseTexture;
  65717. /**
  65718. * Emissivie color used to self-illuminate the model.
  65719. */
  65720. emissiveColor: Color3;
  65721. /**
  65722. * Emissivie texture used to self-illuminate the model.
  65723. */
  65724. emissiveTexture: BaseTexture;
  65725. /**
  65726. * Occlusion Channel Strenght.
  65727. */
  65728. occlusionStrength: number;
  65729. /**
  65730. * Occlusion Texture of the material (adding extra occlusion effects).
  65731. */
  65732. occlusionTexture: BaseTexture;
  65733. /**
  65734. * Defines the alpha limits in alpha test mode.
  65735. */
  65736. alphaCutOff: number;
  65737. /**
  65738. * Gets the current double sided mode.
  65739. */
  65740. get doubleSided(): boolean;
  65741. /**
  65742. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  65743. */
  65744. set doubleSided(value: boolean);
  65745. /**
  65746. * Stores the pre-calculated light information of a mesh in a texture.
  65747. */
  65748. lightmapTexture: BaseTexture;
  65749. /**
  65750. * If true, the light map contains occlusion information instead of lighting info.
  65751. */
  65752. useLightmapAsShadowmap: boolean;
  65753. /**
  65754. * Instantiates a new PBRMaterial instance.
  65755. *
  65756. * @param name The material name
  65757. * @param scene The scene the material will be use in.
  65758. */
  65759. constructor(name: string, scene: Scene);
  65760. getClassName(): string;
  65761. }
  65762. }
  65763. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  65764. import { Scene } from "babylonjs/scene";
  65765. import { Color3 } from "babylonjs/Maths/math.color";
  65766. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65767. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65768. /**
  65769. * The PBR material of BJS following the metal roughness convention.
  65770. *
  65771. * This fits to the PBR convention in the GLTF definition:
  65772. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  65773. */
  65774. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  65775. /**
  65776. * The base color has two different interpretations depending on the value of metalness.
  65777. * When the material is a metal, the base color is the specific measured reflectance value
  65778. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  65779. * of the material.
  65780. */
  65781. baseColor: Color3;
  65782. /**
  65783. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  65784. * well as opacity information in the alpha channel.
  65785. */
  65786. baseTexture: BaseTexture;
  65787. /**
  65788. * Specifies the metallic scalar value of the material.
  65789. * Can also be used to scale the metalness values of the metallic texture.
  65790. */
  65791. metallic: number;
  65792. /**
  65793. * Specifies the roughness scalar value of the material.
  65794. * Can also be used to scale the roughness values of the metallic texture.
  65795. */
  65796. roughness: number;
  65797. /**
  65798. * Texture containing both the metallic value in the B channel and the
  65799. * roughness value in the G channel to keep better precision.
  65800. */
  65801. metallicRoughnessTexture: BaseTexture;
  65802. /**
  65803. * Instantiates a new PBRMetalRoughnessMaterial instance.
  65804. *
  65805. * @param name The material name
  65806. * @param scene The scene the material will be use in.
  65807. */
  65808. constructor(name: string, scene: Scene);
  65809. /**
  65810. * Return the currrent class name of the material.
  65811. */
  65812. getClassName(): string;
  65813. /**
  65814. * Makes a duplicate of the current material.
  65815. * @param name - name to use for the new material.
  65816. */
  65817. clone(name: string): PBRMetallicRoughnessMaterial;
  65818. /**
  65819. * Serialize the material to a parsable JSON object.
  65820. */
  65821. serialize(): any;
  65822. /**
  65823. * Parses a JSON object correponding to the serialize function.
  65824. */
  65825. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  65826. }
  65827. }
  65828. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  65829. import { Scene } from "babylonjs/scene";
  65830. import { Color3 } from "babylonjs/Maths/math.color";
  65831. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65832. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65833. /**
  65834. * The PBR material of BJS following the specular glossiness convention.
  65835. *
  65836. * This fits to the PBR convention in the GLTF definition:
  65837. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  65838. */
  65839. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65840. /**
  65841. * Specifies the diffuse color of the material.
  65842. */
  65843. diffuseColor: Color3;
  65844. /**
  65845. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65846. * channel.
  65847. */
  65848. diffuseTexture: BaseTexture;
  65849. /**
  65850. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65851. */
  65852. specularColor: Color3;
  65853. /**
  65854. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65855. */
  65856. glossiness: number;
  65857. /**
  65858. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65859. */
  65860. specularGlossinessTexture: BaseTexture;
  65861. /**
  65862. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65863. *
  65864. * @param name The material name
  65865. * @param scene The scene the material will be use in.
  65866. */
  65867. constructor(name: string, scene: Scene);
  65868. /**
  65869. * Return the currrent class name of the material.
  65870. */
  65871. getClassName(): string;
  65872. /**
  65873. * Makes a duplicate of the current material.
  65874. * @param name - name to use for the new material.
  65875. */
  65876. clone(name: string): PBRSpecularGlossinessMaterial;
  65877. /**
  65878. * Serialize the material to a parsable JSON object.
  65879. */
  65880. serialize(): any;
  65881. /**
  65882. * Parses a JSON object correponding to the serialize function.
  65883. */
  65884. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65885. }
  65886. }
  65887. declare module "babylonjs/Materials/PBR/index" {
  65888. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65889. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65890. export * from "babylonjs/Materials/PBR/pbrMaterial";
  65891. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  65892. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  65893. }
  65894. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  65895. import { Nullable } from "babylonjs/types";
  65896. import { Scene } from "babylonjs/scene";
  65897. import { Matrix } from "babylonjs/Maths/math.vector";
  65898. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65899. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65900. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65901. /**
  65902. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65903. * It can help converting any input color in a desired output one. This can then be used to create effects
  65904. * from sepia, black and white to sixties or futuristic rendering...
  65905. *
  65906. * The only supported format is currently 3dl.
  65907. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65908. */
  65909. export class ColorGradingTexture extends BaseTexture {
  65910. /**
  65911. * The texture URL.
  65912. */
  65913. url: string;
  65914. /**
  65915. * Empty line regex stored for GC.
  65916. */
  65917. private static _noneEmptyLineRegex;
  65918. private _textureMatrix;
  65919. private _onLoad;
  65920. /**
  65921. * Instantiates a ColorGradingTexture from the following parameters.
  65922. *
  65923. * @param url The location of the color gradind data (currently only supporting 3dl)
  65924. * @param sceneOrEngine The scene or engine the texture will be used in
  65925. * @param onLoad defines a callback triggered when the texture has been loaded
  65926. */
  65927. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65928. /**
  65929. * Fires the onload event from the constructor if requested.
  65930. */
  65931. private _triggerOnLoad;
  65932. /**
  65933. * Returns the texture matrix used in most of the material.
  65934. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65935. */
  65936. getTextureMatrix(): Matrix;
  65937. /**
  65938. * Occurs when the file being loaded is a .3dl LUT file.
  65939. */
  65940. private load3dlTexture;
  65941. /**
  65942. * Starts the loading process of the texture.
  65943. */
  65944. private loadTexture;
  65945. /**
  65946. * Clones the color gradind texture.
  65947. */
  65948. clone(): ColorGradingTexture;
  65949. /**
  65950. * Called during delayed load for textures.
  65951. */
  65952. delayLoad(): void;
  65953. /**
  65954. * Parses a color grading texture serialized by Babylon.
  65955. * @param parsedTexture The texture information being parsedTexture
  65956. * @param scene The scene to load the texture in
  65957. * @param rootUrl The root url of the data assets to load
  65958. * @return A color gradind texture
  65959. */
  65960. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  65961. /**
  65962. * Serializes the LUT texture to json format.
  65963. */
  65964. serialize(): any;
  65965. }
  65966. }
  65967. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  65968. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65969. import { Scene } from "babylonjs/scene";
  65970. import { Nullable } from "babylonjs/types";
  65971. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65972. /**
  65973. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  65974. */
  65975. export class EquiRectangularCubeTexture extends BaseTexture {
  65976. /** The six faces of the cube. */
  65977. private static _FacesMapping;
  65978. private _noMipmap;
  65979. private _onLoad;
  65980. private _onError;
  65981. /** The size of the cubemap. */
  65982. private _size;
  65983. /** The buffer of the image. */
  65984. private _buffer;
  65985. /** The width of the input image. */
  65986. private _width;
  65987. /** The height of the input image. */
  65988. private _height;
  65989. /** The URL to the image. */
  65990. url: string;
  65991. /**
  65992. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  65993. * @param url The location of the image
  65994. * @param scene The scene the texture will be used in
  65995. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65996. * @param noMipmap Forces to not generate the mipmap if true
  65997. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65998. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65999. * @param onLoad — defines a callback called when texture is loaded
  66000. * @param onError — defines a callback called if there is an error
  66001. */
  66002. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  66003. /**
  66004. * Load the image data, by putting the image on a canvas and extracting its buffer.
  66005. */
  66006. private loadImage;
  66007. /**
  66008. * Convert the image buffer into a cubemap and create a CubeTexture.
  66009. */
  66010. private loadTexture;
  66011. /**
  66012. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  66013. * @param buffer The ArrayBuffer that should be converted.
  66014. * @returns The buffer as Float32Array.
  66015. */
  66016. private getFloat32ArrayFromArrayBuffer;
  66017. /**
  66018. * Get the current class name of the texture useful for serialization or dynamic coding.
  66019. * @returns "EquiRectangularCubeTexture"
  66020. */
  66021. getClassName(): string;
  66022. /**
  66023. * Create a clone of the current EquiRectangularCubeTexture and return it.
  66024. * @returns A clone of the current EquiRectangularCubeTexture.
  66025. */
  66026. clone(): EquiRectangularCubeTexture;
  66027. }
  66028. }
  66029. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  66030. import { Nullable } from "babylonjs/types";
  66031. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66032. import { Matrix } from "babylonjs/Maths/math.vector";
  66033. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  66034. import "babylonjs/Engines/Extensions/engine.videoTexture";
  66035. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  66036. import { Scene } from "babylonjs/scene";
  66037. /**
  66038. * Defines the options related to the creation of an HtmlElementTexture
  66039. */
  66040. export interface IHtmlElementTextureOptions {
  66041. /**
  66042. * Defines wether mip maps should be created or not.
  66043. */
  66044. generateMipMaps?: boolean;
  66045. /**
  66046. * Defines the sampling mode of the texture.
  66047. */
  66048. samplingMode?: number;
  66049. /**
  66050. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  66051. */
  66052. engine: Nullable<ThinEngine>;
  66053. /**
  66054. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  66055. */
  66056. scene: Nullable<Scene>;
  66057. }
  66058. /**
  66059. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  66060. * To be as efficient as possible depending on your constraints nothing aside the first upload
  66061. * is automatically managed.
  66062. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  66063. * in your application.
  66064. *
  66065. * As the update is not automatic, you need to call them manually.
  66066. */
  66067. export class HtmlElementTexture extends BaseTexture {
  66068. /**
  66069. * The texture URL.
  66070. */
  66071. element: HTMLVideoElement | HTMLCanvasElement;
  66072. private static readonly DefaultOptions;
  66073. private _textureMatrix;
  66074. private _isVideo;
  66075. private _generateMipMaps;
  66076. private _samplingMode;
  66077. /**
  66078. * Instantiates a HtmlElementTexture from the following parameters.
  66079. *
  66080. * @param name Defines the name of the texture
  66081. * @param element Defines the video or canvas the texture is filled with
  66082. * @param options Defines the other none mandatory texture creation options
  66083. */
  66084. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  66085. private _createInternalTexture;
  66086. /**
  66087. * Returns the texture matrix used in most of the material.
  66088. */
  66089. getTextureMatrix(): Matrix;
  66090. /**
  66091. * Updates the content of the texture.
  66092. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  66093. */
  66094. update(invertY?: Nullable<boolean>): void;
  66095. }
  66096. }
  66097. declare module "babylonjs/Misc/tga" {
  66098. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66099. /**
  66100. * Based on jsTGALoader - Javascript loader for TGA file
  66101. * By Vincent Thibault
  66102. * @see http://blog.robrowser.com/javascript-tga-loader.html
  66103. */
  66104. export class TGATools {
  66105. private static _TYPE_INDEXED;
  66106. private static _TYPE_RGB;
  66107. private static _TYPE_GREY;
  66108. private static _TYPE_RLE_INDEXED;
  66109. private static _TYPE_RLE_RGB;
  66110. private static _TYPE_RLE_GREY;
  66111. private static _ORIGIN_MASK;
  66112. private static _ORIGIN_SHIFT;
  66113. private static _ORIGIN_BL;
  66114. private static _ORIGIN_BR;
  66115. private static _ORIGIN_UL;
  66116. private static _ORIGIN_UR;
  66117. /**
  66118. * Gets the header of a TGA file
  66119. * @param data defines the TGA data
  66120. * @returns the header
  66121. */
  66122. static GetTGAHeader(data: Uint8Array): any;
  66123. /**
  66124. * Uploads TGA content to a Babylon Texture
  66125. * @hidden
  66126. */
  66127. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  66128. /** @hidden */
  66129. 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;
  66130. /** @hidden */
  66131. 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;
  66132. /** @hidden */
  66133. 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;
  66134. /** @hidden */
  66135. 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;
  66136. /** @hidden */
  66137. 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;
  66138. /** @hidden */
  66139. 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;
  66140. }
  66141. }
  66142. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  66143. import { Nullable } from "babylonjs/types";
  66144. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66145. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  66146. /**
  66147. * Implementation of the TGA Texture Loader.
  66148. * @hidden
  66149. */
  66150. export class _TGATextureLoader implements IInternalTextureLoader {
  66151. /**
  66152. * Defines wether the loader supports cascade loading the different faces.
  66153. */
  66154. readonly supportCascades: boolean;
  66155. /**
  66156. * This returns if the loader support the current file information.
  66157. * @param extension defines the file extension of the file being loaded
  66158. * @returns true if the loader can load the specified file
  66159. */
  66160. canLoad(extension: string): boolean;
  66161. /**
  66162. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66163. * @param data contains the texture data
  66164. * @param texture defines the BabylonJS internal texture
  66165. * @param createPolynomials will be true if polynomials have been requested
  66166. * @param onLoad defines the callback to trigger once the texture is ready
  66167. * @param onError defines the callback to trigger in case of error
  66168. */
  66169. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66170. /**
  66171. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66172. * @param data contains the texture data
  66173. * @param texture defines the BabylonJS internal texture
  66174. * @param callback defines the method to call once ready to upload
  66175. */
  66176. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66177. }
  66178. }
  66179. declare module "babylonjs/Misc/basis" {
  66180. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66181. /**
  66182. * Info about the .basis files
  66183. */
  66184. class BasisFileInfo {
  66185. /**
  66186. * If the file has alpha
  66187. */
  66188. hasAlpha: boolean;
  66189. /**
  66190. * Info about each image of the basis file
  66191. */
  66192. images: Array<{
  66193. levels: Array<{
  66194. width: number;
  66195. height: number;
  66196. transcodedPixels: ArrayBufferView;
  66197. }>;
  66198. }>;
  66199. }
  66200. /**
  66201. * Result of transcoding a basis file
  66202. */
  66203. class TranscodeResult {
  66204. /**
  66205. * Info about the .basis file
  66206. */
  66207. fileInfo: BasisFileInfo;
  66208. /**
  66209. * Format to use when loading the file
  66210. */
  66211. format: number;
  66212. }
  66213. /**
  66214. * Configuration options for the Basis transcoder
  66215. */
  66216. export class BasisTranscodeConfiguration {
  66217. /**
  66218. * Supported compression formats used to determine the supported output format of the transcoder
  66219. */
  66220. supportedCompressionFormats?: {
  66221. /**
  66222. * etc1 compression format
  66223. */
  66224. etc1?: boolean;
  66225. /**
  66226. * s3tc compression format
  66227. */
  66228. s3tc?: boolean;
  66229. /**
  66230. * pvrtc compression format
  66231. */
  66232. pvrtc?: boolean;
  66233. /**
  66234. * etc2 compression format
  66235. */
  66236. etc2?: boolean;
  66237. };
  66238. /**
  66239. * If mipmap levels should be loaded for transcoded images (Default: true)
  66240. */
  66241. loadMipmapLevels?: boolean;
  66242. /**
  66243. * Index of a single image to load (Default: all images)
  66244. */
  66245. loadSingleImage?: number;
  66246. }
  66247. /**
  66248. * Used to load .Basis files
  66249. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  66250. */
  66251. export class BasisTools {
  66252. private static _IgnoreSupportedFormats;
  66253. /**
  66254. * URL to use when loading the basis transcoder
  66255. */
  66256. static JSModuleURL: string;
  66257. /**
  66258. * URL to use when loading the wasm module for the transcoder
  66259. */
  66260. static WasmModuleURL: string;
  66261. /**
  66262. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  66263. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  66264. * @returns internal format corresponding to the Basis format
  66265. */
  66266. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  66267. private static _WorkerPromise;
  66268. private static _Worker;
  66269. private static _actionId;
  66270. private static _CreateWorkerAsync;
  66271. /**
  66272. * Transcodes a loaded image file to compressed pixel data
  66273. * @param data image data to transcode
  66274. * @param config configuration options for the transcoding
  66275. * @returns a promise resulting in the transcoded image
  66276. */
  66277. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  66278. /**
  66279. * Loads a texture from the transcode result
  66280. * @param texture texture load to
  66281. * @param transcodeResult the result of transcoding the basis file to load from
  66282. */
  66283. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  66284. }
  66285. }
  66286. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  66287. import { Nullable } from "babylonjs/types";
  66288. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66289. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  66290. /**
  66291. * Loader for .basis file format
  66292. */
  66293. export class _BasisTextureLoader implements IInternalTextureLoader {
  66294. /**
  66295. * Defines whether the loader supports cascade loading the different faces.
  66296. */
  66297. readonly supportCascades: boolean;
  66298. /**
  66299. * This returns if the loader support the current file information.
  66300. * @param extension defines the file extension of the file being loaded
  66301. * @returns true if the loader can load the specified file
  66302. */
  66303. canLoad(extension: string): boolean;
  66304. /**
  66305. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66306. * @param data contains the texture data
  66307. * @param texture defines the BabylonJS internal texture
  66308. * @param createPolynomials will be true if polynomials have been requested
  66309. * @param onLoad defines the callback to trigger once the texture is ready
  66310. * @param onError defines the callback to trigger in case of error
  66311. */
  66312. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66313. /**
  66314. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66315. * @param data contains the texture data
  66316. * @param texture defines the BabylonJS internal texture
  66317. * @param callback defines the method to call once ready to upload
  66318. */
  66319. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66320. }
  66321. }
  66322. declare module "babylonjs/Materials/Textures/Loaders/index" {
  66323. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  66324. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  66325. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  66326. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  66327. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  66328. }
  66329. declare module "babylonjs/Materials/Textures/Packer/frame" {
  66330. import { Vector2 } from "babylonjs/Maths/math.vector";
  66331. /**
  66332. * Defines the basic options interface of a TexturePacker Frame
  66333. */
  66334. export interface ITexturePackerFrame {
  66335. /**
  66336. * The frame ID
  66337. */
  66338. id: number;
  66339. /**
  66340. * The frames Scale
  66341. */
  66342. scale: Vector2;
  66343. /**
  66344. * The Frames offset
  66345. */
  66346. offset: Vector2;
  66347. }
  66348. /**
  66349. * This is a support class for frame Data on texture packer sets.
  66350. */
  66351. export class TexturePackerFrame implements ITexturePackerFrame {
  66352. /**
  66353. * The frame ID
  66354. */
  66355. id: number;
  66356. /**
  66357. * The frames Scale
  66358. */
  66359. scale: Vector2;
  66360. /**
  66361. * The Frames offset
  66362. */
  66363. offset: Vector2;
  66364. /**
  66365. * Initializes a texture package frame.
  66366. * @param id The numerical frame identifier
  66367. * @param scale Scalar Vector2 for UV frame
  66368. * @param offset Vector2 for the frame position in UV units.
  66369. * @returns TexturePackerFrame
  66370. */
  66371. constructor(id: number, scale: Vector2, offset: Vector2);
  66372. }
  66373. }
  66374. declare module "babylonjs/Materials/Textures/Packer/packer" {
  66375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66376. import { Scene } from "babylonjs/scene";
  66377. import { Nullable } from "babylonjs/types";
  66378. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  66379. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  66380. /**
  66381. * Defines the basic options interface of a TexturePacker
  66382. */
  66383. export interface ITexturePackerOptions {
  66384. /**
  66385. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  66386. */
  66387. map?: string[];
  66388. /**
  66389. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66390. */
  66391. uvsIn?: string;
  66392. /**
  66393. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66394. */
  66395. uvsOut?: string;
  66396. /**
  66397. * number representing the layout style. Defaults to LAYOUT_STRIP
  66398. */
  66399. layout?: number;
  66400. /**
  66401. * number of columns if using custom column count layout(2). This defaults to 4.
  66402. */
  66403. colnum?: number;
  66404. /**
  66405. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  66406. */
  66407. updateInputMeshes?: boolean;
  66408. /**
  66409. * boolean flag to dispose all the source textures. Defaults to true.
  66410. */
  66411. disposeSources?: boolean;
  66412. /**
  66413. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  66414. */
  66415. fillBlanks?: boolean;
  66416. /**
  66417. * string value representing the context fill style color. Defaults to 'black'.
  66418. */
  66419. customFillColor?: string;
  66420. /**
  66421. * Width and Height Value of each Frame in the TexturePacker Sets
  66422. */
  66423. frameSize?: number;
  66424. /**
  66425. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  66426. */
  66427. paddingRatio?: number;
  66428. /**
  66429. * Number that declares the fill method for the padding gutter.
  66430. */
  66431. paddingMode?: number;
  66432. /**
  66433. * If in SUBUV_COLOR padding mode what color to use.
  66434. */
  66435. paddingColor?: Color3 | Color4;
  66436. }
  66437. /**
  66438. * Defines the basic interface of a TexturePacker JSON File
  66439. */
  66440. export interface ITexturePackerJSON {
  66441. /**
  66442. * The frame ID
  66443. */
  66444. name: string;
  66445. /**
  66446. * The base64 channel data
  66447. */
  66448. sets: any;
  66449. /**
  66450. * The options of the Packer
  66451. */
  66452. options: ITexturePackerOptions;
  66453. /**
  66454. * The frame data of the Packer
  66455. */
  66456. frames: Array<number>;
  66457. }
  66458. /**
  66459. * This is a support class that generates a series of packed texture sets.
  66460. * @see https://doc.babylonjs.com/babylon101/materials
  66461. */
  66462. export class TexturePacker {
  66463. /** Packer Layout Constant 0 */
  66464. static readonly LAYOUT_STRIP: number;
  66465. /** Packer Layout Constant 1 */
  66466. static readonly LAYOUT_POWER2: number;
  66467. /** Packer Layout Constant 2 */
  66468. static readonly LAYOUT_COLNUM: number;
  66469. /** Packer Layout Constant 0 */
  66470. static readonly SUBUV_WRAP: number;
  66471. /** Packer Layout Constant 1 */
  66472. static readonly SUBUV_EXTEND: number;
  66473. /** Packer Layout Constant 2 */
  66474. static readonly SUBUV_COLOR: number;
  66475. /** The Name of the Texture Package */
  66476. name: string;
  66477. /** The scene scope of the TexturePacker */
  66478. scene: Scene;
  66479. /** The Meshes to target */
  66480. meshes: AbstractMesh[];
  66481. /** Arguments passed with the Constructor */
  66482. options: ITexturePackerOptions;
  66483. /** The promise that is started upon initialization */
  66484. promise: Nullable<Promise<TexturePacker | string>>;
  66485. /** The Container object for the channel sets that are generated */
  66486. sets: object;
  66487. /** The Container array for the frames that are generated */
  66488. frames: TexturePackerFrame[];
  66489. /** The expected number of textures the system is parsing. */
  66490. private _expecting;
  66491. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  66492. private _paddingValue;
  66493. /**
  66494. * Initializes a texture package series from an array of meshes or a single mesh.
  66495. * @param name The name of the package
  66496. * @param meshes The target meshes to compose the package from
  66497. * @param options The arguments that texture packer should follow while building.
  66498. * @param scene The scene which the textures are scoped to.
  66499. * @returns TexturePacker
  66500. */
  66501. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  66502. /**
  66503. * Starts the package process
  66504. * @param resolve The promises resolution function
  66505. * @returns TexturePacker
  66506. */
  66507. private _createFrames;
  66508. /**
  66509. * Calculates the Size of the Channel Sets
  66510. * @returns Vector2
  66511. */
  66512. private _calculateSize;
  66513. /**
  66514. * Calculates the UV data for the frames.
  66515. * @param baseSize the base frameSize
  66516. * @param padding the base frame padding
  66517. * @param dtSize size of the Dynamic Texture for that channel
  66518. * @param dtUnits is 1/dtSize
  66519. * @param update flag to update the input meshes
  66520. */
  66521. private _calculateMeshUVFrames;
  66522. /**
  66523. * Calculates the frames Offset.
  66524. * @param index of the frame
  66525. * @returns Vector2
  66526. */
  66527. private _getFrameOffset;
  66528. /**
  66529. * Updates a Mesh to the frame data
  66530. * @param mesh that is the target
  66531. * @param frameID or the frame index
  66532. */
  66533. private _updateMeshUV;
  66534. /**
  66535. * Updates a Meshes materials to use the texture packer channels
  66536. * @param m is the mesh to target
  66537. * @param force all channels on the packer to be set.
  66538. */
  66539. private _updateTextureReferences;
  66540. /**
  66541. * Public method to set a Mesh to a frame
  66542. * @param m that is the target
  66543. * @param frameID or the frame index
  66544. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  66545. */
  66546. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  66547. /**
  66548. * Starts the async promise to compile the texture packer.
  66549. * @returns Promise<void>
  66550. */
  66551. processAsync(): Promise<void>;
  66552. /**
  66553. * Disposes all textures associated with this packer
  66554. */
  66555. dispose(): void;
  66556. /**
  66557. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  66558. * @param imageType is the image type to use.
  66559. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  66560. */
  66561. download(imageType?: string, quality?: number): void;
  66562. /**
  66563. * Public method to load a texturePacker JSON file.
  66564. * @param data of the JSON file in string format.
  66565. */
  66566. updateFromJSON(data: string): void;
  66567. }
  66568. }
  66569. declare module "babylonjs/Materials/Textures/Packer/index" {
  66570. export * from "babylonjs/Materials/Textures/Packer/packer";
  66571. export * from "babylonjs/Materials/Textures/Packer/frame";
  66572. }
  66573. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  66574. import { Scene } from "babylonjs/scene";
  66575. import { Texture } from "babylonjs/Materials/Textures/texture";
  66576. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66577. /**
  66578. * 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.
  66579. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66580. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66581. */
  66582. export class CustomProceduralTexture extends ProceduralTexture {
  66583. private _animate;
  66584. private _time;
  66585. private _config;
  66586. private _texturePath;
  66587. /**
  66588. * Instantiates a new Custom Procedural Texture.
  66589. * 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.
  66590. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66591. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66592. * @param name Define the name of the texture
  66593. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  66594. * @param size Define the size of the texture to create
  66595. * @param scene Define the scene the texture belongs to
  66596. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  66597. * @param generateMipMaps Define if the texture should creates mip maps or not
  66598. */
  66599. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66600. private _loadJson;
  66601. /**
  66602. * Is the texture ready to be used ? (rendered at least once)
  66603. * @returns true if ready, otherwise, false.
  66604. */
  66605. isReady(): boolean;
  66606. /**
  66607. * Render the texture to its associated render target.
  66608. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  66609. */
  66610. render(useCameraPostProcess?: boolean): void;
  66611. /**
  66612. * Update the list of dependant textures samplers in the shader.
  66613. */
  66614. updateTextures(): void;
  66615. /**
  66616. * Update the uniform values of the procedural texture in the shader.
  66617. */
  66618. updateShaderUniforms(): void;
  66619. /**
  66620. * Define if the texture animates or not.
  66621. */
  66622. get animate(): boolean;
  66623. set animate(value: boolean);
  66624. }
  66625. }
  66626. declare module "babylonjs/Shaders/noise.fragment" {
  66627. /** @hidden */
  66628. export var noisePixelShader: {
  66629. name: string;
  66630. shader: string;
  66631. };
  66632. }
  66633. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  66634. import { Nullable } from "babylonjs/types";
  66635. import { Scene } from "babylonjs/scene";
  66636. import { Texture } from "babylonjs/Materials/Textures/texture";
  66637. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66638. import "babylonjs/Shaders/noise.fragment";
  66639. /**
  66640. * Class used to generate noise procedural textures
  66641. */
  66642. export class NoiseProceduralTexture extends ProceduralTexture {
  66643. /** Gets or sets the start time (default is 0) */
  66644. time: number;
  66645. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  66646. brightness: number;
  66647. /** Defines the number of octaves to process */
  66648. octaves: number;
  66649. /** Defines the level of persistence (0.8 by default) */
  66650. persistence: number;
  66651. /** Gets or sets animation speed factor (default is 1) */
  66652. animationSpeedFactor: number;
  66653. /**
  66654. * Creates a new NoiseProceduralTexture
  66655. * @param name defines the name fo the texture
  66656. * @param size defines the size of the texture (default is 256)
  66657. * @param scene defines the hosting scene
  66658. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  66659. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  66660. */
  66661. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66662. private _updateShaderUniforms;
  66663. protected _getDefines(): string;
  66664. /** Generate the current state of the procedural texture */
  66665. render(useCameraPostProcess?: boolean): void;
  66666. /**
  66667. * Serializes this noise procedural texture
  66668. * @returns a serialized noise procedural texture object
  66669. */
  66670. serialize(): any;
  66671. /**
  66672. * Clone the texture.
  66673. * @returns the cloned texture
  66674. */
  66675. clone(): NoiseProceduralTexture;
  66676. /**
  66677. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  66678. * @param parsedTexture defines parsed texture data
  66679. * @param scene defines the current scene
  66680. * @param rootUrl defines the root URL containing noise procedural texture information
  66681. * @returns a parsed NoiseProceduralTexture
  66682. */
  66683. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  66684. }
  66685. }
  66686. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  66687. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  66688. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  66689. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66690. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  66691. }
  66692. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  66693. import { Nullable } from "babylonjs/types";
  66694. import { Scene } from "babylonjs/scene";
  66695. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  66696. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66697. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  66698. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66699. /**
  66700. * Raw cube texture where the raw buffers are passed in
  66701. */
  66702. export class RawCubeTexture extends CubeTexture {
  66703. /**
  66704. * Creates a cube texture where the raw buffers are passed in.
  66705. * @param scene defines the scene the texture is attached to
  66706. * @param data defines the array of data to use to create each face
  66707. * @param size defines the size of the textures
  66708. * @param format defines the format of the data
  66709. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  66710. * @param generateMipMaps defines if the engine should generate the mip levels
  66711. * @param invertY defines if data must be stored with Y axis inverted
  66712. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  66713. * @param compression defines the compression used (null by default)
  66714. */
  66715. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  66716. /**
  66717. * Updates the raw cube texture.
  66718. * @param data defines the data to store
  66719. * @param format defines the data format
  66720. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66721. * @param invertY defines if data must be stored with Y axis inverted
  66722. * @param compression defines the compression used (null by default)
  66723. * @param level defines which level of the texture to update
  66724. */
  66725. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  66726. /**
  66727. * Updates a raw cube texture with RGBD encoded data.
  66728. * @param data defines the array of data [mipmap][face] to use to create each face
  66729. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  66730. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66731. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66732. * @returns a promsie that resolves when the operation is complete
  66733. */
  66734. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  66735. /**
  66736. * Clones the raw cube texture.
  66737. * @return a new cube texture
  66738. */
  66739. clone(): CubeTexture;
  66740. /** @hidden */
  66741. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  66742. }
  66743. }
  66744. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  66745. import { Scene } from "babylonjs/scene";
  66746. import { Texture } from "babylonjs/Materials/Textures/texture";
  66747. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66748. /**
  66749. * Class used to store 2D array textures containing user data
  66750. */
  66751. export class RawTexture2DArray extends Texture {
  66752. /** Gets or sets the texture format to use */
  66753. format: number;
  66754. /**
  66755. * Create a new RawTexture2DArray
  66756. * @param data defines the data of the texture
  66757. * @param width defines the width of the texture
  66758. * @param height defines the height of the texture
  66759. * @param depth defines the number of layers of the texture
  66760. * @param format defines the texture format to use
  66761. * @param scene defines the hosting scene
  66762. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66763. * @param invertY defines if texture must be stored with Y axis inverted
  66764. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66765. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66766. */
  66767. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66768. /** Gets or sets the texture format to use */
  66769. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66770. /**
  66771. * Update the texture with new data
  66772. * @param data defines the data to store in the texture
  66773. */
  66774. update(data: ArrayBufferView): void;
  66775. }
  66776. }
  66777. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  66778. import { Scene } from "babylonjs/scene";
  66779. import { Texture } from "babylonjs/Materials/Textures/texture";
  66780. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66781. /**
  66782. * Class used to store 3D textures containing user data
  66783. */
  66784. export class RawTexture3D extends Texture {
  66785. /** Gets or sets the texture format to use */
  66786. format: number;
  66787. /**
  66788. * Create a new RawTexture3D
  66789. * @param data defines the data of the texture
  66790. * @param width defines the width of the texture
  66791. * @param height defines the height of the texture
  66792. * @param depth defines the depth of the texture
  66793. * @param format defines the texture format to use
  66794. * @param scene defines the hosting scene
  66795. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66796. * @param invertY defines if texture must be stored with Y axis inverted
  66797. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66798. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66799. */
  66800. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66801. /** Gets or sets the texture format to use */
  66802. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66803. /**
  66804. * Update the texture with new data
  66805. * @param data defines the data to store in the texture
  66806. */
  66807. update(data: ArrayBufferView): void;
  66808. }
  66809. }
  66810. declare module "babylonjs/Materials/Textures/refractionTexture" {
  66811. import { Scene } from "babylonjs/scene";
  66812. import { Plane } from "babylonjs/Maths/math.plane";
  66813. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66814. /**
  66815. * Creates a refraction texture used by refraction channel of the standard material.
  66816. * It is like a mirror but to see through a material.
  66817. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66818. */
  66819. export class RefractionTexture extends RenderTargetTexture {
  66820. /**
  66821. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  66822. * 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.
  66823. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66824. */
  66825. refractionPlane: Plane;
  66826. /**
  66827. * Define how deep under the surface we should see.
  66828. */
  66829. depth: number;
  66830. /**
  66831. * Creates a refraction texture used by refraction channel of the standard material.
  66832. * It is like a mirror but to see through a material.
  66833. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66834. * @param name Define the texture name
  66835. * @param size Define the size of the underlying texture
  66836. * @param scene Define the scene the refraction belongs to
  66837. * @param generateMipMaps Define if we need to generate mips level for the refraction
  66838. */
  66839. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66840. /**
  66841. * Clone the refraction texture.
  66842. * @returns the cloned texture
  66843. */
  66844. clone(): RefractionTexture;
  66845. /**
  66846. * Serialize the texture to a JSON representation you could use in Parse later on
  66847. * @returns the serialized JSON representation
  66848. */
  66849. serialize(): any;
  66850. }
  66851. }
  66852. declare module "babylonjs/Materials/Textures/index" {
  66853. export * from "babylonjs/Materials/Textures/baseTexture";
  66854. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  66855. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  66856. export * from "babylonjs/Materials/Textures/cubeTexture";
  66857. export * from "babylonjs/Materials/Textures/dynamicTexture";
  66858. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66859. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  66860. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  66861. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  66862. export * from "babylonjs/Materials/Textures/internalTexture";
  66863. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  66864. export * from "babylonjs/Materials/Textures/Loaders/index";
  66865. export * from "babylonjs/Materials/Textures/mirrorTexture";
  66866. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  66867. export * from "babylonjs/Materials/Textures/Packer/index";
  66868. export * from "babylonjs/Materials/Textures/Procedurals/index";
  66869. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  66870. export * from "babylonjs/Materials/Textures/rawTexture";
  66871. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  66872. export * from "babylonjs/Materials/Textures/rawTexture3D";
  66873. export * from "babylonjs/Materials/Textures/refractionTexture";
  66874. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  66875. export * from "babylonjs/Materials/Textures/texture";
  66876. export * from "babylonjs/Materials/Textures/videoTexture";
  66877. }
  66878. declare module "babylonjs/Materials/Node/Enums/index" {
  66879. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  66880. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  66881. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  66882. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  66883. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  66884. }
  66885. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  66886. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66887. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66889. import { Mesh } from "babylonjs/Meshes/mesh";
  66890. import { Effect } from "babylonjs/Materials/effect";
  66891. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66892. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66893. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66894. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66895. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66896. /**
  66897. * Block used to add support for vertex skinning (bones)
  66898. */
  66899. export class BonesBlock extends NodeMaterialBlock {
  66900. /**
  66901. * Creates a new BonesBlock
  66902. * @param name defines the block name
  66903. */
  66904. constructor(name: string);
  66905. /**
  66906. * Initialize the block and prepare the context for build
  66907. * @param state defines the state that will be used for the build
  66908. */
  66909. initialize(state: NodeMaterialBuildState): void;
  66910. /**
  66911. * Gets the current class name
  66912. * @returns the class name
  66913. */
  66914. getClassName(): string;
  66915. /**
  66916. * Gets the matrix indices input component
  66917. */
  66918. get matricesIndices(): NodeMaterialConnectionPoint;
  66919. /**
  66920. * Gets the matrix weights input component
  66921. */
  66922. get matricesWeights(): NodeMaterialConnectionPoint;
  66923. /**
  66924. * Gets the extra matrix indices input component
  66925. */
  66926. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66927. /**
  66928. * Gets the extra matrix weights input component
  66929. */
  66930. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66931. /**
  66932. * Gets the world input component
  66933. */
  66934. get world(): NodeMaterialConnectionPoint;
  66935. /**
  66936. * Gets the output component
  66937. */
  66938. get output(): NodeMaterialConnectionPoint;
  66939. autoConfigure(material: NodeMaterial): void;
  66940. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66941. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66942. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66943. protected _buildBlock(state: NodeMaterialBuildState): this;
  66944. }
  66945. }
  66946. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  66947. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66948. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66949. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66950. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66951. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66952. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66953. /**
  66954. * Block used to add support for instances
  66955. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66956. */
  66957. export class InstancesBlock extends NodeMaterialBlock {
  66958. /**
  66959. * Creates a new InstancesBlock
  66960. * @param name defines the block name
  66961. */
  66962. constructor(name: string);
  66963. /**
  66964. * Gets the current class name
  66965. * @returns the class name
  66966. */
  66967. getClassName(): string;
  66968. /**
  66969. * Gets the first world row input component
  66970. */
  66971. get world0(): NodeMaterialConnectionPoint;
  66972. /**
  66973. * Gets the second world row input component
  66974. */
  66975. get world1(): NodeMaterialConnectionPoint;
  66976. /**
  66977. * Gets the third world row input component
  66978. */
  66979. get world2(): NodeMaterialConnectionPoint;
  66980. /**
  66981. * Gets the forth world row input component
  66982. */
  66983. get world3(): NodeMaterialConnectionPoint;
  66984. /**
  66985. * Gets the world input component
  66986. */
  66987. get world(): NodeMaterialConnectionPoint;
  66988. /**
  66989. * Gets the output component
  66990. */
  66991. get output(): NodeMaterialConnectionPoint;
  66992. /**
  66993. * Gets the isntanceID component
  66994. */
  66995. get instanceID(): NodeMaterialConnectionPoint;
  66996. autoConfigure(material: NodeMaterial): void;
  66997. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  66998. protected _buildBlock(state: NodeMaterialBuildState): this;
  66999. }
  67000. }
  67001. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  67002. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67003. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67004. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67006. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67007. import { Effect } from "babylonjs/Materials/effect";
  67008. import { Mesh } from "babylonjs/Meshes/mesh";
  67009. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67010. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67011. /**
  67012. * Block used to add morph targets support to vertex shader
  67013. */
  67014. export class MorphTargetsBlock extends NodeMaterialBlock {
  67015. private _repeatableContentAnchor;
  67016. /**
  67017. * Create a new MorphTargetsBlock
  67018. * @param name defines the block name
  67019. */
  67020. constructor(name: string);
  67021. /**
  67022. * Gets the current class name
  67023. * @returns the class name
  67024. */
  67025. getClassName(): string;
  67026. /**
  67027. * Gets the position input component
  67028. */
  67029. get position(): NodeMaterialConnectionPoint;
  67030. /**
  67031. * Gets the normal input component
  67032. */
  67033. get normal(): NodeMaterialConnectionPoint;
  67034. /**
  67035. * Gets the tangent input component
  67036. */
  67037. get tangent(): NodeMaterialConnectionPoint;
  67038. /**
  67039. * Gets the tangent input component
  67040. */
  67041. get uv(): NodeMaterialConnectionPoint;
  67042. /**
  67043. * Gets the position output component
  67044. */
  67045. get positionOutput(): NodeMaterialConnectionPoint;
  67046. /**
  67047. * Gets the normal output component
  67048. */
  67049. get normalOutput(): NodeMaterialConnectionPoint;
  67050. /**
  67051. * Gets the tangent output component
  67052. */
  67053. get tangentOutput(): NodeMaterialConnectionPoint;
  67054. /**
  67055. * Gets the tangent output component
  67056. */
  67057. get uvOutput(): NodeMaterialConnectionPoint;
  67058. initialize(state: NodeMaterialBuildState): void;
  67059. autoConfigure(material: NodeMaterial): void;
  67060. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67061. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67062. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  67063. protected _buildBlock(state: NodeMaterialBuildState): this;
  67064. }
  67065. }
  67066. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  67067. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67068. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67069. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67070. import { Nullable } from "babylonjs/types";
  67071. import { Scene } from "babylonjs/scene";
  67072. import { Effect } from "babylonjs/Materials/effect";
  67073. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67074. import { Mesh } from "babylonjs/Meshes/mesh";
  67075. import { Light } from "babylonjs/Lights/light";
  67076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67077. /**
  67078. * Block used to get data information from a light
  67079. */
  67080. export class LightInformationBlock extends NodeMaterialBlock {
  67081. private _lightDataUniformName;
  67082. private _lightColorUniformName;
  67083. private _lightTypeDefineName;
  67084. /**
  67085. * Gets or sets the light associated with this block
  67086. */
  67087. light: Nullable<Light>;
  67088. /**
  67089. * Creates a new LightInformationBlock
  67090. * @param name defines the block name
  67091. */
  67092. constructor(name: string);
  67093. /**
  67094. * Gets the current class name
  67095. * @returns the class name
  67096. */
  67097. getClassName(): string;
  67098. /**
  67099. * Gets the world position input component
  67100. */
  67101. get worldPosition(): NodeMaterialConnectionPoint;
  67102. /**
  67103. * Gets the direction output component
  67104. */
  67105. get direction(): NodeMaterialConnectionPoint;
  67106. /**
  67107. * Gets the direction output component
  67108. */
  67109. get color(): NodeMaterialConnectionPoint;
  67110. /**
  67111. * Gets the direction output component
  67112. */
  67113. get intensity(): NodeMaterialConnectionPoint;
  67114. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67115. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67116. protected _buildBlock(state: NodeMaterialBuildState): this;
  67117. serialize(): any;
  67118. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67119. }
  67120. }
  67121. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  67122. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  67123. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  67124. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  67125. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  67126. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  67127. }
  67128. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  67129. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67130. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67131. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67133. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67134. import { Effect } from "babylonjs/Materials/effect";
  67135. import { Mesh } from "babylonjs/Meshes/mesh";
  67136. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67137. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  67138. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  67139. /**
  67140. * Block used to add image processing support to fragment shader
  67141. */
  67142. export class ImageProcessingBlock extends NodeMaterialBlock {
  67143. /**
  67144. * Create a new ImageProcessingBlock
  67145. * @param name defines the block name
  67146. */
  67147. constructor(name: string);
  67148. /**
  67149. * Gets the current class name
  67150. * @returns the class name
  67151. */
  67152. getClassName(): string;
  67153. /**
  67154. * Gets the color input component
  67155. */
  67156. get color(): NodeMaterialConnectionPoint;
  67157. /**
  67158. * Gets the output component
  67159. */
  67160. get output(): NodeMaterialConnectionPoint;
  67161. /**
  67162. * Initialize the block and prepare the context for build
  67163. * @param state defines the state that will be used for the build
  67164. */
  67165. initialize(state: NodeMaterialBuildState): void;
  67166. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  67167. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67168. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67169. protected _buildBlock(state: NodeMaterialBuildState): this;
  67170. }
  67171. }
  67172. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  67173. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67174. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67175. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67176. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67178. import { Effect } from "babylonjs/Materials/effect";
  67179. import { Mesh } from "babylonjs/Meshes/mesh";
  67180. import { Scene } from "babylonjs/scene";
  67181. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  67182. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67183. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67184. /**
  67185. * Block used to pertub normals based on a normal map
  67186. */
  67187. export class PerturbNormalBlock extends NodeMaterialBlock {
  67188. private _tangentSpaceParameterName;
  67189. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67190. invertX: boolean;
  67191. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  67192. invertY: boolean;
  67193. /**
  67194. * Create a new PerturbNormalBlock
  67195. * @param name defines the block name
  67196. */
  67197. constructor(name: string);
  67198. /**
  67199. * Gets the current class name
  67200. * @returns the class name
  67201. */
  67202. getClassName(): string;
  67203. /**
  67204. * Gets the world position input component
  67205. */
  67206. get worldPosition(): NodeMaterialConnectionPoint;
  67207. /**
  67208. * Gets the world normal input component
  67209. */
  67210. get worldNormal(): NodeMaterialConnectionPoint;
  67211. /**
  67212. * Gets the world tangent input component
  67213. */
  67214. get worldTangent(): NodeMaterialConnectionPoint;
  67215. /**
  67216. * Gets the uv input component
  67217. */
  67218. get uv(): NodeMaterialConnectionPoint;
  67219. /**
  67220. * Gets the normal map color input component
  67221. */
  67222. get normalMapColor(): NodeMaterialConnectionPoint;
  67223. /**
  67224. * Gets the strength input component
  67225. */
  67226. get strength(): NodeMaterialConnectionPoint;
  67227. /**
  67228. * Gets the output component
  67229. */
  67230. get output(): NodeMaterialConnectionPoint;
  67231. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67232. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67233. autoConfigure(material: NodeMaterial): void;
  67234. protected _buildBlock(state: NodeMaterialBuildState): this;
  67235. protected _dumpPropertiesCode(): string;
  67236. serialize(): any;
  67237. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67238. }
  67239. }
  67240. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  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. /**
  67245. * Block used to discard a pixel if a value is smaller than a cutoff
  67246. */
  67247. export class DiscardBlock extends NodeMaterialBlock {
  67248. /**
  67249. * Create a new DiscardBlock
  67250. * @param name defines the block name
  67251. */
  67252. constructor(name: string);
  67253. /**
  67254. * Gets the current class name
  67255. * @returns the class name
  67256. */
  67257. getClassName(): string;
  67258. /**
  67259. * Gets the color input component
  67260. */
  67261. get value(): NodeMaterialConnectionPoint;
  67262. /**
  67263. * Gets the cutoff input component
  67264. */
  67265. get cutoff(): NodeMaterialConnectionPoint;
  67266. protected _buildBlock(state: NodeMaterialBuildState): this;
  67267. }
  67268. }
  67269. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  67270. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67271. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67272. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67273. /**
  67274. * Block used to test if the fragment shader is front facing
  67275. */
  67276. export class FrontFacingBlock extends NodeMaterialBlock {
  67277. /**
  67278. * Creates a new FrontFacingBlock
  67279. * @param name defines the block name
  67280. */
  67281. constructor(name: string);
  67282. /**
  67283. * Gets the current class name
  67284. * @returns the class name
  67285. */
  67286. getClassName(): string;
  67287. /**
  67288. * Gets the output component
  67289. */
  67290. get output(): NodeMaterialConnectionPoint;
  67291. protected _buildBlock(state: NodeMaterialBuildState): this;
  67292. }
  67293. }
  67294. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  67295. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67296. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67297. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67298. /**
  67299. * Block used to get the derivative value on x and y of a given input
  67300. */
  67301. export class DerivativeBlock extends NodeMaterialBlock {
  67302. /**
  67303. * Create a new DerivativeBlock
  67304. * @param name defines the block name
  67305. */
  67306. constructor(name: string);
  67307. /**
  67308. * Gets the current class name
  67309. * @returns the class name
  67310. */
  67311. getClassName(): string;
  67312. /**
  67313. * Gets the input component
  67314. */
  67315. get input(): NodeMaterialConnectionPoint;
  67316. /**
  67317. * Gets the derivative output on x
  67318. */
  67319. get dx(): NodeMaterialConnectionPoint;
  67320. /**
  67321. * Gets the derivative output on y
  67322. */
  67323. get dy(): NodeMaterialConnectionPoint;
  67324. protected _buildBlock(state: NodeMaterialBuildState): this;
  67325. }
  67326. }
  67327. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  67328. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67329. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67330. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67331. /**
  67332. * Block used to make gl_FragCoord available
  67333. */
  67334. export class FragCoordBlock extends NodeMaterialBlock {
  67335. /**
  67336. * Creates a new FragCoordBlock
  67337. * @param name defines the block name
  67338. */
  67339. constructor(name: string);
  67340. /**
  67341. * Gets the current class name
  67342. * @returns the class name
  67343. */
  67344. getClassName(): string;
  67345. /**
  67346. * Gets the xy component
  67347. */
  67348. get xy(): NodeMaterialConnectionPoint;
  67349. /**
  67350. * Gets the xyz component
  67351. */
  67352. get xyz(): NodeMaterialConnectionPoint;
  67353. /**
  67354. * Gets the xyzw component
  67355. */
  67356. get xyzw(): NodeMaterialConnectionPoint;
  67357. /**
  67358. * Gets the x component
  67359. */
  67360. get x(): NodeMaterialConnectionPoint;
  67361. /**
  67362. * Gets the y component
  67363. */
  67364. get y(): NodeMaterialConnectionPoint;
  67365. /**
  67366. * Gets the z component
  67367. */
  67368. get z(): NodeMaterialConnectionPoint;
  67369. /**
  67370. * Gets the w component
  67371. */
  67372. get output(): NodeMaterialConnectionPoint;
  67373. protected writeOutputs(state: NodeMaterialBuildState): string;
  67374. protected _buildBlock(state: NodeMaterialBuildState): this;
  67375. }
  67376. }
  67377. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  67378. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67379. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67380. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67381. import { Effect } from "babylonjs/Materials/effect";
  67382. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67383. import { Mesh } from "babylonjs/Meshes/mesh";
  67384. /**
  67385. * Block used to get the screen sizes
  67386. */
  67387. export class ScreenSizeBlock extends NodeMaterialBlock {
  67388. private _varName;
  67389. private _scene;
  67390. /**
  67391. * Creates a new ScreenSizeBlock
  67392. * @param name defines the block name
  67393. */
  67394. constructor(name: string);
  67395. /**
  67396. * Gets the current class name
  67397. * @returns the class name
  67398. */
  67399. getClassName(): string;
  67400. /**
  67401. * Gets the xy component
  67402. */
  67403. get xy(): NodeMaterialConnectionPoint;
  67404. /**
  67405. * Gets the x component
  67406. */
  67407. get x(): NodeMaterialConnectionPoint;
  67408. /**
  67409. * Gets the y component
  67410. */
  67411. get y(): NodeMaterialConnectionPoint;
  67412. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67413. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  67414. protected _buildBlock(state: NodeMaterialBuildState): this;
  67415. }
  67416. }
  67417. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  67418. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  67419. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  67420. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  67421. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  67422. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  67423. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  67424. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  67425. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  67426. }
  67427. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  67428. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67429. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67430. import { Mesh } from "babylonjs/Meshes/mesh";
  67431. import { Effect } from "babylonjs/Materials/effect";
  67432. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67434. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67435. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  67436. /**
  67437. * Block used to add support for scene fog
  67438. */
  67439. export class FogBlock extends NodeMaterialBlock {
  67440. private _fogDistanceName;
  67441. private _fogParameters;
  67442. /**
  67443. * Create a new FogBlock
  67444. * @param name defines the block name
  67445. */
  67446. constructor(name: string);
  67447. /**
  67448. * Gets the current class name
  67449. * @returns the class name
  67450. */
  67451. getClassName(): string;
  67452. /**
  67453. * Gets the world position input component
  67454. */
  67455. get worldPosition(): NodeMaterialConnectionPoint;
  67456. /**
  67457. * Gets the view input component
  67458. */
  67459. get view(): NodeMaterialConnectionPoint;
  67460. /**
  67461. * Gets the color input component
  67462. */
  67463. get input(): NodeMaterialConnectionPoint;
  67464. /**
  67465. * Gets the fog color input component
  67466. */
  67467. get fogColor(): NodeMaterialConnectionPoint;
  67468. /**
  67469. * Gets the output component
  67470. */
  67471. get output(): NodeMaterialConnectionPoint;
  67472. autoConfigure(material: NodeMaterial): void;
  67473. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67474. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67475. protected _buildBlock(state: NodeMaterialBuildState): this;
  67476. }
  67477. }
  67478. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  67479. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67480. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67481. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67483. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67484. import { Effect } from "babylonjs/Materials/effect";
  67485. import { Mesh } from "babylonjs/Meshes/mesh";
  67486. import { Light } from "babylonjs/Lights/light";
  67487. import { Nullable } from "babylonjs/types";
  67488. import { Scene } from "babylonjs/scene";
  67489. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  67490. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  67491. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  67492. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67493. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  67494. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  67495. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  67496. /**
  67497. * Block used to add light in the fragment shader
  67498. */
  67499. export class LightBlock extends NodeMaterialBlock {
  67500. private _lightId;
  67501. /**
  67502. * Gets or sets the light associated with this block
  67503. */
  67504. light: Nullable<Light>;
  67505. /**
  67506. * Create a new LightBlock
  67507. * @param name defines the block name
  67508. */
  67509. constructor(name: string);
  67510. /**
  67511. * Gets the current class name
  67512. * @returns the class name
  67513. */
  67514. getClassName(): string;
  67515. /**
  67516. * Gets the world position input component
  67517. */
  67518. get worldPosition(): NodeMaterialConnectionPoint;
  67519. /**
  67520. * Gets the world normal input component
  67521. */
  67522. get worldNormal(): NodeMaterialConnectionPoint;
  67523. /**
  67524. * Gets the camera (or eye) position component
  67525. */
  67526. get cameraPosition(): NodeMaterialConnectionPoint;
  67527. /**
  67528. * Gets the glossiness component
  67529. */
  67530. get glossiness(): NodeMaterialConnectionPoint;
  67531. /**
  67532. * Gets the glossinness power component
  67533. */
  67534. get glossPower(): NodeMaterialConnectionPoint;
  67535. /**
  67536. * Gets the diffuse color component
  67537. */
  67538. get diffuseColor(): NodeMaterialConnectionPoint;
  67539. /**
  67540. * Gets the specular color component
  67541. */
  67542. get specularColor(): NodeMaterialConnectionPoint;
  67543. /**
  67544. * Gets the view matrix component
  67545. */
  67546. get view(): NodeMaterialConnectionPoint;
  67547. /**
  67548. * Gets the diffuse output component
  67549. */
  67550. get diffuseOutput(): NodeMaterialConnectionPoint;
  67551. /**
  67552. * Gets the specular output component
  67553. */
  67554. get specularOutput(): NodeMaterialConnectionPoint;
  67555. /**
  67556. * Gets the shadow output component
  67557. */
  67558. get shadow(): NodeMaterialConnectionPoint;
  67559. autoConfigure(material: NodeMaterial): void;
  67560. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67561. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67562. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67563. private _injectVertexCode;
  67564. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67565. serialize(): any;
  67566. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67567. }
  67568. }
  67569. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  67570. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67571. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67572. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67573. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67574. /**
  67575. * Block used to read a reflection texture from a sampler
  67576. */
  67577. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67578. /**
  67579. * Create a new ReflectionTextureBlock
  67580. * @param name defines the block name
  67581. */
  67582. constructor(name: string);
  67583. /**
  67584. * Gets the current class name
  67585. * @returns the class name
  67586. */
  67587. getClassName(): string;
  67588. /**
  67589. * Gets the world position input component
  67590. */
  67591. get position(): NodeMaterialConnectionPoint;
  67592. /**
  67593. * Gets the world position input component
  67594. */
  67595. get worldPosition(): NodeMaterialConnectionPoint;
  67596. /**
  67597. * Gets the world normal input component
  67598. */
  67599. get worldNormal(): NodeMaterialConnectionPoint;
  67600. /**
  67601. * Gets the world input component
  67602. */
  67603. get world(): NodeMaterialConnectionPoint;
  67604. /**
  67605. * Gets the camera (or eye) position component
  67606. */
  67607. get cameraPosition(): NodeMaterialConnectionPoint;
  67608. /**
  67609. * Gets the view input component
  67610. */
  67611. get view(): NodeMaterialConnectionPoint;
  67612. /**
  67613. * Gets the rgb output component
  67614. */
  67615. get rgb(): NodeMaterialConnectionPoint;
  67616. /**
  67617. * Gets the rgba output component
  67618. */
  67619. get rgba(): NodeMaterialConnectionPoint;
  67620. /**
  67621. * Gets the r output component
  67622. */
  67623. get r(): NodeMaterialConnectionPoint;
  67624. /**
  67625. * Gets the g output component
  67626. */
  67627. get g(): NodeMaterialConnectionPoint;
  67628. /**
  67629. * Gets the b output component
  67630. */
  67631. get b(): NodeMaterialConnectionPoint;
  67632. /**
  67633. * Gets the a output component
  67634. */
  67635. get a(): NodeMaterialConnectionPoint;
  67636. autoConfigure(material: NodeMaterial): void;
  67637. protected _buildBlock(state: NodeMaterialBuildState): this;
  67638. }
  67639. }
  67640. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  67641. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  67642. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  67643. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  67644. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  67645. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  67646. }
  67647. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  67648. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  67649. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  67650. }
  67651. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  67652. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67653. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67654. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67655. /**
  67656. * Block used to add 2 vectors
  67657. */
  67658. export class AddBlock extends NodeMaterialBlock {
  67659. /**
  67660. * Creates a new AddBlock
  67661. * @param name defines the block name
  67662. */
  67663. constructor(name: string);
  67664. /**
  67665. * Gets the current class name
  67666. * @returns the class name
  67667. */
  67668. getClassName(): string;
  67669. /**
  67670. * Gets the left operand input component
  67671. */
  67672. get left(): NodeMaterialConnectionPoint;
  67673. /**
  67674. * Gets the right operand input component
  67675. */
  67676. get right(): NodeMaterialConnectionPoint;
  67677. /**
  67678. * Gets the output component
  67679. */
  67680. get output(): NodeMaterialConnectionPoint;
  67681. protected _buildBlock(state: NodeMaterialBuildState): this;
  67682. }
  67683. }
  67684. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  67685. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67686. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67687. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67688. /**
  67689. * Block used to scale a vector by a float
  67690. */
  67691. export class ScaleBlock extends NodeMaterialBlock {
  67692. /**
  67693. * Creates a new ScaleBlock
  67694. * @param name defines the block name
  67695. */
  67696. constructor(name: string);
  67697. /**
  67698. * Gets the current class name
  67699. * @returns the class name
  67700. */
  67701. getClassName(): string;
  67702. /**
  67703. * Gets the input component
  67704. */
  67705. get input(): NodeMaterialConnectionPoint;
  67706. /**
  67707. * Gets the factor input component
  67708. */
  67709. get factor(): NodeMaterialConnectionPoint;
  67710. /**
  67711. * Gets the output component
  67712. */
  67713. get output(): NodeMaterialConnectionPoint;
  67714. protected _buildBlock(state: NodeMaterialBuildState): this;
  67715. }
  67716. }
  67717. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  67718. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67719. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67720. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67721. import { Scene } from "babylonjs/scene";
  67722. /**
  67723. * Block used to clamp a float
  67724. */
  67725. export class ClampBlock extends NodeMaterialBlock {
  67726. /** Gets or sets the minimum range */
  67727. minimum: number;
  67728. /** Gets or sets the maximum range */
  67729. maximum: number;
  67730. /**
  67731. * Creates a new ClampBlock
  67732. * @param name defines the block name
  67733. */
  67734. constructor(name: string);
  67735. /**
  67736. * Gets the current class name
  67737. * @returns the class name
  67738. */
  67739. getClassName(): string;
  67740. /**
  67741. * Gets the value input component
  67742. */
  67743. get value(): NodeMaterialConnectionPoint;
  67744. /**
  67745. * Gets the output component
  67746. */
  67747. get output(): NodeMaterialConnectionPoint;
  67748. protected _buildBlock(state: NodeMaterialBuildState): this;
  67749. protected _dumpPropertiesCode(): string;
  67750. serialize(): any;
  67751. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67752. }
  67753. }
  67754. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  67755. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67756. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67757. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67758. /**
  67759. * Block used to apply a cross product between 2 vectors
  67760. */
  67761. export class CrossBlock extends NodeMaterialBlock {
  67762. /**
  67763. * Creates a new CrossBlock
  67764. * @param name defines the block name
  67765. */
  67766. constructor(name: string);
  67767. /**
  67768. * Gets the current class name
  67769. * @returns the class name
  67770. */
  67771. getClassName(): string;
  67772. /**
  67773. * Gets the left operand input component
  67774. */
  67775. get left(): NodeMaterialConnectionPoint;
  67776. /**
  67777. * Gets the right operand input component
  67778. */
  67779. get right(): NodeMaterialConnectionPoint;
  67780. /**
  67781. * Gets the output component
  67782. */
  67783. get output(): NodeMaterialConnectionPoint;
  67784. protected _buildBlock(state: NodeMaterialBuildState): this;
  67785. }
  67786. }
  67787. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  67788. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67789. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67790. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67791. /**
  67792. * Block used to apply a dot product between 2 vectors
  67793. */
  67794. export class DotBlock extends NodeMaterialBlock {
  67795. /**
  67796. * Creates a new DotBlock
  67797. * @param name defines the block name
  67798. */
  67799. constructor(name: string);
  67800. /**
  67801. * Gets the current class name
  67802. * @returns the class name
  67803. */
  67804. getClassName(): string;
  67805. /**
  67806. * Gets the left operand input component
  67807. */
  67808. get left(): NodeMaterialConnectionPoint;
  67809. /**
  67810. * Gets the right operand input component
  67811. */
  67812. get right(): NodeMaterialConnectionPoint;
  67813. /**
  67814. * Gets the output component
  67815. */
  67816. get output(): NodeMaterialConnectionPoint;
  67817. protected _buildBlock(state: NodeMaterialBuildState): this;
  67818. }
  67819. }
  67820. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  67821. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67822. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67823. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67824. /**
  67825. * Block used to normalize a vector
  67826. */
  67827. export class NormalizeBlock extends NodeMaterialBlock {
  67828. /**
  67829. * Creates a new NormalizeBlock
  67830. * @param name defines the block name
  67831. */
  67832. constructor(name: string);
  67833. /**
  67834. * Gets the current class name
  67835. * @returns the class name
  67836. */
  67837. getClassName(): string;
  67838. /**
  67839. * Gets the input component
  67840. */
  67841. get input(): NodeMaterialConnectionPoint;
  67842. /**
  67843. * Gets the output component
  67844. */
  67845. get output(): NodeMaterialConnectionPoint;
  67846. protected _buildBlock(state: NodeMaterialBuildState): this;
  67847. }
  67848. }
  67849. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  67850. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67851. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67852. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67853. /**
  67854. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67855. */
  67856. export class ColorMergerBlock extends NodeMaterialBlock {
  67857. /**
  67858. * Create a new ColorMergerBlock
  67859. * @param name defines the block name
  67860. */
  67861. constructor(name: string);
  67862. /**
  67863. * Gets the current class name
  67864. * @returns the class name
  67865. */
  67866. getClassName(): string;
  67867. /**
  67868. * Gets the rgb component (input)
  67869. */
  67870. get rgbIn(): NodeMaterialConnectionPoint;
  67871. /**
  67872. * Gets the r component (input)
  67873. */
  67874. get r(): NodeMaterialConnectionPoint;
  67875. /**
  67876. * Gets the g component (input)
  67877. */
  67878. get g(): NodeMaterialConnectionPoint;
  67879. /**
  67880. * Gets the b component (input)
  67881. */
  67882. get b(): NodeMaterialConnectionPoint;
  67883. /**
  67884. * Gets the a component (input)
  67885. */
  67886. get a(): NodeMaterialConnectionPoint;
  67887. /**
  67888. * Gets the rgba component (output)
  67889. */
  67890. get rgba(): NodeMaterialConnectionPoint;
  67891. /**
  67892. * Gets the rgb component (output)
  67893. */
  67894. get rgbOut(): NodeMaterialConnectionPoint;
  67895. /**
  67896. * Gets the rgb component (output)
  67897. * @deprecated Please use rgbOut instead.
  67898. */
  67899. get rgb(): NodeMaterialConnectionPoint;
  67900. protected _buildBlock(state: NodeMaterialBuildState): this;
  67901. }
  67902. }
  67903. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  67904. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67905. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67906. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67907. /**
  67908. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67909. */
  67910. export class VectorSplitterBlock extends NodeMaterialBlock {
  67911. /**
  67912. * Create a new VectorSplitterBlock
  67913. * @param name defines the block name
  67914. */
  67915. constructor(name: string);
  67916. /**
  67917. * Gets the current class name
  67918. * @returns the class name
  67919. */
  67920. getClassName(): string;
  67921. /**
  67922. * Gets the xyzw component (input)
  67923. */
  67924. get xyzw(): NodeMaterialConnectionPoint;
  67925. /**
  67926. * Gets the xyz component (input)
  67927. */
  67928. get xyzIn(): NodeMaterialConnectionPoint;
  67929. /**
  67930. * Gets the xy component (input)
  67931. */
  67932. get xyIn(): NodeMaterialConnectionPoint;
  67933. /**
  67934. * Gets the xyz component (output)
  67935. */
  67936. get xyzOut(): NodeMaterialConnectionPoint;
  67937. /**
  67938. * Gets the xy component (output)
  67939. */
  67940. get xyOut(): NodeMaterialConnectionPoint;
  67941. /**
  67942. * Gets the x component (output)
  67943. */
  67944. get x(): NodeMaterialConnectionPoint;
  67945. /**
  67946. * Gets the y component (output)
  67947. */
  67948. get y(): NodeMaterialConnectionPoint;
  67949. /**
  67950. * Gets the z component (output)
  67951. */
  67952. get z(): NodeMaterialConnectionPoint;
  67953. /**
  67954. * Gets the w component (output)
  67955. */
  67956. get w(): NodeMaterialConnectionPoint;
  67957. protected _inputRename(name: string): string;
  67958. protected _outputRename(name: string): string;
  67959. protected _buildBlock(state: NodeMaterialBuildState): this;
  67960. }
  67961. }
  67962. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  67963. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67964. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67965. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67966. /**
  67967. * Block used to lerp between 2 values
  67968. */
  67969. export class LerpBlock extends NodeMaterialBlock {
  67970. /**
  67971. * Creates a new LerpBlock
  67972. * @param name defines the block name
  67973. */
  67974. constructor(name: string);
  67975. /**
  67976. * Gets the current class name
  67977. * @returns the class name
  67978. */
  67979. getClassName(): string;
  67980. /**
  67981. * Gets the left operand input component
  67982. */
  67983. get left(): NodeMaterialConnectionPoint;
  67984. /**
  67985. * Gets the right operand input component
  67986. */
  67987. get right(): NodeMaterialConnectionPoint;
  67988. /**
  67989. * Gets the gradient operand input component
  67990. */
  67991. get gradient(): NodeMaterialConnectionPoint;
  67992. /**
  67993. * Gets the output component
  67994. */
  67995. get output(): NodeMaterialConnectionPoint;
  67996. protected _buildBlock(state: NodeMaterialBuildState): this;
  67997. }
  67998. }
  67999. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  68000. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68001. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68002. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68003. /**
  68004. * Block used to divide 2 vectors
  68005. */
  68006. export class DivideBlock extends NodeMaterialBlock {
  68007. /**
  68008. * Creates a new DivideBlock
  68009. * @param name defines the block name
  68010. */
  68011. constructor(name: string);
  68012. /**
  68013. * Gets the current class name
  68014. * @returns the class name
  68015. */
  68016. getClassName(): string;
  68017. /**
  68018. * Gets the left operand input component
  68019. */
  68020. get left(): NodeMaterialConnectionPoint;
  68021. /**
  68022. * Gets the right operand input component
  68023. */
  68024. get right(): NodeMaterialConnectionPoint;
  68025. /**
  68026. * Gets the output component
  68027. */
  68028. get output(): NodeMaterialConnectionPoint;
  68029. protected _buildBlock(state: NodeMaterialBuildState): this;
  68030. }
  68031. }
  68032. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  68033. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68034. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68035. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68036. /**
  68037. * Block used to subtract 2 vectors
  68038. */
  68039. export class SubtractBlock extends NodeMaterialBlock {
  68040. /**
  68041. * Creates a new SubtractBlock
  68042. * @param name defines the block name
  68043. */
  68044. constructor(name: string);
  68045. /**
  68046. * Gets the current class name
  68047. * @returns the class name
  68048. */
  68049. getClassName(): string;
  68050. /**
  68051. * Gets the left operand input component
  68052. */
  68053. get left(): NodeMaterialConnectionPoint;
  68054. /**
  68055. * Gets the right operand input component
  68056. */
  68057. get right(): NodeMaterialConnectionPoint;
  68058. /**
  68059. * Gets the output component
  68060. */
  68061. get output(): NodeMaterialConnectionPoint;
  68062. protected _buildBlock(state: NodeMaterialBuildState): this;
  68063. }
  68064. }
  68065. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  68066. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68067. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68068. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68069. /**
  68070. * Block used to step a value
  68071. */
  68072. export class StepBlock extends NodeMaterialBlock {
  68073. /**
  68074. * Creates a new StepBlock
  68075. * @param name defines the block name
  68076. */
  68077. constructor(name: string);
  68078. /**
  68079. * Gets the current class name
  68080. * @returns the class name
  68081. */
  68082. getClassName(): string;
  68083. /**
  68084. * Gets the value operand input component
  68085. */
  68086. get value(): NodeMaterialConnectionPoint;
  68087. /**
  68088. * Gets the edge operand input component
  68089. */
  68090. get edge(): NodeMaterialConnectionPoint;
  68091. /**
  68092. * Gets the output component
  68093. */
  68094. get output(): NodeMaterialConnectionPoint;
  68095. protected _buildBlock(state: NodeMaterialBuildState): this;
  68096. }
  68097. }
  68098. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  68099. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68100. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68101. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68102. /**
  68103. * Block used to get the opposite (1 - x) of a value
  68104. */
  68105. export class OneMinusBlock extends NodeMaterialBlock {
  68106. /**
  68107. * Creates a new OneMinusBlock
  68108. * @param name defines the block name
  68109. */
  68110. constructor(name: string);
  68111. /**
  68112. * Gets the current class name
  68113. * @returns the class name
  68114. */
  68115. getClassName(): string;
  68116. /**
  68117. * Gets the input component
  68118. */
  68119. get input(): NodeMaterialConnectionPoint;
  68120. /**
  68121. * Gets the output component
  68122. */
  68123. get output(): NodeMaterialConnectionPoint;
  68124. protected _buildBlock(state: NodeMaterialBuildState): this;
  68125. }
  68126. }
  68127. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  68128. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68129. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68130. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68131. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68132. /**
  68133. * Block used to get the view direction
  68134. */
  68135. export class ViewDirectionBlock extends NodeMaterialBlock {
  68136. /**
  68137. * Creates a new ViewDirectionBlock
  68138. * @param name defines the block name
  68139. */
  68140. constructor(name: string);
  68141. /**
  68142. * Gets the current class name
  68143. * @returns the class name
  68144. */
  68145. getClassName(): string;
  68146. /**
  68147. * Gets the world position component
  68148. */
  68149. get worldPosition(): NodeMaterialConnectionPoint;
  68150. /**
  68151. * Gets the camera position component
  68152. */
  68153. get cameraPosition(): NodeMaterialConnectionPoint;
  68154. /**
  68155. * Gets the output component
  68156. */
  68157. get output(): NodeMaterialConnectionPoint;
  68158. autoConfigure(material: NodeMaterial): void;
  68159. protected _buildBlock(state: NodeMaterialBuildState): this;
  68160. }
  68161. }
  68162. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  68163. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68164. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68165. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68166. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68167. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  68168. /**
  68169. * Block used to compute fresnel value
  68170. */
  68171. export class FresnelBlock extends NodeMaterialBlock {
  68172. /**
  68173. * Create a new FresnelBlock
  68174. * @param name defines the block name
  68175. */
  68176. constructor(name: string);
  68177. /**
  68178. * Gets the current class name
  68179. * @returns the class name
  68180. */
  68181. getClassName(): string;
  68182. /**
  68183. * Gets the world normal input component
  68184. */
  68185. get worldNormal(): NodeMaterialConnectionPoint;
  68186. /**
  68187. * Gets the view direction input component
  68188. */
  68189. get viewDirection(): NodeMaterialConnectionPoint;
  68190. /**
  68191. * Gets the bias input component
  68192. */
  68193. get bias(): NodeMaterialConnectionPoint;
  68194. /**
  68195. * Gets the camera (or eye) position component
  68196. */
  68197. get power(): NodeMaterialConnectionPoint;
  68198. /**
  68199. * Gets the fresnel output component
  68200. */
  68201. get fresnel(): NodeMaterialConnectionPoint;
  68202. autoConfigure(material: NodeMaterial): void;
  68203. protected _buildBlock(state: NodeMaterialBuildState): this;
  68204. }
  68205. }
  68206. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  68207. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68208. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68209. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68210. /**
  68211. * Block used to get the max of 2 values
  68212. */
  68213. export class MaxBlock extends NodeMaterialBlock {
  68214. /**
  68215. * Creates a new MaxBlock
  68216. * @param name defines the block name
  68217. */
  68218. constructor(name: string);
  68219. /**
  68220. * Gets the current class name
  68221. * @returns the class name
  68222. */
  68223. getClassName(): string;
  68224. /**
  68225. * Gets the left operand input component
  68226. */
  68227. get left(): NodeMaterialConnectionPoint;
  68228. /**
  68229. * Gets the right operand input component
  68230. */
  68231. get right(): NodeMaterialConnectionPoint;
  68232. /**
  68233. * Gets the output component
  68234. */
  68235. get output(): NodeMaterialConnectionPoint;
  68236. protected _buildBlock(state: NodeMaterialBuildState): this;
  68237. }
  68238. }
  68239. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  68240. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68241. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68242. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68243. /**
  68244. * Block used to get the min of 2 values
  68245. */
  68246. export class MinBlock extends NodeMaterialBlock {
  68247. /**
  68248. * Creates a new MinBlock
  68249. * @param name defines the block name
  68250. */
  68251. constructor(name: string);
  68252. /**
  68253. * Gets the current class name
  68254. * @returns the class name
  68255. */
  68256. getClassName(): string;
  68257. /**
  68258. * Gets the left operand input component
  68259. */
  68260. get left(): NodeMaterialConnectionPoint;
  68261. /**
  68262. * Gets the right operand input component
  68263. */
  68264. get right(): NodeMaterialConnectionPoint;
  68265. /**
  68266. * Gets the output component
  68267. */
  68268. get output(): NodeMaterialConnectionPoint;
  68269. protected _buildBlock(state: NodeMaterialBuildState): this;
  68270. }
  68271. }
  68272. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  68273. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68274. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68275. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68276. /**
  68277. * Block used to get the distance between 2 values
  68278. */
  68279. export class DistanceBlock extends NodeMaterialBlock {
  68280. /**
  68281. * Creates a new DistanceBlock
  68282. * @param name defines the block name
  68283. */
  68284. constructor(name: string);
  68285. /**
  68286. * Gets the current class name
  68287. * @returns the class name
  68288. */
  68289. getClassName(): string;
  68290. /**
  68291. * Gets the left operand input component
  68292. */
  68293. get left(): NodeMaterialConnectionPoint;
  68294. /**
  68295. * Gets the right operand input component
  68296. */
  68297. get right(): NodeMaterialConnectionPoint;
  68298. /**
  68299. * Gets the output component
  68300. */
  68301. get output(): NodeMaterialConnectionPoint;
  68302. protected _buildBlock(state: NodeMaterialBuildState): this;
  68303. }
  68304. }
  68305. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  68306. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68307. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68308. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68309. /**
  68310. * Block used to get the length of a vector
  68311. */
  68312. export class LengthBlock extends NodeMaterialBlock {
  68313. /**
  68314. * Creates a new LengthBlock
  68315. * @param name defines the block name
  68316. */
  68317. constructor(name: string);
  68318. /**
  68319. * Gets the current class name
  68320. * @returns the class name
  68321. */
  68322. getClassName(): string;
  68323. /**
  68324. * Gets the value input component
  68325. */
  68326. get value(): NodeMaterialConnectionPoint;
  68327. /**
  68328. * Gets the output component
  68329. */
  68330. get output(): NodeMaterialConnectionPoint;
  68331. protected _buildBlock(state: NodeMaterialBuildState): this;
  68332. }
  68333. }
  68334. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  68335. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68336. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68337. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68338. /**
  68339. * Block used to get negative version of a value (i.e. x * -1)
  68340. */
  68341. export class NegateBlock extends NodeMaterialBlock {
  68342. /**
  68343. * Creates a new NegateBlock
  68344. * @param name defines the block name
  68345. */
  68346. constructor(name: string);
  68347. /**
  68348. * Gets the current class name
  68349. * @returns the class name
  68350. */
  68351. getClassName(): string;
  68352. /**
  68353. * Gets the value input component
  68354. */
  68355. get value(): NodeMaterialConnectionPoint;
  68356. /**
  68357. * Gets the output component
  68358. */
  68359. get output(): NodeMaterialConnectionPoint;
  68360. protected _buildBlock(state: NodeMaterialBuildState): this;
  68361. }
  68362. }
  68363. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  68364. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68365. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68366. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68367. /**
  68368. * Block used to get the value of the first parameter raised to the power of the second
  68369. */
  68370. export class PowBlock extends NodeMaterialBlock {
  68371. /**
  68372. * Creates a new PowBlock
  68373. * @param name defines the block name
  68374. */
  68375. constructor(name: string);
  68376. /**
  68377. * Gets the current class name
  68378. * @returns the class name
  68379. */
  68380. getClassName(): string;
  68381. /**
  68382. * Gets the value operand input component
  68383. */
  68384. get value(): NodeMaterialConnectionPoint;
  68385. /**
  68386. * Gets the power operand input component
  68387. */
  68388. get power(): NodeMaterialConnectionPoint;
  68389. /**
  68390. * Gets the output component
  68391. */
  68392. get output(): NodeMaterialConnectionPoint;
  68393. protected _buildBlock(state: NodeMaterialBuildState): this;
  68394. }
  68395. }
  68396. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  68397. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68398. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68399. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68400. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68401. /**
  68402. * Block used to get a random number
  68403. */
  68404. export class RandomNumberBlock extends NodeMaterialBlock {
  68405. /**
  68406. * Creates a new RandomNumberBlock
  68407. * @param name defines the block name
  68408. */
  68409. constructor(name: string);
  68410. /**
  68411. * Gets the current class name
  68412. * @returns the class name
  68413. */
  68414. getClassName(): string;
  68415. /**
  68416. * Gets the seed input component
  68417. */
  68418. get seed(): NodeMaterialConnectionPoint;
  68419. /**
  68420. * Gets the output component
  68421. */
  68422. get output(): NodeMaterialConnectionPoint;
  68423. protected _buildBlock(state: NodeMaterialBuildState): this;
  68424. }
  68425. }
  68426. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  68427. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68428. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68429. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68430. /**
  68431. * Block used to compute arc tangent of 2 values
  68432. */
  68433. export class ArcTan2Block extends NodeMaterialBlock {
  68434. /**
  68435. * Creates a new ArcTan2Block
  68436. * @param name defines the block name
  68437. */
  68438. constructor(name: string);
  68439. /**
  68440. * Gets the current class name
  68441. * @returns the class name
  68442. */
  68443. getClassName(): string;
  68444. /**
  68445. * Gets the x operand input component
  68446. */
  68447. get x(): NodeMaterialConnectionPoint;
  68448. /**
  68449. * Gets the y operand input component
  68450. */
  68451. get y(): NodeMaterialConnectionPoint;
  68452. /**
  68453. * Gets the output component
  68454. */
  68455. get output(): NodeMaterialConnectionPoint;
  68456. protected _buildBlock(state: NodeMaterialBuildState): this;
  68457. }
  68458. }
  68459. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  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 smooth step a value
  68465. */
  68466. export class SmoothStepBlock extends NodeMaterialBlock {
  68467. /**
  68468. * Creates a new SmoothStepBlock
  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 value operand input component
  68479. */
  68480. get value(): NodeMaterialConnectionPoint;
  68481. /**
  68482. * Gets the first edge operand input component
  68483. */
  68484. get edge0(): NodeMaterialConnectionPoint;
  68485. /**
  68486. * Gets the second edge operand input component
  68487. */
  68488. get edge1(): NodeMaterialConnectionPoint;
  68489. /**
  68490. * Gets the output component
  68491. */
  68492. get output(): NodeMaterialConnectionPoint;
  68493. protected _buildBlock(state: NodeMaterialBuildState): this;
  68494. }
  68495. }
  68496. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  68497. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68498. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68499. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68500. /**
  68501. * Block used to get the reciprocal (1 / x) of a value
  68502. */
  68503. export class ReciprocalBlock extends NodeMaterialBlock {
  68504. /**
  68505. * Creates a new ReciprocalBlock
  68506. * @param name defines the block name
  68507. */
  68508. constructor(name: string);
  68509. /**
  68510. * Gets the current class name
  68511. * @returns the class name
  68512. */
  68513. getClassName(): string;
  68514. /**
  68515. * Gets the input component
  68516. */
  68517. get input(): NodeMaterialConnectionPoint;
  68518. /**
  68519. * Gets the output component
  68520. */
  68521. get output(): NodeMaterialConnectionPoint;
  68522. protected _buildBlock(state: NodeMaterialBuildState): this;
  68523. }
  68524. }
  68525. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  68526. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68527. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68528. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68529. /**
  68530. * Block used to replace a color by another one
  68531. */
  68532. export class ReplaceColorBlock extends NodeMaterialBlock {
  68533. /**
  68534. * Creates a new ReplaceColorBlock
  68535. * @param name defines the block name
  68536. */
  68537. constructor(name: string);
  68538. /**
  68539. * Gets the current class name
  68540. * @returns the class name
  68541. */
  68542. getClassName(): string;
  68543. /**
  68544. * Gets the value input component
  68545. */
  68546. get value(): NodeMaterialConnectionPoint;
  68547. /**
  68548. * Gets the reference input component
  68549. */
  68550. get reference(): NodeMaterialConnectionPoint;
  68551. /**
  68552. * Gets the distance input component
  68553. */
  68554. get distance(): NodeMaterialConnectionPoint;
  68555. /**
  68556. * Gets the replacement input component
  68557. */
  68558. get replacement(): NodeMaterialConnectionPoint;
  68559. /**
  68560. * Gets the output component
  68561. */
  68562. get output(): NodeMaterialConnectionPoint;
  68563. protected _buildBlock(state: NodeMaterialBuildState): this;
  68564. }
  68565. }
  68566. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  68567. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68568. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68569. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68570. /**
  68571. * Block used to posterize a value
  68572. * @see https://en.wikipedia.org/wiki/Posterization
  68573. */
  68574. export class PosterizeBlock extends NodeMaterialBlock {
  68575. /**
  68576. * Creates a new PosterizeBlock
  68577. * @param name defines the block name
  68578. */
  68579. constructor(name: string);
  68580. /**
  68581. * Gets the current class name
  68582. * @returns the class name
  68583. */
  68584. getClassName(): string;
  68585. /**
  68586. * Gets the value input component
  68587. */
  68588. get value(): NodeMaterialConnectionPoint;
  68589. /**
  68590. * Gets the steps input component
  68591. */
  68592. get steps(): NodeMaterialConnectionPoint;
  68593. /**
  68594. * Gets the output component
  68595. */
  68596. get output(): NodeMaterialConnectionPoint;
  68597. protected _buildBlock(state: NodeMaterialBuildState): this;
  68598. }
  68599. }
  68600. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  68601. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68602. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68603. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68604. import { Scene } from "babylonjs/scene";
  68605. /**
  68606. * Operations supported by the Wave block
  68607. */
  68608. export enum WaveBlockKind {
  68609. /** SawTooth */
  68610. SawTooth = 0,
  68611. /** Square */
  68612. Square = 1,
  68613. /** Triangle */
  68614. Triangle = 2
  68615. }
  68616. /**
  68617. * Block used to apply wave operation to floats
  68618. */
  68619. export class WaveBlock extends NodeMaterialBlock {
  68620. /**
  68621. * Gets or sets the kibnd of wave to be applied by the block
  68622. */
  68623. kind: WaveBlockKind;
  68624. /**
  68625. * Creates a new WaveBlock
  68626. * @param name defines the block name
  68627. */
  68628. constructor(name: string);
  68629. /**
  68630. * Gets the current class name
  68631. * @returns the class name
  68632. */
  68633. getClassName(): string;
  68634. /**
  68635. * Gets the input component
  68636. */
  68637. get input(): NodeMaterialConnectionPoint;
  68638. /**
  68639. * Gets the output component
  68640. */
  68641. get output(): NodeMaterialConnectionPoint;
  68642. protected _buildBlock(state: NodeMaterialBuildState): this;
  68643. serialize(): any;
  68644. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68645. }
  68646. }
  68647. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  68648. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68649. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68650. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68651. import { Color3 } from "babylonjs/Maths/math.color";
  68652. import { Scene } from "babylonjs/scene";
  68653. import { Observable } from "babylonjs/Misc/observable";
  68654. /**
  68655. * Class used to store a color step for the GradientBlock
  68656. */
  68657. export class GradientBlockColorStep {
  68658. private _step;
  68659. /**
  68660. * Gets value indicating which step this color is associated with (between 0 and 1)
  68661. */
  68662. get step(): number;
  68663. /**
  68664. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68665. */
  68666. set step(val: number);
  68667. private _color;
  68668. /**
  68669. * Gets the color associated with this step
  68670. */
  68671. get color(): Color3;
  68672. /**
  68673. * Sets the color associated with this step
  68674. */
  68675. set color(val: Color3);
  68676. /**
  68677. * Creates a new GradientBlockColorStep
  68678. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68679. * @param color defines the color associated with this step
  68680. */
  68681. constructor(step: number, color: Color3);
  68682. }
  68683. /**
  68684. * Block used to return a color from a gradient based on an input value between 0 and 1
  68685. */
  68686. export class GradientBlock extends NodeMaterialBlock {
  68687. /**
  68688. * Gets or sets the list of color steps
  68689. */
  68690. colorSteps: GradientBlockColorStep[];
  68691. /** Gets an observable raised when the value is changed */
  68692. onValueChangedObservable: Observable<GradientBlock>;
  68693. /** calls observable when the value is changed*/
  68694. colorStepsUpdated(): void;
  68695. /**
  68696. * Creates a new GradientBlock
  68697. * @param name defines the block name
  68698. */
  68699. constructor(name: string);
  68700. /**
  68701. * Gets the current class name
  68702. * @returns the class name
  68703. */
  68704. getClassName(): string;
  68705. /**
  68706. * Gets the gradient input component
  68707. */
  68708. get gradient(): NodeMaterialConnectionPoint;
  68709. /**
  68710. * Gets the output component
  68711. */
  68712. get output(): NodeMaterialConnectionPoint;
  68713. private _writeColorConstant;
  68714. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68715. serialize(): any;
  68716. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68717. protected _dumpPropertiesCode(): string;
  68718. }
  68719. }
  68720. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  68721. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68722. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68723. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68724. /**
  68725. * Block used to normalize lerp between 2 values
  68726. */
  68727. export class NLerpBlock extends NodeMaterialBlock {
  68728. /**
  68729. * Creates a new NLerpBlock
  68730. * @param name defines the block name
  68731. */
  68732. constructor(name: string);
  68733. /**
  68734. * Gets the current class name
  68735. * @returns the class name
  68736. */
  68737. getClassName(): string;
  68738. /**
  68739. * Gets the left operand input component
  68740. */
  68741. get left(): NodeMaterialConnectionPoint;
  68742. /**
  68743. * Gets the right operand input component
  68744. */
  68745. get right(): NodeMaterialConnectionPoint;
  68746. /**
  68747. * Gets the gradient operand input component
  68748. */
  68749. get gradient(): NodeMaterialConnectionPoint;
  68750. /**
  68751. * Gets the output component
  68752. */
  68753. get output(): NodeMaterialConnectionPoint;
  68754. protected _buildBlock(state: NodeMaterialBuildState): this;
  68755. }
  68756. }
  68757. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  68758. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68759. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68760. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68761. import { Scene } from "babylonjs/scene";
  68762. /**
  68763. * block used to Generate a Worley Noise 3D Noise Pattern
  68764. */
  68765. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68766. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68767. manhattanDistance: boolean;
  68768. /**
  68769. * Creates a new WorleyNoise3DBlock
  68770. * @param name defines the block name
  68771. */
  68772. constructor(name: string);
  68773. /**
  68774. * Gets the current class name
  68775. * @returns the class name
  68776. */
  68777. getClassName(): string;
  68778. /**
  68779. * Gets the seed input component
  68780. */
  68781. get seed(): NodeMaterialConnectionPoint;
  68782. /**
  68783. * Gets the jitter input component
  68784. */
  68785. get jitter(): NodeMaterialConnectionPoint;
  68786. /**
  68787. * Gets the output component
  68788. */
  68789. get output(): NodeMaterialConnectionPoint;
  68790. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68791. /**
  68792. * Exposes the properties to the UI?
  68793. */
  68794. protected _dumpPropertiesCode(): string;
  68795. /**
  68796. * Exposes the properties to the Seralize?
  68797. */
  68798. serialize(): any;
  68799. /**
  68800. * Exposes the properties to the deseralize?
  68801. */
  68802. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68803. }
  68804. }
  68805. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  68806. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68807. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68808. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68809. /**
  68810. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68811. */
  68812. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68813. /**
  68814. * Creates a new SimplexPerlin3DBlock
  68815. * @param name defines the block name
  68816. */
  68817. constructor(name: string);
  68818. /**
  68819. * Gets the current class name
  68820. * @returns the class name
  68821. */
  68822. getClassName(): string;
  68823. /**
  68824. * Gets the seed operand input component
  68825. */
  68826. get seed(): NodeMaterialConnectionPoint;
  68827. /**
  68828. * Gets the output component
  68829. */
  68830. get output(): NodeMaterialConnectionPoint;
  68831. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68832. }
  68833. }
  68834. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  68835. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68836. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68837. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68838. /**
  68839. * Block used to blend normals
  68840. */
  68841. export class NormalBlendBlock extends NodeMaterialBlock {
  68842. /**
  68843. * Creates a new NormalBlendBlock
  68844. * @param name defines the block name
  68845. */
  68846. constructor(name: string);
  68847. /**
  68848. * Gets the current class name
  68849. * @returns the class name
  68850. */
  68851. getClassName(): string;
  68852. /**
  68853. * Gets the first input component
  68854. */
  68855. get normalMap0(): NodeMaterialConnectionPoint;
  68856. /**
  68857. * Gets the second input component
  68858. */
  68859. get normalMap1(): NodeMaterialConnectionPoint;
  68860. /**
  68861. * Gets the output component
  68862. */
  68863. get output(): NodeMaterialConnectionPoint;
  68864. protected _buildBlock(state: NodeMaterialBuildState): this;
  68865. }
  68866. }
  68867. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  68868. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68869. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68870. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68871. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68872. /**
  68873. * Block used to rotate a 2d vector by a given angle
  68874. */
  68875. export class Rotate2dBlock extends NodeMaterialBlock {
  68876. /**
  68877. * Creates a new Rotate2dBlock
  68878. * @param name defines the block name
  68879. */
  68880. constructor(name: string);
  68881. /**
  68882. * Gets the current class name
  68883. * @returns the class name
  68884. */
  68885. getClassName(): string;
  68886. /**
  68887. * Gets the input vector
  68888. */
  68889. get input(): NodeMaterialConnectionPoint;
  68890. /**
  68891. * Gets the input angle
  68892. */
  68893. get angle(): NodeMaterialConnectionPoint;
  68894. /**
  68895. * Gets the output component
  68896. */
  68897. get output(): NodeMaterialConnectionPoint;
  68898. autoConfigure(material: NodeMaterial): void;
  68899. protected _buildBlock(state: NodeMaterialBuildState): this;
  68900. }
  68901. }
  68902. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  68903. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68904. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68905. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68906. /**
  68907. * Block used to get the reflected vector from a direction and a normal
  68908. */
  68909. export class ReflectBlock extends NodeMaterialBlock {
  68910. /**
  68911. * Creates a new ReflectBlock
  68912. * @param name defines the block name
  68913. */
  68914. constructor(name: string);
  68915. /**
  68916. * Gets the current class name
  68917. * @returns the class name
  68918. */
  68919. getClassName(): string;
  68920. /**
  68921. * Gets the incident component
  68922. */
  68923. get incident(): NodeMaterialConnectionPoint;
  68924. /**
  68925. * Gets the normal component
  68926. */
  68927. get normal(): NodeMaterialConnectionPoint;
  68928. /**
  68929. * Gets the output component
  68930. */
  68931. get output(): NodeMaterialConnectionPoint;
  68932. protected _buildBlock(state: NodeMaterialBuildState): this;
  68933. }
  68934. }
  68935. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  68936. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68937. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68938. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68939. /**
  68940. * Block used to get the refracted vector from a direction and a normal
  68941. */
  68942. export class RefractBlock extends NodeMaterialBlock {
  68943. /**
  68944. * Creates a new RefractBlock
  68945. * @param name defines the block name
  68946. */
  68947. constructor(name: string);
  68948. /**
  68949. * Gets the current class name
  68950. * @returns the class name
  68951. */
  68952. getClassName(): string;
  68953. /**
  68954. * Gets the incident component
  68955. */
  68956. get incident(): NodeMaterialConnectionPoint;
  68957. /**
  68958. * Gets the normal component
  68959. */
  68960. get normal(): NodeMaterialConnectionPoint;
  68961. /**
  68962. * Gets the index of refraction component
  68963. */
  68964. get ior(): NodeMaterialConnectionPoint;
  68965. /**
  68966. * Gets the output component
  68967. */
  68968. get output(): NodeMaterialConnectionPoint;
  68969. protected _buildBlock(state: NodeMaterialBuildState): this;
  68970. }
  68971. }
  68972. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  68973. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68974. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68975. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68976. /**
  68977. * Block used to desaturate a color
  68978. */
  68979. export class DesaturateBlock extends NodeMaterialBlock {
  68980. /**
  68981. * Creates a new DesaturateBlock
  68982. * @param name defines the block name
  68983. */
  68984. constructor(name: string);
  68985. /**
  68986. * Gets the current class name
  68987. * @returns the class name
  68988. */
  68989. getClassName(): string;
  68990. /**
  68991. * Gets the color operand input component
  68992. */
  68993. get color(): NodeMaterialConnectionPoint;
  68994. /**
  68995. * Gets the level operand input component
  68996. */
  68997. get level(): NodeMaterialConnectionPoint;
  68998. /**
  68999. * Gets the output component
  69000. */
  69001. get output(): NodeMaterialConnectionPoint;
  69002. protected _buildBlock(state: NodeMaterialBuildState): this;
  69003. }
  69004. }
  69005. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  69006. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69007. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69008. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69009. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  69010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69011. import { Nullable } from "babylonjs/types";
  69012. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  69013. import { Mesh } from "babylonjs/Meshes/mesh";
  69014. import { SubMesh } from "babylonjs/Meshes/subMesh";
  69015. import { Effect } from "babylonjs/Materials/effect";
  69016. import { Scene } from "babylonjs/scene";
  69017. /**
  69018. * Block used to implement the reflection module of the PBR material
  69019. */
  69020. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  69021. /** @hidden */
  69022. _defineLODReflectionAlpha: string;
  69023. /** @hidden */
  69024. _defineLinearSpecularReflection: string;
  69025. private _vEnvironmentIrradianceName;
  69026. /** @hidden */
  69027. _vReflectionMicrosurfaceInfosName: string;
  69028. /** @hidden */
  69029. _vReflectionInfosName: string;
  69030. /** @hidden */
  69031. _vReflectionFilteringInfoName: string;
  69032. private _scene;
  69033. /**
  69034. * The properties below are set by the main PBR block prior to calling methods of this class.
  69035. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69036. * It's less burden on the user side in the editor part.
  69037. */
  69038. /** @hidden */
  69039. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69040. /** @hidden */
  69041. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69042. /** @hidden */
  69043. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  69044. /** @hidden */
  69045. viewConnectionPoint: NodeMaterialConnectionPoint;
  69046. /**
  69047. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  69048. * diffuse part of the IBL.
  69049. */
  69050. useSphericalHarmonics: boolean;
  69051. /**
  69052. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  69053. */
  69054. forceIrradianceInFragment: boolean;
  69055. /**
  69056. * Create a new ReflectionBlock
  69057. * @param name defines the block name
  69058. */
  69059. constructor(name: string);
  69060. /**
  69061. * Gets the current class name
  69062. * @returns the class name
  69063. */
  69064. getClassName(): string;
  69065. /**
  69066. * Gets the position input component
  69067. */
  69068. get position(): NodeMaterialConnectionPoint;
  69069. /**
  69070. * Gets the world position input component
  69071. */
  69072. get worldPosition(): NodeMaterialConnectionPoint;
  69073. /**
  69074. * Gets the world normal input component
  69075. */
  69076. get worldNormal(): NodeMaterialConnectionPoint;
  69077. /**
  69078. * Gets the world input component
  69079. */
  69080. get world(): NodeMaterialConnectionPoint;
  69081. /**
  69082. * Gets the camera (or eye) position component
  69083. */
  69084. get cameraPosition(): NodeMaterialConnectionPoint;
  69085. /**
  69086. * Gets the view input component
  69087. */
  69088. get view(): NodeMaterialConnectionPoint;
  69089. /**
  69090. * Gets the color input component
  69091. */
  69092. get color(): NodeMaterialConnectionPoint;
  69093. /**
  69094. * Gets the reflection object output component
  69095. */
  69096. get reflection(): NodeMaterialConnectionPoint;
  69097. /**
  69098. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  69099. */
  69100. get hasTexture(): boolean;
  69101. /**
  69102. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  69103. */
  69104. get reflectionColor(): string;
  69105. protected _getTexture(): Nullable<BaseTexture>;
  69106. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69107. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69108. /**
  69109. * Gets the code to inject in the vertex shader
  69110. * @param state current state of the node material building
  69111. * @returns the shader code
  69112. */
  69113. handleVertexSide(state: NodeMaterialBuildState): string;
  69114. /**
  69115. * Gets the main code of the block (fragment side)
  69116. * @param state current state of the node material building
  69117. * @param normalVarName name of the existing variable corresponding to the normal
  69118. * @returns the shader code
  69119. */
  69120. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  69121. protected _buildBlock(state: NodeMaterialBuildState): this;
  69122. protected _dumpPropertiesCode(): string;
  69123. serialize(): any;
  69124. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69125. }
  69126. }
  69127. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  69128. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69129. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69130. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69131. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69133. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69134. import { Scene } from "babylonjs/scene";
  69135. import { Nullable } from "babylonjs/types";
  69136. /**
  69137. * Block used to implement the sheen module of the PBR material
  69138. */
  69139. export class SheenBlock extends NodeMaterialBlock {
  69140. /**
  69141. * Create a new SheenBlock
  69142. * @param name defines the block name
  69143. */
  69144. constructor(name: string);
  69145. /**
  69146. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  69147. * It allows the strength of the sheen effect to not depend on the base color of the material,
  69148. * making it easier to setup and tweak the effect
  69149. */
  69150. albedoScaling: boolean;
  69151. /**
  69152. * Defines if the sheen is linked to the sheen color.
  69153. */
  69154. linkSheenWithAlbedo: boolean;
  69155. /**
  69156. * Initialize the block and prepare the context for build
  69157. * @param state defines the state that will be used for the build
  69158. */
  69159. initialize(state: NodeMaterialBuildState): void;
  69160. /**
  69161. * Gets the current class name
  69162. * @returns the class name
  69163. */
  69164. getClassName(): string;
  69165. /**
  69166. * Gets the intensity input component
  69167. */
  69168. get intensity(): NodeMaterialConnectionPoint;
  69169. /**
  69170. * Gets the color input component
  69171. */
  69172. get color(): NodeMaterialConnectionPoint;
  69173. /**
  69174. * Gets the roughness input component
  69175. */
  69176. get roughness(): NodeMaterialConnectionPoint;
  69177. /**
  69178. * Gets the sheen object output component
  69179. */
  69180. get sheen(): NodeMaterialConnectionPoint;
  69181. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69182. /**
  69183. * Gets the main code of the block (fragment side)
  69184. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69185. * @returns the shader code
  69186. */
  69187. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  69188. protected _buildBlock(state: NodeMaterialBuildState): this;
  69189. protected _dumpPropertiesCode(): string;
  69190. serialize(): any;
  69191. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69192. }
  69193. }
  69194. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  69195. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69196. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69197. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69198. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69200. /**
  69201. * Block used to implement the anisotropy module of the PBR material
  69202. */
  69203. export class AnisotropyBlock extends NodeMaterialBlock {
  69204. /**
  69205. * The two properties below are set by the main PBR block prior to calling methods of this class.
  69206. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69207. * It's less burden on the user side in the editor part.
  69208. */
  69209. /** @hidden */
  69210. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69211. /** @hidden */
  69212. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69213. /**
  69214. * Create a new AnisotropyBlock
  69215. * @param name defines the block name
  69216. */
  69217. constructor(name: string);
  69218. /**
  69219. * Initialize the block and prepare the context for build
  69220. * @param state defines the state that will be used for the build
  69221. */
  69222. initialize(state: NodeMaterialBuildState): void;
  69223. /**
  69224. * Gets the current class name
  69225. * @returns the class name
  69226. */
  69227. getClassName(): string;
  69228. /**
  69229. * Gets the intensity input component
  69230. */
  69231. get intensity(): NodeMaterialConnectionPoint;
  69232. /**
  69233. * Gets the direction input component
  69234. */
  69235. get direction(): NodeMaterialConnectionPoint;
  69236. /**
  69237. * Gets the uv input component
  69238. */
  69239. get uv(): NodeMaterialConnectionPoint;
  69240. /**
  69241. * Gets the worldTangent input component
  69242. */
  69243. get worldTangent(): NodeMaterialConnectionPoint;
  69244. /**
  69245. * Gets the anisotropy object output component
  69246. */
  69247. get anisotropy(): NodeMaterialConnectionPoint;
  69248. private _generateTBNSpace;
  69249. /**
  69250. * Gets the main code of the block (fragment side)
  69251. * @param state current state of the node material building
  69252. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69253. * @returns the shader code
  69254. */
  69255. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  69256. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69257. protected _buildBlock(state: NodeMaterialBuildState): this;
  69258. }
  69259. }
  69260. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  69261. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69262. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69263. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69264. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69266. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69267. import { Scene } from "babylonjs/scene";
  69268. import { Nullable } from "babylonjs/types";
  69269. import { Mesh } from "babylonjs/Meshes/mesh";
  69270. import { SubMesh } from "babylonjs/Meshes/subMesh";
  69271. import { Effect } from "babylonjs/Materials/effect";
  69272. /**
  69273. * Block used to implement the clear coat module of the PBR material
  69274. */
  69275. export class ClearCoatBlock extends NodeMaterialBlock {
  69276. private _scene;
  69277. /**
  69278. * Create a new ClearCoatBlock
  69279. * @param name defines the block name
  69280. */
  69281. constructor(name: string);
  69282. /**
  69283. * Defines if the F0 value should be remapped to account for the interface change in the material.
  69284. */
  69285. remapF0OnInterfaceChange: boolean;
  69286. /**
  69287. * Initialize the block and prepare the context for build
  69288. * @param state defines the state that will be used for the build
  69289. */
  69290. initialize(state: NodeMaterialBuildState): void;
  69291. /**
  69292. * Gets the current class name
  69293. * @returns the class name
  69294. */
  69295. getClassName(): string;
  69296. /**
  69297. * Gets the intensity input component
  69298. */
  69299. get intensity(): NodeMaterialConnectionPoint;
  69300. /**
  69301. * Gets the roughness input component
  69302. */
  69303. get roughness(): NodeMaterialConnectionPoint;
  69304. /**
  69305. * Gets the ior input component
  69306. */
  69307. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69308. /**
  69309. * Gets the bump texture input component
  69310. */
  69311. get normalMapColor(): NodeMaterialConnectionPoint;
  69312. /**
  69313. * Gets the uv input component
  69314. */
  69315. get uv(): NodeMaterialConnectionPoint;
  69316. /**
  69317. * Gets the tint color input component
  69318. */
  69319. get tintColor(): NodeMaterialConnectionPoint;
  69320. /**
  69321. * Gets the tint "at distance" input component
  69322. */
  69323. get tintAtDistance(): NodeMaterialConnectionPoint;
  69324. /**
  69325. * Gets the tint thickness input component
  69326. */
  69327. get tintThickness(): NodeMaterialConnectionPoint;
  69328. /**
  69329. * Gets the world tangent input component
  69330. */
  69331. get worldTangent(): NodeMaterialConnectionPoint;
  69332. /**
  69333. * Gets the clear coat object output component
  69334. */
  69335. get clearcoat(): NodeMaterialConnectionPoint;
  69336. autoConfigure(material: NodeMaterial): void;
  69337. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69338. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69339. private _generateTBNSpace;
  69340. /**
  69341. * Gets the main code of the block (fragment side)
  69342. * @param state current state of the node material building
  69343. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  69344. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69345. * @param worldPosVarName name of the variable holding the world position
  69346. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69347. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  69348. * @param worldNormalVarName name of the variable holding the world normal
  69349. * @returns the shader code
  69350. */
  69351. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  69352. protected _buildBlock(state: NodeMaterialBuildState): this;
  69353. protected _dumpPropertiesCode(): string;
  69354. serialize(): any;
  69355. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69356. }
  69357. }
  69358. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  69359. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69360. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69361. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69362. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69364. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69365. import { Nullable } from "babylonjs/types";
  69366. /**
  69367. * Block used to implement the sub surface module of the PBR material
  69368. */
  69369. export class SubSurfaceBlock extends NodeMaterialBlock {
  69370. /**
  69371. * Create a new SubSurfaceBlock
  69372. * @param name defines the block name
  69373. */
  69374. constructor(name: string);
  69375. /**
  69376. * Initialize the block and prepare the context for build
  69377. * @param state defines the state that will be used for the build
  69378. */
  69379. initialize(state: NodeMaterialBuildState): void;
  69380. /**
  69381. * Gets the current class name
  69382. * @returns the class name
  69383. */
  69384. getClassName(): string;
  69385. /**
  69386. * Gets the thickness component
  69387. */
  69388. get thickness(): NodeMaterialConnectionPoint;
  69389. /**
  69390. * Gets the tint color input component
  69391. */
  69392. get tintColor(): NodeMaterialConnectionPoint;
  69393. /**
  69394. * Gets the translucency intensity input component
  69395. */
  69396. get translucencyIntensity(): NodeMaterialConnectionPoint;
  69397. /**
  69398. * Gets the translucency diffusion distance input component
  69399. */
  69400. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  69401. /**
  69402. * Gets the refraction object parameters
  69403. */
  69404. get refraction(): NodeMaterialConnectionPoint;
  69405. /**
  69406. * Gets the sub surface object output component
  69407. */
  69408. get subsurface(): NodeMaterialConnectionPoint;
  69409. autoConfigure(material: NodeMaterial): void;
  69410. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69411. /**
  69412. * Gets the main code of the block (fragment side)
  69413. * @param state current state of the node material building
  69414. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69415. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69416. * @param worldPosVarName name of the variable holding the world position
  69417. * @returns the shader code
  69418. */
  69419. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69420. protected _buildBlock(state: NodeMaterialBuildState): this;
  69421. }
  69422. }
  69423. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  69424. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69425. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69426. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69427. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69428. import { Light } from "babylonjs/Lights/light";
  69429. import { Nullable } from "babylonjs/types";
  69430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69431. import { Effect } from "babylonjs/Materials/effect";
  69432. import { Mesh } from "babylonjs/Meshes/mesh";
  69433. import { Scene } from "babylonjs/scene";
  69434. /**
  69435. * Block used to implement the PBR metallic/roughness model
  69436. */
  69437. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  69438. /**
  69439. * Gets or sets the light associated with this block
  69440. */
  69441. light: Nullable<Light>;
  69442. private _lightId;
  69443. private _scene;
  69444. private _environmentBRDFTexture;
  69445. private _environmentBrdfSamplerName;
  69446. private _vNormalWName;
  69447. private _invertNormalName;
  69448. private _metallicReflectanceColor;
  69449. private _metallicF0Factor;
  69450. private _vMetallicReflectanceFactorsName;
  69451. /**
  69452. * Create a new ReflectionBlock
  69453. * @param name defines the block name
  69454. */
  69455. constructor(name: string);
  69456. /**
  69457. * Intensity of the direct lights e.g. the four lights available in your scene.
  69458. * This impacts both the direct diffuse and specular highlights.
  69459. */
  69460. directIntensity: number;
  69461. /**
  69462. * Intensity of the environment e.g. how much the environment will light the object
  69463. * either through harmonics for rough material or through the refelction for shiny ones.
  69464. */
  69465. environmentIntensity: number;
  69466. /**
  69467. * This is a special control allowing the reduction of the specular highlights coming from the
  69468. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  69469. */
  69470. specularIntensity: number;
  69471. /**
  69472. * Defines the falloff type used in this material.
  69473. * It by default is Physical.
  69474. */
  69475. lightFalloff: number;
  69476. /**
  69477. * Specifies that alpha test should be used
  69478. */
  69479. useAlphaTest: boolean;
  69480. /**
  69481. * Defines the alpha limits in alpha test mode.
  69482. */
  69483. alphaTestCutoff: number;
  69484. /**
  69485. * Specifies that alpha blending should be used
  69486. */
  69487. useAlphaBlending: boolean;
  69488. /**
  69489. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  69490. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  69491. */
  69492. useRadianceOverAlpha: boolean;
  69493. /**
  69494. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  69495. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  69496. */
  69497. useSpecularOverAlpha: boolean;
  69498. /**
  69499. * Enables specular anti aliasing in the PBR shader.
  69500. * It will both interacts on the Geometry for analytical and IBL lighting.
  69501. * It also prefilter the roughness map based on the bump values.
  69502. */
  69503. enableSpecularAntiAliasing: boolean;
  69504. /**
  69505. * Enables realtime filtering on the texture.
  69506. */
  69507. realTimeFiltering: boolean;
  69508. /**
  69509. * Quality switch for realtime filtering
  69510. */
  69511. realTimeFilteringQuality: number;
  69512. /**
  69513. * Defines if the material uses energy conservation.
  69514. */
  69515. useEnergyConservation: boolean;
  69516. /**
  69517. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  69518. * too much the area relying on ambient texture to define their ambient occlusion.
  69519. */
  69520. useRadianceOcclusion: boolean;
  69521. /**
  69522. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  69523. * makes the reflect vector face the model (under horizon).
  69524. */
  69525. useHorizonOcclusion: boolean;
  69526. /**
  69527. * If set to true, no lighting calculations will be applied.
  69528. */
  69529. unlit: boolean;
  69530. /**
  69531. * Force normal to face away from face.
  69532. */
  69533. forceNormalForward: boolean;
  69534. /**
  69535. * Defines the material debug mode.
  69536. * It helps seeing only some components of the material while troubleshooting.
  69537. */
  69538. debugMode: number;
  69539. /**
  69540. * Specify from where on screen the debug mode should start.
  69541. * The value goes from -1 (full screen) to 1 (not visible)
  69542. * It helps with side by side comparison against the final render
  69543. * This defaults to 0
  69544. */
  69545. debugLimit: number;
  69546. /**
  69547. * As the default viewing range might not be enough (if the ambient is really small for instance)
  69548. * You can use the factor to better multiply the final value.
  69549. */
  69550. debugFactor: number;
  69551. /**
  69552. * Initialize the block and prepare the context for build
  69553. * @param state defines the state that will be used for the build
  69554. */
  69555. initialize(state: NodeMaterialBuildState): void;
  69556. /**
  69557. * Gets the current class name
  69558. * @returns the class name
  69559. */
  69560. getClassName(): string;
  69561. /**
  69562. * Gets the world position input component
  69563. */
  69564. get worldPosition(): NodeMaterialConnectionPoint;
  69565. /**
  69566. * Gets the world normal input component
  69567. */
  69568. get worldNormal(): NodeMaterialConnectionPoint;
  69569. /**
  69570. * Gets the view matrix parameter
  69571. */
  69572. get view(): NodeMaterialConnectionPoint;
  69573. /**
  69574. * Gets the camera position input component
  69575. */
  69576. get cameraPosition(): NodeMaterialConnectionPoint;
  69577. /**
  69578. * Gets the perturbed normal input component
  69579. */
  69580. get perturbedNormal(): NodeMaterialConnectionPoint;
  69581. /**
  69582. * Gets the base color input component
  69583. */
  69584. get baseColor(): NodeMaterialConnectionPoint;
  69585. /**
  69586. * Gets the metallic input component
  69587. */
  69588. get metallic(): NodeMaterialConnectionPoint;
  69589. /**
  69590. * Gets the roughness input component
  69591. */
  69592. get roughness(): NodeMaterialConnectionPoint;
  69593. /**
  69594. * Gets the ambient occlusion input component
  69595. */
  69596. get ambientOcc(): NodeMaterialConnectionPoint;
  69597. /**
  69598. * Gets the opacity input component
  69599. */
  69600. get opacity(): NodeMaterialConnectionPoint;
  69601. /**
  69602. * Gets the index of refraction input component
  69603. */
  69604. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69605. /**
  69606. * Gets the ambient color input component
  69607. */
  69608. get ambientColor(): NodeMaterialConnectionPoint;
  69609. /**
  69610. * Gets the reflection object parameters
  69611. */
  69612. get reflection(): NodeMaterialConnectionPoint;
  69613. /**
  69614. * Gets the clear coat object parameters
  69615. */
  69616. get clearcoat(): NodeMaterialConnectionPoint;
  69617. /**
  69618. * Gets the sheen object parameters
  69619. */
  69620. get sheen(): NodeMaterialConnectionPoint;
  69621. /**
  69622. * Gets the sub surface object parameters
  69623. */
  69624. get subsurface(): NodeMaterialConnectionPoint;
  69625. /**
  69626. * Gets the anisotropy object parameters
  69627. */
  69628. get anisotropy(): NodeMaterialConnectionPoint;
  69629. /**
  69630. * Gets the ambient output component
  69631. */
  69632. get ambientClr(): NodeMaterialConnectionPoint;
  69633. /**
  69634. * Gets the diffuse output component
  69635. */
  69636. get diffuseDir(): NodeMaterialConnectionPoint;
  69637. /**
  69638. * Gets the specular output component
  69639. */
  69640. get specularDir(): NodeMaterialConnectionPoint;
  69641. /**
  69642. * Gets the clear coat output component
  69643. */
  69644. get clearcoatDir(): NodeMaterialConnectionPoint;
  69645. /**
  69646. * Gets the sheen output component
  69647. */
  69648. get sheenDir(): NodeMaterialConnectionPoint;
  69649. /**
  69650. * Gets the indirect diffuse output component
  69651. */
  69652. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69653. /**
  69654. * Gets the indirect specular output component
  69655. */
  69656. get specularIndirect(): NodeMaterialConnectionPoint;
  69657. /**
  69658. * Gets the indirect clear coat output component
  69659. */
  69660. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69661. /**
  69662. * Gets the indirect sheen output component
  69663. */
  69664. get sheenIndirect(): NodeMaterialConnectionPoint;
  69665. /**
  69666. * Gets the refraction output component
  69667. */
  69668. get refraction(): NodeMaterialConnectionPoint;
  69669. /**
  69670. * Gets the global lighting output component
  69671. */
  69672. get lighting(): NodeMaterialConnectionPoint;
  69673. /**
  69674. * Gets the shadow output component
  69675. */
  69676. get shadow(): NodeMaterialConnectionPoint;
  69677. /**
  69678. * Gets the alpha output component
  69679. */
  69680. get alpha(): NodeMaterialConnectionPoint;
  69681. autoConfigure(material: NodeMaterial): void;
  69682. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69683. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69684. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69685. private _injectVertexCode;
  69686. private _getAlbedoOpacityCode;
  69687. private _getAmbientOcclusionCode;
  69688. private _getReflectivityCode;
  69689. protected _buildBlock(state: NodeMaterialBuildState): this;
  69690. protected _dumpPropertiesCode(): string;
  69691. serialize(): any;
  69692. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69693. }
  69694. }
  69695. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  69696. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  69697. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  69698. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  69699. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69700. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  69701. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  69702. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  69703. }
  69704. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  69705. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  69706. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  69707. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  69708. }
  69709. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  69710. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69711. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69712. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69713. /**
  69714. * Block used to compute value of one parameter modulo another
  69715. */
  69716. export class ModBlock extends NodeMaterialBlock {
  69717. /**
  69718. * Creates a new ModBlock
  69719. * @param name defines the block name
  69720. */
  69721. constructor(name: string);
  69722. /**
  69723. * Gets the current class name
  69724. * @returns the class name
  69725. */
  69726. getClassName(): string;
  69727. /**
  69728. * Gets the left operand input component
  69729. */
  69730. get left(): NodeMaterialConnectionPoint;
  69731. /**
  69732. * Gets the right operand input component
  69733. */
  69734. get right(): NodeMaterialConnectionPoint;
  69735. /**
  69736. * Gets the output component
  69737. */
  69738. get output(): NodeMaterialConnectionPoint;
  69739. protected _buildBlock(state: NodeMaterialBuildState): this;
  69740. }
  69741. }
  69742. declare module "babylonjs/Materials/Node/Blocks/index" {
  69743. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  69744. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  69745. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  69746. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  69747. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  69748. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  69749. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  69750. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  69751. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  69752. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  69753. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  69754. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  69755. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  69756. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  69757. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  69758. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  69759. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  69760. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  69761. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  69762. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  69763. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  69764. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  69765. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  69766. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  69767. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  69768. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  69769. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  69770. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  69771. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  69772. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  69773. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  69774. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  69775. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  69776. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  69777. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  69778. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  69779. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  69780. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  69781. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  69782. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  69783. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  69784. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  69785. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  69786. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  69787. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  69788. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  69789. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  69790. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  69791. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  69792. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  69793. }
  69794. declare module "babylonjs/Materials/Node/Optimizers/index" {
  69795. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  69796. }
  69797. declare module "babylonjs/Materials/Node/index" {
  69798. export * from "babylonjs/Materials/Node/Enums/index";
  69799. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69800. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  69801. export * from "babylonjs/Materials/Node/nodeMaterial";
  69802. export * from "babylonjs/Materials/Node/Blocks/index";
  69803. export * from "babylonjs/Materials/Node/Optimizers/index";
  69804. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  69805. }
  69806. declare module "babylonjs/Materials/index" {
  69807. export * from "babylonjs/Materials/Background/index";
  69808. export * from "babylonjs/Materials/colorCurves";
  69809. export * from "babylonjs/Materials/iEffectFallbacks";
  69810. export * from "babylonjs/Materials/effectFallbacks";
  69811. export * from "babylonjs/Materials/effect";
  69812. export * from "babylonjs/Materials/fresnelParameters";
  69813. export * from "babylonjs/Materials/imageProcessingConfiguration";
  69814. export * from "babylonjs/Materials/material";
  69815. export * from "babylonjs/Materials/materialDefines";
  69816. export * from "babylonjs/Materials/thinMaterialHelper";
  69817. export * from "babylonjs/Materials/materialHelper";
  69818. export * from "babylonjs/Materials/multiMaterial";
  69819. export * from "babylonjs/Materials/PBR/index";
  69820. export * from "babylonjs/Materials/pushMaterial";
  69821. export * from "babylonjs/Materials/shaderMaterial";
  69822. export * from "babylonjs/Materials/standardMaterial";
  69823. export * from "babylonjs/Materials/Textures/index";
  69824. export * from "babylonjs/Materials/uniformBuffer";
  69825. export * from "babylonjs/Materials/materialFlags";
  69826. export * from "babylonjs/Materials/Node/index";
  69827. export * from "babylonjs/Materials/effectRenderer";
  69828. export * from "babylonjs/Materials/shadowDepthWrapper";
  69829. }
  69830. declare module "babylonjs/Maths/index" {
  69831. export * from "babylonjs/Maths/math.scalar";
  69832. export * from "babylonjs/Maths/math.functions";
  69833. export * from "babylonjs/Maths/math";
  69834. export * from "babylonjs/Maths/sphericalPolynomial";
  69835. }
  69836. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  69837. import { IDisposable } from "babylonjs/scene";
  69838. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69839. /**
  69840. * Configuration for Draco compression
  69841. */
  69842. export interface IDracoCompressionConfiguration {
  69843. /**
  69844. * Configuration for the decoder.
  69845. */
  69846. decoder: {
  69847. /**
  69848. * The url to the WebAssembly module.
  69849. */
  69850. wasmUrl?: string;
  69851. /**
  69852. * The url to the WebAssembly binary.
  69853. */
  69854. wasmBinaryUrl?: string;
  69855. /**
  69856. * The url to the fallback JavaScript module.
  69857. */
  69858. fallbackUrl?: string;
  69859. };
  69860. }
  69861. /**
  69862. * Draco compression (https://google.github.io/draco/)
  69863. *
  69864. * This class wraps the Draco module.
  69865. *
  69866. * **Encoder**
  69867. *
  69868. * The encoder is not currently implemented.
  69869. *
  69870. * **Decoder**
  69871. *
  69872. * 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.
  69873. *
  69874. * To update the configuration, use the following code:
  69875. * ```javascript
  69876. * DracoCompression.Configuration = {
  69877. * decoder: {
  69878. * wasmUrl: "<url to the WebAssembly library>",
  69879. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69880. * fallbackUrl: "<url to the fallback JavaScript library>",
  69881. * }
  69882. * };
  69883. * ```
  69884. *
  69885. * 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.
  69886. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69887. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69888. *
  69889. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69890. * ```javascript
  69891. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69892. * ```
  69893. *
  69894. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69895. */
  69896. export class DracoCompression implements IDisposable {
  69897. private _workerPoolPromise?;
  69898. private _decoderModulePromise?;
  69899. /**
  69900. * The configuration. Defaults to the following urls:
  69901. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69902. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69903. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69904. */
  69905. static Configuration: IDracoCompressionConfiguration;
  69906. /**
  69907. * Returns true if the decoder configuration is available.
  69908. */
  69909. static get DecoderAvailable(): boolean;
  69910. /**
  69911. * Default number of workers to create when creating the draco compression object.
  69912. */
  69913. static DefaultNumWorkers: number;
  69914. private static GetDefaultNumWorkers;
  69915. private static _Default;
  69916. /**
  69917. * Default instance for the draco compression object.
  69918. */
  69919. static get Default(): DracoCompression;
  69920. /**
  69921. * Constructor
  69922. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69923. */
  69924. constructor(numWorkers?: number);
  69925. /**
  69926. * Stop all async operations and release resources.
  69927. */
  69928. dispose(): void;
  69929. /**
  69930. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69931. * @returns a promise that resolves when ready
  69932. */
  69933. whenReadyAsync(): Promise<void>;
  69934. /**
  69935. * Decode Draco compressed mesh data to vertex data.
  69936. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69937. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69938. * @returns A promise that resolves with the decoded vertex data
  69939. */
  69940. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69941. [kind: string]: number;
  69942. }): Promise<VertexData>;
  69943. }
  69944. }
  69945. declare module "babylonjs/Meshes/Compression/index" {
  69946. export * from "babylonjs/Meshes/Compression/dracoCompression";
  69947. }
  69948. declare module "babylonjs/Meshes/csg" {
  69949. import { Nullable } from "babylonjs/types";
  69950. import { Scene } from "babylonjs/scene";
  69951. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  69952. import { Mesh } from "babylonjs/Meshes/mesh";
  69953. import { Material } from "babylonjs/Materials/material";
  69954. /**
  69955. * Class for building Constructive Solid Geometry
  69956. */
  69957. export class CSG {
  69958. private polygons;
  69959. /**
  69960. * The world matrix
  69961. */
  69962. matrix: Matrix;
  69963. /**
  69964. * Stores the position
  69965. */
  69966. position: Vector3;
  69967. /**
  69968. * Stores the rotation
  69969. */
  69970. rotation: Vector3;
  69971. /**
  69972. * Stores the rotation quaternion
  69973. */
  69974. rotationQuaternion: Nullable<Quaternion>;
  69975. /**
  69976. * Stores the scaling vector
  69977. */
  69978. scaling: Vector3;
  69979. /**
  69980. * Convert the Mesh to CSG
  69981. * @param mesh The Mesh to convert to CSG
  69982. * @returns A new CSG from the Mesh
  69983. */
  69984. static FromMesh(mesh: Mesh): CSG;
  69985. /**
  69986. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69987. * @param polygons Polygons used to construct a CSG solid
  69988. */
  69989. private static FromPolygons;
  69990. /**
  69991. * Clones, or makes a deep copy, of the CSG
  69992. * @returns A new CSG
  69993. */
  69994. clone(): CSG;
  69995. /**
  69996. * Unions this CSG with another CSG
  69997. * @param csg The CSG to union against this CSG
  69998. * @returns The unioned CSG
  69999. */
  70000. union(csg: CSG): CSG;
  70001. /**
  70002. * Unions this CSG with another CSG in place
  70003. * @param csg The CSG to union against this CSG
  70004. */
  70005. unionInPlace(csg: CSG): void;
  70006. /**
  70007. * Subtracts this CSG with another CSG
  70008. * @param csg The CSG to subtract against this CSG
  70009. * @returns A new CSG
  70010. */
  70011. subtract(csg: CSG): CSG;
  70012. /**
  70013. * Subtracts this CSG with another CSG in place
  70014. * @param csg The CSG to subtact against this CSG
  70015. */
  70016. subtractInPlace(csg: CSG): void;
  70017. /**
  70018. * Intersect this CSG with another CSG
  70019. * @param csg The CSG to intersect against this CSG
  70020. * @returns A new CSG
  70021. */
  70022. intersect(csg: CSG): CSG;
  70023. /**
  70024. * Intersects this CSG with another CSG in place
  70025. * @param csg The CSG to intersect against this CSG
  70026. */
  70027. intersectInPlace(csg: CSG): void;
  70028. /**
  70029. * Return a new CSG solid with solid and empty space switched. This solid is
  70030. * not modified.
  70031. * @returns A new CSG solid with solid and empty space switched
  70032. */
  70033. inverse(): CSG;
  70034. /**
  70035. * Inverses the CSG in place
  70036. */
  70037. inverseInPlace(): void;
  70038. /**
  70039. * This is used to keep meshes transformations so they can be restored
  70040. * when we build back a Babylon Mesh
  70041. * NB : All CSG operations are performed in world coordinates
  70042. * @param csg The CSG to copy the transform attributes from
  70043. * @returns This CSG
  70044. */
  70045. copyTransformAttributes(csg: CSG): CSG;
  70046. /**
  70047. * Build Raw mesh from CSG
  70048. * Coordinates here are in world space
  70049. * @param name The name of the mesh geometry
  70050. * @param scene The Scene
  70051. * @param keepSubMeshes Specifies if the submeshes should be kept
  70052. * @returns A new Mesh
  70053. */
  70054. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70055. /**
  70056. * Build Mesh from CSG taking material and transforms into account
  70057. * @param name The name of the Mesh
  70058. * @param material The material of the Mesh
  70059. * @param scene The Scene
  70060. * @param keepSubMeshes Specifies if submeshes should be kept
  70061. * @returns The new Mesh
  70062. */
  70063. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70064. }
  70065. }
  70066. declare module "babylonjs/Meshes/trailMesh" {
  70067. import { Mesh } from "babylonjs/Meshes/mesh";
  70068. import { Scene } from "babylonjs/scene";
  70069. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70070. /**
  70071. * Class used to create a trail following a mesh
  70072. */
  70073. export class TrailMesh extends Mesh {
  70074. private _generator;
  70075. private _autoStart;
  70076. private _running;
  70077. private _diameter;
  70078. private _length;
  70079. private _sectionPolygonPointsCount;
  70080. private _sectionVectors;
  70081. private _sectionNormalVectors;
  70082. private _beforeRenderObserver;
  70083. /**
  70084. * @constructor
  70085. * @param name The value used by scene.getMeshByName() to do a lookup.
  70086. * @param generator The mesh or transform node to generate a trail.
  70087. * @param scene The scene to add this mesh to.
  70088. * @param diameter Diameter of trailing mesh. Default is 1.
  70089. * @param length Length of trailing mesh. Default is 60.
  70090. * @param autoStart Automatically start trailing mesh. Default true.
  70091. */
  70092. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  70093. /**
  70094. * "TrailMesh"
  70095. * @returns "TrailMesh"
  70096. */
  70097. getClassName(): string;
  70098. private _createMesh;
  70099. /**
  70100. * Start trailing mesh.
  70101. */
  70102. start(): void;
  70103. /**
  70104. * Stop trailing mesh.
  70105. */
  70106. stop(): void;
  70107. /**
  70108. * Update trailing mesh geometry.
  70109. */
  70110. update(): void;
  70111. /**
  70112. * Returns a new TrailMesh object.
  70113. * @param name is a string, the name given to the new mesh
  70114. * @param newGenerator use new generator object for cloned trail mesh
  70115. * @returns a new mesh
  70116. */
  70117. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  70118. /**
  70119. * Serializes this trail mesh
  70120. * @param serializationObject object to write serialization to
  70121. */
  70122. serialize(serializationObject: any): void;
  70123. /**
  70124. * Parses a serialized trail mesh
  70125. * @param parsedMesh the serialized mesh
  70126. * @param scene the scene to create the trail mesh in
  70127. * @returns the created trail mesh
  70128. */
  70129. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  70130. }
  70131. }
  70132. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  70133. import { Nullable } from "babylonjs/types";
  70134. import { Scene } from "babylonjs/scene";
  70135. import { Vector4 } from "babylonjs/Maths/math.vector";
  70136. import { Color4 } from "babylonjs/Maths/math.color";
  70137. import { Mesh } from "babylonjs/Meshes/mesh";
  70138. /**
  70139. * Class containing static functions to help procedurally build meshes
  70140. */
  70141. export class TiledBoxBuilder {
  70142. /**
  70143. * Creates a box mesh
  70144. * 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)
  70145. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70147. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70149. * @param name defines the name of the mesh
  70150. * @param options defines the options used to create the mesh
  70151. * @param scene defines the hosting scene
  70152. * @returns the box mesh
  70153. */
  70154. static CreateTiledBox(name: string, options: {
  70155. pattern?: number;
  70156. width?: number;
  70157. height?: number;
  70158. depth?: number;
  70159. tileSize?: number;
  70160. tileWidth?: number;
  70161. tileHeight?: number;
  70162. alignHorizontal?: number;
  70163. alignVertical?: number;
  70164. faceUV?: Vector4[];
  70165. faceColors?: Color4[];
  70166. sideOrientation?: number;
  70167. updatable?: boolean;
  70168. }, scene?: Nullable<Scene>): Mesh;
  70169. }
  70170. }
  70171. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  70172. import { Vector4 } from "babylonjs/Maths/math.vector";
  70173. import { Mesh } from "babylonjs/Meshes/mesh";
  70174. /**
  70175. * Class containing static functions to help procedurally build meshes
  70176. */
  70177. export class TorusKnotBuilder {
  70178. /**
  70179. * Creates a torus knot mesh
  70180. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70181. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70182. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70183. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70185. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70187. * @param name defines the name of the mesh
  70188. * @param options defines the options used to create the mesh
  70189. * @param scene defines the hosting scene
  70190. * @returns the torus knot mesh
  70191. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70192. */
  70193. static CreateTorusKnot(name: string, options: {
  70194. radius?: number;
  70195. tube?: number;
  70196. radialSegments?: number;
  70197. tubularSegments?: number;
  70198. p?: number;
  70199. q?: number;
  70200. updatable?: boolean;
  70201. sideOrientation?: number;
  70202. frontUVs?: Vector4;
  70203. backUVs?: Vector4;
  70204. }, scene: any): Mesh;
  70205. }
  70206. }
  70207. declare module "babylonjs/Meshes/polygonMesh" {
  70208. import { Scene } from "babylonjs/scene";
  70209. import { Vector2 } from "babylonjs/Maths/math.vector";
  70210. import { Mesh } from "babylonjs/Meshes/mesh";
  70211. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  70212. import { Path2 } from "babylonjs/Maths/math.path";
  70213. /**
  70214. * Polygon
  70215. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  70216. */
  70217. export class Polygon {
  70218. /**
  70219. * Creates a rectangle
  70220. * @param xmin bottom X coord
  70221. * @param ymin bottom Y coord
  70222. * @param xmax top X coord
  70223. * @param ymax top Y coord
  70224. * @returns points that make the resulting rectation
  70225. */
  70226. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  70227. /**
  70228. * Creates a circle
  70229. * @param radius radius of circle
  70230. * @param cx scale in x
  70231. * @param cy scale in y
  70232. * @param numberOfSides number of sides that make up the circle
  70233. * @returns points that make the resulting circle
  70234. */
  70235. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  70236. /**
  70237. * Creates a polygon from input string
  70238. * @param input Input polygon data
  70239. * @returns the parsed points
  70240. */
  70241. static Parse(input: string): Vector2[];
  70242. /**
  70243. * Starts building a polygon from x and y coordinates
  70244. * @param x x coordinate
  70245. * @param y y coordinate
  70246. * @returns the started path2
  70247. */
  70248. static StartingAt(x: number, y: number): Path2;
  70249. }
  70250. /**
  70251. * Builds a polygon
  70252. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  70253. */
  70254. export class PolygonMeshBuilder {
  70255. private _points;
  70256. private _outlinepoints;
  70257. private _holes;
  70258. private _name;
  70259. private _scene;
  70260. private _epoints;
  70261. private _eholes;
  70262. private _addToepoint;
  70263. /**
  70264. * Babylon reference to the earcut plugin.
  70265. */
  70266. bjsEarcut: any;
  70267. /**
  70268. * Creates a PolygonMeshBuilder
  70269. * @param name name of the builder
  70270. * @param contours Path of the polygon
  70271. * @param scene scene to add to when creating the mesh
  70272. * @param earcutInjection can be used to inject your own earcut reference
  70273. */
  70274. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  70275. /**
  70276. * Adds a whole within the polygon
  70277. * @param hole Array of points defining the hole
  70278. * @returns this
  70279. */
  70280. addHole(hole: Vector2[]): PolygonMeshBuilder;
  70281. /**
  70282. * Creates the polygon
  70283. * @param updatable If the mesh should be updatable
  70284. * @param depth The depth of the mesh created
  70285. * @returns the created mesh
  70286. */
  70287. build(updatable?: boolean, depth?: number): Mesh;
  70288. /**
  70289. * Creates the polygon
  70290. * @param depth The depth of the mesh created
  70291. * @returns the created VertexData
  70292. */
  70293. buildVertexData(depth?: number): VertexData;
  70294. /**
  70295. * Adds a side to the polygon
  70296. * @param positions points that make the polygon
  70297. * @param normals normals of the polygon
  70298. * @param uvs uvs of the polygon
  70299. * @param indices indices of the polygon
  70300. * @param bounds bounds of the polygon
  70301. * @param points points of the polygon
  70302. * @param depth depth of the polygon
  70303. * @param flip flip of the polygon
  70304. */
  70305. private addSide;
  70306. }
  70307. }
  70308. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  70309. import { Scene } from "babylonjs/scene";
  70310. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70311. import { Color4 } from "babylonjs/Maths/math.color";
  70312. import { Mesh } from "babylonjs/Meshes/mesh";
  70313. import { Nullable } from "babylonjs/types";
  70314. /**
  70315. * Class containing static functions to help procedurally build meshes
  70316. */
  70317. export class PolygonBuilder {
  70318. /**
  70319. * Creates a polygon mesh
  70320. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70321. * * 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
  70322. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70324. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70325. * * Remember you can only change the shape positions, not their number when updating a polygon
  70326. * @param name defines the name of the mesh
  70327. * @param options defines the options used to create the mesh
  70328. * @param scene defines the hosting scene
  70329. * @param earcutInjection can be used to inject your own earcut reference
  70330. * @returns the polygon mesh
  70331. */
  70332. static CreatePolygon(name: string, options: {
  70333. shape: Vector3[];
  70334. holes?: Vector3[][];
  70335. depth?: number;
  70336. faceUV?: Vector4[];
  70337. faceColors?: Color4[];
  70338. updatable?: boolean;
  70339. sideOrientation?: number;
  70340. frontUVs?: Vector4;
  70341. backUVs?: Vector4;
  70342. wrap?: boolean;
  70343. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70344. /**
  70345. * Creates an extruded polygon mesh, with depth in the Y direction.
  70346. * * 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)
  70347. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70348. * @param name defines the name of the mesh
  70349. * @param options defines the options used to create the mesh
  70350. * @param scene defines the hosting scene
  70351. * @param earcutInjection can be used to inject your own earcut reference
  70352. * @returns the polygon mesh
  70353. */
  70354. static ExtrudePolygon(name: string, options: {
  70355. shape: Vector3[];
  70356. holes?: Vector3[][];
  70357. depth?: number;
  70358. faceUV?: Vector4[];
  70359. faceColors?: Color4[];
  70360. updatable?: boolean;
  70361. sideOrientation?: number;
  70362. frontUVs?: Vector4;
  70363. backUVs?: Vector4;
  70364. wrap?: boolean;
  70365. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70366. }
  70367. }
  70368. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  70369. import { Scene } from "babylonjs/scene";
  70370. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70371. import { Mesh } from "babylonjs/Meshes/mesh";
  70372. import { Nullable } from "babylonjs/types";
  70373. /**
  70374. * Class containing static functions to help procedurally build meshes
  70375. */
  70376. export class LatheBuilder {
  70377. /**
  70378. * Creates lathe mesh.
  70379. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70380. * * 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
  70381. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70382. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70383. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70384. * * 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
  70385. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70386. * * 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
  70387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70388. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70389. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70391. * @param name defines the name of the mesh
  70392. * @param options defines the options used to create the mesh
  70393. * @param scene defines the hosting scene
  70394. * @returns the lathe mesh
  70395. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70396. */
  70397. static CreateLathe(name: string, options: {
  70398. shape: Vector3[];
  70399. radius?: number;
  70400. tessellation?: number;
  70401. clip?: number;
  70402. arc?: number;
  70403. closed?: boolean;
  70404. updatable?: boolean;
  70405. sideOrientation?: number;
  70406. frontUVs?: Vector4;
  70407. backUVs?: Vector4;
  70408. cap?: number;
  70409. invertUV?: boolean;
  70410. }, scene?: Nullable<Scene>): Mesh;
  70411. }
  70412. }
  70413. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  70414. import { Nullable } from "babylonjs/types";
  70415. import { Scene } from "babylonjs/scene";
  70416. import { Vector4 } from "babylonjs/Maths/math.vector";
  70417. import { Mesh } from "babylonjs/Meshes/mesh";
  70418. /**
  70419. * Class containing static functions to help procedurally build meshes
  70420. */
  70421. export class TiledPlaneBuilder {
  70422. /**
  70423. * Creates a tiled plane mesh
  70424. * * The parameter `pattern` will, depending on value, do nothing or
  70425. * * * flip (reflect about central vertical) alternate tiles across and up
  70426. * * * flip every tile on alternate rows
  70427. * * * rotate (180 degs) alternate tiles across and up
  70428. * * * rotate every tile on alternate rows
  70429. * * * flip and rotate alternate tiles across and up
  70430. * * * flip and rotate every tile on alternate rows
  70431. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  70432. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  70433. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70434. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70435. * * 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)
  70436. * * 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)
  70437. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70438. * @param name defines the name of the mesh
  70439. * @param options defines the options used to create the mesh
  70440. * @param scene defines the hosting scene
  70441. * @returns the box mesh
  70442. */
  70443. static CreateTiledPlane(name: string, options: {
  70444. pattern?: number;
  70445. tileSize?: number;
  70446. tileWidth?: number;
  70447. tileHeight?: number;
  70448. size?: number;
  70449. width?: number;
  70450. height?: number;
  70451. alignHorizontal?: number;
  70452. alignVertical?: number;
  70453. sideOrientation?: number;
  70454. frontUVs?: Vector4;
  70455. backUVs?: Vector4;
  70456. updatable?: boolean;
  70457. }, scene?: Nullable<Scene>): Mesh;
  70458. }
  70459. }
  70460. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  70461. import { Nullable } from "babylonjs/types";
  70462. import { Scene } from "babylonjs/scene";
  70463. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70464. import { Mesh } from "babylonjs/Meshes/mesh";
  70465. /**
  70466. * Class containing static functions to help procedurally build meshes
  70467. */
  70468. export class TubeBuilder {
  70469. /**
  70470. * Creates a tube mesh.
  70471. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70472. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70473. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70474. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70475. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70476. * * 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)
  70477. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70478. * * 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
  70479. * * 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
  70480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70481. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70482. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70484. * @param name defines the name of the mesh
  70485. * @param options defines the options used to create the mesh
  70486. * @param scene defines the hosting scene
  70487. * @returns the tube mesh
  70488. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70489. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70490. */
  70491. static CreateTube(name: string, options: {
  70492. path: Vector3[];
  70493. radius?: number;
  70494. tessellation?: number;
  70495. radiusFunction?: {
  70496. (i: number, distance: number): number;
  70497. };
  70498. cap?: number;
  70499. arc?: number;
  70500. updatable?: boolean;
  70501. sideOrientation?: number;
  70502. frontUVs?: Vector4;
  70503. backUVs?: Vector4;
  70504. instance?: Mesh;
  70505. invertUV?: boolean;
  70506. }, scene?: Nullable<Scene>): Mesh;
  70507. }
  70508. }
  70509. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  70510. import { Scene } from "babylonjs/scene";
  70511. import { Vector4 } from "babylonjs/Maths/math.vector";
  70512. import { Mesh } from "babylonjs/Meshes/mesh";
  70513. import { Nullable } from "babylonjs/types";
  70514. /**
  70515. * Class containing static functions to help procedurally build meshes
  70516. */
  70517. export class IcoSphereBuilder {
  70518. /**
  70519. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70520. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70521. * * 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`)
  70522. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70523. * * 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
  70524. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70525. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70527. * @param name defines the name of the mesh
  70528. * @param options defines the options used to create the mesh
  70529. * @param scene defines the hosting scene
  70530. * @returns the icosahedron mesh
  70531. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70532. */
  70533. static CreateIcoSphere(name: string, options: {
  70534. radius?: number;
  70535. radiusX?: number;
  70536. radiusY?: number;
  70537. radiusZ?: number;
  70538. flat?: boolean;
  70539. subdivisions?: number;
  70540. sideOrientation?: number;
  70541. frontUVs?: Vector4;
  70542. backUVs?: Vector4;
  70543. updatable?: boolean;
  70544. }, scene?: Nullable<Scene>): Mesh;
  70545. }
  70546. }
  70547. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  70548. import { Vector3 } from "babylonjs/Maths/math.vector";
  70549. import { Mesh } from "babylonjs/Meshes/mesh";
  70550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70551. /**
  70552. * Class containing static functions to help procedurally build meshes
  70553. */
  70554. export class DecalBuilder {
  70555. /**
  70556. * Creates a decal mesh.
  70557. * 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
  70558. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70559. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70560. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70561. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70562. * @param name defines the name of the mesh
  70563. * @param sourceMesh defines the mesh where the decal must be applied
  70564. * @param options defines the options used to create the mesh
  70565. * @param scene defines the hosting scene
  70566. * @returns the decal mesh
  70567. * @see https://doc.babylonjs.com/how_to/decals
  70568. */
  70569. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70570. position?: Vector3;
  70571. normal?: Vector3;
  70572. size?: Vector3;
  70573. angle?: number;
  70574. }): Mesh;
  70575. }
  70576. }
  70577. declare module "babylonjs/Meshes/meshBuilder" {
  70578. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  70579. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  70580. import { Nullable } from "babylonjs/types";
  70581. import { Scene } from "babylonjs/scene";
  70582. import { Mesh } from "babylonjs/Meshes/mesh";
  70583. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  70584. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  70585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70586. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70587. import { Plane } from "babylonjs/Maths/math.plane";
  70588. /**
  70589. * Class containing static functions to help procedurally build meshes
  70590. */
  70591. export class MeshBuilder {
  70592. /**
  70593. * Creates a box mesh
  70594. * * The parameter `size` sets the size (float) of each box side (default 1)
  70595. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70596. * * 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)
  70597. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70598. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70599. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70601. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70602. * @param name defines the name of the mesh
  70603. * @param options defines the options used to create the mesh
  70604. * @param scene defines the hosting scene
  70605. * @returns the box mesh
  70606. */
  70607. static CreateBox(name: string, options: {
  70608. size?: number;
  70609. width?: number;
  70610. height?: number;
  70611. depth?: number;
  70612. faceUV?: Vector4[];
  70613. faceColors?: Color4[];
  70614. sideOrientation?: number;
  70615. frontUVs?: Vector4;
  70616. backUVs?: Vector4;
  70617. wrap?: boolean;
  70618. topBaseAt?: number;
  70619. bottomBaseAt?: number;
  70620. updatable?: boolean;
  70621. }, scene?: Nullable<Scene>): Mesh;
  70622. /**
  70623. * Creates a tiled box mesh
  70624. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70626. * @param name defines the name of the mesh
  70627. * @param options defines the options used to create the mesh
  70628. * @param scene defines the hosting scene
  70629. * @returns the tiled box mesh
  70630. */
  70631. static CreateTiledBox(name: string, options: {
  70632. pattern?: number;
  70633. size?: number;
  70634. width?: number;
  70635. height?: number;
  70636. depth: number;
  70637. tileSize?: number;
  70638. tileWidth?: number;
  70639. tileHeight?: number;
  70640. faceUV?: Vector4[];
  70641. faceColors?: Color4[];
  70642. alignHorizontal?: number;
  70643. alignVertical?: number;
  70644. sideOrientation?: number;
  70645. updatable?: boolean;
  70646. }, scene?: Nullable<Scene>): Mesh;
  70647. /**
  70648. * Creates a sphere mesh
  70649. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70650. * * 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`)
  70651. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70652. * * 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
  70653. * * 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)
  70654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70655. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70657. * @param name defines the name of the mesh
  70658. * @param options defines the options used to create the mesh
  70659. * @param scene defines the hosting scene
  70660. * @returns the sphere mesh
  70661. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70662. */
  70663. static CreateSphere(name: string, options: {
  70664. segments?: number;
  70665. diameter?: number;
  70666. diameterX?: number;
  70667. diameterY?: number;
  70668. diameterZ?: number;
  70669. arc?: number;
  70670. slice?: number;
  70671. sideOrientation?: number;
  70672. frontUVs?: Vector4;
  70673. backUVs?: Vector4;
  70674. updatable?: boolean;
  70675. }, scene?: Nullable<Scene>): Mesh;
  70676. /**
  70677. * Creates a plane polygonal mesh. By default, this is a disc
  70678. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70679. * * 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
  70680. * * 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
  70681. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70682. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70684. * @param name defines the name of the mesh
  70685. * @param options defines the options used to create the mesh
  70686. * @param scene defines the hosting scene
  70687. * @returns the plane polygonal mesh
  70688. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70689. */
  70690. static CreateDisc(name: string, options: {
  70691. radius?: number;
  70692. tessellation?: number;
  70693. arc?: number;
  70694. updatable?: boolean;
  70695. sideOrientation?: number;
  70696. frontUVs?: Vector4;
  70697. backUVs?: Vector4;
  70698. }, scene?: Nullable<Scene>): Mesh;
  70699. /**
  70700. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70701. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70702. * * 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`)
  70703. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70704. * * 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
  70705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70706. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70708. * @param name defines the name of the mesh
  70709. * @param options defines the options used to create the mesh
  70710. * @param scene defines the hosting scene
  70711. * @returns the icosahedron mesh
  70712. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70713. */
  70714. static CreateIcoSphere(name: string, options: {
  70715. radius?: number;
  70716. radiusX?: number;
  70717. radiusY?: number;
  70718. radiusZ?: number;
  70719. flat?: boolean;
  70720. subdivisions?: number;
  70721. sideOrientation?: number;
  70722. frontUVs?: Vector4;
  70723. backUVs?: Vector4;
  70724. updatable?: boolean;
  70725. }, scene?: Nullable<Scene>): Mesh;
  70726. /**
  70727. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70728. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70729. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70730. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70731. * * 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
  70732. * * 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
  70733. * * 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
  70734. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70735. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70736. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70737. * * 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
  70738. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70739. * * 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
  70740. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70742. * @param name defines the name of the mesh
  70743. * @param options defines the options used to create the mesh
  70744. * @param scene defines the hosting scene
  70745. * @returns the ribbon mesh
  70746. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70747. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70748. */
  70749. static CreateRibbon(name: string, options: {
  70750. pathArray: Vector3[][];
  70751. closeArray?: boolean;
  70752. closePath?: boolean;
  70753. offset?: number;
  70754. updatable?: boolean;
  70755. sideOrientation?: number;
  70756. frontUVs?: Vector4;
  70757. backUVs?: Vector4;
  70758. instance?: Mesh;
  70759. invertUV?: boolean;
  70760. uvs?: Vector2[];
  70761. colors?: Color4[];
  70762. }, scene?: Nullable<Scene>): Mesh;
  70763. /**
  70764. * Creates a cylinder or a cone mesh
  70765. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70766. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70767. * * 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.
  70768. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70769. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70770. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70771. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70772. * * 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).
  70773. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70774. * * 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).
  70775. * * 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
  70776. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70777. * * 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
  70778. * * 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.
  70779. * * If `enclose` is false, a ring surface is one element.
  70780. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70781. * * 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
  70782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70783. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70785. * @param name defines the name of the mesh
  70786. * @param options defines the options used to create the mesh
  70787. * @param scene defines the hosting scene
  70788. * @returns the cylinder mesh
  70789. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70790. */
  70791. static CreateCylinder(name: string, options: {
  70792. height?: number;
  70793. diameterTop?: number;
  70794. diameterBottom?: number;
  70795. diameter?: number;
  70796. tessellation?: number;
  70797. subdivisions?: number;
  70798. arc?: number;
  70799. faceColors?: Color4[];
  70800. faceUV?: Vector4[];
  70801. updatable?: boolean;
  70802. hasRings?: boolean;
  70803. enclose?: boolean;
  70804. cap?: number;
  70805. sideOrientation?: number;
  70806. frontUVs?: Vector4;
  70807. backUVs?: Vector4;
  70808. }, scene?: Nullable<Scene>): Mesh;
  70809. /**
  70810. * Creates a torus mesh
  70811. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70812. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70813. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70814. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70815. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70817. * @param name defines the name of the mesh
  70818. * @param options defines the options used to create the mesh
  70819. * @param scene defines the hosting scene
  70820. * @returns the torus mesh
  70821. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70822. */
  70823. static CreateTorus(name: string, options: {
  70824. diameter?: number;
  70825. thickness?: number;
  70826. tessellation?: number;
  70827. updatable?: boolean;
  70828. sideOrientation?: number;
  70829. frontUVs?: Vector4;
  70830. backUVs?: Vector4;
  70831. }, scene?: Nullable<Scene>): Mesh;
  70832. /**
  70833. * Creates a torus knot mesh
  70834. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70835. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70836. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70837. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70839. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70841. * @param name defines the name of the mesh
  70842. * @param options defines the options used to create the mesh
  70843. * @param scene defines the hosting scene
  70844. * @returns the torus knot mesh
  70845. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70846. */
  70847. static CreateTorusKnot(name: string, options: {
  70848. radius?: number;
  70849. tube?: number;
  70850. radialSegments?: number;
  70851. tubularSegments?: number;
  70852. p?: number;
  70853. q?: number;
  70854. updatable?: boolean;
  70855. sideOrientation?: number;
  70856. frontUVs?: Vector4;
  70857. backUVs?: Vector4;
  70858. }, scene?: Nullable<Scene>): Mesh;
  70859. /**
  70860. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70861. * * 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
  70862. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70863. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70864. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70865. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70866. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70867. * * 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
  70868. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70870. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70871. * @param name defines the name of the new line system
  70872. * @param options defines the options used to create the line system
  70873. * @param scene defines the hosting scene
  70874. * @returns a new line system mesh
  70875. */
  70876. static CreateLineSystem(name: string, options: {
  70877. lines: Vector3[][];
  70878. updatable?: boolean;
  70879. instance?: Nullable<LinesMesh>;
  70880. colors?: Nullable<Color4[][]>;
  70881. useVertexAlpha?: boolean;
  70882. }, scene: Nullable<Scene>): LinesMesh;
  70883. /**
  70884. * Creates a line mesh
  70885. * 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
  70886. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70887. * * The parameter `points` is an array successive Vector3
  70888. * * 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
  70889. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70890. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70891. * * When updating an instance, remember that only point positions can change, not the number of points
  70892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70893. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70894. * @param name defines the name of the new line system
  70895. * @param options defines the options used to create the line system
  70896. * @param scene defines the hosting scene
  70897. * @returns a new line mesh
  70898. */
  70899. static CreateLines(name: string, options: {
  70900. points: Vector3[];
  70901. updatable?: boolean;
  70902. instance?: Nullable<LinesMesh>;
  70903. colors?: Color4[];
  70904. useVertexAlpha?: boolean;
  70905. }, scene?: Nullable<Scene>): LinesMesh;
  70906. /**
  70907. * Creates a dashed line mesh
  70908. * * 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
  70909. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70910. * * The parameter `points` is an array successive Vector3
  70911. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70912. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70913. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70914. * * 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
  70915. * * When updating an instance, remember that only point positions can change, not the number of points
  70916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70917. * @param name defines the name of the mesh
  70918. * @param options defines the options used to create the mesh
  70919. * @param scene defines the hosting scene
  70920. * @returns the dashed line mesh
  70921. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70922. */
  70923. static CreateDashedLines(name: string, options: {
  70924. points: Vector3[];
  70925. dashSize?: number;
  70926. gapSize?: number;
  70927. dashNb?: number;
  70928. updatable?: boolean;
  70929. instance?: LinesMesh;
  70930. }, scene?: Nullable<Scene>): LinesMesh;
  70931. /**
  70932. * 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.
  70933. * * 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.
  70934. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70935. * * 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.
  70936. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70937. * * 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
  70938. * * 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
  70939. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70940. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70941. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70942. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70944. * @param name defines the name of the mesh
  70945. * @param options defines the options used to create the mesh
  70946. * @param scene defines the hosting scene
  70947. * @returns the extruded shape mesh
  70948. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70949. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70950. */
  70951. static ExtrudeShape(name: string, options: {
  70952. shape: Vector3[];
  70953. path: Vector3[];
  70954. scale?: number;
  70955. rotation?: number;
  70956. cap?: number;
  70957. updatable?: boolean;
  70958. sideOrientation?: number;
  70959. frontUVs?: Vector4;
  70960. backUVs?: Vector4;
  70961. instance?: Mesh;
  70962. invertUV?: boolean;
  70963. }, scene?: Nullable<Scene>): Mesh;
  70964. /**
  70965. * Creates an custom extruded shape mesh.
  70966. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70967. * * 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.
  70968. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70969. * * 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
  70970. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70971. * * 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
  70972. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70973. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70974. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70975. * * 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
  70976. * * 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
  70977. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70979. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70980. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70982. * @param name defines the name of the mesh
  70983. * @param options defines the options used to create the mesh
  70984. * @param scene defines the hosting scene
  70985. * @returns the custom extruded shape mesh
  70986. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70987. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70988. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70989. */
  70990. static ExtrudeShapeCustom(name: string, options: {
  70991. shape: Vector3[];
  70992. path: Vector3[];
  70993. scaleFunction?: any;
  70994. rotationFunction?: any;
  70995. ribbonCloseArray?: boolean;
  70996. ribbonClosePath?: boolean;
  70997. cap?: number;
  70998. updatable?: boolean;
  70999. sideOrientation?: number;
  71000. frontUVs?: Vector4;
  71001. backUVs?: Vector4;
  71002. instance?: Mesh;
  71003. invertUV?: boolean;
  71004. }, scene?: Nullable<Scene>): Mesh;
  71005. /**
  71006. * Creates lathe mesh.
  71007. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  71008. * * 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
  71009. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  71010. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  71011. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  71012. * * 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
  71013. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  71014. * * 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
  71015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71016. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71017. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71019. * @param name defines the name of the mesh
  71020. * @param options defines the options used to create the mesh
  71021. * @param scene defines the hosting scene
  71022. * @returns the lathe mesh
  71023. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  71024. */
  71025. static CreateLathe(name: string, options: {
  71026. shape: Vector3[];
  71027. radius?: number;
  71028. tessellation?: number;
  71029. clip?: number;
  71030. arc?: number;
  71031. closed?: boolean;
  71032. updatable?: boolean;
  71033. sideOrientation?: number;
  71034. frontUVs?: Vector4;
  71035. backUVs?: Vector4;
  71036. cap?: number;
  71037. invertUV?: boolean;
  71038. }, scene?: Nullable<Scene>): Mesh;
  71039. /**
  71040. * Creates a tiled plane mesh
  71041. * * You can set a limited pattern arrangement with the tiles
  71042. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71043. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71045. * @param name defines the name of the mesh
  71046. * @param options defines the options used to create the mesh
  71047. * @param scene defines the hosting scene
  71048. * @returns the plane mesh
  71049. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71050. */
  71051. static CreateTiledPlane(name: string, options: {
  71052. pattern?: number;
  71053. tileSize?: number;
  71054. tileWidth?: number;
  71055. tileHeight?: number;
  71056. size?: number;
  71057. width?: number;
  71058. height?: number;
  71059. alignHorizontal?: number;
  71060. alignVertical?: number;
  71061. sideOrientation?: number;
  71062. frontUVs?: Vector4;
  71063. backUVs?: Vector4;
  71064. updatable?: boolean;
  71065. }, scene?: Nullable<Scene>): Mesh;
  71066. /**
  71067. * Creates a plane mesh
  71068. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  71069. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  71070. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  71071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71072. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71074. * @param name defines the name of the mesh
  71075. * @param options defines the options used to create the mesh
  71076. * @param scene defines the hosting scene
  71077. * @returns the plane mesh
  71078. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71079. */
  71080. static CreatePlane(name: string, options: {
  71081. size?: number;
  71082. width?: number;
  71083. height?: number;
  71084. sideOrientation?: number;
  71085. frontUVs?: Vector4;
  71086. backUVs?: Vector4;
  71087. updatable?: boolean;
  71088. sourcePlane?: Plane;
  71089. }, scene?: Nullable<Scene>): Mesh;
  71090. /**
  71091. * Creates a ground mesh
  71092. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  71093. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  71094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71095. * @param name defines the name of the mesh
  71096. * @param options defines the options used to create the mesh
  71097. * @param scene defines the hosting scene
  71098. * @returns the ground mesh
  71099. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  71100. */
  71101. static CreateGround(name: string, options: {
  71102. width?: number;
  71103. height?: number;
  71104. subdivisions?: number;
  71105. subdivisionsX?: number;
  71106. subdivisionsY?: number;
  71107. updatable?: boolean;
  71108. }, scene?: Nullable<Scene>): Mesh;
  71109. /**
  71110. * Creates a tiled ground mesh
  71111. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  71112. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  71113. * * 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
  71114. * * 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
  71115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71116. * @param name defines the name of the mesh
  71117. * @param options defines the options used to create the mesh
  71118. * @param scene defines the hosting scene
  71119. * @returns the tiled ground mesh
  71120. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  71121. */
  71122. static CreateTiledGround(name: string, options: {
  71123. xmin: number;
  71124. zmin: number;
  71125. xmax: number;
  71126. zmax: number;
  71127. subdivisions?: {
  71128. w: number;
  71129. h: number;
  71130. };
  71131. precision?: {
  71132. w: number;
  71133. h: number;
  71134. };
  71135. updatable?: boolean;
  71136. }, scene?: Nullable<Scene>): Mesh;
  71137. /**
  71138. * Creates a ground mesh from a height map
  71139. * * The parameter `url` sets the URL of the height map image resource.
  71140. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  71141. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  71142. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  71143. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  71144. * * 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.
  71145. * * 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).
  71146. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  71147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71148. * @param name defines the name of the mesh
  71149. * @param url defines the url to the height map
  71150. * @param options defines the options used to create the mesh
  71151. * @param scene defines the hosting scene
  71152. * @returns the ground mesh
  71153. * @see https://doc.babylonjs.com/babylon101/height_map
  71154. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  71155. */
  71156. static CreateGroundFromHeightMap(name: string, url: string, options: {
  71157. width?: number;
  71158. height?: number;
  71159. subdivisions?: number;
  71160. minHeight?: number;
  71161. maxHeight?: number;
  71162. colorFilter?: Color3;
  71163. alphaFilter?: number;
  71164. updatable?: boolean;
  71165. onReady?: (mesh: GroundMesh) => void;
  71166. }, scene?: Nullable<Scene>): GroundMesh;
  71167. /**
  71168. * Creates a polygon mesh
  71169. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  71170. * * 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
  71171. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  71172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71173. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  71174. * * Remember you can only change the shape positions, not their number when updating a polygon
  71175. * @param name defines the name of the mesh
  71176. * @param options defines the options used to create the mesh
  71177. * @param scene defines the hosting scene
  71178. * @param earcutInjection can be used to inject your own earcut reference
  71179. * @returns the polygon mesh
  71180. */
  71181. static CreatePolygon(name: string, options: {
  71182. shape: Vector3[];
  71183. holes?: Vector3[][];
  71184. depth?: number;
  71185. faceUV?: Vector4[];
  71186. faceColors?: Color4[];
  71187. updatable?: boolean;
  71188. sideOrientation?: number;
  71189. frontUVs?: Vector4;
  71190. backUVs?: Vector4;
  71191. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71192. /**
  71193. * Creates an extruded polygon mesh, with depth in the Y direction.
  71194. * * 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)
  71195. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  71196. * @param name defines the name of the mesh
  71197. * @param options defines the options used to create the mesh
  71198. * @param scene defines the hosting scene
  71199. * @param earcutInjection can be used to inject your own earcut reference
  71200. * @returns the polygon mesh
  71201. */
  71202. static ExtrudePolygon(name: string, options: {
  71203. shape: Vector3[];
  71204. holes?: Vector3[][];
  71205. depth?: number;
  71206. faceUV?: Vector4[];
  71207. faceColors?: Color4[];
  71208. updatable?: boolean;
  71209. sideOrientation?: number;
  71210. frontUVs?: Vector4;
  71211. backUVs?: Vector4;
  71212. wrap?: boolean;
  71213. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71214. /**
  71215. * Creates a tube mesh.
  71216. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  71217. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  71218. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  71219. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  71220. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  71221. * * 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)
  71222. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  71223. * * 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
  71224. * * 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
  71225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71226. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71227. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71229. * @param name defines the name of the mesh
  71230. * @param options defines the options used to create the mesh
  71231. * @param scene defines the hosting scene
  71232. * @returns the tube mesh
  71233. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71234. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  71235. */
  71236. static CreateTube(name: string, options: {
  71237. path: Vector3[];
  71238. radius?: number;
  71239. tessellation?: number;
  71240. radiusFunction?: {
  71241. (i: number, distance: number): number;
  71242. };
  71243. cap?: number;
  71244. arc?: number;
  71245. updatable?: boolean;
  71246. sideOrientation?: number;
  71247. frontUVs?: Vector4;
  71248. backUVs?: Vector4;
  71249. instance?: Mesh;
  71250. invertUV?: boolean;
  71251. }, scene?: Nullable<Scene>): Mesh;
  71252. /**
  71253. * Creates a polyhedron mesh
  71254. * * 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
  71255. * * The parameter `size` (positive float, default 1) sets the polygon size
  71256. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  71257. * * 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`
  71258. * * 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
  71259. * * 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)`)
  71260. * * 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
  71261. * * 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
  71262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71265. * @param name defines the name of the mesh
  71266. * @param options defines the options used to create the mesh
  71267. * @param scene defines the hosting scene
  71268. * @returns the polyhedron mesh
  71269. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  71270. */
  71271. static CreatePolyhedron(name: string, options: {
  71272. type?: number;
  71273. size?: number;
  71274. sizeX?: number;
  71275. sizeY?: number;
  71276. sizeZ?: number;
  71277. custom?: any;
  71278. faceUV?: Vector4[];
  71279. faceColors?: Color4[];
  71280. flat?: boolean;
  71281. updatable?: boolean;
  71282. sideOrientation?: number;
  71283. frontUVs?: Vector4;
  71284. backUVs?: Vector4;
  71285. }, scene?: Nullable<Scene>): Mesh;
  71286. /**
  71287. * Creates a decal mesh.
  71288. * 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
  71289. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  71290. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  71291. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  71292. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  71293. * @param name defines the name of the mesh
  71294. * @param sourceMesh defines the mesh where the decal must be applied
  71295. * @param options defines the options used to create the mesh
  71296. * @param scene defines the hosting scene
  71297. * @returns the decal mesh
  71298. * @see https://doc.babylonjs.com/how_to/decals
  71299. */
  71300. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  71301. position?: Vector3;
  71302. normal?: Vector3;
  71303. size?: Vector3;
  71304. angle?: number;
  71305. }): Mesh;
  71306. /**
  71307. * Creates a Capsule Mesh
  71308. * @param name defines the name of the mesh.
  71309. * @param options the constructors options used to shape the mesh.
  71310. * @param scene defines the scene the mesh is scoped to.
  71311. * @returns the capsule mesh
  71312. * @see https://doc.babylonjs.com/how_to/capsule_shape
  71313. */
  71314. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  71315. }
  71316. }
  71317. declare module "babylonjs/Meshes/meshSimplification" {
  71318. import { Mesh } from "babylonjs/Meshes/mesh";
  71319. /**
  71320. * A simplifier interface for future simplification implementations
  71321. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71322. */
  71323. export interface ISimplifier {
  71324. /**
  71325. * Simplification of a given mesh according to the given settings.
  71326. * Since this requires computation, it is assumed that the function runs async.
  71327. * @param settings The settings of the simplification, including quality and distance
  71328. * @param successCallback A callback that will be called after the mesh was simplified.
  71329. * @param errorCallback in case of an error, this callback will be called. optional.
  71330. */
  71331. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  71332. }
  71333. /**
  71334. * Expected simplification settings.
  71335. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  71336. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71337. */
  71338. export interface ISimplificationSettings {
  71339. /**
  71340. * Gets or sets the expected quality
  71341. */
  71342. quality: number;
  71343. /**
  71344. * Gets or sets the distance when this optimized version should be used
  71345. */
  71346. distance: number;
  71347. /**
  71348. * Gets an already optimized mesh
  71349. */
  71350. optimizeMesh?: boolean;
  71351. }
  71352. /**
  71353. * Class used to specify simplification options
  71354. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71355. */
  71356. export class SimplificationSettings implements ISimplificationSettings {
  71357. /** expected quality */
  71358. quality: number;
  71359. /** distance when this optimized version should be used */
  71360. distance: number;
  71361. /** already optimized mesh */
  71362. optimizeMesh?: boolean | undefined;
  71363. /**
  71364. * Creates a SimplificationSettings
  71365. * @param quality expected quality
  71366. * @param distance distance when this optimized version should be used
  71367. * @param optimizeMesh already optimized mesh
  71368. */
  71369. constructor(
  71370. /** expected quality */
  71371. quality: number,
  71372. /** distance when this optimized version should be used */
  71373. distance: number,
  71374. /** already optimized mesh */
  71375. optimizeMesh?: boolean | undefined);
  71376. }
  71377. /**
  71378. * Interface used to define a simplification task
  71379. */
  71380. export interface ISimplificationTask {
  71381. /**
  71382. * Array of settings
  71383. */
  71384. settings: Array<ISimplificationSettings>;
  71385. /**
  71386. * Simplification type
  71387. */
  71388. simplificationType: SimplificationType;
  71389. /**
  71390. * Mesh to simplify
  71391. */
  71392. mesh: Mesh;
  71393. /**
  71394. * Callback called on success
  71395. */
  71396. successCallback?: () => void;
  71397. /**
  71398. * Defines if parallel processing can be used
  71399. */
  71400. parallelProcessing: boolean;
  71401. }
  71402. /**
  71403. * Queue used to order the simplification tasks
  71404. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71405. */
  71406. export class SimplificationQueue {
  71407. private _simplificationArray;
  71408. /**
  71409. * Gets a boolean indicating that the process is still running
  71410. */
  71411. running: boolean;
  71412. /**
  71413. * Creates a new queue
  71414. */
  71415. constructor();
  71416. /**
  71417. * Adds a new simplification task
  71418. * @param task defines a task to add
  71419. */
  71420. addTask(task: ISimplificationTask): void;
  71421. /**
  71422. * Execute next task
  71423. */
  71424. executeNext(): void;
  71425. /**
  71426. * Execute a simplification task
  71427. * @param task defines the task to run
  71428. */
  71429. runSimplification(task: ISimplificationTask): void;
  71430. private getSimplifier;
  71431. }
  71432. /**
  71433. * The implemented types of simplification
  71434. * At the moment only Quadratic Error Decimation is implemented
  71435. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71436. */
  71437. export enum SimplificationType {
  71438. /** Quadratic error decimation */
  71439. QUADRATIC = 0
  71440. }
  71441. /**
  71442. * An implementation of the Quadratic Error simplification algorithm.
  71443. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  71444. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  71445. * @author RaananW
  71446. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71447. */
  71448. export class QuadraticErrorSimplification implements ISimplifier {
  71449. private _mesh;
  71450. private triangles;
  71451. private vertices;
  71452. private references;
  71453. private _reconstructedMesh;
  71454. /** Gets or sets the number pf sync interations */
  71455. syncIterations: number;
  71456. /** Gets or sets the aggressiveness of the simplifier */
  71457. aggressiveness: number;
  71458. /** Gets or sets the number of allowed iterations for decimation */
  71459. decimationIterations: number;
  71460. /** Gets or sets the espilon to use for bounding box computation */
  71461. boundingBoxEpsilon: number;
  71462. /**
  71463. * Creates a new QuadraticErrorSimplification
  71464. * @param _mesh defines the target mesh
  71465. */
  71466. constructor(_mesh: Mesh);
  71467. /**
  71468. * Simplification of a given mesh according to the given settings.
  71469. * Since this requires computation, it is assumed that the function runs async.
  71470. * @param settings The settings of the simplification, including quality and distance
  71471. * @param successCallback A callback that will be called after the mesh was simplified.
  71472. */
  71473. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  71474. private runDecimation;
  71475. private initWithMesh;
  71476. private init;
  71477. private reconstructMesh;
  71478. private initDecimatedMesh;
  71479. private isFlipped;
  71480. private updateTriangles;
  71481. private identifyBorder;
  71482. private updateMesh;
  71483. private vertexError;
  71484. private calculateError;
  71485. }
  71486. }
  71487. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  71488. import { Scene } from "babylonjs/scene";
  71489. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  71490. import { ISceneComponent } from "babylonjs/sceneComponent";
  71491. module "babylonjs/scene" {
  71492. interface Scene {
  71493. /** @hidden (Backing field) */
  71494. _simplificationQueue: SimplificationQueue;
  71495. /**
  71496. * Gets or sets the simplification queue attached to the scene
  71497. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71498. */
  71499. simplificationQueue: SimplificationQueue;
  71500. }
  71501. }
  71502. module "babylonjs/Meshes/mesh" {
  71503. interface Mesh {
  71504. /**
  71505. * Simplify the mesh according to the given array of settings.
  71506. * Function will return immediately and will simplify async
  71507. * @param settings a collection of simplification settings
  71508. * @param parallelProcessing should all levels calculate parallel or one after the other
  71509. * @param simplificationType the type of simplification to run
  71510. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  71511. * @returns the current mesh
  71512. */
  71513. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  71514. }
  71515. }
  71516. /**
  71517. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  71518. * created in a scene
  71519. */
  71520. export class SimplicationQueueSceneComponent implements ISceneComponent {
  71521. /**
  71522. * The component name helpfull to identify the component in the list of scene components.
  71523. */
  71524. readonly name: string;
  71525. /**
  71526. * The scene the component belongs to.
  71527. */
  71528. scene: Scene;
  71529. /**
  71530. * Creates a new instance of the component for the given scene
  71531. * @param scene Defines the scene to register the component in
  71532. */
  71533. constructor(scene: Scene);
  71534. /**
  71535. * Registers the component in a given scene
  71536. */
  71537. register(): void;
  71538. /**
  71539. * Rebuilds the elements related to this component in case of
  71540. * context lost for instance.
  71541. */
  71542. rebuild(): void;
  71543. /**
  71544. * Disposes the component and the associated ressources
  71545. */
  71546. dispose(): void;
  71547. private _beforeCameraUpdate;
  71548. }
  71549. }
  71550. declare module "babylonjs/Meshes/Builders/index" {
  71551. export * from "babylonjs/Meshes/Builders/boxBuilder";
  71552. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  71553. export * from "babylonjs/Meshes/Builders/discBuilder";
  71554. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  71555. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  71556. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  71557. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  71558. export * from "babylonjs/Meshes/Builders/torusBuilder";
  71559. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  71560. export * from "babylonjs/Meshes/Builders/linesBuilder";
  71561. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  71562. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  71563. export * from "babylonjs/Meshes/Builders/latheBuilder";
  71564. export * from "babylonjs/Meshes/Builders/planeBuilder";
  71565. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  71566. export * from "babylonjs/Meshes/Builders/groundBuilder";
  71567. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  71568. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  71569. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  71570. export * from "babylonjs/Meshes/Builders/decalBuilder";
  71571. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  71572. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  71573. }
  71574. declare module "babylonjs/Meshes/thinInstanceMesh" {
  71575. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  71576. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  71577. import { Matrix } from "babylonjs/Maths/math.vector";
  71578. module "babylonjs/Meshes/mesh" {
  71579. interface Mesh {
  71580. /**
  71581. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71582. */
  71583. thinInstanceEnablePicking: boolean;
  71584. /**
  71585. * Creates a new thin instance
  71586. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71587. * @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
  71588. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71589. */
  71590. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  71591. /**
  71592. * Adds the transformation (matrix) of the current mesh as a thin instance
  71593. * @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
  71594. * @returns the thin instance index number
  71595. */
  71596. thinInstanceAddSelf(refresh: boolean): number;
  71597. /**
  71598. * Registers a custom attribute to be used with thin instances
  71599. * @param kind name of the attribute
  71600. * @param stride size in floats of the attribute
  71601. */
  71602. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71603. /**
  71604. * Sets the matrix of a thin instance
  71605. * @param index index of the thin instance
  71606. * @param matrix matrix to set
  71607. * @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
  71608. */
  71609. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71610. /**
  71611. * Sets the value of a custom attribute for a thin instance
  71612. * @param kind name of the attribute
  71613. * @param index index of the thin instance
  71614. * @param value value to set
  71615. * @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
  71616. */
  71617. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71618. /**
  71619. * 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.
  71620. */
  71621. thinInstanceCount: number;
  71622. /**
  71623. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71624. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71625. * @param buffer buffer to set
  71626. * @param stride size in floats of each value of the buffer
  71627. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71628. */
  71629. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71630. /**
  71631. * Gets the list of world matrices
  71632. * @return an array containing all the world matrices from the thin instances
  71633. */
  71634. thinInstanceGetWorldMatrices(): Matrix[];
  71635. /**
  71636. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71637. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71638. */
  71639. thinInstanceBufferUpdated(kind: string): void;
  71640. /**
  71641. * Applies a partial update to a buffer directly on the GPU
  71642. * 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
  71643. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71644. * @param data the data to set in the GPU buffer
  71645. * @param offset the offset in the GPU buffer where to update the data
  71646. */
  71647. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71648. /**
  71649. * Refreshes the bounding info, taking into account all the thin instances defined
  71650. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71651. */
  71652. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71653. /** @hidden */
  71654. _thinInstanceInitializeUserStorage(): void;
  71655. /** @hidden */
  71656. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71657. /** @hidden */
  71658. _userThinInstanceBuffersStorage: {
  71659. data: {
  71660. [key: string]: Float32Array;
  71661. };
  71662. sizes: {
  71663. [key: string]: number;
  71664. };
  71665. vertexBuffers: {
  71666. [key: string]: Nullable<VertexBuffer>;
  71667. };
  71668. strides: {
  71669. [key: string]: number;
  71670. };
  71671. };
  71672. }
  71673. }
  71674. }
  71675. declare module "babylonjs/Meshes/index" {
  71676. export * from "babylonjs/Meshes/abstractMesh";
  71677. export * from "babylonjs/Meshes/buffer";
  71678. export * from "babylonjs/Meshes/Compression/index";
  71679. export * from "babylonjs/Meshes/csg";
  71680. export * from "babylonjs/Meshes/geometry";
  71681. export * from "babylonjs/Meshes/groundMesh";
  71682. export * from "babylonjs/Meshes/trailMesh";
  71683. export * from "babylonjs/Meshes/instancedMesh";
  71684. export * from "babylonjs/Meshes/linesMesh";
  71685. export * from "babylonjs/Meshes/mesh";
  71686. export * from "babylonjs/Meshes/mesh.vertexData";
  71687. export * from "babylonjs/Meshes/meshBuilder";
  71688. export * from "babylonjs/Meshes/meshSimplification";
  71689. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  71690. export * from "babylonjs/Meshes/polygonMesh";
  71691. export * from "babylonjs/Meshes/subMesh";
  71692. export * from "babylonjs/Meshes/meshLODLevel";
  71693. export * from "babylonjs/Meshes/transformNode";
  71694. export * from "babylonjs/Meshes/Builders/index";
  71695. export * from "babylonjs/Meshes/dataBuffer";
  71696. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  71697. import "babylonjs/Meshes/thinInstanceMesh";
  71698. export * from "babylonjs/Meshes/thinInstanceMesh";
  71699. }
  71700. declare module "babylonjs/Morph/index" {
  71701. export * from "babylonjs/Morph/morphTarget";
  71702. export * from "babylonjs/Morph/morphTargetManager";
  71703. }
  71704. declare module "babylonjs/Navigation/INavigationEngine" {
  71705. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71706. import { Vector3 } from "babylonjs/Maths/math";
  71707. import { Mesh } from "babylonjs/Meshes/mesh";
  71708. import { Scene } from "babylonjs/scene";
  71709. /**
  71710. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71711. */
  71712. export interface INavigationEnginePlugin {
  71713. /**
  71714. * plugin name
  71715. */
  71716. name: string;
  71717. /**
  71718. * Creates a navigation mesh
  71719. * @param meshes array of all the geometry used to compute the navigatio mesh
  71720. * @param parameters bunch of parameters used to filter geometry
  71721. */
  71722. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71723. /**
  71724. * Create a navigation mesh debug mesh
  71725. * @param scene is where the mesh will be added
  71726. * @returns debug display mesh
  71727. */
  71728. createDebugNavMesh(scene: Scene): Mesh;
  71729. /**
  71730. * Get a navigation mesh constrained position, closest to the parameter position
  71731. * @param position world position
  71732. * @returns the closest point to position constrained by the navigation mesh
  71733. */
  71734. getClosestPoint(position: Vector3): Vector3;
  71735. /**
  71736. * Get a navigation mesh constrained position, closest to the parameter position
  71737. * @param position world position
  71738. * @param result output the closest point to position constrained by the navigation mesh
  71739. */
  71740. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71741. /**
  71742. * Get a navigation mesh constrained position, within a particular radius
  71743. * @param position world position
  71744. * @param maxRadius the maximum distance to the constrained world position
  71745. * @returns the closest point to position constrained by the navigation mesh
  71746. */
  71747. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71748. /**
  71749. * Get a navigation mesh constrained position, within a particular radius
  71750. * @param position world position
  71751. * @param maxRadius the maximum distance to the constrained world position
  71752. * @param result output the closest point to position constrained by the navigation mesh
  71753. */
  71754. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71755. /**
  71756. * Compute the final position from a segment made of destination-position
  71757. * @param position world position
  71758. * @param destination world position
  71759. * @returns the resulting point along the navmesh
  71760. */
  71761. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71762. /**
  71763. * Compute the final position from a segment made of destination-position
  71764. * @param position world position
  71765. * @param destination world position
  71766. * @param result output the resulting point along the navmesh
  71767. */
  71768. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71769. /**
  71770. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71771. * @param start world position
  71772. * @param end world position
  71773. * @returns array containing world position composing the path
  71774. */
  71775. computePath(start: Vector3, end: Vector3): Vector3[];
  71776. /**
  71777. * If this plugin is supported
  71778. * @returns true if plugin is supported
  71779. */
  71780. isSupported(): boolean;
  71781. /**
  71782. * Create a new Crowd so you can add agents
  71783. * @param maxAgents the maximum agent count in the crowd
  71784. * @param maxAgentRadius the maximum radius an agent can have
  71785. * @param scene to attach the crowd to
  71786. * @returns the crowd you can add agents to
  71787. */
  71788. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71789. /**
  71790. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71791. * The queries will try to find a solution within those bounds
  71792. * default is (1,1,1)
  71793. * @param extent x,y,z value that define the extent around the queries point of reference
  71794. */
  71795. setDefaultQueryExtent(extent: Vector3): void;
  71796. /**
  71797. * Get the Bounding box extent specified by setDefaultQueryExtent
  71798. * @returns the box extent values
  71799. */
  71800. getDefaultQueryExtent(): Vector3;
  71801. /**
  71802. * build the navmesh from a previously saved state using getNavmeshData
  71803. * @param data the Uint8Array returned by getNavmeshData
  71804. */
  71805. buildFromNavmeshData(data: Uint8Array): void;
  71806. /**
  71807. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71808. * @returns data the Uint8Array that can be saved and reused
  71809. */
  71810. getNavmeshData(): Uint8Array;
  71811. /**
  71812. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71813. * @param result output the box extent values
  71814. */
  71815. getDefaultQueryExtentToRef(result: Vector3): void;
  71816. /**
  71817. * Release all resources
  71818. */
  71819. dispose(): void;
  71820. }
  71821. /**
  71822. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71823. */
  71824. export interface ICrowd {
  71825. /**
  71826. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71827. * You can attach anything to that node. The node position is updated in the scene update tick.
  71828. * @param pos world position that will be constrained by the navigation mesh
  71829. * @param parameters agent parameters
  71830. * @param transform hooked to the agent that will be update by the scene
  71831. * @returns agent index
  71832. */
  71833. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71834. /**
  71835. * Returns the agent position in world space
  71836. * @param index agent index returned by addAgent
  71837. * @returns world space position
  71838. */
  71839. getAgentPosition(index: number): Vector3;
  71840. /**
  71841. * Gets the agent position result in world space
  71842. * @param index agent index returned by addAgent
  71843. * @param result output world space position
  71844. */
  71845. getAgentPositionToRef(index: number, result: Vector3): void;
  71846. /**
  71847. * Gets the agent velocity in world space
  71848. * @param index agent index returned by addAgent
  71849. * @returns world space velocity
  71850. */
  71851. getAgentVelocity(index: number): Vector3;
  71852. /**
  71853. * Gets the agent velocity result in world space
  71854. * @param index agent index returned by addAgent
  71855. * @param result output world space velocity
  71856. */
  71857. getAgentVelocityToRef(index: number, result: Vector3): void;
  71858. /**
  71859. * Gets the agent next target point on the path
  71860. * @param index agent index returned by addAgent
  71861. * @returns world space position
  71862. */
  71863. getAgentNextTargetPath(index: number): Vector3;
  71864. /**
  71865. * Gets the agent state
  71866. * @param index agent index returned by addAgent
  71867. * @returns agent state
  71868. */
  71869. getAgentState(index: number): number;
  71870. /**
  71871. * returns true if the agent in over an off mesh link connection
  71872. * @param index agent index returned by addAgent
  71873. * @returns true if over an off mesh link connection
  71874. */
  71875. overOffmeshConnection(index: number): boolean;
  71876. /**
  71877. * Gets the agent next target point on the path
  71878. * @param index agent index returned by addAgent
  71879. * @param result output world space position
  71880. */
  71881. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71882. /**
  71883. * remove a particular agent previously created
  71884. * @param index agent index returned by addAgent
  71885. */
  71886. removeAgent(index: number): void;
  71887. /**
  71888. * get the list of all agents attached to this crowd
  71889. * @returns list of agent indices
  71890. */
  71891. getAgents(): number[];
  71892. /**
  71893. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71894. * @param deltaTime in seconds
  71895. */
  71896. update(deltaTime: number): void;
  71897. /**
  71898. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71899. * @param index agent index returned by addAgent
  71900. * @param destination targeted world position
  71901. */
  71902. agentGoto(index: number, destination: Vector3): void;
  71903. /**
  71904. * Teleport the agent to a new position
  71905. * @param index agent index returned by addAgent
  71906. * @param destination targeted world position
  71907. */
  71908. agentTeleport(index: number, destination: Vector3): void;
  71909. /**
  71910. * Update agent parameters
  71911. * @param index agent index returned by addAgent
  71912. * @param parameters agent parameters
  71913. */
  71914. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71915. /**
  71916. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71917. * The queries will try to find a solution within those bounds
  71918. * default is (1,1,1)
  71919. * @param extent x,y,z value that define the extent around the queries point of reference
  71920. */
  71921. setDefaultQueryExtent(extent: Vector3): void;
  71922. /**
  71923. * Get the Bounding box extent specified by setDefaultQueryExtent
  71924. * @returns the box extent values
  71925. */
  71926. getDefaultQueryExtent(): Vector3;
  71927. /**
  71928. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71929. * @param result output the box extent values
  71930. */
  71931. getDefaultQueryExtentToRef(result: Vector3): void;
  71932. /**
  71933. * Release all resources
  71934. */
  71935. dispose(): void;
  71936. }
  71937. /**
  71938. * Configures an agent
  71939. */
  71940. export interface IAgentParameters {
  71941. /**
  71942. * Agent radius. [Limit: >= 0]
  71943. */
  71944. radius: number;
  71945. /**
  71946. * Agent height. [Limit: > 0]
  71947. */
  71948. height: number;
  71949. /**
  71950. * Maximum allowed acceleration. [Limit: >= 0]
  71951. */
  71952. maxAcceleration: number;
  71953. /**
  71954. * Maximum allowed speed. [Limit: >= 0]
  71955. */
  71956. maxSpeed: number;
  71957. /**
  71958. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71959. */
  71960. collisionQueryRange: number;
  71961. /**
  71962. * The path visibility optimization range. [Limit: > 0]
  71963. */
  71964. pathOptimizationRange: number;
  71965. /**
  71966. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71967. */
  71968. separationWeight: number;
  71969. }
  71970. /**
  71971. * Configures the navigation mesh creation
  71972. */
  71973. export interface INavMeshParameters {
  71974. /**
  71975. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71976. */
  71977. cs: number;
  71978. /**
  71979. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71980. */
  71981. ch: number;
  71982. /**
  71983. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71984. */
  71985. walkableSlopeAngle: number;
  71986. /**
  71987. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71988. * be considered walkable. [Limit: >= 3] [Units: vx]
  71989. */
  71990. walkableHeight: number;
  71991. /**
  71992. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71993. */
  71994. walkableClimb: number;
  71995. /**
  71996. * The distance to erode/shrink the walkable area of the heightfield away from
  71997. * obstructions. [Limit: >=0] [Units: vx]
  71998. */
  71999. walkableRadius: number;
  72000. /**
  72001. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  72002. */
  72003. maxEdgeLen: number;
  72004. /**
  72005. * The maximum distance a simplfied contour's border edges should deviate
  72006. * the original raw contour. [Limit: >=0] [Units: vx]
  72007. */
  72008. maxSimplificationError: number;
  72009. /**
  72010. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  72011. */
  72012. minRegionArea: number;
  72013. /**
  72014. * Any regions with a span count smaller than this value will, if possible,
  72015. * be merged with larger regions. [Limit: >=0] [Units: vx]
  72016. */
  72017. mergeRegionArea: number;
  72018. /**
  72019. * The maximum number of vertices allowed for polygons generated during the
  72020. * contour to polygon conversion process. [Limit: >= 3]
  72021. */
  72022. maxVertsPerPoly: number;
  72023. /**
  72024. * Sets the sampling distance to use when generating the detail mesh.
  72025. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  72026. */
  72027. detailSampleDist: number;
  72028. /**
  72029. * The maximum distance the detail mesh surface should deviate from heightfield
  72030. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  72031. */
  72032. detailSampleMaxError: number;
  72033. }
  72034. }
  72035. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  72036. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  72037. import { Mesh } from "babylonjs/Meshes/mesh";
  72038. import { Scene } from "babylonjs/scene";
  72039. import { Vector3 } from "babylonjs/Maths/math";
  72040. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72041. /**
  72042. * RecastJS navigation plugin
  72043. */
  72044. export class RecastJSPlugin implements INavigationEnginePlugin {
  72045. /**
  72046. * Reference to the Recast library
  72047. */
  72048. bjsRECAST: any;
  72049. /**
  72050. * plugin name
  72051. */
  72052. name: string;
  72053. /**
  72054. * the first navmesh created. We might extend this to support multiple navmeshes
  72055. */
  72056. navMesh: any;
  72057. /**
  72058. * Initializes the recastJS plugin
  72059. * @param recastInjection can be used to inject your own recast reference
  72060. */
  72061. constructor(recastInjection?: any);
  72062. /**
  72063. * Creates a navigation mesh
  72064. * @param meshes array of all the geometry used to compute the navigatio mesh
  72065. * @param parameters bunch of parameters used to filter geometry
  72066. */
  72067. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  72068. /**
  72069. * Create a navigation mesh debug mesh
  72070. * @param scene is where the mesh will be added
  72071. * @returns debug display mesh
  72072. */
  72073. createDebugNavMesh(scene: Scene): Mesh;
  72074. /**
  72075. * Get a navigation mesh constrained position, closest to the parameter position
  72076. * @param position world position
  72077. * @returns the closest point to position constrained by the navigation mesh
  72078. */
  72079. getClosestPoint(position: Vector3): Vector3;
  72080. /**
  72081. * Get a navigation mesh constrained position, closest to the parameter position
  72082. * @param position world position
  72083. * @param result output the closest point to position constrained by the navigation mesh
  72084. */
  72085. getClosestPointToRef(position: Vector3, result: Vector3): void;
  72086. /**
  72087. * Get a navigation mesh constrained position, within a particular radius
  72088. * @param position world position
  72089. * @param maxRadius the maximum distance to the constrained world position
  72090. * @returns the closest point to position constrained by the navigation mesh
  72091. */
  72092. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  72093. /**
  72094. * Get a navigation mesh constrained position, within a particular radius
  72095. * @param position world position
  72096. * @param maxRadius the maximum distance to the constrained world position
  72097. * @param result output the closest point to position constrained by the navigation mesh
  72098. */
  72099. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  72100. /**
  72101. * Compute the final position from a segment made of destination-position
  72102. * @param position world position
  72103. * @param destination world position
  72104. * @returns the resulting point along the navmesh
  72105. */
  72106. moveAlong(position: Vector3, destination: Vector3): Vector3;
  72107. /**
  72108. * Compute the final position from a segment made of destination-position
  72109. * @param position world position
  72110. * @param destination world position
  72111. * @param result output the resulting point along the navmesh
  72112. */
  72113. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  72114. /**
  72115. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  72116. * @param start world position
  72117. * @param end world position
  72118. * @returns array containing world position composing the path
  72119. */
  72120. computePath(start: Vector3, end: Vector3): Vector3[];
  72121. /**
  72122. * Create a new Crowd so you can add agents
  72123. * @param maxAgents the maximum agent count in the crowd
  72124. * @param maxAgentRadius the maximum radius an agent can have
  72125. * @param scene to attach the crowd to
  72126. * @returns the crowd you can add agents to
  72127. */
  72128. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  72129. /**
  72130. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72131. * The queries will try to find a solution within those bounds
  72132. * default is (1,1,1)
  72133. * @param extent x,y,z value that define the extent around the queries point of reference
  72134. */
  72135. setDefaultQueryExtent(extent: Vector3): void;
  72136. /**
  72137. * Get the Bounding box extent specified by setDefaultQueryExtent
  72138. * @returns the box extent values
  72139. */
  72140. getDefaultQueryExtent(): Vector3;
  72141. /**
  72142. * build the navmesh from a previously saved state using getNavmeshData
  72143. * @param data the Uint8Array returned by getNavmeshData
  72144. */
  72145. buildFromNavmeshData(data: Uint8Array): void;
  72146. /**
  72147. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  72148. * @returns data the Uint8Array that can be saved and reused
  72149. */
  72150. getNavmeshData(): Uint8Array;
  72151. /**
  72152. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72153. * @param result output the box extent values
  72154. */
  72155. getDefaultQueryExtentToRef(result: Vector3): void;
  72156. /**
  72157. * Disposes
  72158. */
  72159. dispose(): void;
  72160. /**
  72161. * If this plugin is supported
  72162. * @returns true if plugin is supported
  72163. */
  72164. isSupported(): boolean;
  72165. }
  72166. /**
  72167. * Recast detour crowd implementation
  72168. */
  72169. export class RecastJSCrowd implements ICrowd {
  72170. /**
  72171. * Recast/detour plugin
  72172. */
  72173. bjsRECASTPlugin: RecastJSPlugin;
  72174. /**
  72175. * Link to the detour crowd
  72176. */
  72177. recastCrowd: any;
  72178. /**
  72179. * One transform per agent
  72180. */
  72181. transforms: TransformNode[];
  72182. /**
  72183. * All agents created
  72184. */
  72185. agents: number[];
  72186. /**
  72187. * Link to the scene is kept to unregister the crowd from the scene
  72188. */
  72189. private _scene;
  72190. /**
  72191. * Observer for crowd updates
  72192. */
  72193. private _onBeforeAnimationsObserver;
  72194. /**
  72195. * Constructor
  72196. * @param plugin recastJS plugin
  72197. * @param maxAgents the maximum agent count in the crowd
  72198. * @param maxAgentRadius the maximum radius an agent can have
  72199. * @param scene to attach the crowd to
  72200. * @returns the crowd you can add agents to
  72201. */
  72202. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  72203. /**
  72204. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  72205. * You can attach anything to that node. The node position is updated in the scene update tick.
  72206. * @param pos world position that will be constrained by the navigation mesh
  72207. * @param parameters agent parameters
  72208. * @param transform hooked to the agent that will be update by the scene
  72209. * @returns agent index
  72210. */
  72211. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  72212. /**
  72213. * Returns the agent position in world space
  72214. * @param index agent index returned by addAgent
  72215. * @returns world space position
  72216. */
  72217. getAgentPosition(index: number): Vector3;
  72218. /**
  72219. * Returns the agent position result in world space
  72220. * @param index agent index returned by addAgent
  72221. * @param result output world space position
  72222. */
  72223. getAgentPositionToRef(index: number, result: Vector3): void;
  72224. /**
  72225. * Returns the agent velocity in world space
  72226. * @param index agent index returned by addAgent
  72227. * @returns world space velocity
  72228. */
  72229. getAgentVelocity(index: number): Vector3;
  72230. /**
  72231. * Returns the agent velocity result in world space
  72232. * @param index agent index returned by addAgent
  72233. * @param result output world space velocity
  72234. */
  72235. getAgentVelocityToRef(index: number, result: Vector3): void;
  72236. /**
  72237. * Returns the agent next target point on the path
  72238. * @param index agent index returned by addAgent
  72239. * @returns world space position
  72240. */
  72241. getAgentNextTargetPath(index: number): Vector3;
  72242. /**
  72243. * Returns the agent next target point on the path
  72244. * @param index agent index returned by addAgent
  72245. * @param result output world space position
  72246. */
  72247. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  72248. /**
  72249. * Gets the agent state
  72250. * @param index agent index returned by addAgent
  72251. * @returns agent state
  72252. */
  72253. getAgentState(index: number): number;
  72254. /**
  72255. * returns true if the agent in over an off mesh link connection
  72256. * @param index agent index returned by addAgent
  72257. * @returns true if over an off mesh link connection
  72258. */
  72259. overOffmeshConnection(index: number): boolean;
  72260. /**
  72261. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  72262. * @param index agent index returned by addAgent
  72263. * @param destination targeted world position
  72264. */
  72265. agentGoto(index: number, destination: Vector3): void;
  72266. /**
  72267. * Teleport the agent to a new position
  72268. * @param index agent index returned by addAgent
  72269. * @param destination targeted world position
  72270. */
  72271. agentTeleport(index: number, destination: Vector3): void;
  72272. /**
  72273. * Update agent parameters
  72274. * @param index agent index returned by addAgent
  72275. * @param parameters agent parameters
  72276. */
  72277. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  72278. /**
  72279. * remove a particular agent previously created
  72280. * @param index agent index returned by addAgent
  72281. */
  72282. removeAgent(index: number): void;
  72283. /**
  72284. * get the list of all agents attached to this crowd
  72285. * @returns list of agent indices
  72286. */
  72287. getAgents(): number[];
  72288. /**
  72289. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  72290. * @param deltaTime in seconds
  72291. */
  72292. update(deltaTime: number): void;
  72293. /**
  72294. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72295. * The queries will try to find a solution within those bounds
  72296. * default is (1,1,1)
  72297. * @param extent x,y,z value that define the extent around the queries point of reference
  72298. */
  72299. setDefaultQueryExtent(extent: Vector3): void;
  72300. /**
  72301. * Get the Bounding box extent specified by setDefaultQueryExtent
  72302. * @returns the box extent values
  72303. */
  72304. getDefaultQueryExtent(): Vector3;
  72305. /**
  72306. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72307. * @param result output the box extent values
  72308. */
  72309. getDefaultQueryExtentToRef(result: Vector3): void;
  72310. /**
  72311. * Release all resources
  72312. */
  72313. dispose(): void;
  72314. }
  72315. }
  72316. declare module "babylonjs/Navigation/Plugins/index" {
  72317. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  72318. }
  72319. declare module "babylonjs/Navigation/index" {
  72320. export * from "babylonjs/Navigation/INavigationEngine";
  72321. export * from "babylonjs/Navigation/Plugins/index";
  72322. }
  72323. declare module "babylonjs/Offline/database" {
  72324. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  72325. /**
  72326. * Class used to enable access to IndexedDB
  72327. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  72328. */
  72329. export class Database implements IOfflineProvider {
  72330. private _callbackManifestChecked;
  72331. private _currentSceneUrl;
  72332. private _db;
  72333. private _enableSceneOffline;
  72334. private _enableTexturesOffline;
  72335. private _manifestVersionFound;
  72336. private _mustUpdateRessources;
  72337. private _hasReachedQuota;
  72338. private _isSupported;
  72339. private _idbFactory;
  72340. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  72341. private static IsUASupportingBlobStorage;
  72342. /**
  72343. * Gets a boolean indicating if Database storate is enabled (off by default)
  72344. */
  72345. static IDBStorageEnabled: boolean;
  72346. /**
  72347. * Gets a boolean indicating if scene must be saved in the database
  72348. */
  72349. get enableSceneOffline(): boolean;
  72350. /**
  72351. * Gets a boolean indicating if textures must be saved in the database
  72352. */
  72353. get enableTexturesOffline(): boolean;
  72354. /**
  72355. * Creates a new Database
  72356. * @param urlToScene defines the url to load the scene
  72357. * @param callbackManifestChecked defines the callback to use when manifest is checked
  72358. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  72359. */
  72360. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  72361. private static _ParseURL;
  72362. private static _ReturnFullUrlLocation;
  72363. private _checkManifestFile;
  72364. /**
  72365. * Open the database and make it available
  72366. * @param successCallback defines the callback to call on success
  72367. * @param errorCallback defines the callback to call on error
  72368. */
  72369. open(successCallback: () => void, errorCallback: () => void): void;
  72370. /**
  72371. * Loads an image from the database
  72372. * @param url defines the url to load from
  72373. * @param image defines the target DOM image
  72374. */
  72375. loadImage(url: string, image: HTMLImageElement): void;
  72376. private _loadImageFromDBAsync;
  72377. private _saveImageIntoDBAsync;
  72378. private _checkVersionFromDB;
  72379. private _loadVersionFromDBAsync;
  72380. private _saveVersionIntoDBAsync;
  72381. /**
  72382. * Loads a file from database
  72383. * @param url defines the URL to load from
  72384. * @param sceneLoaded defines a callback to call on success
  72385. * @param progressCallBack defines a callback to call when progress changed
  72386. * @param errorCallback defines a callback to call on error
  72387. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  72388. */
  72389. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  72390. private _loadFileAsync;
  72391. private _saveFileAsync;
  72392. /**
  72393. * Validates if xhr data is correct
  72394. * @param xhr defines the request to validate
  72395. * @param dataType defines the expected data type
  72396. * @returns true if data is correct
  72397. */
  72398. private static _ValidateXHRData;
  72399. }
  72400. }
  72401. declare module "babylonjs/Offline/index" {
  72402. export * from "babylonjs/Offline/database";
  72403. export * from "babylonjs/Offline/IOfflineProvider";
  72404. }
  72405. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  72406. /** @hidden */
  72407. export var gpuUpdateParticlesPixelShader: {
  72408. name: string;
  72409. shader: string;
  72410. };
  72411. }
  72412. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  72413. /** @hidden */
  72414. export var gpuUpdateParticlesVertexShader: {
  72415. name: string;
  72416. shader: string;
  72417. };
  72418. }
  72419. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  72420. /** @hidden */
  72421. export var clipPlaneFragmentDeclaration2: {
  72422. name: string;
  72423. shader: string;
  72424. };
  72425. }
  72426. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  72427. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  72428. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  72429. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72430. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  72431. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  72432. /** @hidden */
  72433. export var gpuRenderParticlesPixelShader: {
  72434. name: string;
  72435. shader: string;
  72436. };
  72437. }
  72438. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  72439. /** @hidden */
  72440. export var clipPlaneVertexDeclaration2: {
  72441. name: string;
  72442. shader: string;
  72443. };
  72444. }
  72445. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  72446. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  72447. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  72448. /** @hidden */
  72449. export var gpuRenderParticlesVertexShader: {
  72450. name: string;
  72451. shader: string;
  72452. };
  72453. }
  72454. declare module "babylonjs/Particles/gpuParticleSystem" {
  72455. import { Nullable } from "babylonjs/types";
  72456. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  72457. import { Observable } from "babylonjs/Misc/observable";
  72458. import { Matrix } from "babylonjs/Maths/math.vector";
  72459. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  72460. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72461. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  72462. import { IDisposable } from "babylonjs/scene";
  72463. import { Effect } from "babylonjs/Materials/effect";
  72464. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  72465. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72466. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  72467. import { Scene } from "babylonjs/scene";
  72468. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  72469. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  72470. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  72471. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  72472. /**
  72473. * This represents a GPU particle system in Babylon
  72474. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  72475. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  72476. */
  72477. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  72478. /**
  72479. * The layer mask we are rendering the particles through.
  72480. */
  72481. layerMask: number;
  72482. private _capacity;
  72483. private _activeCount;
  72484. private _currentActiveCount;
  72485. private _accumulatedCount;
  72486. private _renderEffect;
  72487. private _updateEffect;
  72488. private _buffer0;
  72489. private _buffer1;
  72490. private _spriteBuffer;
  72491. private _updateVAO;
  72492. private _renderVAO;
  72493. private _targetIndex;
  72494. private _sourceBuffer;
  72495. private _targetBuffer;
  72496. private _currentRenderId;
  72497. private _started;
  72498. private _stopped;
  72499. private _timeDelta;
  72500. private _randomTexture;
  72501. private _randomTexture2;
  72502. private _attributesStrideSize;
  72503. private _updateEffectOptions;
  72504. private _randomTextureSize;
  72505. private _actualFrame;
  72506. private _customEffect;
  72507. private readonly _rawTextureWidth;
  72508. /**
  72509. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  72510. */
  72511. static get IsSupported(): boolean;
  72512. /**
  72513. * An event triggered when the system is disposed.
  72514. */
  72515. onDisposeObservable: Observable<IParticleSystem>;
  72516. /**
  72517. * An event triggered when the system is stopped
  72518. */
  72519. onStoppedObservable: Observable<IParticleSystem>;
  72520. /**
  72521. * Gets the maximum number of particles active at the same time.
  72522. * @returns The max number of active particles.
  72523. */
  72524. getCapacity(): number;
  72525. /**
  72526. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72527. * to override the particles.
  72528. */
  72529. forceDepthWrite: boolean;
  72530. /**
  72531. * Gets or set the number of active particles
  72532. */
  72533. get activeParticleCount(): number;
  72534. set activeParticleCount(value: number);
  72535. private _preWarmDone;
  72536. /**
  72537. * Specifies if the particles are updated in emitter local space or world space.
  72538. */
  72539. isLocal: boolean;
  72540. /** Gets or sets a matrix to use to compute projection */
  72541. defaultProjectionMatrix: Matrix;
  72542. /**
  72543. * Is this system ready to be used/rendered
  72544. * @return true if the system is ready
  72545. */
  72546. isReady(): boolean;
  72547. /**
  72548. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72549. * @returns True if it has been started, otherwise false.
  72550. */
  72551. isStarted(): boolean;
  72552. /**
  72553. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  72554. * @returns True if it has been stopped, otherwise false.
  72555. */
  72556. isStopped(): boolean;
  72557. /**
  72558. * Gets a boolean indicating that the system is stopping
  72559. * @returns true if the system is currently stopping
  72560. */
  72561. isStopping(): boolean;
  72562. /**
  72563. * Gets the number of particles active at the same time.
  72564. * @returns The number of active particles.
  72565. */
  72566. getActiveCount(): number;
  72567. /**
  72568. * Starts the particle system and begins to emit
  72569. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72570. */
  72571. start(delay?: number): void;
  72572. /**
  72573. * Stops the particle system.
  72574. */
  72575. stop(): void;
  72576. /**
  72577. * Remove all active particles
  72578. */
  72579. reset(): void;
  72580. /**
  72581. * Returns the string "GPUParticleSystem"
  72582. * @returns a string containing the class name
  72583. */
  72584. getClassName(): string;
  72585. /**
  72586. * Gets the custom effect used to render the particles
  72587. * @param blendMode Blend mode for which the effect should be retrieved
  72588. * @returns The effect
  72589. */
  72590. getCustomEffect(blendMode?: number): Nullable<Effect>;
  72591. /**
  72592. * Sets the custom effect used to render the particles
  72593. * @param effect The effect to set
  72594. * @param blendMode Blend mode for which the effect should be set
  72595. */
  72596. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  72597. /** @hidden */
  72598. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  72599. /**
  72600. * Observable that will be called just before the particles are drawn
  72601. */
  72602. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  72603. /**
  72604. * Gets the name of the particle vertex shader
  72605. */
  72606. get vertexShaderName(): string;
  72607. private _colorGradientsTexture;
  72608. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  72609. /**
  72610. * Adds a new color gradient
  72611. * @param gradient defines the gradient to use (between 0 and 1)
  72612. * @param color1 defines the color to affect to the specified gradient
  72613. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72614. * @returns the current particle system
  72615. */
  72616. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  72617. private _refreshColorGradient;
  72618. /** Force the system to rebuild all gradients that need to be resync */
  72619. forceRefreshGradients(): void;
  72620. /**
  72621. * Remove a specific color gradient
  72622. * @param gradient defines the gradient to remove
  72623. * @returns the current particle system
  72624. */
  72625. removeColorGradient(gradient: number): GPUParticleSystem;
  72626. private _angularSpeedGradientsTexture;
  72627. private _sizeGradientsTexture;
  72628. private _velocityGradientsTexture;
  72629. private _limitVelocityGradientsTexture;
  72630. private _dragGradientsTexture;
  72631. private _addFactorGradient;
  72632. /**
  72633. * Adds a new size gradient
  72634. * @param gradient defines the gradient to use (between 0 and 1)
  72635. * @param factor defines the size factor to affect to the specified gradient
  72636. * @returns the current particle system
  72637. */
  72638. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72639. /**
  72640. * Remove a specific size gradient
  72641. * @param gradient defines the gradient to remove
  72642. * @returns the current particle system
  72643. */
  72644. removeSizeGradient(gradient: number): GPUParticleSystem;
  72645. private _refreshFactorGradient;
  72646. /**
  72647. * Adds a new angular speed gradient
  72648. * @param gradient defines the gradient to use (between 0 and 1)
  72649. * @param factor defines the angular speed to affect to the specified gradient
  72650. * @returns the current particle system
  72651. */
  72652. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72653. /**
  72654. * Remove a specific angular speed gradient
  72655. * @param gradient defines the gradient to remove
  72656. * @returns the current particle system
  72657. */
  72658. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72659. /**
  72660. * Adds a new velocity gradient
  72661. * @param gradient defines the gradient to use (between 0 and 1)
  72662. * @param factor defines the velocity to affect to the specified gradient
  72663. * @returns the current particle system
  72664. */
  72665. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72666. /**
  72667. * Remove a specific velocity gradient
  72668. * @param gradient defines the gradient to remove
  72669. * @returns the current particle system
  72670. */
  72671. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72672. /**
  72673. * Adds a new limit velocity gradient
  72674. * @param gradient defines the gradient to use (between 0 and 1)
  72675. * @param factor defines the limit velocity value to affect to the specified gradient
  72676. * @returns the current particle system
  72677. */
  72678. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72679. /**
  72680. * Remove a specific limit velocity gradient
  72681. * @param gradient defines the gradient to remove
  72682. * @returns the current particle system
  72683. */
  72684. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72685. /**
  72686. * Adds a new drag gradient
  72687. * @param gradient defines the gradient to use (between 0 and 1)
  72688. * @param factor defines the drag value to affect to the specified gradient
  72689. * @returns the current particle system
  72690. */
  72691. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72692. /**
  72693. * Remove a specific drag gradient
  72694. * @param gradient defines the gradient to remove
  72695. * @returns the current particle system
  72696. */
  72697. removeDragGradient(gradient: number): GPUParticleSystem;
  72698. /**
  72699. * Not supported by GPUParticleSystem
  72700. * @param gradient defines the gradient to use (between 0 and 1)
  72701. * @param factor defines the emit rate value to affect to the specified gradient
  72702. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72703. * @returns the current particle system
  72704. */
  72705. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72706. /**
  72707. * Not supported by GPUParticleSystem
  72708. * @param gradient defines the gradient to remove
  72709. * @returns the current particle system
  72710. */
  72711. removeEmitRateGradient(gradient: number): IParticleSystem;
  72712. /**
  72713. * Not supported by GPUParticleSystem
  72714. * @param gradient defines the gradient to use (between 0 and 1)
  72715. * @param factor defines the start size value to affect to the specified gradient
  72716. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72717. * @returns the current particle system
  72718. */
  72719. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72720. /**
  72721. * Not supported by GPUParticleSystem
  72722. * @param gradient defines the gradient to remove
  72723. * @returns the current particle system
  72724. */
  72725. removeStartSizeGradient(gradient: number): IParticleSystem;
  72726. /**
  72727. * Not supported by GPUParticleSystem
  72728. * @param gradient defines the gradient to use (between 0 and 1)
  72729. * @param min defines the color remap minimal range
  72730. * @param max defines the color remap maximal range
  72731. * @returns the current particle system
  72732. */
  72733. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72734. /**
  72735. * Not supported by GPUParticleSystem
  72736. * @param gradient defines the gradient to remove
  72737. * @returns the current particle system
  72738. */
  72739. removeColorRemapGradient(): IParticleSystem;
  72740. /**
  72741. * Not supported by GPUParticleSystem
  72742. * @param gradient defines the gradient to use (between 0 and 1)
  72743. * @param min defines the alpha remap minimal range
  72744. * @param max defines the alpha remap maximal range
  72745. * @returns the current particle system
  72746. */
  72747. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72748. /**
  72749. * Not supported by GPUParticleSystem
  72750. * @param gradient defines the gradient to remove
  72751. * @returns the current particle system
  72752. */
  72753. removeAlphaRemapGradient(): IParticleSystem;
  72754. /**
  72755. * Not supported by GPUParticleSystem
  72756. * @param gradient defines the gradient to use (between 0 and 1)
  72757. * @param color defines the color to affect to the specified gradient
  72758. * @returns the current particle system
  72759. */
  72760. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72761. /**
  72762. * Not supported by GPUParticleSystem
  72763. * @param gradient defines the gradient to remove
  72764. * @returns the current particle system
  72765. */
  72766. removeRampGradient(): IParticleSystem;
  72767. /**
  72768. * Not supported by GPUParticleSystem
  72769. * @returns the list of ramp gradients
  72770. */
  72771. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72772. /**
  72773. * Not supported by GPUParticleSystem
  72774. * Gets or sets a boolean indicating that ramp gradients must be used
  72775. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72776. */
  72777. get useRampGradients(): boolean;
  72778. set useRampGradients(value: boolean);
  72779. /**
  72780. * Not supported by GPUParticleSystem
  72781. * @param gradient defines the gradient to use (between 0 and 1)
  72782. * @param factor defines the life time factor to affect to the specified gradient
  72783. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72784. * @returns the current particle system
  72785. */
  72786. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72787. /**
  72788. * Not supported by GPUParticleSystem
  72789. * @param gradient defines the gradient to remove
  72790. * @returns the current particle system
  72791. */
  72792. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72793. /**
  72794. * Instantiates a GPU particle system.
  72795. * 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.
  72796. * @param name The name of the particle system
  72797. * @param options The options used to create the system
  72798. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72799. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72800. * @param customEffect a custom effect used to change the way particles are rendered by default
  72801. */
  72802. constructor(name: string, options: Partial<{
  72803. capacity: number;
  72804. randomTextureSize: number;
  72805. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72806. protected _reset(): void;
  72807. private _createUpdateVAO;
  72808. private _createRenderVAO;
  72809. private _initialize;
  72810. /** @hidden */
  72811. _recreateUpdateEffect(): void;
  72812. private _getEffect;
  72813. /**
  72814. * Fill the defines array according to the current settings of the particle system
  72815. * @param defines Array to be updated
  72816. * @param blendMode blend mode to take into account when updating the array
  72817. */
  72818. fillDefines(defines: Array<string>, blendMode?: number): void;
  72819. /**
  72820. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72821. * @param uniforms Uniforms array to fill
  72822. * @param attributes Attributes array to fill
  72823. * @param samplers Samplers array to fill
  72824. */
  72825. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72826. /** @hidden */
  72827. _recreateRenderEffect(): Effect;
  72828. /**
  72829. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72830. * @param preWarm defines if we are in the pre-warmimg phase
  72831. */
  72832. animate(preWarm?: boolean): void;
  72833. private _createFactorGradientTexture;
  72834. private _createSizeGradientTexture;
  72835. private _createAngularSpeedGradientTexture;
  72836. private _createVelocityGradientTexture;
  72837. private _createLimitVelocityGradientTexture;
  72838. private _createDragGradientTexture;
  72839. private _createColorGradientTexture;
  72840. /**
  72841. * Renders the particle system in its current state
  72842. * @param preWarm defines if the system should only update the particles but not render them
  72843. * @returns the current number of particles
  72844. */
  72845. render(preWarm?: boolean): number;
  72846. /**
  72847. * Rebuilds the particle system
  72848. */
  72849. rebuild(): void;
  72850. private _releaseBuffers;
  72851. private _releaseVAOs;
  72852. /**
  72853. * Disposes the particle system and free the associated resources
  72854. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72855. */
  72856. dispose(disposeTexture?: boolean): void;
  72857. /**
  72858. * Clones the particle system.
  72859. * @param name The name of the cloned object
  72860. * @param newEmitter The new emitter to use
  72861. * @returns the cloned particle system
  72862. */
  72863. clone(name: string, newEmitter: any): GPUParticleSystem;
  72864. /**
  72865. * Serializes the particle system to a JSON object
  72866. * @param serializeTexture defines if the texture must be serialized as well
  72867. * @returns the JSON object
  72868. */
  72869. serialize(serializeTexture?: boolean): any;
  72870. /**
  72871. * Parses a JSON object to create a GPU particle system.
  72872. * @param parsedParticleSystem The JSON object to parse
  72873. * @param sceneOrEngine The scene or the engine to create the particle system in
  72874. * @param rootUrl The root url to use to load external dependencies like texture
  72875. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72876. * @returns the parsed GPU particle system
  72877. */
  72878. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72879. }
  72880. }
  72881. declare module "babylonjs/Particles/particleSystemSet" {
  72882. import { Nullable } from "babylonjs/types";
  72883. import { Color3 } from "babylonjs/Maths/math.color";
  72884. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72886. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72887. import { Scene, IDisposable } from "babylonjs/scene";
  72888. /**
  72889. * Represents a set of particle systems working together to create a specific effect
  72890. */
  72891. export class ParticleSystemSet implements IDisposable {
  72892. /**
  72893. * Gets or sets base Assets URL
  72894. */
  72895. static BaseAssetsUrl: string;
  72896. private _emitterCreationOptions;
  72897. private _emitterNode;
  72898. /**
  72899. * Gets the particle system list
  72900. */
  72901. systems: IParticleSystem[];
  72902. /**
  72903. * Gets the emitter node used with this set
  72904. */
  72905. get emitterNode(): Nullable<TransformNode>;
  72906. /**
  72907. * Creates a new emitter mesh as a sphere
  72908. * @param options defines the options used to create the sphere
  72909. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72910. * @param scene defines the hosting scene
  72911. */
  72912. setEmitterAsSphere(options: {
  72913. diameter: number;
  72914. segments: number;
  72915. color: Color3;
  72916. }, renderingGroupId: number, scene: Scene): void;
  72917. /**
  72918. * Starts all particle systems of the set
  72919. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72920. */
  72921. start(emitter?: AbstractMesh): void;
  72922. /**
  72923. * Release all associated resources
  72924. */
  72925. dispose(): void;
  72926. /**
  72927. * Serialize the set into a JSON compatible object
  72928. * @param serializeTexture defines if the texture must be serialized as well
  72929. * @returns a JSON compatible representation of the set
  72930. */
  72931. serialize(serializeTexture?: boolean): any;
  72932. /**
  72933. * Parse a new ParticleSystemSet from a serialized source
  72934. * @param data defines a JSON compatible representation of the set
  72935. * @param scene defines the hosting scene
  72936. * @param gpu defines if we want GPU particles or CPU particles
  72937. * @returns a new ParticleSystemSet
  72938. */
  72939. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72940. }
  72941. }
  72942. declare module "babylonjs/Particles/particleHelper" {
  72943. import { Nullable } from "babylonjs/types";
  72944. import { Scene } from "babylonjs/scene";
  72945. import { Vector3 } from "babylonjs/Maths/math.vector";
  72946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72947. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72948. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  72949. /**
  72950. * This class is made for on one-liner static method to help creating particle system set.
  72951. */
  72952. export class ParticleHelper {
  72953. /**
  72954. * Gets or sets base Assets URL
  72955. */
  72956. static BaseAssetsUrl: string;
  72957. /** Define the Url to load snippets */
  72958. static SnippetUrl: string;
  72959. /**
  72960. * Create a default particle system that you can tweak
  72961. * @param emitter defines the emitter to use
  72962. * @param capacity defines the system capacity (default is 500 particles)
  72963. * @param scene defines the hosting scene
  72964. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72965. * @returns the new Particle system
  72966. */
  72967. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72968. /**
  72969. * This is the main static method (one-liner) of this helper to create different particle systems
  72970. * @param type This string represents the type to the particle system to create
  72971. * @param scene The scene where the particle system should live
  72972. * @param gpu If the system will use gpu
  72973. * @returns the ParticleSystemSet created
  72974. */
  72975. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72976. /**
  72977. * Static function used to export a particle system to a ParticleSystemSet variable.
  72978. * Please note that the emitter shape is not exported
  72979. * @param systems defines the particle systems to export
  72980. * @returns the created particle system set
  72981. */
  72982. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72983. /**
  72984. * Creates a particle system from a snippet saved in a remote file
  72985. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72986. * @param url defines the url to load from
  72987. * @param scene defines the hosting scene
  72988. * @param gpu If the system will use gpu
  72989. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72990. * @returns a promise that will resolve to the new particle system
  72991. */
  72992. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72993. /**
  72994. * Creates a particle system from a snippet saved by the particle system editor
  72995. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72996. * @param scene defines the hosting scene
  72997. * @param gpu If the system will use gpu
  72998. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72999. * @returns a promise that will resolve to the new particle system
  73000. */
  73001. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  73002. }
  73003. }
  73004. declare module "babylonjs/Particles/particleSystemComponent" {
  73005. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  73006. import { Effect } from "babylonjs/Materials/effect";
  73007. import "babylonjs/Shaders/particles.vertex";
  73008. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  73009. module "babylonjs/Engines/engine" {
  73010. interface Engine {
  73011. /**
  73012. * Create an effect to use with particle systems.
  73013. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  73014. * the particle system for which you want to create a custom effect in the last parameter
  73015. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  73016. * @param uniformsNames defines a list of attribute names
  73017. * @param samplers defines an array of string used to represent textures
  73018. * @param defines defines the string containing the defines to use to compile the shaders
  73019. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  73020. * @param onCompiled defines a function to call when the effect creation is successful
  73021. * @param onError defines a function to call when the effect creation has failed
  73022. * @param particleSystem the particle system you want to create the effect for
  73023. * @returns the new Effect
  73024. */
  73025. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  73026. }
  73027. }
  73028. module "babylonjs/Meshes/mesh" {
  73029. interface Mesh {
  73030. /**
  73031. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  73032. * @returns an array of IParticleSystem
  73033. */
  73034. getEmittedParticleSystems(): IParticleSystem[];
  73035. /**
  73036. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  73037. * @returns an array of IParticleSystem
  73038. */
  73039. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  73040. }
  73041. }
  73042. }
  73043. declare module "babylonjs/Particles/pointsCloudSystem" {
  73044. import { Color4 } from "babylonjs/Maths/math";
  73045. import { Mesh } from "babylonjs/Meshes/mesh";
  73046. import { Scene, IDisposable } from "babylonjs/scene";
  73047. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  73048. /** Defines the 4 color options */
  73049. export enum PointColor {
  73050. /** color value */
  73051. Color = 2,
  73052. /** uv value */
  73053. UV = 1,
  73054. /** random value */
  73055. Random = 0,
  73056. /** stated value */
  73057. Stated = 3
  73058. }
  73059. /**
  73060. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  73061. * 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.
  73062. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  73063. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  73064. *
  73065. * Full documentation here : TO BE ENTERED
  73066. */
  73067. export class PointsCloudSystem implements IDisposable {
  73068. /**
  73069. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  73070. * Example : var p = SPS.particles[i];
  73071. */
  73072. particles: CloudPoint[];
  73073. /**
  73074. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  73075. */
  73076. nbParticles: number;
  73077. /**
  73078. * This a counter for your own usage. It's not set by any SPS functions.
  73079. */
  73080. counter: number;
  73081. /**
  73082. * The PCS name. This name is also given to the underlying mesh.
  73083. */
  73084. name: string;
  73085. /**
  73086. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  73087. */
  73088. mesh: Mesh;
  73089. /**
  73090. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  73091. * Please read :
  73092. */
  73093. vars: any;
  73094. /**
  73095. * @hidden
  73096. */
  73097. _size: number;
  73098. private _scene;
  73099. private _promises;
  73100. private _positions;
  73101. private _indices;
  73102. private _normals;
  73103. private _colors;
  73104. private _uvs;
  73105. private _indices32;
  73106. private _positions32;
  73107. private _colors32;
  73108. private _uvs32;
  73109. private _updatable;
  73110. private _isVisibilityBoxLocked;
  73111. private _alwaysVisible;
  73112. private _groups;
  73113. private _groupCounter;
  73114. private _computeParticleColor;
  73115. private _computeParticleTexture;
  73116. private _computeParticleRotation;
  73117. private _computeBoundingBox;
  73118. private _isReady;
  73119. /**
  73120. * Creates a PCS (Points Cloud System) object
  73121. * @param name (String) is the PCS name, this will be the underlying mesh name
  73122. * @param pointSize (number) is the size for each point
  73123. * @param scene (Scene) is the scene in which the PCS is added
  73124. * @param options defines the options of the PCS e.g.
  73125. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  73126. */
  73127. constructor(name: string, pointSize: number, scene: Scene, options?: {
  73128. updatable?: boolean;
  73129. });
  73130. /**
  73131. * Builds the PCS underlying mesh. Returns a standard Mesh.
  73132. * If no points were added to the PCS, the returned mesh is just a single point.
  73133. * @returns a promise for the created mesh
  73134. */
  73135. buildMeshAsync(): Promise<Mesh>;
  73136. /**
  73137. * @hidden
  73138. */
  73139. private _buildMesh;
  73140. private _addParticle;
  73141. private _randomUnitVector;
  73142. private _getColorIndicesForCoord;
  73143. private _setPointsColorOrUV;
  73144. private _colorFromTexture;
  73145. private _calculateDensity;
  73146. /**
  73147. * Adds points to the PCS in random positions within a unit sphere
  73148. * @param nb (positive integer) the number of particles to be created from this model
  73149. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  73150. * @returns the number of groups in the system
  73151. */
  73152. addPoints(nb: number, pointFunction?: any): number;
  73153. /**
  73154. * Adds points to the PCS from the surface of the model shape
  73155. * @param mesh is any Mesh object that will be used as a surface model for the points
  73156. * @param nb (positive integer) the number of particles to be created from this model
  73157. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73158. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73159. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73160. * @returns the number of groups in the system
  73161. */
  73162. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73163. /**
  73164. * Adds points to the PCS inside the model shape
  73165. * @param mesh is any Mesh object that will be used as a surface model for the points
  73166. * @param nb (positive integer) the number of particles to be created from this model
  73167. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73168. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73169. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73170. * @returns the number of groups in the system
  73171. */
  73172. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73173. /**
  73174. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  73175. * This method calls `updateParticle()` for each particle of the SPS.
  73176. * For an animated SPS, it is usually called within the render loop.
  73177. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  73178. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  73179. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  73180. * @returns the PCS.
  73181. */
  73182. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  73183. /**
  73184. * Disposes the PCS.
  73185. */
  73186. dispose(): void;
  73187. /**
  73188. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  73189. * doc :
  73190. * @returns the PCS.
  73191. */
  73192. refreshVisibleSize(): PointsCloudSystem;
  73193. /**
  73194. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  73195. * @param size the size (float) of the visibility box
  73196. * note : this doesn't lock the PCS mesh bounding box.
  73197. * doc :
  73198. */
  73199. setVisibilityBox(size: number): void;
  73200. /**
  73201. * Gets whether the PCS is always visible or not
  73202. * doc :
  73203. */
  73204. get isAlwaysVisible(): boolean;
  73205. /**
  73206. * Sets the PCS as always visible or not
  73207. * doc :
  73208. */
  73209. set isAlwaysVisible(val: boolean);
  73210. /**
  73211. * Tells to `setParticles()` to compute the particle rotations or not
  73212. * Default value : false. The PCS is faster when it's set to false
  73213. * Note : particle rotations are only applied to parent particles
  73214. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  73215. */
  73216. set computeParticleRotation(val: boolean);
  73217. /**
  73218. * Tells to `setParticles()` to compute the particle colors or not.
  73219. * Default value : true. The PCS is faster when it's set to false.
  73220. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73221. */
  73222. set computeParticleColor(val: boolean);
  73223. set computeParticleTexture(val: boolean);
  73224. /**
  73225. * Gets if `setParticles()` computes the particle colors or not.
  73226. * Default value : false. The PCS is faster when it's set to false.
  73227. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73228. */
  73229. get computeParticleColor(): boolean;
  73230. /**
  73231. * Gets if `setParticles()` computes the particle textures or not.
  73232. * Default value : false. The PCS is faster when it's set to false.
  73233. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  73234. */
  73235. get computeParticleTexture(): boolean;
  73236. /**
  73237. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  73238. */
  73239. set computeBoundingBox(val: boolean);
  73240. /**
  73241. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  73242. */
  73243. get computeBoundingBox(): boolean;
  73244. /**
  73245. * This function does nothing. It may be overwritten to set all the particle first values.
  73246. * The PCS doesn't call this function, you may have to call it by your own.
  73247. * doc :
  73248. */
  73249. initParticles(): void;
  73250. /**
  73251. * This function does nothing. It may be overwritten to recycle a particle
  73252. * The PCS doesn't call this function, you can to call it
  73253. * doc :
  73254. * @param particle The particle to recycle
  73255. * @returns the recycled particle
  73256. */
  73257. recycleParticle(particle: CloudPoint): CloudPoint;
  73258. /**
  73259. * Updates a particle : this function should be overwritten by the user.
  73260. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  73261. * doc :
  73262. * @example : just set a particle position or velocity and recycle conditions
  73263. * @param particle The particle to update
  73264. * @returns the updated particle
  73265. */
  73266. updateParticle(particle: CloudPoint): CloudPoint;
  73267. /**
  73268. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  73269. * This does nothing and may be overwritten by the user.
  73270. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73271. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73272. * @param update the boolean update value actually passed to setParticles()
  73273. */
  73274. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73275. /**
  73276. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  73277. * This will be passed three parameters.
  73278. * This does nothing and may be overwritten by the user.
  73279. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73280. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73281. * @param update the boolean update value actually passed to setParticles()
  73282. */
  73283. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73284. }
  73285. }
  73286. declare module "babylonjs/Particles/cloudPoint" {
  73287. import { Nullable } from "babylonjs/types";
  73288. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  73289. import { Mesh } from "babylonjs/Meshes/mesh";
  73290. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  73291. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  73292. /**
  73293. * Represents one particle of a points cloud system.
  73294. */
  73295. export class CloudPoint {
  73296. /**
  73297. * particle global index
  73298. */
  73299. idx: number;
  73300. /**
  73301. * The color of the particle
  73302. */
  73303. color: Nullable<Color4>;
  73304. /**
  73305. * The world space position of the particle.
  73306. */
  73307. position: Vector3;
  73308. /**
  73309. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  73310. */
  73311. rotation: Vector3;
  73312. /**
  73313. * The world space rotation quaternion of the particle.
  73314. */
  73315. rotationQuaternion: Nullable<Quaternion>;
  73316. /**
  73317. * The uv of the particle.
  73318. */
  73319. uv: Nullable<Vector2>;
  73320. /**
  73321. * The current speed of the particle.
  73322. */
  73323. velocity: Vector3;
  73324. /**
  73325. * The pivot point in the particle local space.
  73326. */
  73327. pivot: Vector3;
  73328. /**
  73329. * Must the particle be translated from its pivot point in its local space ?
  73330. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  73331. * Default : false
  73332. */
  73333. translateFromPivot: boolean;
  73334. /**
  73335. * Index of this particle in the global "positions" array (Internal use)
  73336. * @hidden
  73337. */
  73338. _pos: number;
  73339. /**
  73340. * @hidden Index of this particle in the global "indices" array (Internal use)
  73341. */
  73342. _ind: number;
  73343. /**
  73344. * Group this particle belongs to
  73345. */
  73346. _group: PointsGroup;
  73347. /**
  73348. * Group id of this particle
  73349. */
  73350. groupId: number;
  73351. /**
  73352. * Index of the particle in its group id (Internal use)
  73353. */
  73354. idxInGroup: number;
  73355. /**
  73356. * @hidden Particle BoundingInfo object (Internal use)
  73357. */
  73358. _boundingInfo: BoundingInfo;
  73359. /**
  73360. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  73361. */
  73362. _pcs: PointsCloudSystem;
  73363. /**
  73364. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  73365. */
  73366. _stillInvisible: boolean;
  73367. /**
  73368. * @hidden Last computed particle rotation matrix
  73369. */
  73370. _rotationMatrix: number[];
  73371. /**
  73372. * Parent particle Id, if any.
  73373. * Default null.
  73374. */
  73375. parentId: Nullable<number>;
  73376. /**
  73377. * @hidden Internal global position in the PCS.
  73378. */
  73379. _globalPosition: Vector3;
  73380. /**
  73381. * Creates a Point Cloud object.
  73382. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  73383. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  73384. * @param group (PointsGroup) is the group the particle belongs to
  73385. * @param groupId (integer) is the group identifier in the PCS.
  73386. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  73387. * @param pcs defines the PCS it is associated to
  73388. */
  73389. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  73390. /**
  73391. * get point size
  73392. */
  73393. get size(): Vector3;
  73394. /**
  73395. * Set point size
  73396. */
  73397. set size(scale: Vector3);
  73398. /**
  73399. * Legacy support, changed quaternion to rotationQuaternion
  73400. */
  73401. get quaternion(): Nullable<Quaternion>;
  73402. /**
  73403. * Legacy support, changed quaternion to rotationQuaternion
  73404. */
  73405. set quaternion(q: Nullable<Quaternion>);
  73406. /**
  73407. * Returns a boolean. True if the particle intersects a mesh, else false
  73408. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  73409. * @param target is the object (point or mesh) what the intersection is computed against
  73410. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  73411. * @returns true if it intersects
  73412. */
  73413. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  73414. /**
  73415. * get the rotation matrix of the particle
  73416. * @hidden
  73417. */
  73418. getRotationMatrix(m: Matrix): void;
  73419. }
  73420. /**
  73421. * Represents a group of points in a points cloud system
  73422. * * PCS internal tool, don't use it manually.
  73423. */
  73424. export class PointsGroup {
  73425. /**
  73426. * The group id
  73427. * @hidden
  73428. */
  73429. groupID: number;
  73430. /**
  73431. * image data for group (internal use)
  73432. * @hidden
  73433. */
  73434. _groupImageData: Nullable<ArrayBufferView>;
  73435. /**
  73436. * Image Width (internal use)
  73437. * @hidden
  73438. */
  73439. _groupImgWidth: number;
  73440. /**
  73441. * Image Height (internal use)
  73442. * @hidden
  73443. */
  73444. _groupImgHeight: number;
  73445. /**
  73446. * Custom position function (internal use)
  73447. * @hidden
  73448. */
  73449. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  73450. /**
  73451. * density per facet for surface points
  73452. * @hidden
  73453. */
  73454. _groupDensity: number[];
  73455. /**
  73456. * Only when points are colored by texture carries pointer to texture list array
  73457. * @hidden
  73458. */
  73459. _textureNb: number;
  73460. /**
  73461. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  73462. * PCS internal tool, don't use it manually.
  73463. * @hidden
  73464. */
  73465. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  73466. }
  73467. }
  73468. declare module "babylonjs/Particles/index" {
  73469. export * from "babylonjs/Particles/baseParticleSystem";
  73470. export * from "babylonjs/Particles/EmitterTypes/index";
  73471. export * from "babylonjs/Particles/gpuParticleSystem";
  73472. export * from "babylonjs/Particles/IParticleSystem";
  73473. export * from "babylonjs/Particles/particle";
  73474. export * from "babylonjs/Particles/particleHelper";
  73475. export * from "babylonjs/Particles/particleSystem";
  73476. import "babylonjs/Particles/particleSystemComponent";
  73477. export * from "babylonjs/Particles/particleSystemComponent";
  73478. export * from "babylonjs/Particles/particleSystemSet";
  73479. export * from "babylonjs/Particles/solidParticle";
  73480. export * from "babylonjs/Particles/solidParticleSystem";
  73481. export * from "babylonjs/Particles/cloudPoint";
  73482. export * from "babylonjs/Particles/pointsCloudSystem";
  73483. export * from "babylonjs/Particles/subEmitter";
  73484. }
  73485. declare module "babylonjs/Physics/physicsEngineComponent" {
  73486. import { Nullable } from "babylonjs/types";
  73487. import { Observable, Observer } from "babylonjs/Misc/observable";
  73488. import { Vector3 } from "babylonjs/Maths/math.vector";
  73489. import { Mesh } from "babylonjs/Meshes/mesh";
  73490. import { ISceneComponent } from "babylonjs/sceneComponent";
  73491. import { Scene } from "babylonjs/scene";
  73492. import { Node } from "babylonjs/node";
  73493. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  73494. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73495. module "babylonjs/scene" {
  73496. interface Scene {
  73497. /** @hidden (Backing field) */
  73498. _physicsEngine: Nullable<IPhysicsEngine>;
  73499. /** @hidden */
  73500. _physicsTimeAccumulator: number;
  73501. /**
  73502. * Gets the current physics engine
  73503. * @returns a IPhysicsEngine or null if none attached
  73504. */
  73505. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  73506. /**
  73507. * Enables physics to the current scene
  73508. * @param gravity defines the scene's gravity for the physics engine
  73509. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  73510. * @return a boolean indicating if the physics engine was initialized
  73511. */
  73512. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  73513. /**
  73514. * Disables and disposes the physics engine associated with the scene
  73515. */
  73516. disablePhysicsEngine(): void;
  73517. /**
  73518. * Gets a boolean indicating if there is an active physics engine
  73519. * @returns a boolean indicating if there is an active physics engine
  73520. */
  73521. isPhysicsEnabled(): boolean;
  73522. /**
  73523. * Deletes a physics compound impostor
  73524. * @param compound defines the compound to delete
  73525. */
  73526. deleteCompoundImpostor(compound: any): void;
  73527. /**
  73528. * An event triggered when physic simulation is about to be run
  73529. */
  73530. onBeforePhysicsObservable: Observable<Scene>;
  73531. /**
  73532. * An event triggered when physic simulation has been done
  73533. */
  73534. onAfterPhysicsObservable: Observable<Scene>;
  73535. }
  73536. }
  73537. module "babylonjs/Meshes/abstractMesh" {
  73538. interface AbstractMesh {
  73539. /** @hidden */
  73540. _physicsImpostor: Nullable<PhysicsImpostor>;
  73541. /**
  73542. * Gets or sets impostor used for physic simulation
  73543. * @see https://doc.babylonjs.com/features/physics_engine
  73544. */
  73545. physicsImpostor: Nullable<PhysicsImpostor>;
  73546. /**
  73547. * Gets the current physics impostor
  73548. * @see https://doc.babylonjs.com/features/physics_engine
  73549. * @returns a physics impostor or null
  73550. */
  73551. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  73552. /** Apply a physic impulse to the mesh
  73553. * @param force defines the force to apply
  73554. * @param contactPoint defines where to apply the force
  73555. * @returns the current mesh
  73556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73557. */
  73558. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  73559. /**
  73560. * Creates a physic joint between two meshes
  73561. * @param otherMesh defines the other mesh to use
  73562. * @param pivot1 defines the pivot to use on this mesh
  73563. * @param pivot2 defines the pivot to use on the other mesh
  73564. * @param options defines additional options (can be plugin dependent)
  73565. * @returns the current mesh
  73566. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  73567. */
  73568. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  73569. /** @hidden */
  73570. _disposePhysicsObserver: Nullable<Observer<Node>>;
  73571. }
  73572. }
  73573. /**
  73574. * Defines the physics engine scene component responsible to manage a physics engine
  73575. */
  73576. export class PhysicsEngineSceneComponent implements ISceneComponent {
  73577. /**
  73578. * The component name helpful to identify the component in the list of scene components.
  73579. */
  73580. readonly name: string;
  73581. /**
  73582. * The scene the component belongs to.
  73583. */
  73584. scene: Scene;
  73585. /**
  73586. * Creates a new instance of the component for the given scene
  73587. * @param scene Defines the scene to register the component in
  73588. */
  73589. constructor(scene: Scene);
  73590. /**
  73591. * Registers the component in a given scene
  73592. */
  73593. register(): void;
  73594. /**
  73595. * Rebuilds the elements related to this component in case of
  73596. * context lost for instance.
  73597. */
  73598. rebuild(): void;
  73599. /**
  73600. * Disposes the component and the associated ressources
  73601. */
  73602. dispose(): void;
  73603. }
  73604. }
  73605. declare module "babylonjs/Physics/physicsHelper" {
  73606. import { Nullable } from "babylonjs/types";
  73607. import { Vector3 } from "babylonjs/Maths/math.vector";
  73608. import { Mesh } from "babylonjs/Meshes/mesh";
  73609. import { Scene } from "babylonjs/scene";
  73610. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73611. /**
  73612. * A helper for physics simulations
  73613. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73614. */
  73615. export class PhysicsHelper {
  73616. private _scene;
  73617. private _physicsEngine;
  73618. /**
  73619. * Initializes the Physics helper
  73620. * @param scene Babylon.js scene
  73621. */
  73622. constructor(scene: Scene);
  73623. /**
  73624. * Applies a radial explosion impulse
  73625. * @param origin the origin of the explosion
  73626. * @param radiusOrEventOptions the radius or the options of radial explosion
  73627. * @param strength the explosion strength
  73628. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73629. * @returns A physics radial explosion event, or null
  73630. */
  73631. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73632. /**
  73633. * Applies a radial explosion force
  73634. * @param origin the origin of the explosion
  73635. * @param radiusOrEventOptions the radius or the options of radial explosion
  73636. * @param strength the explosion strength
  73637. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73638. * @returns A physics radial explosion event, or null
  73639. */
  73640. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73641. /**
  73642. * Creates a gravitational field
  73643. * @param origin the origin of the explosion
  73644. * @param radiusOrEventOptions the radius or the options of radial explosion
  73645. * @param strength the explosion strength
  73646. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73647. * @returns A physics gravitational field event, or null
  73648. */
  73649. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73650. /**
  73651. * Creates a physics updraft event
  73652. * @param origin the origin of the updraft
  73653. * @param radiusOrEventOptions the radius or the options of the updraft
  73654. * @param strength the strength of the updraft
  73655. * @param height the height of the updraft
  73656. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73657. * @returns A physics updraft event, or null
  73658. */
  73659. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73660. /**
  73661. * Creates a physics vortex event
  73662. * @param origin the of the vortex
  73663. * @param radiusOrEventOptions the radius or the options of the vortex
  73664. * @param strength the strength of the vortex
  73665. * @param height the height of the vortex
  73666. * @returns a Physics vortex event, or null
  73667. * A physics vortex event or null
  73668. */
  73669. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73670. }
  73671. /**
  73672. * Represents a physics radial explosion event
  73673. */
  73674. class PhysicsRadialExplosionEvent {
  73675. private _scene;
  73676. private _options;
  73677. private _sphere;
  73678. private _dataFetched;
  73679. /**
  73680. * Initializes a radial explosioin event
  73681. * @param _scene BabylonJS scene
  73682. * @param _options The options for the vortex event
  73683. */
  73684. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73685. /**
  73686. * Returns the data related to the radial explosion event (sphere).
  73687. * @returns The radial explosion event data
  73688. */
  73689. getData(): PhysicsRadialExplosionEventData;
  73690. /**
  73691. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73692. * @param impostor A physics imposter
  73693. * @param origin the origin of the explosion
  73694. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73695. */
  73696. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73697. /**
  73698. * Triggers affecterd impostors callbacks
  73699. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73700. */
  73701. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73702. /**
  73703. * Disposes the sphere.
  73704. * @param force Specifies if the sphere should be disposed by force
  73705. */
  73706. dispose(force?: boolean): void;
  73707. /*** Helpers ***/
  73708. private _prepareSphere;
  73709. private _intersectsWithSphere;
  73710. }
  73711. /**
  73712. * Represents a gravitational field event
  73713. */
  73714. class PhysicsGravitationalFieldEvent {
  73715. private _physicsHelper;
  73716. private _scene;
  73717. private _origin;
  73718. private _options;
  73719. private _tickCallback;
  73720. private _sphere;
  73721. private _dataFetched;
  73722. /**
  73723. * Initializes the physics gravitational field event
  73724. * @param _physicsHelper A physics helper
  73725. * @param _scene BabylonJS scene
  73726. * @param _origin The origin position of the gravitational field event
  73727. * @param _options The options for the vortex event
  73728. */
  73729. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73730. /**
  73731. * Returns the data related to the gravitational field event (sphere).
  73732. * @returns A gravitational field event
  73733. */
  73734. getData(): PhysicsGravitationalFieldEventData;
  73735. /**
  73736. * Enables the gravitational field.
  73737. */
  73738. enable(): void;
  73739. /**
  73740. * Disables the gravitational field.
  73741. */
  73742. disable(): void;
  73743. /**
  73744. * Disposes the sphere.
  73745. * @param force The force to dispose from the gravitational field event
  73746. */
  73747. dispose(force?: boolean): void;
  73748. private _tick;
  73749. }
  73750. /**
  73751. * Represents a physics updraft event
  73752. */
  73753. class PhysicsUpdraftEvent {
  73754. private _scene;
  73755. private _origin;
  73756. private _options;
  73757. private _physicsEngine;
  73758. private _originTop;
  73759. private _originDirection;
  73760. private _tickCallback;
  73761. private _cylinder;
  73762. private _cylinderPosition;
  73763. private _dataFetched;
  73764. /**
  73765. * Initializes the physics updraft event
  73766. * @param _scene BabylonJS scene
  73767. * @param _origin The origin position of the updraft
  73768. * @param _options The options for the updraft event
  73769. */
  73770. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73771. /**
  73772. * Returns the data related to the updraft event (cylinder).
  73773. * @returns A physics updraft event
  73774. */
  73775. getData(): PhysicsUpdraftEventData;
  73776. /**
  73777. * Enables the updraft.
  73778. */
  73779. enable(): void;
  73780. /**
  73781. * Disables the updraft.
  73782. */
  73783. disable(): void;
  73784. /**
  73785. * Disposes the cylinder.
  73786. * @param force Specifies if the updraft should be disposed by force
  73787. */
  73788. dispose(force?: boolean): void;
  73789. private getImpostorHitData;
  73790. private _tick;
  73791. /*** Helpers ***/
  73792. private _prepareCylinder;
  73793. private _intersectsWithCylinder;
  73794. }
  73795. /**
  73796. * Represents a physics vortex event
  73797. */
  73798. class PhysicsVortexEvent {
  73799. private _scene;
  73800. private _origin;
  73801. private _options;
  73802. private _physicsEngine;
  73803. private _originTop;
  73804. private _tickCallback;
  73805. private _cylinder;
  73806. private _cylinderPosition;
  73807. private _dataFetched;
  73808. /**
  73809. * Initializes the physics vortex event
  73810. * @param _scene The BabylonJS scene
  73811. * @param _origin The origin position of the vortex
  73812. * @param _options The options for the vortex event
  73813. */
  73814. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73815. /**
  73816. * Returns the data related to the vortex event (cylinder).
  73817. * @returns The physics vortex event data
  73818. */
  73819. getData(): PhysicsVortexEventData;
  73820. /**
  73821. * Enables the vortex.
  73822. */
  73823. enable(): void;
  73824. /**
  73825. * Disables the cortex.
  73826. */
  73827. disable(): void;
  73828. /**
  73829. * Disposes the sphere.
  73830. * @param force
  73831. */
  73832. dispose(force?: boolean): void;
  73833. private getImpostorHitData;
  73834. private _tick;
  73835. /*** Helpers ***/
  73836. private _prepareCylinder;
  73837. private _intersectsWithCylinder;
  73838. }
  73839. /**
  73840. * Options fot the radial explosion event
  73841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73842. */
  73843. export class PhysicsRadialExplosionEventOptions {
  73844. /**
  73845. * The radius of the sphere for the radial explosion.
  73846. */
  73847. radius: number;
  73848. /**
  73849. * The strenth of the explosion.
  73850. */
  73851. strength: number;
  73852. /**
  73853. * The strenght of the force in correspondence to the distance of the affected object
  73854. */
  73855. falloff: PhysicsRadialImpulseFalloff;
  73856. /**
  73857. * Sphere options for the radial explosion.
  73858. */
  73859. sphere: {
  73860. segments: number;
  73861. diameter: number;
  73862. };
  73863. /**
  73864. * Sphere options for the radial explosion.
  73865. */
  73866. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73867. }
  73868. /**
  73869. * Options fot the updraft event
  73870. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73871. */
  73872. export class PhysicsUpdraftEventOptions {
  73873. /**
  73874. * The radius of the cylinder for the vortex
  73875. */
  73876. radius: number;
  73877. /**
  73878. * The strenth of the updraft.
  73879. */
  73880. strength: number;
  73881. /**
  73882. * The height of the cylinder for the updraft.
  73883. */
  73884. height: number;
  73885. /**
  73886. * The mode for the the updraft.
  73887. */
  73888. updraftMode: PhysicsUpdraftMode;
  73889. }
  73890. /**
  73891. * Options fot the vortex event
  73892. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73893. */
  73894. export class PhysicsVortexEventOptions {
  73895. /**
  73896. * The radius of the cylinder for the vortex
  73897. */
  73898. radius: number;
  73899. /**
  73900. * The strenth of the vortex.
  73901. */
  73902. strength: number;
  73903. /**
  73904. * The height of the cylinder for the vortex.
  73905. */
  73906. height: number;
  73907. /**
  73908. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73909. */
  73910. centripetalForceThreshold: number;
  73911. /**
  73912. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  73913. */
  73914. centripetalForceMultiplier: number;
  73915. /**
  73916. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  73917. */
  73918. centrifugalForceMultiplier: number;
  73919. /**
  73920. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73921. */
  73922. updraftForceMultiplier: number;
  73923. }
  73924. /**
  73925. * The strenght of the force in correspondence to the distance of the affected object
  73926. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73927. */
  73928. export enum PhysicsRadialImpulseFalloff {
  73929. /** Defines that impulse is constant in strength across it's whole radius */
  73930. Constant = 0,
  73931. /** Defines that impulse gets weaker if it's further from the origin */
  73932. Linear = 1
  73933. }
  73934. /**
  73935. * The strength of the force in correspondence to the distance of the affected object
  73936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73937. */
  73938. export enum PhysicsUpdraftMode {
  73939. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73940. Center = 0,
  73941. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73942. Perpendicular = 1
  73943. }
  73944. /**
  73945. * Interface for a physics hit data
  73946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73947. */
  73948. export interface PhysicsHitData {
  73949. /**
  73950. * The force applied at the contact point
  73951. */
  73952. force: Vector3;
  73953. /**
  73954. * The contact point
  73955. */
  73956. contactPoint: Vector3;
  73957. /**
  73958. * The distance from the origin to the contact point
  73959. */
  73960. distanceFromOrigin: number;
  73961. }
  73962. /**
  73963. * Interface for radial explosion event data
  73964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73965. */
  73966. export interface PhysicsRadialExplosionEventData {
  73967. /**
  73968. * A sphere used for the radial explosion event
  73969. */
  73970. sphere: Mesh;
  73971. }
  73972. /**
  73973. * Interface for gravitational field event data
  73974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73975. */
  73976. export interface PhysicsGravitationalFieldEventData {
  73977. /**
  73978. * A sphere mesh used for the gravitational field event
  73979. */
  73980. sphere: Mesh;
  73981. }
  73982. /**
  73983. * Interface for updraft event data
  73984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73985. */
  73986. export interface PhysicsUpdraftEventData {
  73987. /**
  73988. * A cylinder used for the updraft event
  73989. */
  73990. cylinder: Mesh;
  73991. }
  73992. /**
  73993. * Interface for vortex event data
  73994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73995. */
  73996. export interface PhysicsVortexEventData {
  73997. /**
  73998. * A cylinder used for the vortex event
  73999. */
  74000. cylinder: Mesh;
  74001. }
  74002. /**
  74003. * Interface for an affected physics impostor
  74004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74005. */
  74006. export interface PhysicsAffectedImpostorWithData {
  74007. /**
  74008. * The impostor affected by the effect
  74009. */
  74010. impostor: PhysicsImpostor;
  74011. /**
  74012. * The data about the hit/horce from the explosion
  74013. */
  74014. hitData: PhysicsHitData;
  74015. }
  74016. }
  74017. declare module "babylonjs/Physics/Plugins/index" {
  74018. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  74019. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  74020. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  74021. }
  74022. declare module "babylonjs/Physics/index" {
  74023. export * from "babylonjs/Physics/IPhysicsEngine";
  74024. export * from "babylonjs/Physics/physicsEngine";
  74025. export * from "babylonjs/Physics/physicsEngineComponent";
  74026. export * from "babylonjs/Physics/physicsHelper";
  74027. export * from "babylonjs/Physics/physicsImpostor";
  74028. export * from "babylonjs/Physics/physicsJoint";
  74029. export * from "babylonjs/Physics/Plugins/index";
  74030. }
  74031. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  74032. /** @hidden */
  74033. export var blackAndWhitePixelShader: {
  74034. name: string;
  74035. shader: string;
  74036. };
  74037. }
  74038. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  74039. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74040. import { Camera } from "babylonjs/Cameras/camera";
  74041. import { Engine } from "babylonjs/Engines/engine";
  74042. import "babylonjs/Shaders/blackAndWhite.fragment";
  74043. import { Nullable } from "babylonjs/types";
  74044. import { Scene } from "babylonjs/scene";
  74045. /**
  74046. * Post process used to render in black and white
  74047. */
  74048. export class BlackAndWhitePostProcess extends PostProcess {
  74049. /**
  74050. * Linear about to convert he result to black and white (default: 1)
  74051. */
  74052. degree: number;
  74053. /**
  74054. * Gets a string identifying the name of the class
  74055. * @returns "BlackAndWhitePostProcess" string
  74056. */
  74057. getClassName(): string;
  74058. /**
  74059. * Creates a black and white post process
  74060. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  74061. * @param name The name of the effect.
  74062. * @param options The required width/height ratio to downsize to before computing the render pass.
  74063. * @param camera The camera to apply the render pass to.
  74064. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74065. * @param engine The engine which the post process will be applied. (default: current engine)
  74066. * @param reusable If the post process can be reused on the same frame. (default: false)
  74067. */
  74068. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74069. /** @hidden */
  74070. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  74071. }
  74072. }
  74073. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  74074. import { Nullable } from "babylonjs/types";
  74075. import { Camera } from "babylonjs/Cameras/camera";
  74076. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74077. import { Engine } from "babylonjs/Engines/engine";
  74078. /**
  74079. * This represents a set of one or more post processes in Babylon.
  74080. * A post process can be used to apply a shader to a texture after it is rendered.
  74081. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74082. */
  74083. export class PostProcessRenderEffect {
  74084. private _postProcesses;
  74085. private _getPostProcesses;
  74086. private _singleInstance;
  74087. private _cameras;
  74088. private _indicesForCamera;
  74089. /**
  74090. * Name of the effect
  74091. * @hidden
  74092. */
  74093. _name: string;
  74094. /**
  74095. * Instantiates a post process render effect.
  74096. * A post process can be used to apply a shader to a texture after it is rendered.
  74097. * @param engine The engine the effect is tied to
  74098. * @param name The name of the effect
  74099. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  74100. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  74101. */
  74102. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  74103. /**
  74104. * Checks if all the post processes in the effect are supported.
  74105. */
  74106. get isSupported(): boolean;
  74107. /**
  74108. * Updates the current state of the effect
  74109. * @hidden
  74110. */
  74111. _update(): void;
  74112. /**
  74113. * Attaches the effect on cameras
  74114. * @param cameras The camera to attach to.
  74115. * @hidden
  74116. */
  74117. _attachCameras(cameras: Camera): void;
  74118. /**
  74119. * Attaches the effect on cameras
  74120. * @param cameras The camera to attach to.
  74121. * @hidden
  74122. */
  74123. _attachCameras(cameras: Camera[]): void;
  74124. /**
  74125. * Detaches the effect on cameras
  74126. * @param cameras The camera to detatch from.
  74127. * @hidden
  74128. */
  74129. _detachCameras(cameras: Camera): void;
  74130. /**
  74131. * Detatches the effect on cameras
  74132. * @param cameras The camera to detatch from.
  74133. * @hidden
  74134. */
  74135. _detachCameras(cameras: Camera[]): void;
  74136. /**
  74137. * Enables the effect on given cameras
  74138. * @param cameras The camera to enable.
  74139. * @hidden
  74140. */
  74141. _enable(cameras: Camera): void;
  74142. /**
  74143. * Enables the effect on given cameras
  74144. * @param cameras The camera to enable.
  74145. * @hidden
  74146. */
  74147. _enable(cameras: Nullable<Camera[]>): void;
  74148. /**
  74149. * Disables the effect on the given cameras
  74150. * @param cameras The camera to disable.
  74151. * @hidden
  74152. */
  74153. _disable(cameras: Camera): void;
  74154. /**
  74155. * Disables the effect on the given cameras
  74156. * @param cameras The camera to disable.
  74157. * @hidden
  74158. */
  74159. _disable(cameras: Nullable<Camera[]>): void;
  74160. /**
  74161. * Gets a list of the post processes contained in the effect.
  74162. * @param camera The camera to get the post processes on.
  74163. * @returns The list of the post processes in the effect.
  74164. */
  74165. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  74166. }
  74167. }
  74168. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  74169. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74170. /** @hidden */
  74171. export var extractHighlightsPixelShader: {
  74172. name: string;
  74173. shader: string;
  74174. };
  74175. }
  74176. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  74177. import { Nullable } from "babylonjs/types";
  74178. import { Camera } from "babylonjs/Cameras/camera";
  74179. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74180. import { Engine } from "babylonjs/Engines/engine";
  74181. import "babylonjs/Shaders/extractHighlights.fragment";
  74182. /**
  74183. * 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.
  74184. */
  74185. export class ExtractHighlightsPostProcess extends PostProcess {
  74186. /**
  74187. * The luminance threshold, pixels below this value will be set to black.
  74188. */
  74189. threshold: number;
  74190. /** @hidden */
  74191. _exposure: number;
  74192. /**
  74193. * Post process which has the input texture to be used when performing highlight extraction
  74194. * @hidden
  74195. */
  74196. _inputPostProcess: Nullable<PostProcess>;
  74197. /**
  74198. * Gets a string identifying the name of the class
  74199. * @returns "ExtractHighlightsPostProcess" string
  74200. */
  74201. getClassName(): string;
  74202. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74203. }
  74204. }
  74205. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  74206. /** @hidden */
  74207. export var bloomMergePixelShader: {
  74208. name: string;
  74209. shader: string;
  74210. };
  74211. }
  74212. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  74213. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74214. import { Nullable } from "babylonjs/types";
  74215. import { Engine } from "babylonjs/Engines/engine";
  74216. import { Camera } from "babylonjs/Cameras/camera";
  74217. import "babylonjs/Shaders/bloomMerge.fragment";
  74218. /**
  74219. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74220. */
  74221. export class BloomMergePostProcess extends PostProcess {
  74222. /** Weight of the bloom to be added to the original input. */
  74223. weight: number;
  74224. /**
  74225. * Gets a string identifying the name of the class
  74226. * @returns "BloomMergePostProcess" string
  74227. */
  74228. getClassName(): string;
  74229. /**
  74230. * Creates a new instance of @see BloomMergePostProcess
  74231. * @param name The name of the effect.
  74232. * @param originalFromInput Post process which's input will be used for the merge.
  74233. * @param blurred Blurred highlights post process which's output will be used.
  74234. * @param weight Weight of the bloom to be added to the original input.
  74235. * @param options The required width/height ratio to downsize to before computing the render pass.
  74236. * @param camera The camera to apply the render pass to.
  74237. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74238. * @param engine The engine which the post process will be applied. (default: current engine)
  74239. * @param reusable If the post process can be reused on the same frame. (default: false)
  74240. * @param textureType Type of textures used when performing the post process. (default: 0)
  74241. * @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)
  74242. */
  74243. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  74244. /** Weight of the bloom to be added to the original input. */
  74245. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74246. }
  74247. }
  74248. declare module "babylonjs/PostProcesses/bloomEffect" {
  74249. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74250. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74251. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  74252. import { Camera } from "babylonjs/Cameras/camera";
  74253. import { Scene } from "babylonjs/scene";
  74254. /**
  74255. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  74256. */
  74257. export class BloomEffect extends PostProcessRenderEffect {
  74258. private bloomScale;
  74259. /**
  74260. * @hidden Internal
  74261. */
  74262. _effects: Array<PostProcess>;
  74263. /**
  74264. * @hidden Internal
  74265. */
  74266. _downscale: ExtractHighlightsPostProcess;
  74267. private _blurX;
  74268. private _blurY;
  74269. private _merge;
  74270. /**
  74271. * The luminance threshold to find bright areas of the image to bloom.
  74272. */
  74273. get threshold(): number;
  74274. set threshold(value: number);
  74275. /**
  74276. * The strength of the bloom.
  74277. */
  74278. get weight(): number;
  74279. set weight(value: number);
  74280. /**
  74281. * Specifies the size of the bloom blur kernel, relative to the final output size
  74282. */
  74283. get kernel(): number;
  74284. set kernel(value: number);
  74285. /**
  74286. * Creates a new instance of @see BloomEffect
  74287. * @param scene The scene the effect belongs to.
  74288. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  74289. * @param bloomKernel The size of the kernel to be used when applying the blur.
  74290. * @param bloomWeight The the strength of bloom.
  74291. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74292. * @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)
  74293. */
  74294. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  74295. /**
  74296. * Disposes each of the internal effects for a given camera.
  74297. * @param camera The camera to dispose the effect on.
  74298. */
  74299. disposeEffects(camera: Camera): void;
  74300. /**
  74301. * @hidden Internal
  74302. */
  74303. _updateEffects(): void;
  74304. /**
  74305. * Internal
  74306. * @returns if all the contained post processes are ready.
  74307. * @hidden
  74308. */
  74309. _isReady(): boolean;
  74310. }
  74311. }
  74312. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  74313. /** @hidden */
  74314. export var chromaticAberrationPixelShader: {
  74315. name: string;
  74316. shader: string;
  74317. };
  74318. }
  74319. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  74320. import { Vector2 } from "babylonjs/Maths/math.vector";
  74321. import { Nullable } from "babylonjs/types";
  74322. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74323. import { Camera } from "babylonjs/Cameras/camera";
  74324. import { Engine } from "babylonjs/Engines/engine";
  74325. import "babylonjs/Shaders/chromaticAberration.fragment";
  74326. import { Scene } from "babylonjs/scene";
  74327. /**
  74328. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  74329. */
  74330. export class ChromaticAberrationPostProcess extends PostProcess {
  74331. /**
  74332. * The amount of seperation of rgb channels (default: 30)
  74333. */
  74334. aberrationAmount: number;
  74335. /**
  74336. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  74337. */
  74338. radialIntensity: number;
  74339. /**
  74340. * 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))
  74341. */
  74342. direction: Vector2;
  74343. /**
  74344. * 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))
  74345. */
  74346. centerPosition: Vector2;
  74347. /** The width of the screen to apply the effect on */
  74348. screenWidth: number;
  74349. /** The height of the screen to apply the effect on */
  74350. screenHeight: number;
  74351. /**
  74352. * Gets a string identifying the name of the class
  74353. * @returns "ChromaticAberrationPostProcess" string
  74354. */
  74355. getClassName(): string;
  74356. /**
  74357. * Creates a new instance ChromaticAberrationPostProcess
  74358. * @param name The name of the effect.
  74359. * @param screenWidth The width of the screen to apply the effect on.
  74360. * @param screenHeight The height of the screen to apply the effect on.
  74361. * @param options The required width/height ratio to downsize to before computing the render pass.
  74362. * @param camera The camera to apply the render pass to.
  74363. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74364. * @param engine The engine which the post process will be applied. (default: current engine)
  74365. * @param reusable If the post process can be reused on the same frame. (default: false)
  74366. * @param textureType Type of textures used when performing the post process. (default: 0)
  74367. * @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)
  74368. */
  74369. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74370. /** @hidden */
  74371. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  74372. }
  74373. }
  74374. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  74375. /** @hidden */
  74376. export var circleOfConfusionPixelShader: {
  74377. name: string;
  74378. shader: string;
  74379. };
  74380. }
  74381. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  74382. import { Nullable } from "babylonjs/types";
  74383. import { Engine } from "babylonjs/Engines/engine";
  74384. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74385. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74386. import { Camera } from "babylonjs/Cameras/camera";
  74387. import "babylonjs/Shaders/circleOfConfusion.fragment";
  74388. /**
  74389. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  74390. */
  74391. export class CircleOfConfusionPostProcess extends PostProcess {
  74392. /**
  74393. * 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.
  74394. */
  74395. lensSize: number;
  74396. /**
  74397. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74398. */
  74399. fStop: number;
  74400. /**
  74401. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74402. */
  74403. focusDistance: number;
  74404. /**
  74405. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  74406. */
  74407. focalLength: number;
  74408. /**
  74409. * Gets a string identifying the name of the class
  74410. * @returns "CircleOfConfusionPostProcess" string
  74411. */
  74412. getClassName(): string;
  74413. private _depthTexture;
  74414. /**
  74415. * Creates a new instance CircleOfConfusionPostProcess
  74416. * @param name The name of the effect.
  74417. * @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.
  74418. * @param options The required width/height ratio to downsize to before computing the render pass.
  74419. * @param camera The camera to apply the render pass to.
  74420. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74421. * @param engine The engine which the post process will be applied. (default: current engine)
  74422. * @param reusable If the post process can be reused on the same frame. (default: false)
  74423. * @param textureType Type of textures used when performing the post process. (default: 0)
  74424. * @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)
  74425. */
  74426. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74427. /**
  74428. * 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.
  74429. */
  74430. set depthTexture(value: RenderTargetTexture);
  74431. }
  74432. }
  74433. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  74434. /** @hidden */
  74435. export var colorCorrectionPixelShader: {
  74436. name: string;
  74437. shader: string;
  74438. };
  74439. }
  74440. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  74441. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74442. import { Engine } from "babylonjs/Engines/engine";
  74443. import { Camera } from "babylonjs/Cameras/camera";
  74444. import "babylonjs/Shaders/colorCorrection.fragment";
  74445. import { Nullable } from "babylonjs/types";
  74446. import { Scene } from "babylonjs/scene";
  74447. /**
  74448. *
  74449. * This post-process allows the modification of rendered colors by using
  74450. * a 'look-up table' (LUT). This effect is also called Color Grading.
  74451. *
  74452. * The object needs to be provided an url to a texture containing the color
  74453. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  74454. * Use an image editing software to tweak the LUT to match your needs.
  74455. *
  74456. * For an example of a color LUT, see here:
  74457. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  74458. * For explanations on color grading, see here:
  74459. * @see http://udn.epicgames.com/Three/ColorGrading.html
  74460. *
  74461. */
  74462. export class ColorCorrectionPostProcess extends PostProcess {
  74463. private _colorTableTexture;
  74464. /**
  74465. * Gets the color table url used to create the LUT texture
  74466. */
  74467. colorTableUrl: string;
  74468. /**
  74469. * Gets a string identifying the name of the class
  74470. * @returns "ColorCorrectionPostProcess" string
  74471. */
  74472. getClassName(): string;
  74473. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74474. /** @hidden */
  74475. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  74476. }
  74477. }
  74478. declare module "babylonjs/Shaders/convolution.fragment" {
  74479. /** @hidden */
  74480. export var convolutionPixelShader: {
  74481. name: string;
  74482. shader: string;
  74483. };
  74484. }
  74485. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  74486. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74487. import { Nullable } from "babylonjs/types";
  74488. import { Camera } from "babylonjs/Cameras/camera";
  74489. import { Engine } from "babylonjs/Engines/engine";
  74490. import "babylonjs/Shaders/convolution.fragment";
  74491. import { Scene } from "babylonjs/scene";
  74492. /**
  74493. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  74494. * input texture to perform effects such as edge detection or sharpening
  74495. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74496. */
  74497. export class ConvolutionPostProcess extends PostProcess {
  74498. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  74499. kernel: number[];
  74500. /**
  74501. * Gets a string identifying the name of the class
  74502. * @returns "ConvolutionPostProcess" string
  74503. */
  74504. getClassName(): string;
  74505. /**
  74506. * Creates a new instance ConvolutionPostProcess
  74507. * @param name The name of the effect.
  74508. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  74509. * @param options The required width/height ratio to downsize to before computing the render pass.
  74510. * @param camera The camera to apply the render pass to.
  74511. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74512. * @param engine The engine which the post process will be applied. (default: current engine)
  74513. * @param reusable If the post process can be reused on the same frame. (default: false)
  74514. * @param textureType Type of textures used when performing the post process. (default: 0)
  74515. */
  74516. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74517. /** @hidden */
  74518. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  74519. /**
  74520. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74521. */
  74522. static EdgeDetect0Kernel: number[];
  74523. /**
  74524. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74525. */
  74526. static EdgeDetect1Kernel: number[];
  74527. /**
  74528. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74529. */
  74530. static EdgeDetect2Kernel: number[];
  74531. /**
  74532. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74533. */
  74534. static SharpenKernel: number[];
  74535. /**
  74536. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74537. */
  74538. static EmbossKernel: number[];
  74539. /**
  74540. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74541. */
  74542. static GaussianKernel: number[];
  74543. }
  74544. }
  74545. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  74546. import { Nullable } from "babylonjs/types";
  74547. import { Vector2 } from "babylonjs/Maths/math.vector";
  74548. import { Camera } from "babylonjs/Cameras/camera";
  74549. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74550. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74551. import { Engine } from "babylonjs/Engines/engine";
  74552. import { Scene } from "babylonjs/scene";
  74553. /**
  74554. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  74555. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  74556. * based on samples that have a large difference in distance than the center pixel.
  74557. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  74558. */
  74559. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  74560. /**
  74561. * The direction the blur should be applied
  74562. */
  74563. direction: Vector2;
  74564. /**
  74565. * Gets a string identifying the name of the class
  74566. * @returns "DepthOfFieldBlurPostProcess" string
  74567. */
  74568. getClassName(): string;
  74569. /**
  74570. * Creates a new instance CircleOfConfusionPostProcess
  74571. * @param name The name of the effect.
  74572. * @param scene The scene the effect belongs to.
  74573. * @param direction The direction the blur should be applied.
  74574. * @param kernel The size of the kernel used to blur.
  74575. * @param options The required width/height ratio to downsize to before computing the render pass.
  74576. * @param camera The camera to apply the render pass to.
  74577. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  74578. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  74579. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74580. * @param engine The engine which the post process will be applied. (default: current engine)
  74581. * @param reusable If the post process can be reused on the same frame. (default: false)
  74582. * @param textureType Type of textures used when performing the post process. (default: 0)
  74583. * @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)
  74584. */
  74585. 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);
  74586. }
  74587. }
  74588. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  74589. /** @hidden */
  74590. export var depthOfFieldMergePixelShader: {
  74591. name: string;
  74592. shader: string;
  74593. };
  74594. }
  74595. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  74596. import { Nullable } from "babylonjs/types";
  74597. import { Camera } from "babylonjs/Cameras/camera";
  74598. import { Effect } from "babylonjs/Materials/effect";
  74599. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74600. import { Engine } from "babylonjs/Engines/engine";
  74601. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  74602. /**
  74603. * Options to be set when merging outputs from the default pipeline.
  74604. */
  74605. export class DepthOfFieldMergePostProcessOptions {
  74606. /**
  74607. * The original image to merge on top of
  74608. */
  74609. originalFromInput: PostProcess;
  74610. /**
  74611. * Parameters to perform the merge of the depth of field effect
  74612. */
  74613. depthOfField?: {
  74614. circleOfConfusion: PostProcess;
  74615. blurSteps: Array<PostProcess>;
  74616. };
  74617. /**
  74618. * Parameters to perform the merge of bloom effect
  74619. */
  74620. bloom?: {
  74621. blurred: PostProcess;
  74622. weight: number;
  74623. };
  74624. }
  74625. /**
  74626. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74627. */
  74628. export class DepthOfFieldMergePostProcess extends PostProcess {
  74629. private blurSteps;
  74630. /**
  74631. * Gets a string identifying the name of the class
  74632. * @returns "DepthOfFieldMergePostProcess" string
  74633. */
  74634. getClassName(): string;
  74635. /**
  74636. * Creates a new instance of DepthOfFieldMergePostProcess
  74637. * @param name The name of the effect.
  74638. * @param originalFromInput Post process which's input will be used for the merge.
  74639. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  74640. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  74641. * @param options The required width/height ratio to downsize to before computing the render pass.
  74642. * @param camera The camera to apply the render pass to.
  74643. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74644. * @param engine The engine which the post process will be applied. (default: current engine)
  74645. * @param reusable If the post process can be reused on the same frame. (default: false)
  74646. * @param textureType Type of textures used when performing the post process. (default: 0)
  74647. * @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)
  74648. */
  74649. 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);
  74650. /**
  74651. * Updates the effect with the current post process compile time values and recompiles the shader.
  74652. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  74653. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  74654. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  74655. * @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
  74656. * @param onCompiled Called when the shader has been compiled.
  74657. * @param onError Called if there is an error when compiling a shader.
  74658. */
  74659. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  74660. }
  74661. }
  74662. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  74663. import { Nullable } from "babylonjs/types";
  74664. import { Camera } from "babylonjs/Cameras/camera";
  74665. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74666. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74667. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74668. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74669. import { Scene } from "babylonjs/scene";
  74670. /**
  74671. * Specifies the level of max blur that should be applied when using the depth of field effect
  74672. */
  74673. export enum DepthOfFieldEffectBlurLevel {
  74674. /**
  74675. * Subtle blur
  74676. */
  74677. Low = 0,
  74678. /**
  74679. * Medium blur
  74680. */
  74681. Medium = 1,
  74682. /**
  74683. * Large blur
  74684. */
  74685. High = 2
  74686. }
  74687. /**
  74688. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74689. */
  74690. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74691. private _circleOfConfusion;
  74692. /**
  74693. * @hidden Internal, blurs from high to low
  74694. */
  74695. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74696. private _depthOfFieldBlurY;
  74697. private _dofMerge;
  74698. /**
  74699. * @hidden Internal post processes in depth of field effect
  74700. */
  74701. _effects: Array<PostProcess>;
  74702. /**
  74703. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74704. */
  74705. set focalLength(value: number);
  74706. get focalLength(): number;
  74707. /**
  74708. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74709. */
  74710. set fStop(value: number);
  74711. get fStop(): number;
  74712. /**
  74713. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74714. */
  74715. set focusDistance(value: number);
  74716. get focusDistance(): number;
  74717. /**
  74718. * 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.
  74719. */
  74720. set lensSize(value: number);
  74721. get lensSize(): number;
  74722. /**
  74723. * Creates a new instance DepthOfFieldEffect
  74724. * @param scene The scene the effect belongs to.
  74725. * @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.
  74726. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74727. * @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)
  74728. */
  74729. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74730. /**
  74731. * Get the current class name of the current effet
  74732. * @returns "DepthOfFieldEffect"
  74733. */
  74734. getClassName(): string;
  74735. /**
  74736. * 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.
  74737. */
  74738. set depthTexture(value: RenderTargetTexture);
  74739. /**
  74740. * Disposes each of the internal effects for a given camera.
  74741. * @param camera The camera to dispose the effect on.
  74742. */
  74743. disposeEffects(camera: Camera): void;
  74744. /**
  74745. * @hidden Internal
  74746. */
  74747. _updateEffects(): void;
  74748. /**
  74749. * Internal
  74750. * @returns if all the contained post processes are ready.
  74751. * @hidden
  74752. */
  74753. _isReady(): boolean;
  74754. }
  74755. }
  74756. declare module "babylonjs/Shaders/displayPass.fragment" {
  74757. /** @hidden */
  74758. export var displayPassPixelShader: {
  74759. name: string;
  74760. shader: string;
  74761. };
  74762. }
  74763. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  74764. import { Nullable } from "babylonjs/types";
  74765. import { Camera } from "babylonjs/Cameras/camera";
  74766. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74767. import { Engine } from "babylonjs/Engines/engine";
  74768. import "babylonjs/Shaders/displayPass.fragment";
  74769. import { Scene } from "babylonjs/scene";
  74770. /**
  74771. * DisplayPassPostProcess which produces an output the same as it's input
  74772. */
  74773. export class DisplayPassPostProcess extends PostProcess {
  74774. /**
  74775. * Gets a string identifying the name of the class
  74776. * @returns "DisplayPassPostProcess" string
  74777. */
  74778. getClassName(): string;
  74779. /**
  74780. * Creates the DisplayPassPostProcess
  74781. * @param name The name of the effect.
  74782. * @param options The required width/height ratio to downsize to before computing the render pass.
  74783. * @param camera The camera to apply the render pass to.
  74784. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74785. * @param engine The engine which the post process will be applied. (default: current engine)
  74786. * @param reusable If the post process can be reused on the same frame. (default: false)
  74787. */
  74788. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74789. /** @hidden */
  74790. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74791. }
  74792. }
  74793. declare module "babylonjs/Shaders/filter.fragment" {
  74794. /** @hidden */
  74795. export var filterPixelShader: {
  74796. name: string;
  74797. shader: string;
  74798. };
  74799. }
  74800. declare module "babylonjs/PostProcesses/filterPostProcess" {
  74801. import { Nullable } from "babylonjs/types";
  74802. import { Matrix } from "babylonjs/Maths/math.vector";
  74803. import { Camera } from "babylonjs/Cameras/camera";
  74804. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74805. import { Engine } from "babylonjs/Engines/engine";
  74806. import "babylonjs/Shaders/filter.fragment";
  74807. import { Scene } from "babylonjs/scene";
  74808. /**
  74809. * Applies a kernel filter to the image
  74810. */
  74811. export class FilterPostProcess extends PostProcess {
  74812. /** The matrix to be applied to the image */
  74813. kernelMatrix: Matrix;
  74814. /**
  74815. * Gets a string identifying the name of the class
  74816. * @returns "FilterPostProcess" string
  74817. */
  74818. getClassName(): string;
  74819. /**
  74820. *
  74821. * @param name The name of the effect.
  74822. * @param kernelMatrix The matrix to be applied to the image
  74823. * @param options The required width/height ratio to downsize to before computing the render pass.
  74824. * @param camera The camera to apply the render pass to.
  74825. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74826. * @param engine The engine which the post process will be applied. (default: current engine)
  74827. * @param reusable If the post process can be reused on the same frame. (default: false)
  74828. */
  74829. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74830. /** @hidden */
  74831. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74832. }
  74833. }
  74834. declare module "babylonjs/Shaders/fxaa.fragment" {
  74835. /** @hidden */
  74836. export var fxaaPixelShader: {
  74837. name: string;
  74838. shader: string;
  74839. };
  74840. }
  74841. declare module "babylonjs/Shaders/fxaa.vertex" {
  74842. /** @hidden */
  74843. export var fxaaVertexShader: {
  74844. name: string;
  74845. shader: string;
  74846. };
  74847. }
  74848. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  74849. import { Nullable } from "babylonjs/types";
  74850. import { Camera } from "babylonjs/Cameras/camera";
  74851. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74852. import { Engine } from "babylonjs/Engines/engine";
  74853. import "babylonjs/Shaders/fxaa.fragment";
  74854. import "babylonjs/Shaders/fxaa.vertex";
  74855. import { Scene } from "babylonjs/scene";
  74856. /**
  74857. * Fxaa post process
  74858. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74859. */
  74860. export class FxaaPostProcess extends PostProcess {
  74861. /**
  74862. * Gets a string identifying the name of the class
  74863. * @returns "FxaaPostProcess" string
  74864. */
  74865. getClassName(): string;
  74866. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74867. private _getDefines;
  74868. /** @hidden */
  74869. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74870. }
  74871. }
  74872. declare module "babylonjs/Shaders/grain.fragment" {
  74873. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74874. /** @hidden */
  74875. export var grainPixelShader: {
  74876. name: string;
  74877. shader: string;
  74878. };
  74879. }
  74880. declare module "babylonjs/PostProcesses/grainPostProcess" {
  74881. import { Nullable } from "babylonjs/types";
  74882. import { Camera } from "babylonjs/Cameras/camera";
  74883. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74884. import { Engine } from "babylonjs/Engines/engine";
  74885. import "babylonjs/Shaders/grain.fragment";
  74886. import { Scene } from "babylonjs/scene";
  74887. /**
  74888. * The GrainPostProcess adds noise to the image at mid luminance levels
  74889. */
  74890. export class GrainPostProcess extends PostProcess {
  74891. /**
  74892. * The intensity of the grain added (default: 30)
  74893. */
  74894. intensity: number;
  74895. /**
  74896. * If the grain should be randomized on every frame
  74897. */
  74898. animated: boolean;
  74899. /**
  74900. * Gets a string identifying the name of the class
  74901. * @returns "GrainPostProcess" string
  74902. */
  74903. getClassName(): string;
  74904. /**
  74905. * Creates a new instance of @see GrainPostProcess
  74906. * @param name The name of the effect.
  74907. * @param options The required width/height ratio to downsize to before computing the render pass.
  74908. * @param camera The camera to apply the render pass to.
  74909. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74910. * @param engine The engine which the post process will be applied. (default: current engine)
  74911. * @param reusable If the post process can be reused on the same frame. (default: false)
  74912. * @param textureType Type of textures used when performing the post process. (default: 0)
  74913. * @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)
  74914. */
  74915. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74916. /** @hidden */
  74917. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74918. }
  74919. }
  74920. declare module "babylonjs/Shaders/highlights.fragment" {
  74921. /** @hidden */
  74922. export var highlightsPixelShader: {
  74923. name: string;
  74924. shader: string;
  74925. };
  74926. }
  74927. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  74928. import { Nullable } from "babylonjs/types";
  74929. import { Camera } from "babylonjs/Cameras/camera";
  74930. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74931. import { Engine } from "babylonjs/Engines/engine";
  74932. import "babylonjs/Shaders/highlights.fragment";
  74933. /**
  74934. * Extracts highlights from the image
  74935. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74936. */
  74937. export class HighlightsPostProcess extends PostProcess {
  74938. /**
  74939. * Gets a string identifying the name of the class
  74940. * @returns "HighlightsPostProcess" string
  74941. */
  74942. getClassName(): string;
  74943. /**
  74944. * Extracts highlights from the image
  74945. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74946. * @param name The name of the effect.
  74947. * @param options The required width/height ratio to downsize to before computing the render pass.
  74948. * @param camera The camera to apply the render pass to.
  74949. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74950. * @param engine The engine which the post process will be applied. (default: current engine)
  74951. * @param reusable If the post process can be reused on the same frame. (default: false)
  74952. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74953. */
  74954. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74955. }
  74956. }
  74957. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  74958. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74959. /**
  74960. * Contains all parameters needed for the prepass to perform
  74961. * motion blur
  74962. */
  74963. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74964. /**
  74965. * Is motion blur enabled
  74966. */
  74967. enabled: boolean;
  74968. /**
  74969. * Name of the configuration
  74970. */
  74971. name: string;
  74972. /**
  74973. * Textures that should be present in the MRT for this effect to work
  74974. */
  74975. readonly texturesRequired: number[];
  74976. }
  74977. }
  74978. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  74979. import { Nullable } from "babylonjs/types";
  74980. import { Scene } from "babylonjs/scene";
  74981. import { ISceneComponent } from "babylonjs/sceneComponent";
  74982. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  74983. module "babylonjs/scene" {
  74984. interface Scene {
  74985. /** @hidden (Backing field) */
  74986. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74987. /**
  74988. * Gets or Sets the current geometry buffer associated to the scene.
  74989. */
  74990. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74991. /**
  74992. * Enables a GeometryBufferRender and associates it with the scene
  74993. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74994. * @returns the GeometryBufferRenderer
  74995. */
  74996. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74997. /**
  74998. * Disables the GeometryBufferRender associated with the scene
  74999. */
  75000. disableGeometryBufferRenderer(): void;
  75001. }
  75002. }
  75003. /**
  75004. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  75005. * in several rendering techniques.
  75006. */
  75007. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  75008. /**
  75009. * The component name helpful to identify the component in the list of scene components.
  75010. */
  75011. readonly name: string;
  75012. /**
  75013. * The scene the component belongs to.
  75014. */
  75015. scene: Scene;
  75016. /**
  75017. * Creates a new instance of the component for the given scene
  75018. * @param scene Defines the scene to register the component in
  75019. */
  75020. constructor(scene: Scene);
  75021. /**
  75022. * Registers the component in a given scene
  75023. */
  75024. register(): void;
  75025. /**
  75026. * Rebuilds the elements related to this component in case of
  75027. * context lost for instance.
  75028. */
  75029. rebuild(): void;
  75030. /**
  75031. * Disposes the component and the associated ressources
  75032. */
  75033. dispose(): void;
  75034. private _gatherRenderTargets;
  75035. }
  75036. }
  75037. declare module "babylonjs/Shaders/motionBlur.fragment" {
  75038. /** @hidden */
  75039. export var motionBlurPixelShader: {
  75040. name: string;
  75041. shader: string;
  75042. };
  75043. }
  75044. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  75045. import { Nullable } from "babylonjs/types";
  75046. import { Camera } from "babylonjs/Cameras/camera";
  75047. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75049. import "babylonjs/Animations/animatable";
  75050. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75051. import "babylonjs/Shaders/motionBlur.fragment";
  75052. import { Engine } from "babylonjs/Engines/engine";
  75053. import { Scene } from "babylonjs/scene";
  75054. /**
  75055. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  75056. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  75057. * As an example, all you have to do is to create the post-process:
  75058. * var mb = new BABYLON.MotionBlurPostProcess(
  75059. * 'mb', // The name of the effect.
  75060. * scene, // The scene containing the objects to blur according to their velocity.
  75061. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  75062. * camera // The camera to apply the render pass to.
  75063. * );
  75064. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  75065. */
  75066. export class MotionBlurPostProcess extends PostProcess {
  75067. /**
  75068. * Defines how much the image is blurred by the movement. Default value is equal to 1
  75069. */
  75070. motionStrength: number;
  75071. /**
  75072. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  75073. */
  75074. get motionBlurSamples(): number;
  75075. /**
  75076. * Sets the number of iterations to be used for motion blur quality
  75077. */
  75078. set motionBlurSamples(samples: number);
  75079. private _motionBlurSamples;
  75080. private _forceGeometryBuffer;
  75081. private _geometryBufferRenderer;
  75082. private _prePassRenderer;
  75083. /**
  75084. * Gets a string identifying the name of the class
  75085. * @returns "MotionBlurPostProcess" string
  75086. */
  75087. getClassName(): string;
  75088. /**
  75089. * Creates a new instance MotionBlurPostProcess
  75090. * @param name The name of the effect.
  75091. * @param scene The scene containing the objects to blur according to their velocity.
  75092. * @param options The required width/height ratio to downsize to before computing the render pass.
  75093. * @param camera The camera to apply the render pass to.
  75094. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75095. * @param engine The engine which the post process will be applied. (default: current engine)
  75096. * @param reusable If the post process can be reused on the same frame. (default: false)
  75097. * @param textureType Type of textures used when performing the post process. (default: 0)
  75098. * @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)
  75099. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75100. */
  75101. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75102. /**
  75103. * Excludes the given skinned mesh from computing bones velocities.
  75104. * 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.
  75105. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  75106. */
  75107. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  75108. /**
  75109. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  75110. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  75111. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  75112. */
  75113. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  75114. /**
  75115. * Disposes the post process.
  75116. * @param camera The camera to dispose the post process on.
  75117. */
  75118. dispose(camera?: Camera): void;
  75119. /** @hidden */
  75120. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  75121. }
  75122. }
  75123. declare module "babylonjs/Shaders/refraction.fragment" {
  75124. /** @hidden */
  75125. export var refractionPixelShader: {
  75126. name: string;
  75127. shader: string;
  75128. };
  75129. }
  75130. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  75131. import { Color3 } from "babylonjs/Maths/math.color";
  75132. import { Camera } from "babylonjs/Cameras/camera";
  75133. import { Texture } from "babylonjs/Materials/Textures/texture";
  75134. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75135. import { Engine } from "babylonjs/Engines/engine";
  75136. import "babylonjs/Shaders/refraction.fragment";
  75137. import { Scene } from "babylonjs/scene";
  75138. /**
  75139. * Post process which applies a refractin texture
  75140. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  75141. */
  75142. export class RefractionPostProcess extends PostProcess {
  75143. private _refTexture;
  75144. private _ownRefractionTexture;
  75145. /** the base color of the refraction (used to taint the rendering) */
  75146. color: Color3;
  75147. /** simulated refraction depth */
  75148. depth: number;
  75149. /** the coefficient of the base color (0 to remove base color tainting) */
  75150. colorLevel: number;
  75151. /** Gets the url used to load the refraction texture */
  75152. refractionTextureUrl: string;
  75153. /**
  75154. * Gets or sets the refraction texture
  75155. * Please note that you are responsible for disposing the texture if you set it manually
  75156. */
  75157. get refractionTexture(): Texture;
  75158. set refractionTexture(value: Texture);
  75159. /**
  75160. * Gets a string identifying the name of the class
  75161. * @returns "RefractionPostProcess" string
  75162. */
  75163. getClassName(): string;
  75164. /**
  75165. * Initializes the RefractionPostProcess
  75166. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  75167. * @param name The name of the effect.
  75168. * @param refractionTextureUrl Url of the refraction texture to use
  75169. * @param color the base color of the refraction (used to taint the rendering)
  75170. * @param depth simulated refraction depth
  75171. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  75172. * @param camera The camera to apply the render pass to.
  75173. * @param options The required width/height ratio to downsize to before computing the render pass.
  75174. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75175. * @param engine The engine which the post process will be applied. (default: current engine)
  75176. * @param reusable If the post process can be reused on the same frame. (default: false)
  75177. */
  75178. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75179. /**
  75180. * Disposes of the post process
  75181. * @param camera Camera to dispose post process on
  75182. */
  75183. dispose(camera: Camera): void;
  75184. /** @hidden */
  75185. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  75186. }
  75187. }
  75188. declare module "babylonjs/Shaders/sharpen.fragment" {
  75189. /** @hidden */
  75190. export var sharpenPixelShader: {
  75191. name: string;
  75192. shader: string;
  75193. };
  75194. }
  75195. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  75196. import { Nullable } from "babylonjs/types";
  75197. import { Camera } from "babylonjs/Cameras/camera";
  75198. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75199. import "babylonjs/Shaders/sharpen.fragment";
  75200. import { Engine } from "babylonjs/Engines/engine";
  75201. import { Scene } from "babylonjs/scene";
  75202. /**
  75203. * The SharpenPostProcess applies a sharpen kernel to every pixel
  75204. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  75205. */
  75206. export class SharpenPostProcess extends PostProcess {
  75207. /**
  75208. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  75209. */
  75210. colorAmount: number;
  75211. /**
  75212. * How much sharpness should be applied (default: 0.3)
  75213. */
  75214. edgeAmount: number;
  75215. /**
  75216. * Gets a string identifying the name of the class
  75217. * @returns "SharpenPostProcess" string
  75218. */
  75219. getClassName(): string;
  75220. /**
  75221. * Creates a new instance ConvolutionPostProcess
  75222. * @param name The name of the effect.
  75223. * @param options The required width/height ratio to downsize to before computing the render pass.
  75224. * @param camera The camera to apply the render pass to.
  75225. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75226. * @param engine The engine which the post process will be applied. (default: current engine)
  75227. * @param reusable If the post process can be reused on the same frame. (default: false)
  75228. * @param textureType Type of textures used when performing the post process. (default: 0)
  75229. * @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)
  75230. */
  75231. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75232. /** @hidden */
  75233. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  75234. }
  75235. }
  75236. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  75237. import { Nullable } from "babylonjs/types";
  75238. import { Camera } from "babylonjs/Cameras/camera";
  75239. import { Engine } from "babylonjs/Engines/engine";
  75240. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75241. import { IInspectable } from "babylonjs/Misc/iInspectable";
  75242. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  75243. /**
  75244. * PostProcessRenderPipeline
  75245. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75246. */
  75247. export class PostProcessRenderPipeline {
  75248. private engine;
  75249. private _renderEffects;
  75250. private _renderEffectsForIsolatedPass;
  75251. /**
  75252. * List of inspectable custom properties (used by the Inspector)
  75253. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75254. */
  75255. inspectableCustomProperties: IInspectable[];
  75256. /**
  75257. * @hidden
  75258. */
  75259. protected _cameras: Camera[];
  75260. /** @hidden */
  75261. _name: string;
  75262. /**
  75263. * Gets pipeline name
  75264. */
  75265. get name(): string;
  75266. /** Gets the list of attached cameras */
  75267. get cameras(): Camera[];
  75268. /**
  75269. * Initializes a PostProcessRenderPipeline
  75270. * @param engine engine to add the pipeline to
  75271. * @param name name of the pipeline
  75272. */
  75273. constructor(engine: Engine, name: string);
  75274. /**
  75275. * Gets the class name
  75276. * @returns "PostProcessRenderPipeline"
  75277. */
  75278. getClassName(): string;
  75279. /**
  75280. * If all the render effects in the pipeline are supported
  75281. */
  75282. get isSupported(): boolean;
  75283. /**
  75284. * Adds an effect to the pipeline
  75285. * @param renderEffect the effect to add
  75286. */
  75287. addEffect(renderEffect: PostProcessRenderEffect): void;
  75288. /** @hidden */
  75289. _rebuild(): void;
  75290. /** @hidden */
  75291. _enableEffect(renderEffectName: string, cameras: Camera): void;
  75292. /** @hidden */
  75293. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  75294. /** @hidden */
  75295. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75296. /** @hidden */
  75297. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75298. /** @hidden */
  75299. _attachCameras(cameras: Camera, unique: boolean): void;
  75300. /** @hidden */
  75301. _attachCameras(cameras: Camera[], unique: boolean): void;
  75302. /** @hidden */
  75303. _detachCameras(cameras: Camera): void;
  75304. /** @hidden */
  75305. _detachCameras(cameras: Nullable<Camera[]>): void;
  75306. /** @hidden */
  75307. _update(): void;
  75308. /** @hidden */
  75309. _reset(): void;
  75310. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  75311. /**
  75312. * Sets the required values to the prepass renderer.
  75313. * @param prePassRenderer defines the prepass renderer to setup.
  75314. * @returns true if the pre pass is needed.
  75315. */
  75316. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  75317. /**
  75318. * Disposes of the pipeline
  75319. */
  75320. dispose(): void;
  75321. }
  75322. }
  75323. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  75324. import { Camera } from "babylonjs/Cameras/camera";
  75325. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75326. /**
  75327. * PostProcessRenderPipelineManager class
  75328. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75329. */
  75330. export class PostProcessRenderPipelineManager {
  75331. private _renderPipelines;
  75332. /**
  75333. * Initializes a PostProcessRenderPipelineManager
  75334. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75335. */
  75336. constructor();
  75337. /**
  75338. * Gets the list of supported render pipelines
  75339. */
  75340. get supportedPipelines(): PostProcessRenderPipeline[];
  75341. /**
  75342. * Adds a pipeline to the manager
  75343. * @param renderPipeline The pipeline to add
  75344. */
  75345. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  75346. /**
  75347. * Attaches a camera to the pipeline
  75348. * @param renderPipelineName The name of the pipeline to attach to
  75349. * @param cameras the camera to attach
  75350. * @param unique if the camera can be attached multiple times to the pipeline
  75351. */
  75352. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  75353. /**
  75354. * Detaches a camera from the pipeline
  75355. * @param renderPipelineName The name of the pipeline to detach from
  75356. * @param cameras the camera to detach
  75357. */
  75358. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  75359. /**
  75360. * Enables an effect by name on a pipeline
  75361. * @param renderPipelineName the name of the pipeline to enable the effect in
  75362. * @param renderEffectName the name of the effect to enable
  75363. * @param cameras the cameras that the effect should be enabled on
  75364. */
  75365. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75366. /**
  75367. * Disables an effect by name on a pipeline
  75368. * @param renderPipelineName the name of the pipeline to disable the effect in
  75369. * @param renderEffectName the name of the effect to disable
  75370. * @param cameras the cameras that the effect should be disabled on
  75371. */
  75372. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75373. /**
  75374. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  75375. */
  75376. update(): void;
  75377. /** @hidden */
  75378. _rebuild(): void;
  75379. /**
  75380. * Disposes of the manager and pipelines
  75381. */
  75382. dispose(): void;
  75383. }
  75384. }
  75385. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  75386. import { ISceneComponent } from "babylonjs/sceneComponent";
  75387. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75388. import { Scene } from "babylonjs/scene";
  75389. module "babylonjs/scene" {
  75390. interface Scene {
  75391. /** @hidden (Backing field) */
  75392. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75393. /**
  75394. * Gets the postprocess render pipeline manager
  75395. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75396. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75397. */
  75398. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75399. }
  75400. }
  75401. /**
  75402. * Defines the Render Pipeline scene component responsible to rendering pipelines
  75403. */
  75404. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  75405. /**
  75406. * The component name helpfull to identify the component in the list of scene components.
  75407. */
  75408. readonly name: string;
  75409. /**
  75410. * The scene the component belongs to.
  75411. */
  75412. scene: Scene;
  75413. /**
  75414. * Creates a new instance of the component for the given scene
  75415. * @param scene Defines the scene to register the component in
  75416. */
  75417. constructor(scene: Scene);
  75418. /**
  75419. * Registers the component in a given scene
  75420. */
  75421. register(): void;
  75422. /**
  75423. * Rebuilds the elements related to this component in case of
  75424. * context lost for instance.
  75425. */
  75426. rebuild(): void;
  75427. /**
  75428. * Disposes the component and the associated ressources
  75429. */
  75430. dispose(): void;
  75431. private _gatherRenderTargets;
  75432. }
  75433. }
  75434. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  75435. import { Nullable } from "babylonjs/types";
  75436. import { Observable } from "babylonjs/Misc/observable";
  75437. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75438. import { Camera } from "babylonjs/Cameras/camera";
  75439. import { IDisposable } from "babylonjs/scene";
  75440. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  75441. import { Scene } from "babylonjs/scene";
  75442. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  75443. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75444. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75445. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  75446. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75447. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75448. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  75449. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75450. import { Animation } from "babylonjs/Animations/animation";
  75451. /**
  75452. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  75453. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75454. */
  75455. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75456. private _scene;
  75457. private _camerasToBeAttached;
  75458. /**
  75459. * ID of the sharpen post process,
  75460. */
  75461. private readonly SharpenPostProcessId;
  75462. /**
  75463. * @ignore
  75464. * ID of the image processing post process;
  75465. */
  75466. readonly ImageProcessingPostProcessId: string;
  75467. /**
  75468. * @ignore
  75469. * ID of the Fast Approximate Anti-Aliasing post process;
  75470. */
  75471. readonly FxaaPostProcessId: string;
  75472. /**
  75473. * ID of the chromatic aberration post process,
  75474. */
  75475. private readonly ChromaticAberrationPostProcessId;
  75476. /**
  75477. * ID of the grain post process
  75478. */
  75479. private readonly GrainPostProcessId;
  75480. /**
  75481. * Sharpen post process which will apply a sharpen convolution to enhance edges
  75482. */
  75483. sharpen: SharpenPostProcess;
  75484. private _sharpenEffect;
  75485. private bloom;
  75486. /**
  75487. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  75488. */
  75489. depthOfField: DepthOfFieldEffect;
  75490. /**
  75491. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75492. */
  75493. fxaa: FxaaPostProcess;
  75494. /**
  75495. * Image post processing pass used to perform operations such as tone mapping or color grading.
  75496. */
  75497. imageProcessing: ImageProcessingPostProcess;
  75498. /**
  75499. * Chromatic aberration post process which will shift rgb colors in the image
  75500. */
  75501. chromaticAberration: ChromaticAberrationPostProcess;
  75502. private _chromaticAberrationEffect;
  75503. /**
  75504. * Grain post process which add noise to the image
  75505. */
  75506. grain: GrainPostProcess;
  75507. private _grainEffect;
  75508. /**
  75509. * Glow post process which adds a glow to emissive areas of the image
  75510. */
  75511. private _glowLayer;
  75512. /**
  75513. * Animations which can be used to tweak settings over a period of time
  75514. */
  75515. animations: Animation[];
  75516. private _imageProcessingConfigurationObserver;
  75517. private _sharpenEnabled;
  75518. private _bloomEnabled;
  75519. private _depthOfFieldEnabled;
  75520. private _depthOfFieldBlurLevel;
  75521. private _fxaaEnabled;
  75522. private _imageProcessingEnabled;
  75523. private _defaultPipelineTextureType;
  75524. private _bloomScale;
  75525. private _chromaticAberrationEnabled;
  75526. private _grainEnabled;
  75527. private _buildAllowed;
  75528. /**
  75529. * This is triggered each time the pipeline has been built.
  75530. */
  75531. onBuildObservable: Observable<DefaultRenderingPipeline>;
  75532. /**
  75533. * Gets active scene
  75534. */
  75535. get scene(): Scene;
  75536. /**
  75537. * Enable or disable the sharpen process from the pipeline
  75538. */
  75539. set sharpenEnabled(enabled: boolean);
  75540. get sharpenEnabled(): boolean;
  75541. private _resizeObserver;
  75542. private _hardwareScaleLevel;
  75543. private _bloomKernel;
  75544. /**
  75545. * Specifies the size of the bloom blur kernel, relative to the final output size
  75546. */
  75547. get bloomKernel(): number;
  75548. set bloomKernel(value: number);
  75549. /**
  75550. * Specifies the weight of the bloom in the final rendering
  75551. */
  75552. private _bloomWeight;
  75553. /**
  75554. * Specifies the luma threshold for the area that will be blurred by the bloom
  75555. */
  75556. private _bloomThreshold;
  75557. private _hdr;
  75558. /**
  75559. * The strength of the bloom.
  75560. */
  75561. set bloomWeight(value: number);
  75562. get bloomWeight(): number;
  75563. /**
  75564. * The strength of the bloom.
  75565. */
  75566. set bloomThreshold(value: number);
  75567. get bloomThreshold(): number;
  75568. /**
  75569. * The scale of the bloom, lower value will provide better performance.
  75570. */
  75571. set bloomScale(value: number);
  75572. get bloomScale(): number;
  75573. /**
  75574. * Enable or disable the bloom from the pipeline
  75575. */
  75576. set bloomEnabled(enabled: boolean);
  75577. get bloomEnabled(): boolean;
  75578. private _rebuildBloom;
  75579. /**
  75580. * If the depth of field is enabled.
  75581. */
  75582. get depthOfFieldEnabled(): boolean;
  75583. set depthOfFieldEnabled(enabled: boolean);
  75584. /**
  75585. * Blur level of the depth of field effect. (Higher blur will effect performance)
  75586. */
  75587. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  75588. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  75589. /**
  75590. * If the anti aliasing is enabled.
  75591. */
  75592. set fxaaEnabled(enabled: boolean);
  75593. get fxaaEnabled(): boolean;
  75594. private _samples;
  75595. /**
  75596. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75597. */
  75598. set samples(sampleCount: number);
  75599. get samples(): number;
  75600. /**
  75601. * If image processing is enabled.
  75602. */
  75603. set imageProcessingEnabled(enabled: boolean);
  75604. get imageProcessingEnabled(): boolean;
  75605. /**
  75606. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  75607. */
  75608. set glowLayerEnabled(enabled: boolean);
  75609. get glowLayerEnabled(): boolean;
  75610. /**
  75611. * Gets the glow layer (or null if not defined)
  75612. */
  75613. get glowLayer(): Nullable<GlowLayer>;
  75614. /**
  75615. * Enable or disable the chromaticAberration process from the pipeline
  75616. */
  75617. set chromaticAberrationEnabled(enabled: boolean);
  75618. get chromaticAberrationEnabled(): boolean;
  75619. /**
  75620. * Enable or disable the grain process from the pipeline
  75621. */
  75622. set grainEnabled(enabled: boolean);
  75623. get grainEnabled(): boolean;
  75624. /**
  75625. * @constructor
  75626. * @param name - The rendering pipeline name (default: "")
  75627. * @param hdr - If high dynamic range textures should be used (default: true)
  75628. * @param scene - The scene linked to this pipeline (default: the last created scene)
  75629. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  75630. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  75631. */
  75632. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  75633. /**
  75634. * Get the class name
  75635. * @returns "DefaultRenderingPipeline"
  75636. */
  75637. getClassName(): string;
  75638. /**
  75639. * Force the compilation of the entire pipeline.
  75640. */
  75641. prepare(): void;
  75642. private _hasCleared;
  75643. private _prevPostProcess;
  75644. private _prevPrevPostProcess;
  75645. private _setAutoClearAndTextureSharing;
  75646. private _depthOfFieldSceneObserver;
  75647. private _buildPipeline;
  75648. private _disposePostProcesses;
  75649. /**
  75650. * Adds a camera to the pipeline
  75651. * @param camera the camera to be added
  75652. */
  75653. addCamera(camera: Camera): void;
  75654. /**
  75655. * Removes a camera from the pipeline
  75656. * @param camera the camera to remove
  75657. */
  75658. removeCamera(camera: Camera): void;
  75659. /**
  75660. * Dispose of the pipeline and stop all post processes
  75661. */
  75662. dispose(): void;
  75663. /**
  75664. * Serialize the rendering pipeline (Used when exporting)
  75665. * @returns the serialized object
  75666. */
  75667. serialize(): any;
  75668. /**
  75669. * Parse the serialized pipeline
  75670. * @param source Source pipeline.
  75671. * @param scene The scene to load the pipeline to.
  75672. * @param rootUrl The URL of the serialized pipeline.
  75673. * @returns An instantiated pipeline from the serialized object.
  75674. */
  75675. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  75676. }
  75677. }
  75678. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  75679. /** @hidden */
  75680. export var lensHighlightsPixelShader: {
  75681. name: string;
  75682. shader: string;
  75683. };
  75684. }
  75685. declare module "babylonjs/Shaders/depthOfField.fragment" {
  75686. /** @hidden */
  75687. export var depthOfFieldPixelShader: {
  75688. name: string;
  75689. shader: string;
  75690. };
  75691. }
  75692. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  75693. import { Camera } from "babylonjs/Cameras/camera";
  75694. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75695. import { Scene } from "babylonjs/scene";
  75696. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75697. import "babylonjs/Shaders/chromaticAberration.fragment";
  75698. import "babylonjs/Shaders/lensHighlights.fragment";
  75699. import "babylonjs/Shaders/depthOfField.fragment";
  75700. /**
  75701. * BABYLON.JS Chromatic Aberration GLSL Shader
  75702. * Author: Olivier Guyot
  75703. * Separates very slightly R, G and B colors on the edges of the screen
  75704. * Inspired by Francois Tarlier & Martins Upitis
  75705. */
  75706. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  75707. /**
  75708. * @ignore
  75709. * The chromatic aberration PostProcess id in the pipeline
  75710. */
  75711. LensChromaticAberrationEffect: string;
  75712. /**
  75713. * @ignore
  75714. * The highlights enhancing PostProcess id in the pipeline
  75715. */
  75716. HighlightsEnhancingEffect: string;
  75717. /**
  75718. * @ignore
  75719. * The depth-of-field PostProcess id in the pipeline
  75720. */
  75721. LensDepthOfFieldEffect: string;
  75722. private _scene;
  75723. private _depthTexture;
  75724. private _grainTexture;
  75725. private _chromaticAberrationPostProcess;
  75726. private _highlightsPostProcess;
  75727. private _depthOfFieldPostProcess;
  75728. private _edgeBlur;
  75729. private _grainAmount;
  75730. private _chromaticAberration;
  75731. private _distortion;
  75732. private _highlightsGain;
  75733. private _highlightsThreshold;
  75734. private _dofDistance;
  75735. private _dofAperture;
  75736. private _dofDarken;
  75737. private _dofPentagon;
  75738. private _blurNoise;
  75739. /**
  75740. * @constructor
  75741. *
  75742. * Effect parameters are as follow:
  75743. * {
  75744. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75745. * edge_blur: number; // from 0 to x (1 for realism)
  75746. * distortion: number; // from 0 to x (1 for realism)
  75747. * grain_amount: number; // from 0 to 1
  75748. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75749. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75750. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75751. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75752. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75753. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75754. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75755. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75756. * }
  75757. * Note: if an effect parameter is unset, effect is disabled
  75758. *
  75759. * @param name The rendering pipeline name
  75760. * @param parameters - An object containing all parameters (see above)
  75761. * @param scene The scene linked to this pipeline
  75762. * @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)
  75763. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75764. */
  75765. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75766. /**
  75767. * Get the class name
  75768. * @returns "LensRenderingPipeline"
  75769. */
  75770. getClassName(): string;
  75771. /**
  75772. * Gets associated scene
  75773. */
  75774. get scene(): Scene;
  75775. /**
  75776. * Gets or sets the edge blur
  75777. */
  75778. get edgeBlur(): number;
  75779. set edgeBlur(value: number);
  75780. /**
  75781. * Gets or sets the grain amount
  75782. */
  75783. get grainAmount(): number;
  75784. set grainAmount(value: number);
  75785. /**
  75786. * Gets or sets the chromatic aberration amount
  75787. */
  75788. get chromaticAberration(): number;
  75789. set chromaticAberration(value: number);
  75790. /**
  75791. * Gets or sets the depth of field aperture
  75792. */
  75793. get dofAperture(): number;
  75794. set dofAperture(value: number);
  75795. /**
  75796. * Gets or sets the edge distortion
  75797. */
  75798. get edgeDistortion(): number;
  75799. set edgeDistortion(value: number);
  75800. /**
  75801. * Gets or sets the depth of field distortion
  75802. */
  75803. get dofDistortion(): number;
  75804. set dofDistortion(value: number);
  75805. /**
  75806. * Gets or sets the darken out of focus amount
  75807. */
  75808. get darkenOutOfFocus(): number;
  75809. set darkenOutOfFocus(value: number);
  75810. /**
  75811. * Gets or sets a boolean indicating if blur noise is enabled
  75812. */
  75813. get blurNoise(): boolean;
  75814. set blurNoise(value: boolean);
  75815. /**
  75816. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75817. */
  75818. get pentagonBokeh(): boolean;
  75819. set pentagonBokeh(value: boolean);
  75820. /**
  75821. * Gets or sets the highlight grain amount
  75822. */
  75823. get highlightsGain(): number;
  75824. set highlightsGain(value: number);
  75825. /**
  75826. * Gets or sets the highlight threshold
  75827. */
  75828. get highlightsThreshold(): number;
  75829. set highlightsThreshold(value: number);
  75830. /**
  75831. * Sets the amount of blur at the edges
  75832. * @param amount blur amount
  75833. */
  75834. setEdgeBlur(amount: number): void;
  75835. /**
  75836. * Sets edge blur to 0
  75837. */
  75838. disableEdgeBlur(): void;
  75839. /**
  75840. * Sets the amout of grain
  75841. * @param amount Amount of grain
  75842. */
  75843. setGrainAmount(amount: number): void;
  75844. /**
  75845. * Set grain amount to 0
  75846. */
  75847. disableGrain(): void;
  75848. /**
  75849. * Sets the chromatic aberration amount
  75850. * @param amount amount of chromatic aberration
  75851. */
  75852. setChromaticAberration(amount: number): void;
  75853. /**
  75854. * Sets chromatic aberration amount to 0
  75855. */
  75856. disableChromaticAberration(): void;
  75857. /**
  75858. * Sets the EdgeDistortion amount
  75859. * @param amount amount of EdgeDistortion
  75860. */
  75861. setEdgeDistortion(amount: number): void;
  75862. /**
  75863. * Sets edge distortion to 0
  75864. */
  75865. disableEdgeDistortion(): void;
  75866. /**
  75867. * Sets the FocusDistance amount
  75868. * @param amount amount of FocusDistance
  75869. */
  75870. setFocusDistance(amount: number): void;
  75871. /**
  75872. * Disables depth of field
  75873. */
  75874. disableDepthOfField(): void;
  75875. /**
  75876. * Sets the Aperture amount
  75877. * @param amount amount of Aperture
  75878. */
  75879. setAperture(amount: number): void;
  75880. /**
  75881. * Sets the DarkenOutOfFocus amount
  75882. * @param amount amount of DarkenOutOfFocus
  75883. */
  75884. setDarkenOutOfFocus(amount: number): void;
  75885. private _pentagonBokehIsEnabled;
  75886. /**
  75887. * Creates a pentagon bokeh effect
  75888. */
  75889. enablePentagonBokeh(): void;
  75890. /**
  75891. * Disables the pentagon bokeh effect
  75892. */
  75893. disablePentagonBokeh(): void;
  75894. /**
  75895. * Enables noise blur
  75896. */
  75897. enableNoiseBlur(): void;
  75898. /**
  75899. * Disables noise blur
  75900. */
  75901. disableNoiseBlur(): void;
  75902. /**
  75903. * Sets the HighlightsGain amount
  75904. * @param amount amount of HighlightsGain
  75905. */
  75906. setHighlightsGain(amount: number): void;
  75907. /**
  75908. * Sets the HighlightsThreshold amount
  75909. * @param amount amount of HighlightsThreshold
  75910. */
  75911. setHighlightsThreshold(amount: number): void;
  75912. /**
  75913. * Disables highlights
  75914. */
  75915. disableHighlights(): void;
  75916. /**
  75917. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75918. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  75919. */
  75920. dispose(disableDepthRender?: boolean): void;
  75921. private _createChromaticAberrationPostProcess;
  75922. private _createHighlightsPostProcess;
  75923. private _createDepthOfFieldPostProcess;
  75924. private _createGrainTexture;
  75925. }
  75926. }
  75927. declare module "babylonjs/Rendering/ssao2Configuration" {
  75928. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75929. /**
  75930. * Contains all parameters needed for the prepass to perform
  75931. * screen space subsurface scattering
  75932. */
  75933. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75934. /**
  75935. * Is subsurface enabled
  75936. */
  75937. enabled: boolean;
  75938. /**
  75939. * Name of the configuration
  75940. */
  75941. name: string;
  75942. /**
  75943. * Textures that should be present in the MRT for this effect to work
  75944. */
  75945. readonly texturesRequired: number[];
  75946. }
  75947. }
  75948. declare module "babylonjs/Shaders/ssao2.fragment" {
  75949. /** @hidden */
  75950. export var ssao2PixelShader: {
  75951. name: string;
  75952. shader: string;
  75953. };
  75954. }
  75955. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  75956. /** @hidden */
  75957. export var ssaoCombinePixelShader: {
  75958. name: string;
  75959. shader: string;
  75960. };
  75961. }
  75962. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  75963. import { Camera } from "babylonjs/Cameras/camera";
  75964. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75965. import { Scene } from "babylonjs/scene";
  75966. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75967. import "babylonjs/Shaders/ssao2.fragment";
  75968. import "babylonjs/Shaders/ssaoCombine.fragment";
  75969. /**
  75970. * Render pipeline to produce ssao effect
  75971. */
  75972. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75973. /**
  75974. * @ignore
  75975. * The PassPostProcess id in the pipeline that contains the original scene color
  75976. */
  75977. SSAOOriginalSceneColorEffect: string;
  75978. /**
  75979. * @ignore
  75980. * The SSAO PostProcess id in the pipeline
  75981. */
  75982. SSAORenderEffect: string;
  75983. /**
  75984. * @ignore
  75985. * The horizontal blur PostProcess id in the pipeline
  75986. */
  75987. SSAOBlurHRenderEffect: string;
  75988. /**
  75989. * @ignore
  75990. * The vertical blur PostProcess id in the pipeline
  75991. */
  75992. SSAOBlurVRenderEffect: string;
  75993. /**
  75994. * @ignore
  75995. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75996. */
  75997. SSAOCombineRenderEffect: string;
  75998. /**
  75999. * The output strength of the SSAO post-process. Default value is 1.0.
  76000. */
  76001. totalStrength: number;
  76002. /**
  76003. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  76004. */
  76005. maxZ: number;
  76006. /**
  76007. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  76008. */
  76009. minZAspect: number;
  76010. private _samples;
  76011. /**
  76012. * Number of samples used for the SSAO calculations. Default value is 8
  76013. */
  76014. set samples(n: number);
  76015. get samples(): number;
  76016. private _textureSamples;
  76017. /**
  76018. * Number of samples to use for antialiasing
  76019. */
  76020. set textureSamples(n: number);
  76021. get textureSamples(): number;
  76022. /**
  76023. * Force rendering the geometry through geometry buffer
  76024. */
  76025. private _forceGeometryBuffer;
  76026. /**
  76027. * Ratio object used for SSAO ratio and blur ratio
  76028. */
  76029. private _ratio;
  76030. /**
  76031. * Dynamically generated sphere sampler.
  76032. */
  76033. private _sampleSphere;
  76034. /**
  76035. * Blur filter offsets
  76036. */
  76037. private _samplerOffsets;
  76038. private _expensiveBlur;
  76039. /**
  76040. * If bilateral blur should be used
  76041. */
  76042. set expensiveBlur(b: boolean);
  76043. get expensiveBlur(): boolean;
  76044. /**
  76045. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  76046. */
  76047. radius: number;
  76048. /**
  76049. * The base color of the SSAO post-process
  76050. * The final result is "base + ssao" between [0, 1]
  76051. */
  76052. base: number;
  76053. /**
  76054. * Support test.
  76055. */
  76056. static get IsSupported(): boolean;
  76057. private _scene;
  76058. private _randomTexture;
  76059. private _originalColorPostProcess;
  76060. private _ssaoPostProcess;
  76061. private _blurHPostProcess;
  76062. private _blurVPostProcess;
  76063. private _ssaoCombinePostProcess;
  76064. private _prePassRenderer;
  76065. /**
  76066. * Gets active scene
  76067. */
  76068. get scene(): Scene;
  76069. /**
  76070. * @constructor
  76071. * @param name The rendering pipeline name
  76072. * @param scene The scene linked to this pipeline
  76073. * @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 }
  76074. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76075. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  76076. */
  76077. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  76078. /**
  76079. * Get the class name
  76080. * @returns "SSAO2RenderingPipeline"
  76081. */
  76082. getClassName(): string;
  76083. /**
  76084. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  76085. */
  76086. dispose(disableGeometryBufferRenderer?: boolean): void;
  76087. private _createBlurPostProcess;
  76088. /** @hidden */
  76089. _rebuild(): void;
  76090. private _bits;
  76091. private _radicalInverse_VdC;
  76092. private _hammersley;
  76093. private _hemisphereSample_uniform;
  76094. private _generateHemisphere;
  76095. private _getDefinesForSSAO;
  76096. private _createSSAOPostProcess;
  76097. private _createSSAOCombinePostProcess;
  76098. private _createRandomTexture;
  76099. /**
  76100. * Serialize the rendering pipeline (Used when exporting)
  76101. * @returns the serialized object
  76102. */
  76103. serialize(): any;
  76104. /**
  76105. * Parse the serialized pipeline
  76106. * @param source Source pipeline.
  76107. * @param scene The scene to load the pipeline to.
  76108. * @param rootUrl The URL of the serialized pipeline.
  76109. * @returns An instantiated pipeline from the serialized object.
  76110. */
  76111. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  76112. }
  76113. }
  76114. declare module "babylonjs/Shaders/ssao.fragment" {
  76115. /** @hidden */
  76116. export var ssaoPixelShader: {
  76117. name: string;
  76118. shader: string;
  76119. };
  76120. }
  76121. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  76122. import { Camera } from "babylonjs/Cameras/camera";
  76123. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76124. import { Scene } from "babylonjs/scene";
  76125. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76126. import "babylonjs/Shaders/ssao.fragment";
  76127. import "babylonjs/Shaders/ssaoCombine.fragment";
  76128. /**
  76129. * Render pipeline to produce ssao effect
  76130. */
  76131. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  76132. /**
  76133. * @ignore
  76134. * The PassPostProcess id in the pipeline that contains the original scene color
  76135. */
  76136. SSAOOriginalSceneColorEffect: string;
  76137. /**
  76138. * @ignore
  76139. * The SSAO PostProcess id in the pipeline
  76140. */
  76141. SSAORenderEffect: string;
  76142. /**
  76143. * @ignore
  76144. * The horizontal blur PostProcess id in the pipeline
  76145. */
  76146. SSAOBlurHRenderEffect: string;
  76147. /**
  76148. * @ignore
  76149. * The vertical blur PostProcess id in the pipeline
  76150. */
  76151. SSAOBlurVRenderEffect: string;
  76152. /**
  76153. * @ignore
  76154. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  76155. */
  76156. SSAOCombineRenderEffect: string;
  76157. /**
  76158. * The output strength of the SSAO post-process. Default value is 1.0.
  76159. */
  76160. totalStrength: number;
  76161. /**
  76162. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  76163. */
  76164. radius: number;
  76165. /**
  76166. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  76167. * Must not be equal to fallOff and superior to fallOff.
  76168. * Default value is 0.0075
  76169. */
  76170. area: number;
  76171. /**
  76172. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  76173. * Must not be equal to area and inferior to area.
  76174. * Default value is 0.000001
  76175. */
  76176. fallOff: number;
  76177. /**
  76178. * The base color of the SSAO post-process
  76179. * The final result is "base + ssao" between [0, 1]
  76180. */
  76181. base: number;
  76182. private _scene;
  76183. private _depthTexture;
  76184. private _randomTexture;
  76185. private _originalColorPostProcess;
  76186. private _ssaoPostProcess;
  76187. private _blurHPostProcess;
  76188. private _blurVPostProcess;
  76189. private _ssaoCombinePostProcess;
  76190. private _firstUpdate;
  76191. /**
  76192. * Gets active scene
  76193. */
  76194. get scene(): Scene;
  76195. /**
  76196. * @constructor
  76197. * @param name - The rendering pipeline name
  76198. * @param scene - The scene linked to this pipeline
  76199. * @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 }
  76200. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  76201. */
  76202. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  76203. /**
  76204. * Get the class name
  76205. * @returns "SSAORenderingPipeline"
  76206. */
  76207. getClassName(): string;
  76208. /**
  76209. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  76210. */
  76211. dispose(disableDepthRender?: boolean): void;
  76212. private _createBlurPostProcess;
  76213. /** @hidden */
  76214. _rebuild(): void;
  76215. private _createSSAOPostProcess;
  76216. private _createSSAOCombinePostProcess;
  76217. private _createRandomTexture;
  76218. }
  76219. }
  76220. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  76221. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76222. /**
  76223. * Contains all parameters needed for the prepass to perform
  76224. * screen space reflections
  76225. */
  76226. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  76227. /**
  76228. * Is ssr enabled
  76229. */
  76230. enabled: boolean;
  76231. /**
  76232. * Name of the configuration
  76233. */
  76234. name: string;
  76235. /**
  76236. * Textures that should be present in the MRT for this effect to work
  76237. */
  76238. readonly texturesRequired: number[];
  76239. }
  76240. }
  76241. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  76242. /** @hidden */
  76243. export var screenSpaceReflectionPixelShader: {
  76244. name: string;
  76245. shader: string;
  76246. };
  76247. }
  76248. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  76249. import { Nullable } from "babylonjs/types";
  76250. import { Camera } from "babylonjs/Cameras/camera";
  76251. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76252. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  76253. import { Engine } from "babylonjs/Engines/engine";
  76254. import { Scene } from "babylonjs/scene";
  76255. /**
  76256. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  76257. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  76258. */
  76259. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  76260. /**
  76261. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  76262. */
  76263. threshold: number;
  76264. /**
  76265. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  76266. */
  76267. strength: number;
  76268. /**
  76269. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  76270. */
  76271. reflectionSpecularFalloffExponent: number;
  76272. /**
  76273. * 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]
  76274. */
  76275. step: number;
  76276. /**
  76277. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  76278. */
  76279. roughnessFactor: number;
  76280. private _forceGeometryBuffer;
  76281. private _geometryBufferRenderer;
  76282. private _prePassRenderer;
  76283. private _enableSmoothReflections;
  76284. private _reflectionSamples;
  76285. private _smoothSteps;
  76286. /**
  76287. * Gets a string identifying the name of the class
  76288. * @returns "ScreenSpaceReflectionPostProcess" string
  76289. */
  76290. getClassName(): string;
  76291. /**
  76292. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  76293. * @param name The name of the effect.
  76294. * @param scene The scene containing the objects to calculate reflections.
  76295. * @param options The required width/height ratio to downsize to before computing the render pass.
  76296. * @param camera The camera to apply the render pass to.
  76297. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76298. * @param engine The engine which the post process will be applied. (default: current engine)
  76299. * @param reusable If the post process can be reused on the same frame. (default: false)
  76300. * @param textureType Type of textures used when performing the post process. (default: 0)
  76301. * @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)
  76302. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  76303. */
  76304. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  76305. /**
  76306. * Gets wether or not smoothing reflections is enabled.
  76307. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76308. */
  76309. get enableSmoothReflections(): boolean;
  76310. /**
  76311. * Sets wether or not smoothing reflections is enabled.
  76312. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76313. */
  76314. set enableSmoothReflections(enabled: boolean);
  76315. /**
  76316. * Gets the number of samples taken while computing reflections. More samples count is high,
  76317. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76318. */
  76319. get reflectionSamples(): number;
  76320. /**
  76321. * Sets the number of samples taken while computing reflections. More samples count is high,
  76322. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76323. */
  76324. set reflectionSamples(samples: number);
  76325. /**
  76326. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  76327. * more the post-process will require GPU power and can generate a drop in FPS.
  76328. * Default value (5.0) work pretty well in all cases but can be adjusted.
  76329. */
  76330. get smoothSteps(): number;
  76331. set smoothSteps(steps: number);
  76332. private _updateEffectDefines;
  76333. /** @hidden */
  76334. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  76335. }
  76336. }
  76337. declare module "babylonjs/Shaders/standard.fragment" {
  76338. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  76339. /** @hidden */
  76340. export var standardPixelShader: {
  76341. name: string;
  76342. shader: string;
  76343. };
  76344. }
  76345. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  76346. import { Nullable } from "babylonjs/types";
  76347. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  76348. import { Camera } from "babylonjs/Cameras/camera";
  76349. import { Texture } from "babylonjs/Materials/Textures/texture";
  76350. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76351. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76352. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  76353. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  76354. import { IDisposable } from "babylonjs/scene";
  76355. import { SpotLight } from "babylonjs/Lights/spotLight";
  76356. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  76357. import { Scene } from "babylonjs/scene";
  76358. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76359. import { Animation } from "babylonjs/Animations/animation";
  76360. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76361. import "babylonjs/Shaders/standard.fragment";
  76362. /**
  76363. * Standard rendering pipeline
  76364. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76365. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  76366. */
  76367. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  76368. /**
  76369. * Public members
  76370. */
  76371. /**
  76372. * Post-process which contains the original scene color before the pipeline applies all the effects
  76373. */
  76374. originalPostProcess: Nullable<PostProcess>;
  76375. /**
  76376. * Post-process used to down scale an image x4
  76377. */
  76378. downSampleX4PostProcess: Nullable<PostProcess>;
  76379. /**
  76380. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  76381. */
  76382. brightPassPostProcess: Nullable<PostProcess>;
  76383. /**
  76384. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  76385. */
  76386. blurHPostProcesses: PostProcess[];
  76387. /**
  76388. * Post-process array storing all the vertical blur post-processes used by the pipeline
  76389. */
  76390. blurVPostProcesses: PostProcess[];
  76391. /**
  76392. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  76393. */
  76394. textureAdderPostProcess: Nullable<PostProcess>;
  76395. /**
  76396. * Post-process used to create volumetric lighting effect
  76397. */
  76398. volumetricLightPostProcess: Nullable<PostProcess>;
  76399. /**
  76400. * Post-process used to smooth the previous volumetric light post-process on the X axis
  76401. */
  76402. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  76403. /**
  76404. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  76405. */
  76406. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  76407. /**
  76408. * Post-process used to merge the volumetric light effect and the real scene color
  76409. */
  76410. volumetricLightMergePostProces: Nullable<PostProcess>;
  76411. /**
  76412. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  76413. */
  76414. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  76415. /**
  76416. * Base post-process used to calculate the average luminance of the final image for HDR
  76417. */
  76418. luminancePostProcess: Nullable<PostProcess>;
  76419. /**
  76420. * Post-processes used to create down sample post-processes in order to get
  76421. * the average luminance of the final image for HDR
  76422. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  76423. */
  76424. luminanceDownSamplePostProcesses: PostProcess[];
  76425. /**
  76426. * Post-process used to create a HDR effect (light adaptation)
  76427. */
  76428. hdrPostProcess: Nullable<PostProcess>;
  76429. /**
  76430. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  76431. */
  76432. textureAdderFinalPostProcess: Nullable<PostProcess>;
  76433. /**
  76434. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  76435. */
  76436. lensFlareFinalPostProcess: Nullable<PostProcess>;
  76437. /**
  76438. * Post-process used to merge the final HDR post-process and the real scene color
  76439. */
  76440. hdrFinalPostProcess: Nullable<PostProcess>;
  76441. /**
  76442. * Post-process used to create a lens flare effect
  76443. */
  76444. lensFlarePostProcess: Nullable<PostProcess>;
  76445. /**
  76446. * Post-process that merges the result of the lens flare post-process and the real scene color
  76447. */
  76448. lensFlareComposePostProcess: Nullable<PostProcess>;
  76449. /**
  76450. * Post-process used to create a motion blur effect
  76451. */
  76452. motionBlurPostProcess: Nullable<PostProcess>;
  76453. /**
  76454. * Post-process used to create a depth of field effect
  76455. */
  76456. depthOfFieldPostProcess: Nullable<PostProcess>;
  76457. /**
  76458. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  76459. */
  76460. fxaaPostProcess: Nullable<FxaaPostProcess>;
  76461. /**
  76462. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  76463. */
  76464. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  76465. /**
  76466. * Represents the brightness threshold in order to configure the illuminated surfaces
  76467. */
  76468. brightThreshold: number;
  76469. /**
  76470. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  76471. */
  76472. blurWidth: number;
  76473. /**
  76474. * Sets if the blur for highlighted surfaces must be only horizontal
  76475. */
  76476. horizontalBlur: boolean;
  76477. /**
  76478. * Gets the overall exposure used by the pipeline
  76479. */
  76480. get exposure(): number;
  76481. /**
  76482. * Sets the overall exposure used by the pipeline
  76483. */
  76484. set exposure(value: number);
  76485. /**
  76486. * Texture used typically to simulate "dirty" on camera lens
  76487. */
  76488. lensTexture: Nullable<Texture>;
  76489. /**
  76490. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  76491. */
  76492. volumetricLightCoefficient: number;
  76493. /**
  76494. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  76495. */
  76496. volumetricLightPower: number;
  76497. /**
  76498. * Used the set the blur intensity to smooth the volumetric lights
  76499. */
  76500. volumetricLightBlurScale: number;
  76501. /**
  76502. * Light (spot or directional) used to generate the volumetric lights rays
  76503. * The source light must have a shadow generate so the pipeline can get its
  76504. * depth map
  76505. */
  76506. sourceLight: Nullable<SpotLight | DirectionalLight>;
  76507. /**
  76508. * For eye adaptation, represents the minimum luminance the eye can see
  76509. */
  76510. hdrMinimumLuminance: number;
  76511. /**
  76512. * For eye adaptation, represents the decrease luminance speed
  76513. */
  76514. hdrDecreaseRate: number;
  76515. /**
  76516. * For eye adaptation, represents the increase luminance speed
  76517. */
  76518. hdrIncreaseRate: number;
  76519. /**
  76520. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76521. */
  76522. get hdrAutoExposure(): boolean;
  76523. /**
  76524. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76525. */
  76526. set hdrAutoExposure(value: boolean);
  76527. /**
  76528. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  76529. */
  76530. lensColorTexture: Nullable<Texture>;
  76531. /**
  76532. * The overall strengh for the lens flare effect
  76533. */
  76534. lensFlareStrength: number;
  76535. /**
  76536. * Dispersion coefficient for lens flare ghosts
  76537. */
  76538. lensFlareGhostDispersal: number;
  76539. /**
  76540. * Main lens flare halo width
  76541. */
  76542. lensFlareHaloWidth: number;
  76543. /**
  76544. * Based on the lens distortion effect, defines how much the lens flare result
  76545. * is distorted
  76546. */
  76547. lensFlareDistortionStrength: number;
  76548. /**
  76549. * Configures the blur intensity used for for lens flare (halo)
  76550. */
  76551. lensFlareBlurWidth: number;
  76552. /**
  76553. * Lens star texture must be used to simulate rays on the flares and is available
  76554. * in the documentation
  76555. */
  76556. lensStarTexture: Nullable<Texture>;
  76557. /**
  76558. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  76559. * flare effect by taking account of the dirt texture
  76560. */
  76561. lensFlareDirtTexture: Nullable<Texture>;
  76562. /**
  76563. * Represents the focal length for the depth of field effect
  76564. */
  76565. depthOfFieldDistance: number;
  76566. /**
  76567. * Represents the blur intensity for the blurred part of the depth of field effect
  76568. */
  76569. depthOfFieldBlurWidth: number;
  76570. /**
  76571. * Gets how much the image is blurred by the movement while using the motion blur post-process
  76572. */
  76573. get motionStrength(): number;
  76574. /**
  76575. * Sets how much the image is blurred by the movement while using the motion blur post-process
  76576. */
  76577. set motionStrength(strength: number);
  76578. /**
  76579. * Gets wether or not the motion blur post-process is object based or screen based.
  76580. */
  76581. get objectBasedMotionBlur(): boolean;
  76582. /**
  76583. * Sets wether or not the motion blur post-process should be object based or screen based
  76584. */
  76585. set objectBasedMotionBlur(value: boolean);
  76586. /**
  76587. * List of animations for the pipeline (IAnimatable implementation)
  76588. */
  76589. animations: Animation[];
  76590. /**
  76591. * Private members
  76592. */
  76593. private _scene;
  76594. private _currentDepthOfFieldSource;
  76595. private _basePostProcess;
  76596. private _fixedExposure;
  76597. private _currentExposure;
  76598. private _hdrAutoExposure;
  76599. private _hdrCurrentLuminance;
  76600. private _motionStrength;
  76601. private _isObjectBasedMotionBlur;
  76602. private _floatTextureType;
  76603. private _camerasToBeAttached;
  76604. private _ratio;
  76605. private _bloomEnabled;
  76606. private _depthOfFieldEnabled;
  76607. private _vlsEnabled;
  76608. private _lensFlareEnabled;
  76609. private _hdrEnabled;
  76610. private _motionBlurEnabled;
  76611. private _fxaaEnabled;
  76612. private _screenSpaceReflectionsEnabled;
  76613. private _motionBlurSamples;
  76614. private _volumetricLightStepsCount;
  76615. private _samples;
  76616. /**
  76617. * @ignore
  76618. * Specifies if the bloom pipeline is enabled
  76619. */
  76620. get BloomEnabled(): boolean;
  76621. set BloomEnabled(enabled: boolean);
  76622. /**
  76623. * @ignore
  76624. * Specifies if the depth of field pipeline is enabed
  76625. */
  76626. get DepthOfFieldEnabled(): boolean;
  76627. set DepthOfFieldEnabled(enabled: boolean);
  76628. /**
  76629. * @ignore
  76630. * Specifies if the lens flare pipeline is enabed
  76631. */
  76632. get LensFlareEnabled(): boolean;
  76633. set LensFlareEnabled(enabled: boolean);
  76634. /**
  76635. * @ignore
  76636. * Specifies if the HDR pipeline is enabled
  76637. */
  76638. get HDREnabled(): boolean;
  76639. set HDREnabled(enabled: boolean);
  76640. /**
  76641. * @ignore
  76642. * Specifies if the volumetric lights scattering effect is enabled
  76643. */
  76644. get VLSEnabled(): boolean;
  76645. set VLSEnabled(enabled: boolean);
  76646. /**
  76647. * @ignore
  76648. * Specifies if the motion blur effect is enabled
  76649. */
  76650. get MotionBlurEnabled(): boolean;
  76651. set MotionBlurEnabled(enabled: boolean);
  76652. /**
  76653. * Specifies if anti-aliasing is enabled
  76654. */
  76655. get fxaaEnabled(): boolean;
  76656. set fxaaEnabled(enabled: boolean);
  76657. /**
  76658. * Specifies if screen space reflections are enabled.
  76659. */
  76660. get screenSpaceReflectionsEnabled(): boolean;
  76661. set screenSpaceReflectionsEnabled(enabled: boolean);
  76662. /**
  76663. * Specifies the number of steps used to calculate the volumetric lights
  76664. * Typically in interval [50, 200]
  76665. */
  76666. get volumetricLightStepsCount(): number;
  76667. set volumetricLightStepsCount(count: number);
  76668. /**
  76669. * Specifies the number of samples used for the motion blur effect
  76670. * Typically in interval [16, 64]
  76671. */
  76672. get motionBlurSamples(): number;
  76673. set motionBlurSamples(samples: number);
  76674. /**
  76675. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  76676. */
  76677. get samples(): number;
  76678. set samples(sampleCount: number);
  76679. /**
  76680. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76681. * @constructor
  76682. * @param name The rendering pipeline name
  76683. * @param scene The scene linked to this pipeline
  76684. * @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)
  76685. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  76686. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76687. */
  76688. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  76689. private _buildPipeline;
  76690. private _createDownSampleX4PostProcess;
  76691. private _createBrightPassPostProcess;
  76692. private _createBlurPostProcesses;
  76693. private _createTextureAdderPostProcess;
  76694. private _createVolumetricLightPostProcess;
  76695. private _createLuminancePostProcesses;
  76696. private _createHdrPostProcess;
  76697. private _createLensFlarePostProcess;
  76698. private _createDepthOfFieldPostProcess;
  76699. private _createMotionBlurPostProcess;
  76700. private _getDepthTexture;
  76701. private _disposePostProcesses;
  76702. /**
  76703. * Dispose of the pipeline and stop all post processes
  76704. */
  76705. dispose(): void;
  76706. /**
  76707. * Serialize the rendering pipeline (Used when exporting)
  76708. * @returns the serialized object
  76709. */
  76710. serialize(): any;
  76711. /**
  76712. * Parse the serialized pipeline
  76713. * @param source Source pipeline.
  76714. * @param scene The scene to load the pipeline to.
  76715. * @param rootUrl The URL of the serialized pipeline.
  76716. * @returns An instantiated pipeline from the serialized object.
  76717. */
  76718. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  76719. /**
  76720. * Luminance steps
  76721. */
  76722. static LuminanceSteps: number;
  76723. }
  76724. }
  76725. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  76726. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  76727. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  76728. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  76729. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  76730. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  76731. }
  76732. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  76733. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  76734. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  76735. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76736. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  76737. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76738. }
  76739. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  76740. /** @hidden */
  76741. export var stereoscopicInterlacePixelShader: {
  76742. name: string;
  76743. shader: string;
  76744. };
  76745. }
  76746. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  76747. import { Camera } from "babylonjs/Cameras/camera";
  76748. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76749. import { Engine } from "babylonjs/Engines/engine";
  76750. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  76751. /**
  76752. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  76753. */
  76754. export class StereoscopicInterlacePostProcessI extends PostProcess {
  76755. private _stepSize;
  76756. private _passedProcess;
  76757. /**
  76758. * Gets a string identifying the name of the class
  76759. * @returns "StereoscopicInterlacePostProcessI" string
  76760. */
  76761. getClassName(): string;
  76762. /**
  76763. * Initializes a StereoscopicInterlacePostProcessI
  76764. * @param name The name of the effect.
  76765. * @param rigCameras The rig cameras to be appled to the post process
  76766. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  76767. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  76768. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76769. * @param engine The engine which the post process will be applied. (default: current engine)
  76770. * @param reusable If the post process can be reused on the same frame. (default: false)
  76771. */
  76772. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76773. }
  76774. /**
  76775. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  76776. */
  76777. export class StereoscopicInterlacePostProcess extends PostProcess {
  76778. private _stepSize;
  76779. private _passedProcess;
  76780. /**
  76781. * Gets a string identifying the name of the class
  76782. * @returns "StereoscopicInterlacePostProcess" string
  76783. */
  76784. getClassName(): string;
  76785. /**
  76786. * Initializes a StereoscopicInterlacePostProcess
  76787. * @param name The name of the effect.
  76788. * @param rigCameras The rig cameras to be appled to the post process
  76789. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  76790. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76791. * @param engine The engine which the post process will be applied. (default: current engine)
  76792. * @param reusable If the post process can be reused on the same frame. (default: false)
  76793. */
  76794. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76795. }
  76796. }
  76797. declare module "babylonjs/Shaders/tonemap.fragment" {
  76798. /** @hidden */
  76799. export var tonemapPixelShader: {
  76800. name: string;
  76801. shader: string;
  76802. };
  76803. }
  76804. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  76805. import { Camera } from "babylonjs/Cameras/camera";
  76806. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76807. import "babylonjs/Shaders/tonemap.fragment";
  76808. import { Engine } from "babylonjs/Engines/engine";
  76809. /** Defines operator used for tonemapping */
  76810. export enum TonemappingOperator {
  76811. /** Hable */
  76812. Hable = 0,
  76813. /** Reinhard */
  76814. Reinhard = 1,
  76815. /** HejiDawson */
  76816. HejiDawson = 2,
  76817. /** Photographic */
  76818. Photographic = 3
  76819. }
  76820. /**
  76821. * Defines a post process to apply tone mapping
  76822. */
  76823. export class TonemapPostProcess extends PostProcess {
  76824. private _operator;
  76825. /** Defines the required exposure adjustement */
  76826. exposureAdjustment: number;
  76827. /**
  76828. * Gets a string identifying the name of the class
  76829. * @returns "TonemapPostProcess" string
  76830. */
  76831. getClassName(): string;
  76832. /**
  76833. * Creates a new TonemapPostProcess
  76834. * @param name defines the name of the postprocess
  76835. * @param _operator defines the operator to use
  76836. * @param exposureAdjustment defines the required exposure adjustement
  76837. * @param camera defines the camera to use (can be null)
  76838. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76839. * @param engine defines the hosting engine (can be ignore if camera is set)
  76840. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76841. */
  76842. constructor(name: string, _operator: TonemappingOperator,
  76843. /** Defines the required exposure adjustement */
  76844. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76845. }
  76846. }
  76847. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  76848. /** @hidden */
  76849. export var volumetricLightScatteringPixelShader: {
  76850. name: string;
  76851. shader: string;
  76852. };
  76853. }
  76854. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  76855. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76856. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76857. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76858. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76859. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76860. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76861. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76862. /** @hidden */
  76863. export var volumetricLightScatteringPassVertexShader: {
  76864. name: string;
  76865. shader: string;
  76866. };
  76867. }
  76868. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  76869. /** @hidden */
  76870. export var volumetricLightScatteringPassPixelShader: {
  76871. name: string;
  76872. shader: string;
  76873. };
  76874. }
  76875. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  76876. import { Vector3 } from "babylonjs/Maths/math.vector";
  76877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76878. import { Mesh } from "babylonjs/Meshes/mesh";
  76879. import { Camera } from "babylonjs/Cameras/camera";
  76880. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  76881. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76882. import { Scene } from "babylonjs/scene";
  76883. import "babylonjs/Meshes/Builders/planeBuilder";
  76884. import "babylonjs/Shaders/depth.vertex";
  76885. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  76886. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  76887. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  76888. import { Engine } from "babylonjs/Engines/engine";
  76889. /**
  76890. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76891. */
  76892. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76893. private _volumetricLightScatteringPass;
  76894. private _volumetricLightScatteringRTT;
  76895. private _viewPort;
  76896. private _screenCoordinates;
  76897. private _cachedDefines;
  76898. /**
  76899. * If not undefined, the mesh position is computed from the attached node position
  76900. */
  76901. attachedNode: {
  76902. position: Vector3;
  76903. };
  76904. /**
  76905. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76906. */
  76907. customMeshPosition: Vector3;
  76908. /**
  76909. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76910. */
  76911. useCustomMeshPosition: boolean;
  76912. /**
  76913. * If the post-process should inverse the light scattering direction
  76914. */
  76915. invert: boolean;
  76916. /**
  76917. * The internal mesh used by the post-process
  76918. */
  76919. mesh: Mesh;
  76920. /**
  76921. * @hidden
  76922. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76923. */
  76924. get useDiffuseColor(): boolean;
  76925. set useDiffuseColor(useDiffuseColor: boolean);
  76926. /**
  76927. * Array containing the excluded meshes not rendered in the internal pass
  76928. */
  76929. excludedMeshes: AbstractMesh[];
  76930. /**
  76931. * Controls the overall intensity of the post-process
  76932. */
  76933. exposure: number;
  76934. /**
  76935. * Dissipates each sample's contribution in range [0, 1]
  76936. */
  76937. decay: number;
  76938. /**
  76939. * Controls the overall intensity of each sample
  76940. */
  76941. weight: number;
  76942. /**
  76943. * Controls the density of each sample
  76944. */
  76945. density: number;
  76946. /**
  76947. * @constructor
  76948. * @param name The post-process name
  76949. * @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)
  76950. * @param camera The camera that the post-process will be attached to
  76951. * @param mesh The mesh used to create the light scattering
  76952. * @param samples The post-process quality, default 100
  76953. * @param samplingModeThe post-process filtering mode
  76954. * @param engine The babylon engine
  76955. * @param reusable If the post-process is reusable
  76956. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76957. */
  76958. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76959. /**
  76960. * Returns the string "VolumetricLightScatteringPostProcess"
  76961. * @returns "VolumetricLightScatteringPostProcess"
  76962. */
  76963. getClassName(): string;
  76964. private _isReady;
  76965. /**
  76966. * Sets the new light position for light scattering effect
  76967. * @param position The new custom light position
  76968. */
  76969. setCustomMeshPosition(position: Vector3): void;
  76970. /**
  76971. * Returns the light position for light scattering effect
  76972. * @return Vector3 The custom light position
  76973. */
  76974. getCustomMeshPosition(): Vector3;
  76975. /**
  76976. * Disposes the internal assets and detaches the post-process from the camera
  76977. */
  76978. dispose(camera: Camera): void;
  76979. /**
  76980. * Returns the render target texture used by the post-process
  76981. * @return the render target texture used by the post-process
  76982. */
  76983. getPass(): RenderTargetTexture;
  76984. private _meshExcluded;
  76985. private _createPass;
  76986. private _updateMeshScreenCoordinates;
  76987. /**
  76988. * Creates a default mesh for the Volumeric Light Scattering post-process
  76989. * @param name The mesh name
  76990. * @param scene The scene where to create the mesh
  76991. * @return the default mesh
  76992. */
  76993. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76994. }
  76995. }
  76996. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  76997. /** @hidden */
  76998. export var screenSpaceCurvaturePixelShader: {
  76999. name: string;
  77000. shader: string;
  77001. };
  77002. }
  77003. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  77004. import { Nullable } from "babylonjs/types";
  77005. import { Camera } from "babylonjs/Cameras/camera";
  77006. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77007. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  77008. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  77009. import { Engine } from "babylonjs/Engines/engine";
  77010. import { Scene } from "babylonjs/scene";
  77011. /**
  77012. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  77013. */
  77014. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  77015. /**
  77016. * Defines how much ridge the curvature effect displays.
  77017. */
  77018. ridge: number;
  77019. /**
  77020. * Defines how much valley the curvature effect displays.
  77021. */
  77022. valley: number;
  77023. private _geometryBufferRenderer;
  77024. /**
  77025. * Gets a string identifying the name of the class
  77026. * @returns "ScreenSpaceCurvaturePostProcess" string
  77027. */
  77028. getClassName(): string;
  77029. /**
  77030. * Creates a new instance ScreenSpaceCurvaturePostProcess
  77031. * @param name The name of the effect.
  77032. * @param scene The scene containing the objects to blur according to their velocity.
  77033. * @param options The required width/height ratio to downsize to before computing the render pass.
  77034. * @param camera The camera to apply the render pass to.
  77035. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77036. * @param engine The engine which the post process will be applied. (default: current engine)
  77037. * @param reusable If the post process can be reused on the same frame. (default: false)
  77038. * @param textureType Type of textures used when performing the post process. (default: 0)
  77039. * @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)
  77040. */
  77041. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77042. /**
  77043. * Support test.
  77044. */
  77045. static get IsSupported(): boolean;
  77046. /** @hidden */
  77047. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  77048. }
  77049. }
  77050. declare module "babylonjs/PostProcesses/index" {
  77051. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  77052. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  77053. export * from "babylonjs/PostProcesses/bloomEffect";
  77054. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  77055. export * from "babylonjs/PostProcesses/blurPostProcess";
  77056. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  77057. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  77058. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  77059. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  77060. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  77061. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  77062. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  77063. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  77064. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  77065. export * from "babylonjs/PostProcesses/filterPostProcess";
  77066. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  77067. export * from "babylonjs/PostProcesses/grainPostProcess";
  77068. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  77069. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  77070. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  77071. export * from "babylonjs/PostProcesses/passPostProcess";
  77072. export * from "babylonjs/PostProcesses/postProcess";
  77073. export * from "babylonjs/PostProcesses/postProcessManager";
  77074. export * from "babylonjs/PostProcesses/refractionPostProcess";
  77075. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  77076. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  77077. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  77078. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  77079. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  77080. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  77081. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  77082. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  77083. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  77084. }
  77085. declare module "babylonjs/Probes/index" {
  77086. export * from "babylonjs/Probes/reflectionProbe";
  77087. }
  77088. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  77089. import { Scene } from "babylonjs/scene";
  77090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77091. import { SmartArray } from "babylonjs/Misc/smartArray";
  77092. import { ISceneComponent } from "babylonjs/sceneComponent";
  77093. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  77094. import "babylonjs/Meshes/Builders/boxBuilder";
  77095. import "babylonjs/Shaders/color.fragment";
  77096. import "babylonjs/Shaders/color.vertex";
  77097. import { Color3 } from "babylonjs/Maths/math.color";
  77098. import { Observable } from "babylonjs/Misc/observable";
  77099. module "babylonjs/scene" {
  77100. interface Scene {
  77101. /** @hidden (Backing field) */
  77102. _boundingBoxRenderer: BoundingBoxRenderer;
  77103. /** @hidden (Backing field) */
  77104. _forceShowBoundingBoxes: boolean;
  77105. /**
  77106. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  77107. */
  77108. forceShowBoundingBoxes: boolean;
  77109. /**
  77110. * Gets the bounding box renderer associated with the scene
  77111. * @returns a BoundingBoxRenderer
  77112. */
  77113. getBoundingBoxRenderer(): BoundingBoxRenderer;
  77114. }
  77115. }
  77116. module "babylonjs/Meshes/abstractMesh" {
  77117. interface AbstractMesh {
  77118. /** @hidden (Backing field) */
  77119. _showBoundingBox: boolean;
  77120. /**
  77121. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  77122. */
  77123. showBoundingBox: boolean;
  77124. }
  77125. }
  77126. /**
  77127. * Component responsible of rendering the bounding box of the meshes in a scene.
  77128. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  77129. */
  77130. export class BoundingBoxRenderer implements ISceneComponent {
  77131. /**
  77132. * The component name helpfull to identify the component in the list of scene components.
  77133. */
  77134. readonly name: string;
  77135. /**
  77136. * The scene the component belongs to.
  77137. */
  77138. scene: Scene;
  77139. /**
  77140. * Color of the bounding box lines placed in front of an object
  77141. */
  77142. frontColor: Color3;
  77143. /**
  77144. * Color of the bounding box lines placed behind an object
  77145. */
  77146. backColor: Color3;
  77147. /**
  77148. * Defines if the renderer should show the back lines or not
  77149. */
  77150. showBackLines: boolean;
  77151. /**
  77152. * Observable raised before rendering a bounding box
  77153. */
  77154. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  77155. /**
  77156. * Observable raised after rendering a bounding box
  77157. */
  77158. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  77159. /**
  77160. * Observable raised after resources are created
  77161. */
  77162. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  77163. /**
  77164. * When false, no bounding boxes will be rendered
  77165. */
  77166. enabled: boolean;
  77167. /**
  77168. * @hidden
  77169. */
  77170. renderList: SmartArray<BoundingBox>;
  77171. private _colorShader;
  77172. private _vertexBuffers;
  77173. private _indexBuffer;
  77174. private _fillIndexBuffer;
  77175. private _fillIndexData;
  77176. /**
  77177. * Instantiates a new bounding box renderer in a scene.
  77178. * @param scene the scene the renderer renders in
  77179. */
  77180. constructor(scene: Scene);
  77181. /**
  77182. * Registers the component in a given scene
  77183. */
  77184. register(): void;
  77185. private _evaluateSubMesh;
  77186. private _preActiveMesh;
  77187. private _prepareResources;
  77188. private _createIndexBuffer;
  77189. /**
  77190. * Rebuilds the elements related to this component in case of
  77191. * context lost for instance.
  77192. */
  77193. rebuild(): void;
  77194. /**
  77195. * @hidden
  77196. */
  77197. reset(): void;
  77198. /**
  77199. * Render the bounding boxes of a specific rendering group
  77200. * @param renderingGroupId defines the rendering group to render
  77201. */
  77202. render(renderingGroupId: number): void;
  77203. /**
  77204. * In case of occlusion queries, we can render the occlusion bounding box through this method
  77205. * @param mesh Define the mesh to render the occlusion bounding box for
  77206. */
  77207. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  77208. /**
  77209. * Dispose and release the resources attached to this renderer.
  77210. */
  77211. dispose(): void;
  77212. }
  77213. }
  77214. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  77215. import { Nullable } from "babylonjs/types";
  77216. import { Scene } from "babylonjs/scene";
  77217. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  77218. import { Camera } from "babylonjs/Cameras/camera";
  77219. import { ISceneComponent } from "babylonjs/sceneComponent";
  77220. module "babylonjs/scene" {
  77221. interface Scene {
  77222. /** @hidden (Backing field) */
  77223. _depthRenderer: {
  77224. [id: string]: DepthRenderer;
  77225. };
  77226. /**
  77227. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  77228. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  77229. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  77230. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  77231. * @returns the created depth renderer
  77232. */
  77233. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  77234. /**
  77235. * Disables a depth renderer for a given camera
  77236. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  77237. */
  77238. disableDepthRenderer(camera?: Nullable<Camera>): void;
  77239. }
  77240. }
  77241. /**
  77242. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  77243. * in several rendering techniques.
  77244. */
  77245. export class DepthRendererSceneComponent implements ISceneComponent {
  77246. /**
  77247. * The component name helpfull to identify the component in the list of scene components.
  77248. */
  77249. readonly name: string;
  77250. /**
  77251. * The scene the component belongs to.
  77252. */
  77253. scene: Scene;
  77254. /**
  77255. * Creates a new instance of the component for the given scene
  77256. * @param scene Defines the scene to register the component in
  77257. */
  77258. constructor(scene: Scene);
  77259. /**
  77260. * Registers the component in a given scene
  77261. */
  77262. register(): void;
  77263. /**
  77264. * Rebuilds the elements related to this component in case of
  77265. * context lost for instance.
  77266. */
  77267. rebuild(): void;
  77268. /**
  77269. * Disposes the component and the associated ressources
  77270. */
  77271. dispose(): void;
  77272. private _gatherRenderTargets;
  77273. private _gatherActiveCameraRenderTargets;
  77274. }
  77275. }
  77276. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  77277. import { Nullable } from "babylonjs/types";
  77278. import { Scene } from "babylonjs/scene";
  77279. import { ISceneComponent } from "babylonjs/sceneComponent";
  77280. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  77281. module "babylonjs/abstractScene" {
  77282. interface AbstractScene {
  77283. /** @hidden (Backing field) */
  77284. _prePassRenderer: Nullable<PrePassRenderer>;
  77285. /**
  77286. * Gets or Sets the current prepass renderer associated to the scene.
  77287. */
  77288. prePassRenderer: Nullable<PrePassRenderer>;
  77289. /**
  77290. * Enables the prepass and associates it with the scene
  77291. * @returns the PrePassRenderer
  77292. */
  77293. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  77294. /**
  77295. * Disables the prepass associated with the scene
  77296. */
  77297. disablePrePassRenderer(): void;
  77298. }
  77299. }
  77300. /**
  77301. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77302. * in several rendering techniques.
  77303. */
  77304. export class PrePassRendererSceneComponent implements ISceneComponent {
  77305. /**
  77306. * The component name helpful to identify the component in the list of scene components.
  77307. */
  77308. readonly name: string;
  77309. /**
  77310. * The scene the component belongs to.
  77311. */
  77312. scene: Scene;
  77313. /**
  77314. * Creates a new instance of the component for the given scene
  77315. * @param scene Defines the scene to register the component in
  77316. */
  77317. constructor(scene: Scene);
  77318. /**
  77319. * Registers the component in a given scene
  77320. */
  77321. register(): void;
  77322. private _beforeCameraDraw;
  77323. private _afterCameraDraw;
  77324. private _beforeClearStage;
  77325. /**
  77326. * Rebuilds the elements related to this component in case of
  77327. * context lost for instance.
  77328. */
  77329. rebuild(): void;
  77330. /**
  77331. * Disposes the component and the associated ressources
  77332. */
  77333. dispose(): void;
  77334. }
  77335. }
  77336. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  77337. /** @hidden */
  77338. export var fibonacci: {
  77339. name: string;
  77340. shader: string;
  77341. };
  77342. }
  77343. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  77344. /** @hidden */
  77345. export var diffusionProfile: {
  77346. name: string;
  77347. shader: string;
  77348. };
  77349. }
  77350. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  77351. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  77352. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  77353. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  77354. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  77355. /** @hidden */
  77356. export var subSurfaceScatteringPixelShader: {
  77357. name: string;
  77358. shader: string;
  77359. };
  77360. }
  77361. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  77362. import { Nullable } from "babylonjs/types";
  77363. import { Camera } from "babylonjs/Cameras/camera";
  77364. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77365. import { Engine } from "babylonjs/Engines/engine";
  77366. import { Scene } from "babylonjs/scene";
  77367. import "babylonjs/Shaders/imageProcessing.fragment";
  77368. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  77369. import "babylonjs/Shaders/postprocess.vertex";
  77370. /**
  77371. * Sub surface scattering post process
  77372. */
  77373. export class SubSurfaceScatteringPostProcess extends PostProcess {
  77374. /**
  77375. * Gets a string identifying the name of the class
  77376. * @returns "SubSurfaceScatteringPostProcess" string
  77377. */
  77378. getClassName(): string;
  77379. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  77380. }
  77381. }
  77382. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  77383. import { Scene } from "babylonjs/scene";
  77384. import { Color3 } from "babylonjs/Maths/math.color";
  77385. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  77386. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  77387. /**
  77388. * Contains all parameters needed for the prepass to perform
  77389. * screen space subsurface scattering
  77390. */
  77391. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  77392. /** @hidden */
  77393. static _SceneComponentInitialization: (scene: Scene) => void;
  77394. private _ssDiffusionS;
  77395. private _ssFilterRadii;
  77396. private _ssDiffusionD;
  77397. /**
  77398. * Post process to attach for screen space subsurface scattering
  77399. */
  77400. postProcess: SubSurfaceScatteringPostProcess;
  77401. /**
  77402. * Diffusion profile color for subsurface scattering
  77403. */
  77404. get ssDiffusionS(): number[];
  77405. /**
  77406. * Diffusion profile max color channel value for subsurface scattering
  77407. */
  77408. get ssDiffusionD(): number[];
  77409. /**
  77410. * Diffusion profile filter radius for subsurface scattering
  77411. */
  77412. get ssFilterRadii(): number[];
  77413. /**
  77414. * Is subsurface enabled
  77415. */
  77416. enabled: boolean;
  77417. /**
  77418. * Name of the configuration
  77419. */
  77420. name: string;
  77421. /**
  77422. * Diffusion profile colors for subsurface scattering
  77423. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  77424. * See ...
  77425. * Note that you can only store up to 5 of them
  77426. */
  77427. ssDiffusionProfileColors: Color3[];
  77428. /**
  77429. * Defines the ratio real world => scene units.
  77430. * Used for subsurface scattering
  77431. */
  77432. metersPerUnit: number;
  77433. /**
  77434. * Textures that should be present in the MRT for this effect to work
  77435. */
  77436. readonly texturesRequired: number[];
  77437. private _scene;
  77438. /**
  77439. * Builds a subsurface configuration object
  77440. * @param scene The scene
  77441. */
  77442. constructor(scene: Scene);
  77443. /**
  77444. * Adds a new diffusion profile.
  77445. * Useful for more realistic subsurface scattering on diverse materials.
  77446. * @param color The color of the diffusion profile. Should be the average color of the material.
  77447. * @return The index of the diffusion profile for the material subsurface configuration
  77448. */
  77449. addDiffusionProfile(color: Color3): number;
  77450. /**
  77451. * Creates the sss post process
  77452. * @return The created post process
  77453. */
  77454. createPostProcess(): SubSurfaceScatteringPostProcess;
  77455. /**
  77456. * Deletes all diffusion profiles.
  77457. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  77458. */
  77459. clearAllDiffusionProfiles(): void;
  77460. /**
  77461. * Disposes this object
  77462. */
  77463. dispose(): void;
  77464. /**
  77465. * @hidden
  77466. * https://zero-radiance.github.io/post/sampling-diffusion/
  77467. *
  77468. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  77469. * ------------------------------------------------------------------------------------
  77470. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  77471. * PDF[r, phi, s] = r * R[r, phi, s]
  77472. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  77473. * ------------------------------------------------------------------------------------
  77474. * We importance sample the color channel with the widest scattering distance.
  77475. */
  77476. getDiffusionProfileParameters(color: Color3): number;
  77477. /**
  77478. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  77479. * 'u' is the random number (the value of the CDF): [0, 1).
  77480. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  77481. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  77482. */
  77483. private _sampleBurleyDiffusionProfile;
  77484. }
  77485. }
  77486. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  77487. import { Nullable } from "babylonjs/types";
  77488. import { Scene } from "babylonjs/scene";
  77489. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  77490. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  77491. import { AbstractScene } from "babylonjs/abstractScene";
  77492. module "babylonjs/abstractScene" {
  77493. interface AbstractScene {
  77494. /** @hidden (Backing field) */
  77495. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77496. /**
  77497. * Gets or Sets the current prepass renderer associated to the scene.
  77498. */
  77499. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77500. /**
  77501. * Enables the subsurface effect for prepass
  77502. * @returns the SubSurfaceConfiguration
  77503. */
  77504. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  77505. /**
  77506. * Disables the subsurface effect for prepass
  77507. */
  77508. disableSubSurfaceForPrePass(): void;
  77509. }
  77510. }
  77511. /**
  77512. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77513. * in several rendering techniques.
  77514. */
  77515. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  77516. /**
  77517. * The component name helpful to identify the component in the list of scene components.
  77518. */
  77519. readonly name: string;
  77520. /**
  77521. * The scene the component belongs to.
  77522. */
  77523. scene: Scene;
  77524. /**
  77525. * Creates a new instance of the component for the given scene
  77526. * @param scene Defines the scene to register the component in
  77527. */
  77528. constructor(scene: Scene);
  77529. /**
  77530. * Registers the component in a given scene
  77531. */
  77532. register(): void;
  77533. /**
  77534. * Serializes the component data to the specified json object
  77535. * @param serializationObject The object to serialize to
  77536. */
  77537. serialize(serializationObject: any): void;
  77538. /**
  77539. * Adds all the elements from the container to the scene
  77540. * @param container the container holding the elements
  77541. */
  77542. addFromContainer(container: AbstractScene): void;
  77543. /**
  77544. * Removes all the elements in the container from the scene
  77545. * @param container contains the elements to remove
  77546. * @param dispose if the removed element should be disposed (default: false)
  77547. */
  77548. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77549. /**
  77550. * Rebuilds the elements related to this component in case of
  77551. * context lost for instance.
  77552. */
  77553. rebuild(): void;
  77554. /**
  77555. * Disposes the component and the associated ressources
  77556. */
  77557. dispose(): void;
  77558. }
  77559. }
  77560. declare module "babylonjs/Shaders/outline.fragment" {
  77561. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  77562. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  77563. /** @hidden */
  77564. export var outlinePixelShader: {
  77565. name: string;
  77566. shader: string;
  77567. };
  77568. }
  77569. declare module "babylonjs/Shaders/outline.vertex" {
  77570. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  77571. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  77572. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  77573. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  77574. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  77575. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  77576. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  77577. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  77578. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  77579. /** @hidden */
  77580. export var outlineVertexShader: {
  77581. name: string;
  77582. shader: string;
  77583. };
  77584. }
  77585. declare module "babylonjs/Rendering/outlineRenderer" {
  77586. import { SubMesh } from "babylonjs/Meshes/subMesh";
  77587. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  77588. import { Scene } from "babylonjs/scene";
  77589. import { ISceneComponent } from "babylonjs/sceneComponent";
  77590. import "babylonjs/Shaders/outline.fragment";
  77591. import "babylonjs/Shaders/outline.vertex";
  77592. module "babylonjs/scene" {
  77593. interface Scene {
  77594. /** @hidden */
  77595. _outlineRenderer: OutlineRenderer;
  77596. /**
  77597. * Gets the outline renderer associated with the scene
  77598. * @returns a OutlineRenderer
  77599. */
  77600. getOutlineRenderer(): OutlineRenderer;
  77601. }
  77602. }
  77603. module "babylonjs/Meshes/abstractMesh" {
  77604. interface AbstractMesh {
  77605. /** @hidden (Backing field) */
  77606. _renderOutline: boolean;
  77607. /**
  77608. * Gets or sets a boolean indicating if the outline must be rendered as well
  77609. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  77610. */
  77611. renderOutline: boolean;
  77612. /** @hidden (Backing field) */
  77613. _renderOverlay: boolean;
  77614. /**
  77615. * Gets or sets a boolean indicating if the overlay must be rendered as well
  77616. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  77617. */
  77618. renderOverlay: boolean;
  77619. }
  77620. }
  77621. /**
  77622. * This class is responsible to draw bothe outline/overlay of meshes.
  77623. * It should not be used directly but through the available method on mesh.
  77624. */
  77625. export class OutlineRenderer implements ISceneComponent {
  77626. /**
  77627. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  77628. */
  77629. private static _StencilReference;
  77630. /**
  77631. * The name of the component. Each component must have a unique name.
  77632. */
  77633. name: string;
  77634. /**
  77635. * The scene the component belongs to.
  77636. */
  77637. scene: Scene;
  77638. /**
  77639. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  77640. */
  77641. zOffset: number;
  77642. private _engine;
  77643. private _effect;
  77644. private _cachedDefines;
  77645. private _savedDepthWrite;
  77646. /**
  77647. * Instantiates a new outline renderer. (There could be only one per scene).
  77648. * @param scene Defines the scene it belongs to
  77649. */
  77650. constructor(scene: Scene);
  77651. /**
  77652. * Register the component to one instance of a scene.
  77653. */
  77654. register(): void;
  77655. /**
  77656. * Rebuilds the elements related to this component in case of
  77657. * context lost for instance.
  77658. */
  77659. rebuild(): void;
  77660. /**
  77661. * Disposes the component and the associated ressources.
  77662. */
  77663. dispose(): void;
  77664. /**
  77665. * Renders the outline in the canvas.
  77666. * @param subMesh Defines the sumesh to render
  77667. * @param batch Defines the batch of meshes in case of instances
  77668. * @param useOverlay Defines if the rendering is for the overlay or the outline
  77669. */
  77670. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  77671. /**
  77672. * Returns whether or not the outline renderer is ready for a given submesh.
  77673. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  77674. * @param subMesh Defines the submesh to check readyness for
  77675. * @param useInstances Defines wheter wee are trying to render instances or not
  77676. * @returns true if ready otherwise false
  77677. */
  77678. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77679. private _beforeRenderingMesh;
  77680. private _afterRenderingMesh;
  77681. }
  77682. }
  77683. declare module "babylonjs/Rendering/index" {
  77684. export * from "babylonjs/Rendering/boundingBoxRenderer";
  77685. export * from "babylonjs/Rendering/depthRenderer";
  77686. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  77687. export * from "babylonjs/Rendering/edgesRenderer";
  77688. export * from "babylonjs/Rendering/geometryBufferRenderer";
  77689. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  77690. export * from "babylonjs/Rendering/prePassRenderer";
  77691. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  77692. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  77693. export * from "babylonjs/Rendering/outlineRenderer";
  77694. export * from "babylonjs/Rendering/renderingGroup";
  77695. export * from "babylonjs/Rendering/renderingManager";
  77696. export * from "babylonjs/Rendering/utilityLayerRenderer";
  77697. }
  77698. declare module "babylonjs/Sprites/ISprites" {
  77699. /**
  77700. * Defines the basic options interface of a Sprite Frame Source Size.
  77701. */
  77702. export interface ISpriteJSONSpriteSourceSize {
  77703. /**
  77704. * number of the original width of the Frame
  77705. */
  77706. w: number;
  77707. /**
  77708. * number of the original height of the Frame
  77709. */
  77710. h: number;
  77711. }
  77712. /**
  77713. * Defines the basic options interface of a Sprite Frame Data.
  77714. */
  77715. export interface ISpriteJSONSpriteFrameData {
  77716. /**
  77717. * number of the x offset of the Frame
  77718. */
  77719. x: number;
  77720. /**
  77721. * number of the y offset of the Frame
  77722. */
  77723. y: number;
  77724. /**
  77725. * number of the width of the Frame
  77726. */
  77727. w: number;
  77728. /**
  77729. * number of the height of the Frame
  77730. */
  77731. h: number;
  77732. }
  77733. /**
  77734. * Defines the basic options interface of a JSON Sprite.
  77735. */
  77736. export interface ISpriteJSONSprite {
  77737. /**
  77738. * string name of the Frame
  77739. */
  77740. filename: string;
  77741. /**
  77742. * ISpriteJSONSpriteFrame basic object of the frame data
  77743. */
  77744. frame: ISpriteJSONSpriteFrameData;
  77745. /**
  77746. * boolean to flag is the frame was rotated.
  77747. */
  77748. rotated: boolean;
  77749. /**
  77750. * boolean to flag is the frame was trimmed.
  77751. */
  77752. trimmed: boolean;
  77753. /**
  77754. * ISpriteJSONSpriteFrame basic object of the source data
  77755. */
  77756. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77757. /**
  77758. * ISpriteJSONSpriteFrame basic object of the source data
  77759. */
  77760. sourceSize: ISpriteJSONSpriteSourceSize;
  77761. }
  77762. /**
  77763. * Defines the basic options interface of a JSON atlas.
  77764. */
  77765. export interface ISpriteJSONAtlas {
  77766. /**
  77767. * Array of objects that contain the frame data.
  77768. */
  77769. frames: Array<ISpriteJSONSprite>;
  77770. /**
  77771. * object basic object containing the sprite meta data.
  77772. */
  77773. meta?: object;
  77774. }
  77775. }
  77776. declare module "babylonjs/Shaders/spriteMap.fragment" {
  77777. /** @hidden */
  77778. export var spriteMapPixelShader: {
  77779. name: string;
  77780. shader: string;
  77781. };
  77782. }
  77783. declare module "babylonjs/Shaders/spriteMap.vertex" {
  77784. /** @hidden */
  77785. export var spriteMapVertexShader: {
  77786. name: string;
  77787. shader: string;
  77788. };
  77789. }
  77790. declare module "babylonjs/Sprites/spriteMap" {
  77791. import { IDisposable, Scene } from "babylonjs/scene";
  77792. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  77793. import { Texture } from "babylonjs/Materials/Textures/texture";
  77794. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  77795. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  77796. import "babylonjs/Meshes/Builders/planeBuilder";
  77797. import "babylonjs/Shaders/spriteMap.fragment";
  77798. import "babylonjs/Shaders/spriteMap.vertex";
  77799. /**
  77800. * Defines the basic options interface of a SpriteMap
  77801. */
  77802. export interface ISpriteMapOptions {
  77803. /**
  77804. * Vector2 of the number of cells in the grid.
  77805. */
  77806. stageSize?: Vector2;
  77807. /**
  77808. * Vector2 of the size of the output plane in World Units.
  77809. */
  77810. outputSize?: Vector2;
  77811. /**
  77812. * Vector3 of the position of the output plane in World Units.
  77813. */
  77814. outputPosition?: Vector3;
  77815. /**
  77816. * Vector3 of the rotation of the output plane.
  77817. */
  77818. outputRotation?: Vector3;
  77819. /**
  77820. * number of layers that the system will reserve in resources.
  77821. */
  77822. layerCount?: number;
  77823. /**
  77824. * number of max animation frames a single cell will reserve in resources.
  77825. */
  77826. maxAnimationFrames?: number;
  77827. /**
  77828. * number cell index of the base tile when the system compiles.
  77829. */
  77830. baseTile?: number;
  77831. /**
  77832. * boolean flip the sprite after its been repositioned by the framing data.
  77833. */
  77834. flipU?: boolean;
  77835. /**
  77836. * Vector3 scalar of the global RGB values of the SpriteMap.
  77837. */
  77838. colorMultiply?: Vector3;
  77839. }
  77840. /**
  77841. * Defines the IDisposable interface in order to be cleanable from resources.
  77842. */
  77843. export interface ISpriteMap extends IDisposable {
  77844. /**
  77845. * String name of the SpriteMap.
  77846. */
  77847. name: string;
  77848. /**
  77849. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77850. */
  77851. atlasJSON: ISpriteJSONAtlas;
  77852. /**
  77853. * Texture of the SpriteMap.
  77854. */
  77855. spriteSheet: Texture;
  77856. /**
  77857. * The parameters to initialize the SpriteMap with.
  77858. */
  77859. options: ISpriteMapOptions;
  77860. }
  77861. /**
  77862. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77863. */
  77864. export class SpriteMap implements ISpriteMap {
  77865. /** The Name of the spriteMap */
  77866. name: string;
  77867. /** The JSON file with the frame and meta data */
  77868. atlasJSON: ISpriteJSONAtlas;
  77869. /** The systems Sprite Sheet Texture */
  77870. spriteSheet: Texture;
  77871. /** Arguments passed with the Constructor */
  77872. options: ISpriteMapOptions;
  77873. /** Public Sprite Storage array, parsed from atlasJSON */
  77874. sprites: Array<ISpriteJSONSprite>;
  77875. /** Returns the Number of Sprites in the System */
  77876. get spriteCount(): number;
  77877. /** Returns the Position of Output Plane*/
  77878. get position(): Vector3;
  77879. /** Returns the Position of Output Plane*/
  77880. set position(v: Vector3);
  77881. /** Returns the Rotation of Output Plane*/
  77882. get rotation(): Vector3;
  77883. /** Returns the Rotation of Output Plane*/
  77884. set rotation(v: Vector3);
  77885. /** Sets the AnimationMap*/
  77886. get animationMap(): RawTexture;
  77887. /** Sets the AnimationMap*/
  77888. set animationMap(v: RawTexture);
  77889. /** Scene that the SpriteMap was created in */
  77890. private _scene;
  77891. /** Texture Buffer of Float32 that holds tile frame data*/
  77892. private _frameMap;
  77893. /** Texture Buffers of Float32 that holds tileMap data*/
  77894. private _tileMaps;
  77895. /** Texture Buffer of Float32 that holds Animation Data*/
  77896. private _animationMap;
  77897. /** Custom ShaderMaterial Central to the System*/
  77898. private _material;
  77899. /** Custom ShaderMaterial Central to the System*/
  77900. private _output;
  77901. /** Systems Time Ticker*/
  77902. private _time;
  77903. /**
  77904. * Creates a new SpriteMap
  77905. * @param name defines the SpriteMaps Name
  77906. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77907. * @param spriteSheet is the Texture that the Sprites are on.
  77908. * @param options a basic deployment configuration
  77909. * @param scene The Scene that the map is deployed on
  77910. */
  77911. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77912. /**
  77913. * Returns tileID location
  77914. * @returns Vector2 the cell position ID
  77915. */
  77916. getTileID(): Vector2;
  77917. /**
  77918. * Gets the UV location of the mouse over the SpriteMap.
  77919. * @returns Vector2 the UV position of the mouse interaction
  77920. */
  77921. getMousePosition(): Vector2;
  77922. /**
  77923. * Creates the "frame" texture Buffer
  77924. * -------------------------------------
  77925. * Structure of frames
  77926. * "filename": "Falling-Water-2.png",
  77927. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77928. * "rotated": true,
  77929. * "trimmed": true,
  77930. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77931. * "sourceSize": {"w":32,"h":32}
  77932. * @returns RawTexture of the frameMap
  77933. */
  77934. private _createFrameBuffer;
  77935. /**
  77936. * Creates the tileMap texture Buffer
  77937. * @param buffer normally and array of numbers, or a false to generate from scratch
  77938. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77939. * @returns RawTexture of the tileMap
  77940. */
  77941. private _createTileBuffer;
  77942. /**
  77943. * Modifies the data of the tileMaps
  77944. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77945. * @param pos is the iVector2 Coordinates of the Tile
  77946. * @param tile The SpriteIndex of the new Tile
  77947. */
  77948. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77949. /**
  77950. * Creates the animationMap texture Buffer
  77951. * @param buffer normally and array of numbers, or a false to generate from scratch
  77952. * @returns RawTexture of the animationMap
  77953. */
  77954. private _createTileAnimationBuffer;
  77955. /**
  77956. * Modifies the data of the animationMap
  77957. * @param cellID is the Index of the Sprite
  77958. * @param _frame is the target Animation frame
  77959. * @param toCell is the Target Index of the next frame of the animation
  77960. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77961. * @param speed is a global scalar of the time variable on the map.
  77962. */
  77963. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77964. /**
  77965. * Exports the .tilemaps file
  77966. */
  77967. saveTileMaps(): void;
  77968. /**
  77969. * Imports the .tilemaps file
  77970. * @param url of the .tilemaps file
  77971. */
  77972. loadTileMaps(url: string): void;
  77973. /**
  77974. * Release associated resources
  77975. */
  77976. dispose(): void;
  77977. }
  77978. }
  77979. declare module "babylonjs/Sprites/spritePackedManager" {
  77980. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  77981. import { Scene } from "babylonjs/scene";
  77982. /**
  77983. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77984. * @see https://doc.babylonjs.com/babylon101/sprites
  77985. */
  77986. export class SpritePackedManager extends SpriteManager {
  77987. /** defines the packed manager's name */
  77988. name: string;
  77989. /**
  77990. * Creates a new sprite manager from a packed sprite sheet
  77991. * @param name defines the manager's name
  77992. * @param imgUrl defines the sprite sheet url
  77993. * @param capacity defines the maximum allowed number of sprites
  77994. * @param scene defines the hosting scene
  77995. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77996. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77997. * @param samplingMode defines the smapling mode to use with spritesheet
  77998. * @param fromPacked set to true; do not alter
  77999. */
  78000. constructor(
  78001. /** defines the packed manager's name */
  78002. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  78003. }
  78004. }
  78005. declare module "babylonjs/Sprites/index" {
  78006. export * from "babylonjs/Sprites/sprite";
  78007. export * from "babylonjs/Sprites/ISprites";
  78008. export * from "babylonjs/Sprites/spriteManager";
  78009. export * from "babylonjs/Sprites/spriteMap";
  78010. export * from "babylonjs/Sprites/spritePackedManager";
  78011. export * from "babylonjs/Sprites/spriteSceneComponent";
  78012. }
  78013. declare module "babylonjs/States/index" {
  78014. export * from "babylonjs/States/alphaCullingState";
  78015. export * from "babylonjs/States/depthCullingState";
  78016. export * from "babylonjs/States/stencilState";
  78017. }
  78018. declare module "babylonjs/Misc/assetsManager" {
  78019. import { Scene } from "babylonjs/scene";
  78020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78021. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  78022. import { Skeleton } from "babylonjs/Bones/skeleton";
  78023. import { Observable } from "babylonjs/Misc/observable";
  78024. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  78025. import { Texture } from "babylonjs/Materials/Textures/texture";
  78026. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  78027. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  78028. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  78029. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  78030. import { AssetContainer } from "babylonjs/assetContainer";
  78031. /**
  78032. * Defines the list of states available for a task inside a AssetsManager
  78033. */
  78034. export enum AssetTaskState {
  78035. /**
  78036. * Initialization
  78037. */
  78038. INIT = 0,
  78039. /**
  78040. * Running
  78041. */
  78042. RUNNING = 1,
  78043. /**
  78044. * Done
  78045. */
  78046. DONE = 2,
  78047. /**
  78048. * Error
  78049. */
  78050. ERROR = 3
  78051. }
  78052. /**
  78053. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  78054. */
  78055. export abstract class AbstractAssetTask {
  78056. /**
  78057. * Task name
  78058. */ name: string;
  78059. /**
  78060. * Callback called when the task is successful
  78061. */
  78062. onSuccess: (task: any) => void;
  78063. /**
  78064. * Callback called when the task is not successful
  78065. */
  78066. onError: (task: any, message?: string, exception?: any) => void;
  78067. /**
  78068. * Creates a new AssetsManager
  78069. * @param name defines the name of the task
  78070. */
  78071. constructor(
  78072. /**
  78073. * Task name
  78074. */ name: string);
  78075. private _isCompleted;
  78076. private _taskState;
  78077. private _errorObject;
  78078. /**
  78079. * Get if the task is completed
  78080. */
  78081. get isCompleted(): boolean;
  78082. /**
  78083. * Gets the current state of the task
  78084. */
  78085. get taskState(): AssetTaskState;
  78086. /**
  78087. * Gets the current error object (if task is in error)
  78088. */
  78089. get errorObject(): {
  78090. message?: string;
  78091. exception?: any;
  78092. };
  78093. /**
  78094. * Internal only
  78095. * @hidden
  78096. */
  78097. _setErrorObject(message?: string, exception?: any): void;
  78098. /**
  78099. * Execute the current task
  78100. * @param scene defines the scene where you want your assets to be loaded
  78101. * @param onSuccess is a callback called when the task is successfully executed
  78102. * @param onError is a callback called if an error occurs
  78103. */
  78104. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78105. /**
  78106. * Execute the current task
  78107. * @param scene defines the scene where you want your assets to be loaded
  78108. * @param onSuccess is a callback called when the task is successfully executed
  78109. * @param onError is a callback called if an error occurs
  78110. */
  78111. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78112. /**
  78113. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  78114. * This can be used with failed tasks that have the reason for failure fixed.
  78115. */
  78116. reset(): void;
  78117. private onErrorCallback;
  78118. private onDoneCallback;
  78119. }
  78120. /**
  78121. * Define the interface used by progress events raised during assets loading
  78122. */
  78123. export interface IAssetsProgressEvent {
  78124. /**
  78125. * Defines the number of remaining tasks to process
  78126. */
  78127. remainingCount: number;
  78128. /**
  78129. * Defines the total number of tasks
  78130. */
  78131. totalCount: number;
  78132. /**
  78133. * Defines the task that was just processed
  78134. */
  78135. task: AbstractAssetTask;
  78136. }
  78137. /**
  78138. * Class used to share progress information about assets loading
  78139. */
  78140. export class AssetsProgressEvent implements IAssetsProgressEvent {
  78141. /**
  78142. * Defines the number of remaining tasks to process
  78143. */
  78144. remainingCount: number;
  78145. /**
  78146. * Defines the total number of tasks
  78147. */
  78148. totalCount: number;
  78149. /**
  78150. * Defines the task that was just processed
  78151. */
  78152. task: AbstractAssetTask;
  78153. /**
  78154. * Creates a AssetsProgressEvent
  78155. * @param remainingCount defines the number of remaining tasks to process
  78156. * @param totalCount defines the total number of tasks
  78157. * @param task defines the task that was just processed
  78158. */
  78159. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  78160. }
  78161. /**
  78162. * Define a task used by AssetsManager to load assets into a container
  78163. */
  78164. export class ContainerAssetTask extends AbstractAssetTask {
  78165. /**
  78166. * Defines the name of the task
  78167. */
  78168. name: string;
  78169. /**
  78170. * Defines the list of mesh's names you want to load
  78171. */
  78172. meshesNames: any;
  78173. /**
  78174. * Defines the root url to use as a base to load your meshes and associated resources
  78175. */
  78176. rootUrl: string;
  78177. /**
  78178. * Defines the filename or File of the scene to load from
  78179. */
  78180. sceneFilename: string | File;
  78181. /**
  78182. * Get the loaded asset container
  78183. */
  78184. loadedContainer: AssetContainer;
  78185. /**
  78186. * Gets the list of loaded meshes
  78187. */
  78188. loadedMeshes: Array<AbstractMesh>;
  78189. /**
  78190. * Gets the list of loaded particle systems
  78191. */
  78192. loadedParticleSystems: Array<IParticleSystem>;
  78193. /**
  78194. * Gets the list of loaded skeletons
  78195. */
  78196. loadedSkeletons: Array<Skeleton>;
  78197. /**
  78198. * Gets the list of loaded animation groups
  78199. */
  78200. loadedAnimationGroups: Array<AnimationGroup>;
  78201. /**
  78202. * Callback called when the task is successful
  78203. */
  78204. onSuccess: (task: ContainerAssetTask) => void;
  78205. /**
  78206. * Callback called when the task is successful
  78207. */
  78208. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  78209. /**
  78210. * Creates a new ContainerAssetTask
  78211. * @param name defines the name of the task
  78212. * @param meshesNames defines the list of mesh's names you want to load
  78213. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  78214. * @param sceneFilename defines the filename or File of the scene to load from
  78215. */
  78216. constructor(
  78217. /**
  78218. * Defines the name of the task
  78219. */
  78220. name: string,
  78221. /**
  78222. * Defines the list of mesh's names you want to load
  78223. */
  78224. meshesNames: any,
  78225. /**
  78226. * Defines the root url to use as a base to load your meshes and associated resources
  78227. */
  78228. rootUrl: string,
  78229. /**
  78230. * Defines the filename or File of the scene to load from
  78231. */
  78232. sceneFilename: string | File);
  78233. /**
  78234. * Execute the current task
  78235. * @param scene defines the scene where you want your assets to be loaded
  78236. * @param onSuccess is a callback called when the task is successfully executed
  78237. * @param onError is a callback called if an error occurs
  78238. */
  78239. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78240. }
  78241. /**
  78242. * Define a task used by AssetsManager to load meshes
  78243. */
  78244. export class MeshAssetTask extends AbstractAssetTask {
  78245. /**
  78246. * Defines the name of the task
  78247. */
  78248. name: string;
  78249. /**
  78250. * Defines the list of mesh's names you want to load
  78251. */
  78252. meshesNames: any;
  78253. /**
  78254. * Defines the root url to use as a base to load your meshes and associated resources
  78255. */
  78256. rootUrl: string;
  78257. /**
  78258. * Defines the filename or File of the scene to load from
  78259. */
  78260. sceneFilename: string | File;
  78261. /**
  78262. * Gets the list of loaded meshes
  78263. */
  78264. loadedMeshes: Array<AbstractMesh>;
  78265. /**
  78266. * Gets the list of loaded particle systems
  78267. */
  78268. loadedParticleSystems: Array<IParticleSystem>;
  78269. /**
  78270. * Gets the list of loaded skeletons
  78271. */
  78272. loadedSkeletons: Array<Skeleton>;
  78273. /**
  78274. * Gets the list of loaded animation groups
  78275. */
  78276. loadedAnimationGroups: Array<AnimationGroup>;
  78277. /**
  78278. * Callback called when the task is successful
  78279. */
  78280. onSuccess: (task: MeshAssetTask) => void;
  78281. /**
  78282. * Callback called when the task is successful
  78283. */
  78284. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  78285. /**
  78286. * Creates a new MeshAssetTask
  78287. * @param name defines the name of the task
  78288. * @param meshesNames defines the list of mesh's names you want to load
  78289. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  78290. * @param sceneFilename defines the filename or File of the scene to load from
  78291. */
  78292. constructor(
  78293. /**
  78294. * Defines the name of the task
  78295. */
  78296. name: string,
  78297. /**
  78298. * Defines the list of mesh's names you want to load
  78299. */
  78300. meshesNames: any,
  78301. /**
  78302. * Defines the root url to use as a base to load your meshes and associated resources
  78303. */
  78304. rootUrl: string,
  78305. /**
  78306. * Defines the filename or File of the scene to load from
  78307. */
  78308. sceneFilename: string | File);
  78309. /**
  78310. * Execute the current task
  78311. * @param scene defines the scene where you want your assets to be loaded
  78312. * @param onSuccess is a callback called when the task is successfully executed
  78313. * @param onError is a callback called if an error occurs
  78314. */
  78315. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78316. }
  78317. /**
  78318. * Define a task used by AssetsManager to load text content
  78319. */
  78320. export class TextFileAssetTask extends AbstractAssetTask {
  78321. /**
  78322. * Defines the name of the task
  78323. */
  78324. name: string;
  78325. /**
  78326. * Defines the location of the file to load
  78327. */
  78328. url: string;
  78329. /**
  78330. * Gets the loaded text string
  78331. */
  78332. text: string;
  78333. /**
  78334. * Callback called when the task is successful
  78335. */
  78336. onSuccess: (task: TextFileAssetTask) => void;
  78337. /**
  78338. * Callback called when the task is successful
  78339. */
  78340. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  78341. /**
  78342. * Creates a new TextFileAssetTask object
  78343. * @param name defines the name of the task
  78344. * @param url defines the location of the file to load
  78345. */
  78346. constructor(
  78347. /**
  78348. * Defines the name of the task
  78349. */
  78350. name: string,
  78351. /**
  78352. * Defines the location of the file to load
  78353. */
  78354. url: string);
  78355. /**
  78356. * Execute the current task
  78357. * @param scene defines the scene where you want your assets to be loaded
  78358. * @param onSuccess is a callback called when the task is successfully executed
  78359. * @param onError is a callback called if an error occurs
  78360. */
  78361. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78362. }
  78363. /**
  78364. * Define a task used by AssetsManager to load binary data
  78365. */
  78366. export class BinaryFileAssetTask extends AbstractAssetTask {
  78367. /**
  78368. * Defines the name of the task
  78369. */
  78370. name: string;
  78371. /**
  78372. * Defines the location of the file to load
  78373. */
  78374. url: string;
  78375. /**
  78376. * Gets the lodaded data (as an array buffer)
  78377. */
  78378. data: ArrayBuffer;
  78379. /**
  78380. * Callback called when the task is successful
  78381. */
  78382. onSuccess: (task: BinaryFileAssetTask) => void;
  78383. /**
  78384. * Callback called when the task is successful
  78385. */
  78386. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  78387. /**
  78388. * Creates a new BinaryFileAssetTask object
  78389. * @param name defines the name of the new task
  78390. * @param url defines the location of the file to load
  78391. */
  78392. constructor(
  78393. /**
  78394. * Defines the name of the task
  78395. */
  78396. name: string,
  78397. /**
  78398. * Defines the location of the file to load
  78399. */
  78400. url: string);
  78401. /**
  78402. * Execute the current task
  78403. * @param scene defines the scene where you want your assets to be loaded
  78404. * @param onSuccess is a callback called when the task is successfully executed
  78405. * @param onError is a callback called if an error occurs
  78406. */
  78407. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78408. }
  78409. /**
  78410. * Define a task used by AssetsManager to load images
  78411. */
  78412. export class ImageAssetTask extends AbstractAssetTask {
  78413. /**
  78414. * Defines the name of the task
  78415. */
  78416. name: string;
  78417. /**
  78418. * Defines the location of the image to load
  78419. */
  78420. url: string;
  78421. /**
  78422. * Gets the loaded images
  78423. */
  78424. image: HTMLImageElement;
  78425. /**
  78426. * Callback called when the task is successful
  78427. */
  78428. onSuccess: (task: ImageAssetTask) => void;
  78429. /**
  78430. * Callback called when the task is successful
  78431. */
  78432. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  78433. /**
  78434. * Creates a new ImageAssetTask
  78435. * @param name defines the name of the task
  78436. * @param url defines the location of the image to load
  78437. */
  78438. constructor(
  78439. /**
  78440. * Defines the name of the task
  78441. */
  78442. name: string,
  78443. /**
  78444. * Defines the location of the image to load
  78445. */
  78446. url: string);
  78447. /**
  78448. * Execute the current task
  78449. * @param scene defines the scene where you want your assets to be loaded
  78450. * @param onSuccess is a callback called when the task is successfully executed
  78451. * @param onError is a callback called if an error occurs
  78452. */
  78453. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78454. }
  78455. /**
  78456. * Defines the interface used by texture loading tasks
  78457. */
  78458. export interface ITextureAssetTask<TEX extends BaseTexture> {
  78459. /**
  78460. * Gets the loaded texture
  78461. */
  78462. texture: TEX;
  78463. }
  78464. /**
  78465. * Define a task used by AssetsManager to load 2D textures
  78466. */
  78467. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  78468. /**
  78469. * Defines the name of the task
  78470. */
  78471. name: string;
  78472. /**
  78473. * Defines the location of the file to load
  78474. */
  78475. url: string;
  78476. /**
  78477. * Defines if mipmap should not be generated (default is false)
  78478. */
  78479. noMipmap?: boolean | undefined;
  78480. /**
  78481. * Defines if texture must be inverted on Y axis (default is true)
  78482. */
  78483. invertY: boolean;
  78484. /**
  78485. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78486. */
  78487. samplingMode: number;
  78488. /**
  78489. * Gets the loaded texture
  78490. */
  78491. texture: Texture;
  78492. /**
  78493. * Callback called when the task is successful
  78494. */
  78495. onSuccess: (task: TextureAssetTask) => void;
  78496. /**
  78497. * Callback called when the task is successful
  78498. */
  78499. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  78500. /**
  78501. * Creates a new TextureAssetTask object
  78502. * @param name defines the name of the task
  78503. * @param url defines the location of the file to load
  78504. * @param noMipmap defines if mipmap should not be generated (default is false)
  78505. * @param invertY defines if texture must be inverted on Y axis (default is true)
  78506. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78507. */
  78508. constructor(
  78509. /**
  78510. * Defines the name of the task
  78511. */
  78512. name: string,
  78513. /**
  78514. * Defines the location of the file to load
  78515. */
  78516. url: string,
  78517. /**
  78518. * Defines if mipmap should not be generated (default is false)
  78519. */
  78520. noMipmap?: boolean | undefined,
  78521. /**
  78522. * Defines if texture must be inverted on Y axis (default is true)
  78523. */
  78524. invertY?: boolean,
  78525. /**
  78526. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78527. */
  78528. samplingMode?: number);
  78529. /**
  78530. * Execute the current task
  78531. * @param scene defines the scene where you want your assets to be loaded
  78532. * @param onSuccess is a callback called when the task is successfully executed
  78533. * @param onError is a callback called if an error occurs
  78534. */
  78535. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78536. }
  78537. /**
  78538. * Define a task used by AssetsManager to load cube textures
  78539. */
  78540. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  78541. /**
  78542. * Defines the name of the task
  78543. */
  78544. name: string;
  78545. /**
  78546. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78547. */
  78548. url: string;
  78549. /**
  78550. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78551. */
  78552. extensions?: string[] | undefined;
  78553. /**
  78554. * Defines if mipmaps should not be generated (default is false)
  78555. */
  78556. noMipmap?: boolean | undefined;
  78557. /**
  78558. * Defines the explicit list of files (undefined by default)
  78559. */
  78560. files?: string[] | undefined;
  78561. /**
  78562. * Gets the loaded texture
  78563. */
  78564. texture: CubeTexture;
  78565. /**
  78566. * Callback called when the task is successful
  78567. */
  78568. onSuccess: (task: CubeTextureAssetTask) => void;
  78569. /**
  78570. * Callback called when the task is successful
  78571. */
  78572. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  78573. /**
  78574. * Creates a new CubeTextureAssetTask
  78575. * @param name defines the name of the task
  78576. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78577. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78578. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78579. * @param files defines the explicit list of files (undefined by default)
  78580. */
  78581. constructor(
  78582. /**
  78583. * Defines the name of the task
  78584. */
  78585. name: string,
  78586. /**
  78587. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78588. */
  78589. url: string,
  78590. /**
  78591. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78592. */
  78593. extensions?: string[] | undefined,
  78594. /**
  78595. * Defines if mipmaps should not be generated (default is false)
  78596. */
  78597. noMipmap?: boolean | undefined,
  78598. /**
  78599. * Defines the explicit list of files (undefined by default)
  78600. */
  78601. files?: string[] | undefined);
  78602. /**
  78603. * Execute the current task
  78604. * @param scene defines the scene where you want your assets to be loaded
  78605. * @param onSuccess is a callback called when the task is successfully executed
  78606. * @param onError is a callback called if an error occurs
  78607. */
  78608. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78609. }
  78610. /**
  78611. * Define a task used by AssetsManager to load HDR cube textures
  78612. */
  78613. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  78614. /**
  78615. * Defines the name of the task
  78616. */
  78617. name: string;
  78618. /**
  78619. * Defines the location of the file to load
  78620. */
  78621. url: string;
  78622. /**
  78623. * Defines the desired size (the more it increases the longer the generation will be)
  78624. */
  78625. size: number;
  78626. /**
  78627. * Defines if mipmaps should not be generated (default is false)
  78628. */
  78629. noMipmap: boolean;
  78630. /**
  78631. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78632. */
  78633. generateHarmonics: boolean;
  78634. /**
  78635. * 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)
  78636. */
  78637. gammaSpace: boolean;
  78638. /**
  78639. * Internal Use Only
  78640. */
  78641. reserved: boolean;
  78642. /**
  78643. * Gets the loaded texture
  78644. */
  78645. texture: HDRCubeTexture;
  78646. /**
  78647. * Callback called when the task is successful
  78648. */
  78649. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  78650. /**
  78651. * Callback called when the task is successful
  78652. */
  78653. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  78654. /**
  78655. * Creates a new HDRCubeTextureAssetTask object
  78656. * @param name defines the name of the task
  78657. * @param url defines the location of the file to load
  78658. * @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.
  78659. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78660. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78661. * @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)
  78662. * @param reserved Internal use only
  78663. */
  78664. constructor(
  78665. /**
  78666. * Defines the name of the task
  78667. */
  78668. name: string,
  78669. /**
  78670. * Defines the location of the file to load
  78671. */
  78672. url: string,
  78673. /**
  78674. * Defines the desired size (the more it increases the longer the generation will be)
  78675. */
  78676. size: number,
  78677. /**
  78678. * Defines if mipmaps should not be generated (default is false)
  78679. */
  78680. noMipmap?: boolean,
  78681. /**
  78682. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78683. */
  78684. generateHarmonics?: boolean,
  78685. /**
  78686. * 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)
  78687. */
  78688. gammaSpace?: boolean,
  78689. /**
  78690. * Internal Use Only
  78691. */
  78692. reserved?: boolean);
  78693. /**
  78694. * Execute the current task
  78695. * @param scene defines the scene where you want your assets to be loaded
  78696. * @param onSuccess is a callback called when the task is successfully executed
  78697. * @param onError is a callback called if an error occurs
  78698. */
  78699. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78700. }
  78701. /**
  78702. * Define a task used by AssetsManager to load Equirectangular cube textures
  78703. */
  78704. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  78705. /**
  78706. * Defines the name of the task
  78707. */
  78708. name: string;
  78709. /**
  78710. * Defines the location of the file to load
  78711. */
  78712. url: string;
  78713. /**
  78714. * Defines the desired size (the more it increases the longer the generation will be)
  78715. */
  78716. size: number;
  78717. /**
  78718. * Defines if mipmaps should not be generated (default is false)
  78719. */
  78720. noMipmap: boolean;
  78721. /**
  78722. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78723. * but the standard material would require them in Gamma space) (default is true)
  78724. */
  78725. gammaSpace: boolean;
  78726. /**
  78727. * Gets the loaded texture
  78728. */
  78729. texture: EquiRectangularCubeTexture;
  78730. /**
  78731. * Callback called when the task is successful
  78732. */
  78733. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  78734. /**
  78735. * Callback called when the task is successful
  78736. */
  78737. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  78738. /**
  78739. * Creates a new EquiRectangularCubeTextureAssetTask object
  78740. * @param name defines the name of the task
  78741. * @param url defines the location of the file to load
  78742. * @param size defines the desired size (the more it increases the longer the generation will be)
  78743. * If the size is omitted this implies you are using a preprocessed cubemap.
  78744. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78745. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  78746. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  78747. * (default is true)
  78748. */
  78749. constructor(
  78750. /**
  78751. * Defines the name of the task
  78752. */
  78753. name: string,
  78754. /**
  78755. * Defines the location of the file to load
  78756. */
  78757. url: string,
  78758. /**
  78759. * Defines the desired size (the more it increases the longer the generation will be)
  78760. */
  78761. size: number,
  78762. /**
  78763. * Defines if mipmaps should not be generated (default is false)
  78764. */
  78765. noMipmap?: boolean,
  78766. /**
  78767. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78768. * but the standard material would require them in Gamma space) (default is true)
  78769. */
  78770. gammaSpace?: boolean);
  78771. /**
  78772. * Execute the current task
  78773. * @param scene defines the scene where you want your assets to be loaded
  78774. * @param onSuccess is a callback called when the task is successfully executed
  78775. * @param onError is a callback called if an error occurs
  78776. */
  78777. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78778. }
  78779. /**
  78780. * This class can be used to easily import assets into a scene
  78781. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  78782. */
  78783. export class AssetsManager {
  78784. private _scene;
  78785. private _isLoading;
  78786. protected _tasks: AbstractAssetTask[];
  78787. protected _waitingTasksCount: number;
  78788. protected _totalTasksCount: number;
  78789. /**
  78790. * Callback called when all tasks are processed
  78791. */
  78792. onFinish: (tasks: AbstractAssetTask[]) => void;
  78793. /**
  78794. * Callback called when a task is successful
  78795. */
  78796. onTaskSuccess: (task: AbstractAssetTask) => void;
  78797. /**
  78798. * Callback called when a task had an error
  78799. */
  78800. onTaskError: (task: AbstractAssetTask) => void;
  78801. /**
  78802. * Callback called when a task is done (whatever the result is)
  78803. */
  78804. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78805. /**
  78806. * Observable called when all tasks are processed
  78807. */
  78808. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78809. /**
  78810. * Observable called when a task had an error
  78811. */
  78812. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78813. /**
  78814. * Observable called when all tasks were executed
  78815. */
  78816. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78817. /**
  78818. * Observable called when a task is done (whatever the result is)
  78819. */
  78820. onProgressObservable: Observable<IAssetsProgressEvent>;
  78821. /**
  78822. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78823. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78824. */
  78825. useDefaultLoadingScreen: boolean;
  78826. /**
  78827. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78828. * when all assets have been downloaded.
  78829. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78830. */
  78831. autoHideLoadingUI: boolean;
  78832. /**
  78833. * Creates a new AssetsManager
  78834. * @param scene defines the scene to work on
  78835. */
  78836. constructor(scene: Scene);
  78837. /**
  78838. * Add a ContainerAssetTask to the list of active tasks
  78839. * @param taskName defines the name of the new task
  78840. * @param meshesNames defines the name of meshes to load
  78841. * @param rootUrl defines the root url to use to locate files
  78842. * @param sceneFilename defines the filename of the scene file
  78843. * @returns a new ContainerAssetTask object
  78844. */
  78845. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78846. /**
  78847. * Add a MeshAssetTask to the list of active tasks
  78848. * @param taskName defines the name of the new task
  78849. * @param meshesNames defines the name of meshes to load
  78850. * @param rootUrl defines the root url to use to locate files
  78851. * @param sceneFilename defines the filename of the scene file
  78852. * @returns a new MeshAssetTask object
  78853. */
  78854. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78855. /**
  78856. * Add a TextFileAssetTask to the list of active tasks
  78857. * @param taskName defines the name of the new task
  78858. * @param url defines the url of the file to load
  78859. * @returns a new TextFileAssetTask object
  78860. */
  78861. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78862. /**
  78863. * Add a BinaryFileAssetTask to the list of active tasks
  78864. * @param taskName defines the name of the new task
  78865. * @param url defines the url of the file to load
  78866. * @returns a new BinaryFileAssetTask object
  78867. */
  78868. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78869. /**
  78870. * Add a ImageAssetTask to the list of active tasks
  78871. * @param taskName defines the name of the new task
  78872. * @param url defines the url of the file to load
  78873. * @returns a new ImageAssetTask object
  78874. */
  78875. addImageTask(taskName: string, url: string): ImageAssetTask;
  78876. /**
  78877. * Add a TextureAssetTask to the list of active tasks
  78878. * @param taskName defines the name of the new task
  78879. * @param url defines the url of the file to load
  78880. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78881. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78882. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78883. * @returns a new TextureAssetTask object
  78884. */
  78885. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78886. /**
  78887. * Add a CubeTextureAssetTask to the list of active tasks
  78888. * @param taskName defines the name of the new task
  78889. * @param url defines the url of the file to load
  78890. * @param extensions defines the extension to use to load the cube map (can be null)
  78891. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78892. * @param files defines the list of files to load (can be null)
  78893. * @returns a new CubeTextureAssetTask object
  78894. */
  78895. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78896. /**
  78897. *
  78898. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78899. * @param taskName defines the name of the new task
  78900. * @param url defines the url of the file to load
  78901. * @param size defines the size you want for the cubemap (can be null)
  78902. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78903. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78904. * @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)
  78905. * @param reserved Internal use only
  78906. * @returns a new HDRCubeTextureAssetTask object
  78907. */
  78908. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78909. /**
  78910. *
  78911. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78912. * @param taskName defines the name of the new task
  78913. * @param url defines the url of the file to load
  78914. * @param size defines the size you want for the cubemap (can be null)
  78915. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78916. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78917. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78918. * @returns a new EquiRectangularCubeTextureAssetTask object
  78919. */
  78920. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78921. /**
  78922. * Remove a task from the assets manager.
  78923. * @param task the task to remove
  78924. */
  78925. removeTask(task: AbstractAssetTask): void;
  78926. private _decreaseWaitingTasksCount;
  78927. private _runTask;
  78928. /**
  78929. * Reset the AssetsManager and remove all tasks
  78930. * @return the current instance of the AssetsManager
  78931. */
  78932. reset(): AssetsManager;
  78933. /**
  78934. * Start the loading process
  78935. * @return the current instance of the AssetsManager
  78936. */
  78937. load(): AssetsManager;
  78938. /**
  78939. * Start the loading process as an async operation
  78940. * @return a promise returning the list of failed tasks
  78941. */
  78942. loadAsync(): Promise<void>;
  78943. }
  78944. }
  78945. declare module "babylonjs/Misc/deferred" {
  78946. /**
  78947. * Wrapper class for promise with external resolve and reject.
  78948. */
  78949. export class Deferred<T> {
  78950. /**
  78951. * The promise associated with this deferred object.
  78952. */
  78953. readonly promise: Promise<T>;
  78954. private _resolve;
  78955. private _reject;
  78956. /**
  78957. * The resolve method of the promise associated with this deferred object.
  78958. */
  78959. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  78960. /**
  78961. * The reject method of the promise associated with this deferred object.
  78962. */
  78963. get reject(): (reason?: any) => void;
  78964. /**
  78965. * Constructor for this deferred object.
  78966. */
  78967. constructor();
  78968. }
  78969. }
  78970. declare module "babylonjs/Misc/meshExploder" {
  78971. import { Mesh } from "babylonjs/Meshes/mesh";
  78972. /**
  78973. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78974. */
  78975. export class MeshExploder {
  78976. private _centerMesh;
  78977. private _meshes;
  78978. private _meshesOrigins;
  78979. private _toCenterVectors;
  78980. private _scaledDirection;
  78981. private _newPosition;
  78982. private _centerPosition;
  78983. /**
  78984. * Explodes meshes from a center mesh.
  78985. * @param meshes The meshes to explode.
  78986. * @param centerMesh The mesh to be center of explosion.
  78987. */
  78988. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78989. private _setCenterMesh;
  78990. /**
  78991. * Get class name
  78992. * @returns "MeshExploder"
  78993. */
  78994. getClassName(): string;
  78995. /**
  78996. * "Exploded meshes"
  78997. * @returns Array of meshes with the centerMesh at index 0.
  78998. */
  78999. getMeshes(): Array<Mesh>;
  79000. /**
  79001. * Explodes meshes giving a specific direction
  79002. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  79003. */
  79004. explode(direction?: number): void;
  79005. }
  79006. }
  79007. declare module "babylonjs/Misc/filesInput" {
  79008. import { Engine } from "babylonjs/Engines/engine";
  79009. import { Scene } from "babylonjs/scene";
  79010. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  79011. import { Nullable } from "babylonjs/types";
  79012. /**
  79013. * Class used to help managing file picking and drag'n'drop
  79014. */
  79015. export class FilesInput {
  79016. /**
  79017. * List of files ready to be loaded
  79018. */
  79019. static get FilesToLoad(): {
  79020. [key: string]: File;
  79021. };
  79022. /**
  79023. * Callback called when a file is processed
  79024. */
  79025. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  79026. private _engine;
  79027. private _currentScene;
  79028. private _sceneLoadedCallback;
  79029. private _progressCallback;
  79030. private _additionalRenderLoopLogicCallback;
  79031. private _textureLoadingCallback;
  79032. private _startingProcessingFilesCallback;
  79033. private _onReloadCallback;
  79034. private _errorCallback;
  79035. private _elementToMonitor;
  79036. private _sceneFileToLoad;
  79037. private _filesToLoad;
  79038. /**
  79039. * Creates a new FilesInput
  79040. * @param engine defines the rendering engine
  79041. * @param scene defines the hosting scene
  79042. * @param sceneLoadedCallback callback called when scene is loaded
  79043. * @param progressCallback callback called to track progress
  79044. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  79045. * @param textureLoadingCallback callback called when a texture is loading
  79046. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  79047. * @param onReloadCallback callback called when a reload is requested
  79048. * @param errorCallback callback call if an error occurs
  79049. */
  79050. 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>);
  79051. private _dragEnterHandler;
  79052. private _dragOverHandler;
  79053. private _dropHandler;
  79054. /**
  79055. * Calls this function to listen to drag'n'drop events on a specific DOM element
  79056. * @param elementToMonitor defines the DOM element to track
  79057. */
  79058. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  79059. /** Gets the current list of files to load */
  79060. get filesToLoad(): File[];
  79061. /**
  79062. * Release all associated resources
  79063. */
  79064. dispose(): void;
  79065. private renderFunction;
  79066. private drag;
  79067. private drop;
  79068. private _traverseFolder;
  79069. private _processFiles;
  79070. /**
  79071. * Load files from a drop event
  79072. * @param event defines the drop event to use as source
  79073. */
  79074. loadFiles(event: any): void;
  79075. private _processReload;
  79076. /**
  79077. * Reload the current scene from the loaded files
  79078. */
  79079. reload(): void;
  79080. }
  79081. }
  79082. declare module "babylonjs/Misc/HighDynamicRange/index" {
  79083. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  79084. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  79085. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  79086. }
  79087. declare module "babylonjs/Misc/sceneOptimizer" {
  79088. import { Scene, IDisposable } from "babylonjs/scene";
  79089. import { Observable } from "babylonjs/Misc/observable";
  79090. /**
  79091. * Defines the root class used to create scene optimization to use with SceneOptimizer
  79092. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79093. */
  79094. export class SceneOptimization {
  79095. /**
  79096. * Defines the priority of this optimization (0 by default which means first in the list)
  79097. */
  79098. priority: number;
  79099. /**
  79100. * Gets a string describing the action executed by the current optimization
  79101. * @returns description string
  79102. */
  79103. getDescription(): string;
  79104. /**
  79105. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79106. * @param scene defines the current scene where to apply this optimization
  79107. * @param optimizer defines the current optimizer
  79108. * @returns true if everything that can be done was applied
  79109. */
  79110. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79111. /**
  79112. * Creates the SceneOptimization object
  79113. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79114. * @param desc defines the description associated with the optimization
  79115. */
  79116. constructor(
  79117. /**
  79118. * Defines the priority of this optimization (0 by default which means first in the list)
  79119. */
  79120. priority?: number);
  79121. }
  79122. /**
  79123. * Defines an optimization used to reduce the size of render target textures
  79124. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79125. */
  79126. export class TextureOptimization extends SceneOptimization {
  79127. /**
  79128. * Defines the priority of this optimization (0 by default which means first in the list)
  79129. */
  79130. priority: number;
  79131. /**
  79132. * 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
  79133. */
  79134. maximumSize: number;
  79135. /**
  79136. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79137. */
  79138. step: number;
  79139. /**
  79140. * Gets a string describing the action executed by the current optimization
  79141. * @returns description string
  79142. */
  79143. getDescription(): string;
  79144. /**
  79145. * Creates the TextureOptimization object
  79146. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79147. * @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
  79148. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79149. */
  79150. constructor(
  79151. /**
  79152. * Defines the priority of this optimization (0 by default which means first in the list)
  79153. */
  79154. priority?: number,
  79155. /**
  79156. * 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
  79157. */
  79158. maximumSize?: number,
  79159. /**
  79160. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79161. */
  79162. step?: number);
  79163. /**
  79164. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79165. * @param scene defines the current scene where to apply this optimization
  79166. * @param optimizer defines the current optimizer
  79167. * @returns true if everything that can be done was applied
  79168. */
  79169. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79170. }
  79171. /**
  79172. * Defines an optimization used to increase or decrease the rendering resolution
  79173. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79174. */
  79175. export class HardwareScalingOptimization extends SceneOptimization {
  79176. /**
  79177. * Defines the priority of this optimization (0 by default which means first in the list)
  79178. */
  79179. priority: number;
  79180. /**
  79181. * Defines the maximum scale to use (2 by default)
  79182. */
  79183. maximumScale: number;
  79184. /**
  79185. * Defines the step to use between two passes (0.5 by default)
  79186. */
  79187. step: number;
  79188. private _currentScale;
  79189. private _directionOffset;
  79190. /**
  79191. * Gets a string describing the action executed by the current optimization
  79192. * @return description string
  79193. */
  79194. getDescription(): string;
  79195. /**
  79196. * Creates the HardwareScalingOptimization object
  79197. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79198. * @param maximumScale defines the maximum scale to use (2 by default)
  79199. * @param step defines the step to use between two passes (0.5 by default)
  79200. */
  79201. constructor(
  79202. /**
  79203. * Defines the priority of this optimization (0 by default which means first in the list)
  79204. */
  79205. priority?: number,
  79206. /**
  79207. * Defines the maximum scale to use (2 by default)
  79208. */
  79209. maximumScale?: number,
  79210. /**
  79211. * Defines the step to use between two passes (0.5 by default)
  79212. */
  79213. step?: number);
  79214. /**
  79215. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79216. * @param scene defines the current scene where to apply this optimization
  79217. * @param optimizer defines the current optimizer
  79218. * @returns true if everything that can be done was applied
  79219. */
  79220. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79221. }
  79222. /**
  79223. * Defines an optimization used to remove shadows
  79224. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79225. */
  79226. export class ShadowsOptimization extends SceneOptimization {
  79227. /**
  79228. * Gets a string describing the action executed by the current optimization
  79229. * @return description string
  79230. */
  79231. getDescription(): string;
  79232. /**
  79233. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79234. * @param scene defines the current scene where to apply this optimization
  79235. * @param optimizer defines the current optimizer
  79236. * @returns true if everything that can be done was applied
  79237. */
  79238. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79239. }
  79240. /**
  79241. * Defines an optimization used to turn post-processes off
  79242. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79243. */
  79244. export class PostProcessesOptimization extends SceneOptimization {
  79245. /**
  79246. * Gets a string describing the action executed by the current optimization
  79247. * @return description string
  79248. */
  79249. getDescription(): string;
  79250. /**
  79251. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79252. * @param scene defines the current scene where to apply this optimization
  79253. * @param optimizer defines the current optimizer
  79254. * @returns true if everything that can be done was applied
  79255. */
  79256. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79257. }
  79258. /**
  79259. * Defines an optimization used to turn lens flares off
  79260. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79261. */
  79262. export class LensFlaresOptimization extends SceneOptimization {
  79263. /**
  79264. * Gets a string describing the action executed by the current optimization
  79265. * @return description string
  79266. */
  79267. getDescription(): string;
  79268. /**
  79269. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79270. * @param scene defines the current scene where to apply this optimization
  79271. * @param optimizer defines the current optimizer
  79272. * @returns true if everything that can be done was applied
  79273. */
  79274. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79275. }
  79276. /**
  79277. * Defines an optimization based on user defined callback.
  79278. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79279. */
  79280. export class CustomOptimization extends SceneOptimization {
  79281. /**
  79282. * Callback called to apply the custom optimization.
  79283. */
  79284. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  79285. /**
  79286. * Callback called to get custom description
  79287. */
  79288. onGetDescription: () => string;
  79289. /**
  79290. * Gets a string describing the action executed by the current optimization
  79291. * @returns description string
  79292. */
  79293. getDescription(): string;
  79294. /**
  79295. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79296. * @param scene defines the current scene where to apply this optimization
  79297. * @param optimizer defines the current optimizer
  79298. * @returns true if everything that can be done was applied
  79299. */
  79300. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79301. }
  79302. /**
  79303. * Defines an optimization used to turn particles off
  79304. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79305. */
  79306. export class ParticlesOptimization extends SceneOptimization {
  79307. /**
  79308. * Gets a string describing the action executed by the current optimization
  79309. * @return description string
  79310. */
  79311. getDescription(): string;
  79312. /**
  79313. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79314. * @param scene defines the current scene where to apply this optimization
  79315. * @param optimizer defines the current optimizer
  79316. * @returns true if everything that can be done was applied
  79317. */
  79318. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79319. }
  79320. /**
  79321. * Defines an optimization used to turn render targets off
  79322. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79323. */
  79324. export class RenderTargetsOptimization extends SceneOptimization {
  79325. /**
  79326. * Gets a string describing the action executed by the current optimization
  79327. * @return description string
  79328. */
  79329. getDescription(): string;
  79330. /**
  79331. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79332. * @param scene defines the current scene where to apply this optimization
  79333. * @param optimizer defines the current optimizer
  79334. * @returns true if everything that can be done was applied
  79335. */
  79336. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79337. }
  79338. /**
  79339. * Defines an optimization used to merge meshes with compatible materials
  79340. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79341. */
  79342. export class MergeMeshesOptimization extends SceneOptimization {
  79343. private static _UpdateSelectionTree;
  79344. /**
  79345. * Gets or sets a boolean which defines if optimization octree has to be updated
  79346. */
  79347. static get UpdateSelectionTree(): boolean;
  79348. /**
  79349. * Gets or sets a boolean which defines if optimization octree has to be updated
  79350. */
  79351. static set UpdateSelectionTree(value: boolean);
  79352. /**
  79353. * Gets a string describing the action executed by the current optimization
  79354. * @return description string
  79355. */
  79356. getDescription(): string;
  79357. private _canBeMerged;
  79358. /**
  79359. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79360. * @param scene defines the current scene where to apply this optimization
  79361. * @param optimizer defines the current optimizer
  79362. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  79363. * @returns true if everything that can be done was applied
  79364. */
  79365. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  79366. }
  79367. /**
  79368. * Defines a list of options used by SceneOptimizer
  79369. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79370. */
  79371. export class SceneOptimizerOptions {
  79372. /**
  79373. * Defines the target frame rate to reach (60 by default)
  79374. */
  79375. targetFrameRate: number;
  79376. /**
  79377. * Defines the interval between two checkes (2000ms by default)
  79378. */
  79379. trackerDuration: number;
  79380. /**
  79381. * Gets the list of optimizations to apply
  79382. */
  79383. optimizations: SceneOptimization[];
  79384. /**
  79385. * Creates a new list of options used by SceneOptimizer
  79386. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  79387. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  79388. */
  79389. constructor(
  79390. /**
  79391. * Defines the target frame rate to reach (60 by default)
  79392. */
  79393. targetFrameRate?: number,
  79394. /**
  79395. * Defines the interval between two checkes (2000ms by default)
  79396. */
  79397. trackerDuration?: number);
  79398. /**
  79399. * Add a new optimization
  79400. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  79401. * @returns the current SceneOptimizerOptions
  79402. */
  79403. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  79404. /**
  79405. * Add a new custom optimization
  79406. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  79407. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  79408. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79409. * @returns the current SceneOptimizerOptions
  79410. */
  79411. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  79412. /**
  79413. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  79414. * @param targetFrameRate defines the target frame rate (60 by default)
  79415. * @returns a SceneOptimizerOptions object
  79416. */
  79417. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79418. /**
  79419. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  79420. * @param targetFrameRate defines the target frame rate (60 by default)
  79421. * @returns a SceneOptimizerOptions object
  79422. */
  79423. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79424. /**
  79425. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  79426. * @param targetFrameRate defines the target frame rate (60 by default)
  79427. * @returns a SceneOptimizerOptions object
  79428. */
  79429. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79430. }
  79431. /**
  79432. * Class used to run optimizations in order to reach a target frame rate
  79433. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79434. */
  79435. export class SceneOptimizer implements IDisposable {
  79436. private _isRunning;
  79437. private _options;
  79438. private _scene;
  79439. private _currentPriorityLevel;
  79440. private _targetFrameRate;
  79441. private _trackerDuration;
  79442. private _currentFrameRate;
  79443. private _sceneDisposeObserver;
  79444. private _improvementMode;
  79445. /**
  79446. * Defines an observable called when the optimizer reaches the target frame rate
  79447. */
  79448. onSuccessObservable: Observable<SceneOptimizer>;
  79449. /**
  79450. * Defines an observable called when the optimizer enables an optimization
  79451. */
  79452. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  79453. /**
  79454. * Defines an observable called when the optimizer is not able to reach the target frame rate
  79455. */
  79456. onFailureObservable: Observable<SceneOptimizer>;
  79457. /**
  79458. * Gets a boolean indicating if the optimizer is in improvement mode
  79459. */
  79460. get isInImprovementMode(): boolean;
  79461. /**
  79462. * Gets the current priority level (0 at start)
  79463. */
  79464. get currentPriorityLevel(): number;
  79465. /**
  79466. * Gets the current frame rate checked by the SceneOptimizer
  79467. */
  79468. get currentFrameRate(): number;
  79469. /**
  79470. * Gets or sets the current target frame rate (60 by default)
  79471. */
  79472. get targetFrameRate(): number;
  79473. /**
  79474. * Gets or sets the current target frame rate (60 by default)
  79475. */
  79476. set targetFrameRate(value: number);
  79477. /**
  79478. * Gets or sets the current interval between two checks (every 2000ms by default)
  79479. */
  79480. get trackerDuration(): number;
  79481. /**
  79482. * Gets or sets the current interval between two checks (every 2000ms by default)
  79483. */
  79484. set trackerDuration(value: number);
  79485. /**
  79486. * Gets the list of active optimizations
  79487. */
  79488. get optimizations(): SceneOptimization[];
  79489. /**
  79490. * Creates a new SceneOptimizer
  79491. * @param scene defines the scene to work on
  79492. * @param options defines the options to use with the SceneOptimizer
  79493. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  79494. * @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)
  79495. */
  79496. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  79497. /**
  79498. * Stops the current optimizer
  79499. */
  79500. stop(): void;
  79501. /**
  79502. * Reset the optimizer to initial step (current priority level = 0)
  79503. */
  79504. reset(): void;
  79505. /**
  79506. * Start the optimizer. By default it will try to reach a specific framerate
  79507. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  79508. */
  79509. start(): void;
  79510. private _checkCurrentState;
  79511. /**
  79512. * Release all resources
  79513. */
  79514. dispose(): void;
  79515. /**
  79516. * Helper function to create a SceneOptimizer with one single line of code
  79517. * @param scene defines the scene to work on
  79518. * @param options defines the options to use with the SceneOptimizer
  79519. * @param onSuccess defines a callback to call on success
  79520. * @param onFailure defines a callback to call on failure
  79521. * @returns the new SceneOptimizer object
  79522. */
  79523. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  79524. }
  79525. }
  79526. declare module "babylonjs/Misc/sceneSerializer" {
  79527. import { Scene } from "babylonjs/scene";
  79528. /**
  79529. * Class used to serialize a scene into a string
  79530. */
  79531. export class SceneSerializer {
  79532. /**
  79533. * Clear cache used by a previous serialization
  79534. */
  79535. static ClearCache(): void;
  79536. /**
  79537. * Serialize a scene into a JSON compatible object
  79538. * @param scene defines the scene to serialize
  79539. * @returns a JSON compatible object
  79540. */
  79541. static Serialize(scene: Scene): any;
  79542. /**
  79543. * Serialize a mesh into a JSON compatible object
  79544. * @param toSerialize defines the mesh to serialize
  79545. * @param withParents defines if parents must be serialized as well
  79546. * @param withChildren defines if children must be serialized as well
  79547. * @returns a JSON compatible object
  79548. */
  79549. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  79550. }
  79551. }
  79552. declare module "babylonjs/Misc/textureTools" {
  79553. import { Texture } from "babylonjs/Materials/Textures/texture";
  79554. /**
  79555. * Class used to host texture specific utilities
  79556. */
  79557. export class TextureTools {
  79558. /**
  79559. * Uses the GPU to create a copy texture rescaled at a given size
  79560. * @param texture Texture to copy from
  79561. * @param width defines the desired width
  79562. * @param height defines the desired height
  79563. * @param useBilinearMode defines if bilinear mode has to be used
  79564. * @return the generated texture
  79565. */
  79566. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  79567. }
  79568. }
  79569. declare module "babylonjs/Misc/videoRecorder" {
  79570. import { Nullable } from "babylonjs/types";
  79571. import { Engine } from "babylonjs/Engines/engine";
  79572. /**
  79573. * This represents the different options available for the video capture.
  79574. */
  79575. export interface VideoRecorderOptions {
  79576. /** Defines the mime type of the video. */
  79577. mimeType: string;
  79578. /** Defines the FPS the video should be recorded at. */
  79579. fps: number;
  79580. /** Defines the chunk size for the recording data. */
  79581. recordChunckSize: number;
  79582. /** The audio tracks to attach to the recording. */
  79583. audioTracks?: MediaStreamTrack[];
  79584. }
  79585. /**
  79586. * This can help with recording videos from BabylonJS.
  79587. * This is based on the available WebRTC functionalities of the browser.
  79588. *
  79589. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  79590. */
  79591. export class VideoRecorder {
  79592. private static readonly _defaultOptions;
  79593. /**
  79594. * Returns whether or not the VideoRecorder is available in your browser.
  79595. * @param engine Defines the Babylon Engine.
  79596. * @returns true if supported otherwise false.
  79597. */
  79598. static IsSupported(engine: Engine): boolean;
  79599. private readonly _options;
  79600. private _canvas;
  79601. private _mediaRecorder;
  79602. private _recordedChunks;
  79603. private _fileName;
  79604. private _resolve;
  79605. private _reject;
  79606. /**
  79607. * True when a recording is already in progress.
  79608. */
  79609. get isRecording(): boolean;
  79610. /**
  79611. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  79612. * @param engine Defines the BabylonJS Engine you wish to record.
  79613. * @param options Defines options that can be used to customize the capture.
  79614. */
  79615. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  79616. /**
  79617. * Stops the current recording before the default capture timeout passed in the startRecording function.
  79618. */
  79619. stopRecording(): void;
  79620. /**
  79621. * Starts recording the canvas for a max duration specified in parameters.
  79622. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  79623. * If null no automatic download will start and you can rely on the promise to get the data back.
  79624. * @param maxDuration Defines the maximum recording time in seconds.
  79625. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  79626. * @return A promise callback at the end of the recording with the video data in Blob.
  79627. */
  79628. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  79629. /**
  79630. * Releases internal resources used during the recording.
  79631. */
  79632. dispose(): void;
  79633. private _handleDataAvailable;
  79634. private _handleError;
  79635. private _handleStop;
  79636. }
  79637. }
  79638. declare module "babylonjs/Misc/screenshotTools" {
  79639. import { Camera } from "babylonjs/Cameras/camera";
  79640. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  79641. import { Engine } from "babylonjs/Engines/engine";
  79642. /**
  79643. * Class containing a set of static utilities functions for screenshots
  79644. */
  79645. export class ScreenshotTools {
  79646. /**
  79647. * Captures a screenshot of the current rendering
  79648. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79649. * @param engine defines the rendering engine
  79650. * @param camera defines the source camera
  79651. * @param size This parameter can be set to a single number or to an object with the
  79652. * following (optional) properties: precision, width, height. If a single number is passed,
  79653. * it will be used for both width and height. If an object is passed, the screenshot size
  79654. * will be derived from the parameters. The precision property is a multiplier allowing
  79655. * rendering at a higher or lower resolution
  79656. * @param successCallback defines the callback receives a single parameter which contains the
  79657. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79658. * src parameter of an <img> to display it
  79659. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79660. * Check your browser for supported MIME types
  79661. */
  79662. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  79663. /**
  79664. * Captures a screenshot of the current rendering
  79665. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79666. * @param engine defines the rendering engine
  79667. * @param camera defines the source camera
  79668. * @param size This parameter can be set to a single number or to an object with the
  79669. * following (optional) properties: precision, width, height. If a single number is passed,
  79670. * it will be used for both width and height. If an object is passed, the screenshot size
  79671. * will be derived from the parameters. The precision property is a multiplier allowing
  79672. * rendering at a higher or lower resolution
  79673. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79674. * Check your browser for supported MIME types
  79675. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79676. * to the src parameter of an <img> to display it
  79677. */
  79678. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  79679. /**
  79680. * Generates an image screenshot from the specified camera.
  79681. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79682. * @param engine The engine to use for rendering
  79683. * @param camera The camera to use for rendering
  79684. * @param size This parameter can be set to a single number or to an object with the
  79685. * following (optional) properties: precision, width, height. If a single number is passed,
  79686. * it will be used for both width and height. If an object is passed, the screenshot size
  79687. * will be derived from the parameters. The precision property is a multiplier allowing
  79688. * rendering at a higher or lower resolution
  79689. * @param successCallback The callback receives a single parameter which contains the
  79690. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79691. * src parameter of an <img> to display it
  79692. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79693. * Check your browser for supported MIME types
  79694. * @param samples Texture samples (default: 1)
  79695. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79696. * @param fileName A name for for the downloaded file.
  79697. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79698. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  79699. */
  79700. 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;
  79701. /**
  79702. * Generates an image screenshot from the specified camera.
  79703. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79704. * @param engine The engine to use for rendering
  79705. * @param camera The camera to use for rendering
  79706. * @param size This parameter can be set to a single number or to an object with the
  79707. * following (optional) properties: precision, width, height. If a single number is passed,
  79708. * it will be used for both width and height. If an object is passed, the screenshot size
  79709. * will be derived from the parameters. The precision property is a multiplier allowing
  79710. * rendering at a higher or lower resolution
  79711. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79712. * Check your browser for supported MIME types
  79713. * @param samples Texture samples (default: 1)
  79714. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79715. * @param fileName A name for for the downloaded file.
  79716. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79717. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79718. * to the src parameter of an <img> to display it
  79719. */
  79720. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  79721. /**
  79722. * Gets height and width for screenshot size
  79723. * @private
  79724. */
  79725. private static _getScreenshotSize;
  79726. }
  79727. }
  79728. declare module "babylonjs/Misc/dataReader" {
  79729. /**
  79730. * Interface for a data buffer
  79731. */
  79732. export interface IDataBuffer {
  79733. /**
  79734. * Reads bytes from the data buffer.
  79735. * @param byteOffset The byte offset to read
  79736. * @param byteLength The byte length to read
  79737. * @returns A promise that resolves when the bytes are read
  79738. */
  79739. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  79740. /**
  79741. * The byte length of the buffer.
  79742. */
  79743. readonly byteLength: number;
  79744. }
  79745. /**
  79746. * Utility class for reading from a data buffer
  79747. */
  79748. export class DataReader {
  79749. /**
  79750. * The data buffer associated with this data reader.
  79751. */
  79752. readonly buffer: IDataBuffer;
  79753. /**
  79754. * The current byte offset from the beginning of the data buffer.
  79755. */
  79756. byteOffset: number;
  79757. private _dataView;
  79758. private _dataByteOffset;
  79759. /**
  79760. * Constructor
  79761. * @param buffer The buffer to read
  79762. */
  79763. constructor(buffer: IDataBuffer);
  79764. /**
  79765. * Loads the given byte length.
  79766. * @param byteLength The byte length to load
  79767. * @returns A promise that resolves when the load is complete
  79768. */
  79769. loadAsync(byteLength: number): Promise<void>;
  79770. /**
  79771. * Read a unsigned 32-bit integer from the currently loaded data range.
  79772. * @returns The 32-bit integer read
  79773. */
  79774. readUint32(): number;
  79775. /**
  79776. * Read a byte array from the currently loaded data range.
  79777. * @param byteLength The byte length to read
  79778. * @returns The byte array read
  79779. */
  79780. readUint8Array(byteLength: number): Uint8Array;
  79781. /**
  79782. * Read a string from the currently loaded data range.
  79783. * @param byteLength The byte length to read
  79784. * @returns The string read
  79785. */
  79786. readString(byteLength: number): string;
  79787. /**
  79788. * Skips the given byte length the currently loaded data range.
  79789. * @param byteLength The byte length to skip
  79790. */
  79791. skipBytes(byteLength: number): void;
  79792. }
  79793. }
  79794. declare module "babylonjs/Misc/dataStorage" {
  79795. /**
  79796. * Class for storing data to local storage if available or in-memory storage otherwise
  79797. */
  79798. export class DataStorage {
  79799. private static _Storage;
  79800. private static _GetStorage;
  79801. /**
  79802. * Reads a string from the data storage
  79803. * @param key The key to read
  79804. * @param defaultValue The value if the key doesn't exist
  79805. * @returns The string value
  79806. */
  79807. static ReadString(key: string, defaultValue: string): string;
  79808. /**
  79809. * Writes a string to the data storage
  79810. * @param key The key to write
  79811. * @param value The value to write
  79812. */
  79813. static WriteString(key: string, value: string): void;
  79814. /**
  79815. * Reads a boolean from the data storage
  79816. * @param key The key to read
  79817. * @param defaultValue The value if the key doesn't exist
  79818. * @returns The boolean value
  79819. */
  79820. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79821. /**
  79822. * Writes a boolean to the data storage
  79823. * @param key The key to write
  79824. * @param value The value to write
  79825. */
  79826. static WriteBoolean(key: string, value: boolean): void;
  79827. /**
  79828. * Reads a number from the data storage
  79829. * @param key The key to read
  79830. * @param defaultValue The value if the key doesn't exist
  79831. * @returns The number value
  79832. */
  79833. static ReadNumber(key: string, defaultValue: number): number;
  79834. /**
  79835. * Writes a number to the data storage
  79836. * @param key The key to write
  79837. * @param value The value to write
  79838. */
  79839. static WriteNumber(key: string, value: number): void;
  79840. }
  79841. }
  79842. declare module "babylonjs/Misc/sceneRecorder" {
  79843. import { Scene } from "babylonjs/scene";
  79844. /**
  79845. * Class used to record delta files between 2 scene states
  79846. */
  79847. export class SceneRecorder {
  79848. private _trackedScene;
  79849. private _savedJSON;
  79850. /**
  79851. * Track a given scene. This means the current scene state will be considered the original state
  79852. * @param scene defines the scene to track
  79853. */
  79854. track(scene: Scene): void;
  79855. /**
  79856. * Get the delta between current state and original state
  79857. * @returns a string containing the delta
  79858. */
  79859. getDelta(): any;
  79860. private _compareArray;
  79861. private _compareObjects;
  79862. private _compareCollections;
  79863. private static GetShadowGeneratorById;
  79864. /**
  79865. * Apply a given delta to a given scene
  79866. * @param deltaJSON defines the JSON containing the delta
  79867. * @param scene defines the scene to apply the delta to
  79868. */
  79869. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79870. private static _ApplyPropertiesToEntity;
  79871. private static _ApplyDeltaForEntity;
  79872. }
  79873. }
  79874. declare module "babylonjs/Misc/trajectoryClassifier" {
  79875. import { DeepImmutable, Nullable } from "babylonjs/types";
  79876. import { Vector3 } from "babylonjs/Maths/math.vector";
  79877. /**
  79878. * A 3D trajectory consisting of an order list of vectors describing a
  79879. * path of motion through 3D space.
  79880. */
  79881. export class Trajectory {
  79882. private _points;
  79883. private readonly _segmentLength;
  79884. /**
  79885. * Serialize to JSON.
  79886. * @returns serialized JSON string
  79887. */
  79888. serialize(): string;
  79889. /**
  79890. * Deserialize from JSON.
  79891. * @param json serialized JSON string
  79892. * @returns deserialized Trajectory
  79893. */
  79894. static Deserialize(json: string): Trajectory;
  79895. /**
  79896. * Create a new empty Trajectory.
  79897. * @param segmentLength radius of discretization for Trajectory points
  79898. */
  79899. constructor(segmentLength?: number);
  79900. /**
  79901. * Get the length of the Trajectory.
  79902. * @returns length of the Trajectory
  79903. */
  79904. getLength(): number;
  79905. /**
  79906. * Append a new point to the Trajectory.
  79907. * NOTE: This implementation has many allocations.
  79908. * @param point point to append to the Trajectory
  79909. */
  79910. add(point: DeepImmutable<Vector3>): void;
  79911. /**
  79912. * Create a new Trajectory with a segment length chosen to make it
  79913. * probable that the new Trajectory will have a specified number of
  79914. * segments. This operation is imprecise.
  79915. * @param targetResolution number of segments desired
  79916. * @returns new Trajectory with approximately the requested number of segments
  79917. */
  79918. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79919. /**
  79920. * Convert Trajectory segments into tokenized representation. This
  79921. * representation is an array of numbers where each nth number is the
  79922. * index of the token which is most similar to the nth segment of the
  79923. * Trajectory.
  79924. * @param tokens list of vectors which serve as discrete tokens
  79925. * @returns list of indices of most similar token per segment
  79926. */
  79927. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79928. private static _forwardDir;
  79929. private static _inverseFromVec;
  79930. private static _upDir;
  79931. private static _fromToVec;
  79932. private static _lookMatrix;
  79933. /**
  79934. * Transform the rotation (i.e., direction) of a segment to isolate
  79935. * the relative transformation represented by the segment. This operation
  79936. * may or may not succeed due to singularities in the equations that define
  79937. * motion relativity in this context.
  79938. * @param priorVec the origin of the prior segment
  79939. * @param fromVec the origin of the current segment
  79940. * @param toVec the destination of the current segment
  79941. * @param result reference to output variable
  79942. * @returns whether or not transformation was successful
  79943. */
  79944. private static _transformSegmentDirToRef;
  79945. private static _bestMatch;
  79946. private static _score;
  79947. private static _bestScore;
  79948. /**
  79949. * Determine which token vector is most similar to the
  79950. * segment vector.
  79951. * @param segment segment vector
  79952. * @param tokens token vector list
  79953. * @returns index of the most similar token to the segment
  79954. */
  79955. private static _tokenizeSegment;
  79956. }
  79957. /**
  79958. * Class representing a set of known, named trajectories to which Trajectories can be
  79959. * added and using which Trajectories can be recognized.
  79960. */
  79961. export class TrajectoryClassifier {
  79962. private _maximumAllowableMatchCost;
  79963. private _vector3Alphabet;
  79964. private _levenshteinAlphabet;
  79965. private _nameToDescribedTrajectory;
  79966. /**
  79967. * Serialize to JSON.
  79968. * @returns JSON serialization
  79969. */
  79970. serialize(): string;
  79971. /**
  79972. * Deserialize from JSON.
  79973. * @param json JSON serialization
  79974. * @returns deserialized TrajectorySet
  79975. */
  79976. static Deserialize(json: string): TrajectoryClassifier;
  79977. /**
  79978. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79979. * VERY naive, need to be generating these things from known
  79980. * sets. Better version later, probably eliminating this one.
  79981. * @returns auto-generated TrajectorySet
  79982. */
  79983. static Generate(): TrajectoryClassifier;
  79984. private constructor();
  79985. /**
  79986. * Add a new Trajectory to the set with a given name.
  79987. * @param trajectory new Trajectory to be added
  79988. * @param classification name to which to add the Trajectory
  79989. */
  79990. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79991. /**
  79992. * Remove a known named trajectory and all Trajectories associated with it.
  79993. * @param classification name to remove
  79994. * @returns whether anything was removed
  79995. */
  79996. deleteClassification(classification: string): boolean;
  79997. /**
  79998. * Attempt to recognize a Trajectory from among all the classifications
  79999. * already known to the classifier.
  80000. * @param trajectory Trajectory to be recognized
  80001. * @returns classification of Trajectory if recognized, null otherwise
  80002. */
  80003. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  80004. }
  80005. }
  80006. declare module "babylonjs/Misc/index" {
  80007. export * from "babylonjs/Misc/andOrNotEvaluator";
  80008. export * from "babylonjs/Misc/assetsManager";
  80009. export * from "babylonjs/Misc/basis";
  80010. export * from "babylonjs/Misc/dds";
  80011. export * from "babylonjs/Misc/decorators";
  80012. export * from "babylonjs/Misc/deferred";
  80013. export * from "babylonjs/Misc/environmentTextureTools";
  80014. export * from "babylonjs/Misc/meshExploder";
  80015. export * from "babylonjs/Misc/filesInput";
  80016. export * from "babylonjs/Misc/HighDynamicRange/index";
  80017. export * from "babylonjs/Misc/khronosTextureContainer";
  80018. export * from "babylonjs/Misc/observable";
  80019. export * from "babylonjs/Misc/performanceMonitor";
  80020. export * from "babylonjs/Misc/promise";
  80021. export * from "babylonjs/Misc/sceneOptimizer";
  80022. export * from "babylonjs/Misc/sceneSerializer";
  80023. export * from "babylonjs/Misc/smartArray";
  80024. export * from "babylonjs/Misc/stringDictionary";
  80025. export * from "babylonjs/Misc/tags";
  80026. export * from "babylonjs/Misc/textureTools";
  80027. export * from "babylonjs/Misc/tga";
  80028. export * from "babylonjs/Misc/tools";
  80029. export * from "babylonjs/Misc/videoRecorder";
  80030. export * from "babylonjs/Misc/virtualJoystick";
  80031. export * from "babylonjs/Misc/workerPool";
  80032. export * from "babylonjs/Misc/logger";
  80033. export * from "babylonjs/Misc/typeStore";
  80034. export * from "babylonjs/Misc/filesInputStore";
  80035. export * from "babylonjs/Misc/deepCopier";
  80036. export * from "babylonjs/Misc/pivotTools";
  80037. export * from "babylonjs/Misc/precisionDate";
  80038. export * from "babylonjs/Misc/screenshotTools";
  80039. export * from "babylonjs/Misc/typeStore";
  80040. export * from "babylonjs/Misc/webRequest";
  80041. export * from "babylonjs/Misc/iInspectable";
  80042. export * from "babylonjs/Misc/brdfTextureTools";
  80043. export * from "babylonjs/Misc/rgbdTextureTools";
  80044. export * from "babylonjs/Misc/gradients";
  80045. export * from "babylonjs/Misc/perfCounter";
  80046. export * from "babylonjs/Misc/fileRequest";
  80047. export * from "babylonjs/Misc/customAnimationFrameRequester";
  80048. export * from "babylonjs/Misc/retryStrategy";
  80049. export * from "babylonjs/Misc/interfaces/screenshotSize";
  80050. export * from "babylonjs/Misc/canvasGenerator";
  80051. export * from "babylonjs/Misc/fileTools";
  80052. export * from "babylonjs/Misc/stringTools";
  80053. export * from "babylonjs/Misc/dataReader";
  80054. export * from "babylonjs/Misc/minMaxReducer";
  80055. export * from "babylonjs/Misc/depthReducer";
  80056. export * from "babylonjs/Misc/dataStorage";
  80057. export * from "babylonjs/Misc/sceneRecorder";
  80058. export * from "babylonjs/Misc/khronosTextureContainer2";
  80059. export * from "babylonjs/Misc/trajectoryClassifier";
  80060. export * from "babylonjs/Misc/timer";
  80061. export * from "babylonjs/Misc/copyTools";
  80062. }
  80063. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  80064. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  80065. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80066. import { Observable } from "babylonjs/Misc/observable";
  80067. import { Matrix } from "babylonjs/Maths/math.vector";
  80068. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80069. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80070. /**
  80071. * An interface for all Hit test features
  80072. */
  80073. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  80074. /**
  80075. * Triggered when new babylon (transformed) hit test results are available
  80076. */
  80077. onHitTestResultObservable: Observable<T[]>;
  80078. }
  80079. /**
  80080. * Options used for hit testing
  80081. */
  80082. export interface IWebXRLegacyHitTestOptions {
  80083. /**
  80084. * Only test when user interacted with the scene. Default - hit test every frame
  80085. */
  80086. testOnPointerDownOnly?: boolean;
  80087. /**
  80088. * The node to use to transform the local results to world coordinates
  80089. */
  80090. worldParentNode?: TransformNode;
  80091. }
  80092. /**
  80093. * Interface defining the babylon result of raycasting/hit-test
  80094. */
  80095. export interface IWebXRLegacyHitResult {
  80096. /**
  80097. * Transformation matrix that can be applied to a node that will put it in the hit point location
  80098. */
  80099. transformationMatrix: Matrix;
  80100. /**
  80101. * The native hit test result
  80102. */
  80103. xrHitResult: XRHitResult | XRHitTestResult;
  80104. }
  80105. /**
  80106. * The currently-working hit-test module.
  80107. * Hit test (or Ray-casting) is used to interact with the real world.
  80108. * For further information read here - https://github.com/immersive-web/hit-test
  80109. */
  80110. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  80111. /**
  80112. * options to use when constructing this feature
  80113. */
  80114. readonly options: IWebXRLegacyHitTestOptions;
  80115. private _direction;
  80116. private _mat;
  80117. private _onSelectEnabled;
  80118. private _origin;
  80119. /**
  80120. * The module's name
  80121. */
  80122. static readonly Name: string;
  80123. /**
  80124. * The (Babylon) version of this module.
  80125. * This is an integer representing the implementation version.
  80126. * This number does not correspond to the WebXR specs version
  80127. */
  80128. static readonly Version: number;
  80129. /**
  80130. * Populated with the last native XR Hit Results
  80131. */
  80132. lastNativeXRHitResults: XRHitResult[];
  80133. /**
  80134. * Triggered when new babylon (transformed) hit test results are available
  80135. */
  80136. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  80137. /**
  80138. * Creates a new instance of the (legacy version) hit test feature
  80139. * @param _xrSessionManager an instance of WebXRSessionManager
  80140. * @param options options to use when constructing this feature
  80141. */
  80142. constructor(_xrSessionManager: WebXRSessionManager,
  80143. /**
  80144. * options to use when constructing this feature
  80145. */
  80146. options?: IWebXRLegacyHitTestOptions);
  80147. /**
  80148. * execute a hit test with an XR Ray
  80149. *
  80150. * @param xrSession a native xrSession that will execute this hit test
  80151. * @param xrRay the ray (position and direction) to use for ray-casting
  80152. * @param referenceSpace native XR reference space to use for the hit-test
  80153. * @param filter filter function that will filter the results
  80154. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  80155. */
  80156. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  80157. /**
  80158. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  80159. * @param event the (select) event to use to select with
  80160. * @param referenceSpace the reference space to use for this hit test
  80161. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  80162. */
  80163. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  80164. /**
  80165. * attach this feature
  80166. * Will usually be called by the features manager
  80167. *
  80168. * @returns true if successful.
  80169. */
  80170. attach(): boolean;
  80171. /**
  80172. * detach this feature.
  80173. * Will usually be called by the features manager
  80174. *
  80175. * @returns true if successful.
  80176. */
  80177. detach(): boolean;
  80178. /**
  80179. * Dispose this feature and all of the resources attached
  80180. */
  80181. dispose(): void;
  80182. protected _onXRFrame(frame: XRFrame): void;
  80183. private _onHitTestResults;
  80184. private _onSelect;
  80185. }
  80186. }
  80187. declare module "babylonjs/XR/features/WebXRHitTest" {
  80188. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80189. import { Observable } from "babylonjs/Misc/observable";
  80190. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  80191. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80192. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  80193. /**
  80194. * Options used for hit testing (version 2)
  80195. */
  80196. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  80197. /**
  80198. * Do not create a permanent hit test. Will usually be used when only
  80199. * transient inputs are needed.
  80200. */
  80201. disablePermanentHitTest?: boolean;
  80202. /**
  80203. * Enable transient (for example touch-based) hit test inspections
  80204. */
  80205. enableTransientHitTest?: boolean;
  80206. /**
  80207. * Offset ray for the permanent hit test
  80208. */
  80209. offsetRay?: Vector3;
  80210. /**
  80211. * Offset ray for the transient hit test
  80212. */
  80213. transientOffsetRay?: Vector3;
  80214. /**
  80215. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  80216. */
  80217. useReferenceSpace?: boolean;
  80218. /**
  80219. * Override the default entity type(s) of the hit-test result
  80220. */
  80221. entityTypes?: XRHitTestTrackableType[];
  80222. }
  80223. /**
  80224. * Interface defining the babylon result of hit-test
  80225. */
  80226. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  80227. /**
  80228. * The input source that generated this hit test (if transient)
  80229. */
  80230. inputSource?: XRInputSource;
  80231. /**
  80232. * Is this a transient hit test
  80233. */
  80234. isTransient?: boolean;
  80235. /**
  80236. * Position of the hit test result
  80237. */
  80238. position: Vector3;
  80239. /**
  80240. * Rotation of the hit test result
  80241. */
  80242. rotationQuaternion: Quaternion;
  80243. /**
  80244. * The native hit test result
  80245. */
  80246. xrHitResult: XRHitTestResult;
  80247. }
  80248. /**
  80249. * The currently-working hit-test module.
  80250. * Hit test (or Ray-casting) is used to interact with the real world.
  80251. * For further information read here - https://github.com/immersive-web/hit-test
  80252. *
  80253. * Tested on chrome (mobile) 80.
  80254. */
  80255. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  80256. /**
  80257. * options to use when constructing this feature
  80258. */
  80259. readonly options: IWebXRHitTestOptions;
  80260. private _tmpMat;
  80261. private _tmpPos;
  80262. private _tmpQuat;
  80263. private _transientXrHitTestSource;
  80264. private _xrHitTestSource;
  80265. private initHitTestSource;
  80266. /**
  80267. * The module's name
  80268. */
  80269. static readonly Name: string;
  80270. /**
  80271. * The (Babylon) version of this module.
  80272. * This is an integer representing the implementation version.
  80273. * This number does not correspond to the WebXR specs version
  80274. */
  80275. static readonly Version: number;
  80276. /**
  80277. * When set to true, each hit test will have its own position/rotation objects
  80278. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  80279. * the developers will clone them or copy them as they see fit.
  80280. */
  80281. autoCloneTransformation: boolean;
  80282. /**
  80283. * Triggered when new babylon (transformed) hit test results are available
  80284. * Note - this will be called when results come back from the device. It can be an empty array!!
  80285. */
  80286. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  80287. /**
  80288. * Use this to temporarily pause hit test checks.
  80289. */
  80290. paused: boolean;
  80291. /**
  80292. * Creates a new instance of the hit test feature
  80293. * @param _xrSessionManager an instance of WebXRSessionManager
  80294. * @param options options to use when constructing this feature
  80295. */
  80296. constructor(_xrSessionManager: WebXRSessionManager,
  80297. /**
  80298. * options to use when constructing this feature
  80299. */
  80300. options?: IWebXRHitTestOptions);
  80301. /**
  80302. * attach this feature
  80303. * Will usually be called by the features manager
  80304. *
  80305. * @returns true if successful.
  80306. */
  80307. attach(): boolean;
  80308. /**
  80309. * detach this feature.
  80310. * Will usually be called by the features manager
  80311. *
  80312. * @returns true if successful.
  80313. */
  80314. detach(): boolean;
  80315. /**
  80316. * Dispose this feature and all of the resources attached
  80317. */
  80318. dispose(): void;
  80319. protected _onXRFrame(frame: XRFrame): void;
  80320. private _processWebXRHitTestResult;
  80321. }
  80322. }
  80323. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  80324. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80325. import { Observable } from "babylonjs/Misc/observable";
  80326. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  80327. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80328. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80329. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  80330. /**
  80331. * Configuration options of the anchor system
  80332. */
  80333. export interface IWebXRAnchorSystemOptions {
  80334. /**
  80335. * a node that will be used to convert local to world coordinates
  80336. */
  80337. worldParentNode?: TransformNode;
  80338. /**
  80339. * If set to true a reference of the created anchors will be kept until the next session starts
  80340. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  80341. */
  80342. doNotRemoveAnchorsOnSessionEnded?: boolean;
  80343. }
  80344. /**
  80345. * A babylon container for an XR Anchor
  80346. */
  80347. export interface IWebXRAnchor {
  80348. /**
  80349. * A babylon-assigned ID for this anchor
  80350. */
  80351. id: number;
  80352. /**
  80353. * Transformation matrix to apply to an object attached to this anchor
  80354. */
  80355. transformationMatrix: Matrix;
  80356. /**
  80357. * The native anchor object
  80358. */
  80359. xrAnchor: XRAnchor;
  80360. /**
  80361. * if defined, this object will be constantly updated by the anchor's position and rotation
  80362. */
  80363. attachedNode?: TransformNode;
  80364. /**
  80365. * Remove this anchor from the scene
  80366. */
  80367. remove(): void;
  80368. }
  80369. /**
  80370. * An implementation of the anchor system for WebXR.
  80371. * For further information see https://github.com/immersive-web/anchors/
  80372. */
  80373. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  80374. private _options;
  80375. private _lastFrameDetected;
  80376. private _trackedAnchors;
  80377. private _referenceSpaceForFrameAnchors;
  80378. private _futureAnchors;
  80379. /**
  80380. * The module's name
  80381. */
  80382. static readonly Name: string;
  80383. /**
  80384. * The (Babylon) version of this module.
  80385. * This is an integer representing the implementation version.
  80386. * This number does not correspond to the WebXR specs version
  80387. */
  80388. static readonly Version: number;
  80389. /**
  80390. * Observers registered here will be executed when a new anchor was added to the session
  80391. */
  80392. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  80393. /**
  80394. * Observers registered here will be executed when an anchor was removed from the session
  80395. */
  80396. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  80397. /**
  80398. * Observers registered here will be executed when an existing anchor updates
  80399. * This can execute N times every frame
  80400. */
  80401. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  80402. /**
  80403. * Set the reference space to use for anchor creation, when not using a hit test.
  80404. * Will default to the session's reference space if not defined
  80405. */
  80406. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  80407. /**
  80408. * constructs a new anchor system
  80409. * @param _xrSessionManager an instance of WebXRSessionManager
  80410. * @param _options configuration object for this feature
  80411. */
  80412. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  80413. private _tmpVector;
  80414. private _tmpQuaternion;
  80415. private _populateTmpTransformation;
  80416. /**
  80417. * Create a new anchor point using a hit test result at a specific point in the scene
  80418. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80419. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80420. *
  80421. * @param hitTestResult The hit test result to use for this anchor creation
  80422. * @param position an optional position offset for this anchor
  80423. * @param rotationQuaternion an optional rotation offset for this anchor
  80424. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  80425. */
  80426. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  80427. /**
  80428. * Add a new anchor at a specific position and rotation
  80429. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  80430. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  80431. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80432. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80433. *
  80434. * @param position the position in which to add an anchor
  80435. * @param rotationQuaternion an optional rotation for the anchor transformation
  80436. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  80437. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  80438. */
  80439. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  80440. /**
  80441. * Get the list of anchors currently being tracked by the system
  80442. */
  80443. get anchors(): IWebXRAnchor[];
  80444. /**
  80445. * detach this feature.
  80446. * Will usually be called by the features manager
  80447. *
  80448. * @returns true if successful.
  80449. */
  80450. detach(): boolean;
  80451. /**
  80452. * Dispose this feature and all of the resources attached
  80453. */
  80454. dispose(): void;
  80455. protected _onXRFrame(frame: XRFrame): void;
  80456. /**
  80457. * avoiding using Array.find for global support.
  80458. * @param xrAnchor the plane to find in the array
  80459. */
  80460. private _findIndexInAnchorArray;
  80461. private _updateAnchorWithXRFrame;
  80462. private _createAnchorAtTransformation;
  80463. }
  80464. }
  80465. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  80466. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80467. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80468. import { Observable } from "babylonjs/Misc/observable";
  80469. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  80470. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80471. /**
  80472. * Options used in the plane detector module
  80473. */
  80474. export interface IWebXRPlaneDetectorOptions {
  80475. /**
  80476. * The node to use to transform the local results to world coordinates
  80477. */
  80478. worldParentNode?: TransformNode;
  80479. /**
  80480. * If set to true a reference of the created planes will be kept until the next session starts
  80481. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  80482. */
  80483. doNotRemovePlanesOnSessionEnded?: boolean;
  80484. }
  80485. /**
  80486. * A babylon interface for a WebXR plane.
  80487. * A Plane is actually a polygon, built from N points in space
  80488. *
  80489. * Supported in chrome 79, not supported in canary 81 ATM
  80490. */
  80491. export interface IWebXRPlane {
  80492. /**
  80493. * a babylon-assigned ID for this polygon
  80494. */
  80495. id: number;
  80496. /**
  80497. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  80498. */
  80499. polygonDefinition: Array<Vector3>;
  80500. /**
  80501. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  80502. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  80503. */
  80504. transformationMatrix: Matrix;
  80505. /**
  80506. * the native xr-plane object
  80507. */
  80508. xrPlane: XRPlane;
  80509. }
  80510. /**
  80511. * The plane detector is used to detect planes in the real world when in AR
  80512. * For more information see https://github.com/immersive-web/real-world-geometry/
  80513. */
  80514. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  80515. private _options;
  80516. private _detectedPlanes;
  80517. private _enabled;
  80518. private _lastFrameDetected;
  80519. /**
  80520. * The module's name
  80521. */
  80522. static readonly Name: string;
  80523. /**
  80524. * The (Babylon) version of this module.
  80525. * This is an integer representing the implementation version.
  80526. * This number does not correspond to the WebXR specs version
  80527. */
  80528. static readonly Version: number;
  80529. /**
  80530. * Observers registered here will be executed when a new plane was added to the session
  80531. */
  80532. onPlaneAddedObservable: Observable<IWebXRPlane>;
  80533. /**
  80534. * Observers registered here will be executed when a plane is no longer detected in the session
  80535. */
  80536. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  80537. /**
  80538. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  80539. * This can execute N times every frame
  80540. */
  80541. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  80542. /**
  80543. * construct a new Plane Detector
  80544. * @param _xrSessionManager an instance of xr Session manager
  80545. * @param _options configuration to use when constructing this feature
  80546. */
  80547. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  80548. /**
  80549. * detach this feature.
  80550. * Will usually be called by the features manager
  80551. *
  80552. * @returns true if successful.
  80553. */
  80554. detach(): boolean;
  80555. /**
  80556. * Dispose this feature and all of the resources attached
  80557. */
  80558. dispose(): void;
  80559. /**
  80560. * Check if the needed objects are defined.
  80561. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80562. */
  80563. isCompatible(): boolean;
  80564. protected _onXRFrame(frame: XRFrame): void;
  80565. private _init;
  80566. private _updatePlaneWithXRPlane;
  80567. /**
  80568. * avoiding using Array.find for global support.
  80569. * @param xrPlane the plane to find in the array
  80570. */
  80571. private findIndexInPlaneArray;
  80572. }
  80573. }
  80574. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  80575. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80576. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80577. import { Observable } from "babylonjs/Misc/observable";
  80578. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80579. /**
  80580. * Options interface for the background remover plugin
  80581. */
  80582. export interface IWebXRBackgroundRemoverOptions {
  80583. /**
  80584. * Further background meshes to disable when entering AR
  80585. */
  80586. backgroundMeshes?: AbstractMesh[];
  80587. /**
  80588. * flags to configure the removal of the environment helper.
  80589. * If not set, the entire background will be removed. If set, flags should be set as well.
  80590. */
  80591. environmentHelperRemovalFlags?: {
  80592. /**
  80593. * Should the skybox be removed (default false)
  80594. */
  80595. skyBox?: boolean;
  80596. /**
  80597. * Should the ground be removed (default false)
  80598. */
  80599. ground?: boolean;
  80600. };
  80601. /**
  80602. * don't disable the environment helper
  80603. */
  80604. ignoreEnvironmentHelper?: boolean;
  80605. }
  80606. /**
  80607. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  80608. */
  80609. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  80610. /**
  80611. * read-only options to be used in this module
  80612. */
  80613. readonly options: IWebXRBackgroundRemoverOptions;
  80614. /**
  80615. * The module's name
  80616. */
  80617. static readonly Name: string;
  80618. /**
  80619. * The (Babylon) version of this module.
  80620. * This is an integer representing the implementation version.
  80621. * This number does not correspond to the WebXR specs version
  80622. */
  80623. static readonly Version: number;
  80624. /**
  80625. * registered observers will be triggered when the background state changes
  80626. */
  80627. onBackgroundStateChangedObservable: Observable<boolean>;
  80628. /**
  80629. * constructs a new background remover module
  80630. * @param _xrSessionManager the session manager for this module
  80631. * @param options read-only options to be used in this module
  80632. */
  80633. constructor(_xrSessionManager: WebXRSessionManager,
  80634. /**
  80635. * read-only options to be used in this module
  80636. */
  80637. options?: IWebXRBackgroundRemoverOptions);
  80638. /**
  80639. * attach this feature
  80640. * Will usually be called by the features manager
  80641. *
  80642. * @returns true if successful.
  80643. */
  80644. attach(): boolean;
  80645. /**
  80646. * detach this feature.
  80647. * Will usually be called by the features manager
  80648. *
  80649. * @returns true if successful.
  80650. */
  80651. detach(): boolean;
  80652. /**
  80653. * Dispose this feature and all of the resources attached
  80654. */
  80655. dispose(): void;
  80656. protected _onXRFrame(_xrFrame: XRFrame): void;
  80657. private _setBackgroundState;
  80658. }
  80659. }
  80660. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  80661. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80662. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80663. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  80664. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80665. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80666. import { Nullable } from "babylonjs/types";
  80667. /**
  80668. * Options for the controller physics feature
  80669. */
  80670. export class IWebXRControllerPhysicsOptions {
  80671. /**
  80672. * Should the headset get its own impostor
  80673. */
  80674. enableHeadsetImpostor?: boolean;
  80675. /**
  80676. * Optional parameters for the headset impostor
  80677. */
  80678. headsetImpostorParams?: {
  80679. /**
  80680. * The type of impostor to create. Default is sphere
  80681. */
  80682. impostorType: number;
  80683. /**
  80684. * the size of the impostor. Defaults to 10cm
  80685. */
  80686. impostorSize?: number | {
  80687. width: number;
  80688. height: number;
  80689. depth: number;
  80690. };
  80691. /**
  80692. * Friction definitions
  80693. */
  80694. friction?: number;
  80695. /**
  80696. * Restitution
  80697. */
  80698. restitution?: number;
  80699. };
  80700. /**
  80701. * The physics properties of the future impostors
  80702. */
  80703. physicsProperties?: {
  80704. /**
  80705. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  80706. * Note that this requires a physics engine that supports mesh impostors!
  80707. */
  80708. useControllerMesh?: boolean;
  80709. /**
  80710. * The type of impostor to create. Default is sphere
  80711. */
  80712. impostorType?: number;
  80713. /**
  80714. * the size of the impostor. Defaults to 10cm
  80715. */
  80716. impostorSize?: number | {
  80717. width: number;
  80718. height: number;
  80719. depth: number;
  80720. };
  80721. /**
  80722. * Friction definitions
  80723. */
  80724. friction?: number;
  80725. /**
  80726. * Restitution
  80727. */
  80728. restitution?: number;
  80729. };
  80730. /**
  80731. * the xr input to use with this pointer selection
  80732. */
  80733. xrInput: WebXRInput;
  80734. }
  80735. /**
  80736. * Add physics impostor to your webxr controllers,
  80737. * including naive calculation of their linear and angular velocity
  80738. */
  80739. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  80740. private readonly _options;
  80741. private _attachController;
  80742. private _controllers;
  80743. private _debugMode;
  80744. private _delta;
  80745. private _headsetImpostor?;
  80746. private _headsetMesh?;
  80747. private _lastTimestamp;
  80748. private _tmpQuaternion;
  80749. private _tmpVector;
  80750. /**
  80751. * The module's name
  80752. */
  80753. static readonly Name: string;
  80754. /**
  80755. * The (Babylon) version of this module.
  80756. * This is an integer representing the implementation version.
  80757. * This number does not correspond to the webxr specs version
  80758. */
  80759. static readonly Version: number;
  80760. /**
  80761. * Construct a new Controller Physics Feature
  80762. * @param _xrSessionManager the corresponding xr session manager
  80763. * @param _options options to create this feature with
  80764. */
  80765. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  80766. /**
  80767. * @hidden
  80768. * enable debugging - will show console outputs and the impostor mesh
  80769. */
  80770. _enablePhysicsDebug(): void;
  80771. /**
  80772. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  80773. * @param xrController the controller to add
  80774. */
  80775. addController(xrController: WebXRInputSource): void;
  80776. /**
  80777. * attach this feature
  80778. * Will usually be called by the features manager
  80779. *
  80780. * @returns true if successful.
  80781. */
  80782. attach(): boolean;
  80783. /**
  80784. * detach this feature.
  80785. * Will usually be called by the features manager
  80786. *
  80787. * @returns true if successful.
  80788. */
  80789. detach(): boolean;
  80790. /**
  80791. * Get the headset impostor, if enabled
  80792. * @returns the impostor
  80793. */
  80794. getHeadsetImpostor(): PhysicsImpostor | undefined;
  80795. /**
  80796. * Get the physics impostor of a specific controller.
  80797. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  80798. * @param controller the controller or the controller id of which to get the impostor
  80799. * @returns the impostor or null
  80800. */
  80801. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  80802. /**
  80803. * Update the physics properties provided in the constructor
  80804. * @param newProperties the new properties object
  80805. */
  80806. setPhysicsProperties(newProperties: {
  80807. impostorType?: number;
  80808. impostorSize?: number | {
  80809. width: number;
  80810. height: number;
  80811. depth: number;
  80812. };
  80813. friction?: number;
  80814. restitution?: number;
  80815. }): void;
  80816. protected _onXRFrame(_xrFrame: any): void;
  80817. private _detachController;
  80818. }
  80819. }
  80820. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  80821. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80822. import { Observable } from "babylonjs/Misc/observable";
  80823. import { Vector3 } from "babylonjs/Maths/math.vector";
  80824. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80825. /**
  80826. * A babylon interface for a "WebXR" feature point.
  80827. * Represents the position and confidence value of a given feature point.
  80828. */
  80829. export interface IWebXRFeaturePoint {
  80830. /**
  80831. * Represents the position of the feature point in world space.
  80832. */
  80833. position: Vector3;
  80834. /**
  80835. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  80836. */
  80837. confidenceValue: number;
  80838. }
  80839. /**
  80840. * The feature point system is used to detect feature points from real world geometry.
  80841. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80842. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80843. */
  80844. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80845. private _enabled;
  80846. private _featurePointCloud;
  80847. /**
  80848. * The module's name
  80849. */
  80850. static readonly Name: string;
  80851. /**
  80852. * The (Babylon) version of this module.
  80853. * This is an integer representing the implementation version.
  80854. * This number does not correspond to the WebXR specs version
  80855. */
  80856. static readonly Version: number;
  80857. /**
  80858. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  80859. * Will notify the observers about which feature points have been added.
  80860. */
  80861. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  80862. /**
  80863. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  80864. * Will notify the observers about which feature points have been updated.
  80865. */
  80866. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  80867. /**
  80868. * The current feature point cloud maintained across frames.
  80869. */
  80870. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  80871. /**
  80872. * construct the feature point system
  80873. * @param _xrSessionManager an instance of xr Session manager
  80874. */
  80875. constructor(_xrSessionManager: WebXRSessionManager);
  80876. /**
  80877. * Detach this feature.
  80878. * Will usually be called by the features manager
  80879. *
  80880. * @returns true if successful.
  80881. */
  80882. detach(): boolean;
  80883. /**
  80884. * Dispose this feature and all of the resources attached
  80885. */
  80886. dispose(): void;
  80887. /**
  80888. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80889. */
  80890. protected _onXRFrame(frame: XRFrame): void;
  80891. /**
  80892. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80893. */
  80894. private _init;
  80895. }
  80896. }
  80897. declare module "babylonjs/XR/features/WebXRHandTracking" {
  80898. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80899. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80900. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80901. import { Mesh } from "babylonjs/Meshes/mesh";
  80902. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80903. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80904. import { Nullable } from "babylonjs/types";
  80905. import { IDisposable } from "babylonjs/scene";
  80906. import { Observable } from "babylonjs/Misc/observable";
  80907. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  80908. /**
  80909. * Configuration interface for the hand tracking feature
  80910. */
  80911. export interface IWebXRHandTrackingOptions {
  80912. /**
  80913. * The xrInput that will be used as source for new hands
  80914. */
  80915. xrInput: WebXRInput;
  80916. /**
  80917. * Configuration object for the joint meshes
  80918. */
  80919. jointMeshes?: {
  80920. /**
  80921. * Should the meshes created be invisible (defaults to false)
  80922. */
  80923. invisible?: boolean;
  80924. /**
  80925. * A source mesh to be used to create instances. Defaults to a sphere.
  80926. * This mesh will be the source for all other (25) meshes.
  80927. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80928. */
  80929. sourceMesh?: Mesh;
  80930. /**
  80931. * This function will be called after a mesh was created for a specific joint.
  80932. * Using this function you can either manipulate the instance or return a new mesh.
  80933. * When returning a new mesh the instance created before will be disposed
  80934. */
  80935. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80936. /**
  80937. * Should the source mesh stay visible. Defaults to false
  80938. */
  80939. keepOriginalVisible?: boolean;
  80940. /**
  80941. * Scale factor for all instances (defaults to 2)
  80942. */
  80943. scaleFactor?: number;
  80944. /**
  80945. * Should each instance have its own physics impostor
  80946. */
  80947. enablePhysics?: boolean;
  80948. /**
  80949. * If enabled, override default physics properties
  80950. */
  80951. physicsProps?: {
  80952. friction?: number;
  80953. restitution?: number;
  80954. impostorType?: number;
  80955. };
  80956. /**
  80957. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  80958. */
  80959. handMesh?: AbstractMesh;
  80960. };
  80961. }
  80962. /**
  80963. * Parts of the hands divided to writs and finger names
  80964. */
  80965. export const enum HandPart {
  80966. /**
  80967. * HandPart - Wrist
  80968. */
  80969. WRIST = "wrist",
  80970. /**
  80971. * HandPart - The THumb
  80972. */
  80973. THUMB = "thumb",
  80974. /**
  80975. * HandPart - Index finger
  80976. */
  80977. INDEX = "index",
  80978. /**
  80979. * HandPart - Middle finger
  80980. */
  80981. MIDDLE = "middle",
  80982. /**
  80983. * HandPart - Ring finger
  80984. */
  80985. RING = "ring",
  80986. /**
  80987. * HandPart - Little finger
  80988. */
  80989. LITTLE = "little"
  80990. }
  80991. /**
  80992. * Representing a single hand (with its corresponding native XRHand object)
  80993. */
  80994. export class WebXRHand implements IDisposable {
  80995. /** the controller to which the hand correlates */
  80996. readonly xrController: WebXRInputSource;
  80997. /** the meshes to be used to track the hand joints */
  80998. readonly trackedMeshes: AbstractMesh[];
  80999. /**
  81000. * Hand-parts definition (key is HandPart)
  81001. */
  81002. handPartsDefinition: {
  81003. [key: string]: number[];
  81004. };
  81005. /**
  81006. * Populate the HandPartsDefinition object.
  81007. * This is called as a side effect since certain browsers don't have XRHand defined.
  81008. */
  81009. private generateHandPartsDefinition;
  81010. /**
  81011. * Construct a new hand object
  81012. * @param xrController the controller to which the hand correlates
  81013. * @param trackedMeshes the meshes to be used to track the hand joints
  81014. */
  81015. constructor(
  81016. /** the controller to which the hand correlates */
  81017. xrController: WebXRInputSource,
  81018. /** the meshes to be used to track the hand joints */
  81019. trackedMeshes: AbstractMesh[]);
  81020. /**
  81021. * Update this hand from the latest xr frame
  81022. * @param xrFrame xrFrame to update from
  81023. * @param referenceSpace The current viewer reference space
  81024. * @param scaleFactor optional scale factor for the meshes
  81025. */
  81026. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  81027. /**
  81028. * Get meshes of part of the hand
  81029. * @param part the part of hand to get
  81030. * @returns An array of meshes that correlate to the hand part requested
  81031. */
  81032. getHandPartMeshes(part: HandPart): AbstractMesh[];
  81033. /**
  81034. * Dispose this Hand object
  81035. */
  81036. dispose(): void;
  81037. }
  81038. /**
  81039. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  81040. */
  81041. export class WebXRHandTracking extends WebXRAbstractFeature {
  81042. /**
  81043. * options to use when constructing this feature
  81044. */
  81045. readonly options: IWebXRHandTrackingOptions;
  81046. private static _idCounter;
  81047. /**
  81048. * The module's name
  81049. */
  81050. static readonly Name: string;
  81051. /**
  81052. * The (Babylon) version of this module.
  81053. * This is an integer representing the implementation version.
  81054. * This number does not correspond to the WebXR specs version
  81055. */
  81056. static readonly Version: number;
  81057. /**
  81058. * This observable will notify registered observers when a new hand object was added and initialized
  81059. */
  81060. onHandAddedObservable: Observable<WebXRHand>;
  81061. /**
  81062. * This observable will notify its observers right before the hand object is disposed
  81063. */
  81064. onHandRemovedObservable: Observable<WebXRHand>;
  81065. private _hands;
  81066. /**
  81067. * Creates a new instance of the hit test feature
  81068. * @param _xrSessionManager an instance of WebXRSessionManager
  81069. * @param options options to use when constructing this feature
  81070. */
  81071. constructor(_xrSessionManager: WebXRSessionManager,
  81072. /**
  81073. * options to use when constructing this feature
  81074. */
  81075. options: IWebXRHandTrackingOptions);
  81076. /**
  81077. * Check if the needed objects are defined.
  81078. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  81079. */
  81080. isCompatible(): boolean;
  81081. /**
  81082. * attach this feature
  81083. * Will usually be called by the features manager
  81084. *
  81085. * @returns true if successful.
  81086. */
  81087. attach(): boolean;
  81088. /**
  81089. * detach this feature.
  81090. * Will usually be called by the features manager
  81091. *
  81092. * @returns true if successful.
  81093. */
  81094. detach(): boolean;
  81095. /**
  81096. * Dispose this feature and all of the resources attached
  81097. */
  81098. dispose(): void;
  81099. /**
  81100. * Get the hand object according to the controller id
  81101. * @param controllerId the controller id to which we want to get the hand
  81102. * @returns null if not found or the WebXRHand object if found
  81103. */
  81104. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  81105. /**
  81106. * Get a hand object according to the requested handedness
  81107. * @param handedness the handedness to request
  81108. * @returns null if not found or the WebXRHand object if found
  81109. */
  81110. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  81111. protected _onXRFrame(_xrFrame: XRFrame): void;
  81112. private _attachHand;
  81113. private _detachHand;
  81114. }
  81115. }
  81116. declare module "babylonjs/XR/features/index" {
  81117. export * from "babylonjs/XR/features/WebXRAbstractFeature";
  81118. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  81119. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  81120. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  81121. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  81122. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  81123. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  81124. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  81125. export * from "babylonjs/XR/features/WebXRHitTest";
  81126. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  81127. export * from "babylonjs/XR/features/WebXRHandTracking";
  81128. }
  81129. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  81130. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81132. import { Scene } from "babylonjs/scene";
  81133. /**
  81134. * The motion controller class for all microsoft mixed reality controllers
  81135. */
  81136. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  81137. protected readonly _mapping: {
  81138. defaultButton: {
  81139. valueNodeName: string;
  81140. unpressedNodeName: string;
  81141. pressedNodeName: string;
  81142. };
  81143. defaultAxis: {
  81144. valueNodeName: string;
  81145. minNodeName: string;
  81146. maxNodeName: string;
  81147. };
  81148. buttons: {
  81149. "xr-standard-trigger": {
  81150. rootNodeName: string;
  81151. componentProperty: string;
  81152. states: string[];
  81153. };
  81154. "xr-standard-squeeze": {
  81155. rootNodeName: string;
  81156. componentProperty: string;
  81157. states: string[];
  81158. };
  81159. "xr-standard-touchpad": {
  81160. rootNodeName: string;
  81161. labelAnchorNodeName: string;
  81162. touchPointNodeName: string;
  81163. };
  81164. "xr-standard-thumbstick": {
  81165. rootNodeName: string;
  81166. componentProperty: string;
  81167. states: string[];
  81168. };
  81169. };
  81170. axes: {
  81171. "xr-standard-touchpad": {
  81172. "x-axis": {
  81173. rootNodeName: string;
  81174. };
  81175. "y-axis": {
  81176. rootNodeName: string;
  81177. };
  81178. };
  81179. "xr-standard-thumbstick": {
  81180. "x-axis": {
  81181. rootNodeName: string;
  81182. };
  81183. "y-axis": {
  81184. rootNodeName: string;
  81185. };
  81186. };
  81187. };
  81188. };
  81189. /**
  81190. * The base url used to load the left and right controller models
  81191. */
  81192. static MODEL_BASE_URL: string;
  81193. /**
  81194. * The name of the left controller model file
  81195. */
  81196. static MODEL_LEFT_FILENAME: string;
  81197. /**
  81198. * The name of the right controller model file
  81199. */
  81200. static MODEL_RIGHT_FILENAME: string;
  81201. profileId: string;
  81202. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  81203. protected _getFilenameAndPath(): {
  81204. filename: string;
  81205. path: string;
  81206. };
  81207. protected _getModelLoadingConstraints(): boolean;
  81208. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81209. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81210. protected _updateModel(): void;
  81211. }
  81212. }
  81213. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  81214. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81216. import { Scene } from "babylonjs/scene";
  81217. /**
  81218. * The motion controller class for oculus touch (quest, rift).
  81219. * This class supports legacy mapping as well the standard xr mapping
  81220. */
  81221. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  81222. private _forceLegacyControllers;
  81223. private _modelRootNode;
  81224. /**
  81225. * The base url used to load the left and right controller models
  81226. */
  81227. static MODEL_BASE_URL: string;
  81228. /**
  81229. * The name of the left controller model file
  81230. */
  81231. static MODEL_LEFT_FILENAME: string;
  81232. /**
  81233. * The name of the right controller model file
  81234. */
  81235. static MODEL_RIGHT_FILENAME: string;
  81236. /**
  81237. * Base Url for the Quest controller model.
  81238. */
  81239. static QUEST_MODEL_BASE_URL: string;
  81240. profileId: string;
  81241. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  81242. protected _getFilenameAndPath(): {
  81243. filename: string;
  81244. path: string;
  81245. };
  81246. protected _getModelLoadingConstraints(): boolean;
  81247. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81248. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81249. protected _updateModel(): void;
  81250. /**
  81251. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  81252. * between the touch and touch 2.
  81253. */
  81254. private _isQuest;
  81255. }
  81256. }
  81257. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  81258. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81259. import { Scene } from "babylonjs/scene";
  81260. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81261. /**
  81262. * The motion controller class for the standard HTC-Vive controllers
  81263. */
  81264. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  81265. private _modelRootNode;
  81266. /**
  81267. * The base url used to load the left and right controller models
  81268. */
  81269. static MODEL_BASE_URL: string;
  81270. /**
  81271. * File name for the controller model.
  81272. */
  81273. static MODEL_FILENAME: string;
  81274. profileId: string;
  81275. /**
  81276. * Create a new Vive motion controller object
  81277. * @param scene the scene to use to create this controller
  81278. * @param gamepadObject the corresponding gamepad object
  81279. * @param handedness the handedness of the controller
  81280. */
  81281. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  81282. protected _getFilenameAndPath(): {
  81283. filename: string;
  81284. path: string;
  81285. };
  81286. protected _getModelLoadingConstraints(): boolean;
  81287. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81288. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81289. protected _updateModel(): void;
  81290. }
  81291. }
  81292. declare module "babylonjs/XR/motionController/index" {
  81293. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81294. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  81295. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  81296. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  81297. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  81298. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  81299. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  81300. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  81301. }
  81302. declare module "babylonjs/XR/index" {
  81303. export * from "babylonjs/XR/webXRCamera";
  81304. export * from "babylonjs/XR/webXREnterExitUI";
  81305. export * from "babylonjs/XR/webXRExperienceHelper";
  81306. export * from "babylonjs/XR/webXRInput";
  81307. export * from "babylonjs/XR/webXRInputSource";
  81308. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  81309. export * from "babylonjs/XR/webXRTypes";
  81310. export * from "babylonjs/XR/webXRSessionManager";
  81311. export * from "babylonjs/XR/webXRDefaultExperience";
  81312. export * from "babylonjs/XR/webXRFeaturesManager";
  81313. export * from "babylonjs/XR/features/index";
  81314. export * from "babylonjs/XR/motionController/index";
  81315. }
  81316. declare module "babylonjs/index" {
  81317. export * from "babylonjs/abstractScene";
  81318. export * from "babylonjs/Actions/index";
  81319. export * from "babylonjs/Animations/index";
  81320. export * from "babylonjs/assetContainer";
  81321. export * from "babylonjs/Audio/index";
  81322. export * from "babylonjs/Behaviors/index";
  81323. export * from "babylonjs/Bones/index";
  81324. export * from "babylonjs/Cameras/index";
  81325. export * from "babylonjs/Collisions/index";
  81326. export * from "babylonjs/Culling/index";
  81327. export * from "babylonjs/Debug/index";
  81328. export * from "babylonjs/DeviceInput/index";
  81329. export * from "babylonjs/Engines/index";
  81330. export * from "babylonjs/Events/index";
  81331. export * from "babylonjs/Gamepads/index";
  81332. export * from "babylonjs/Gizmos/index";
  81333. export * from "babylonjs/Helpers/index";
  81334. export * from "babylonjs/Instrumentation/index";
  81335. export * from "babylonjs/Layers/index";
  81336. export * from "babylonjs/LensFlares/index";
  81337. export * from "babylonjs/Lights/index";
  81338. export * from "babylonjs/Loading/index";
  81339. export * from "babylonjs/Materials/index";
  81340. export * from "babylonjs/Maths/index";
  81341. export * from "babylonjs/Meshes/index";
  81342. export * from "babylonjs/Morph/index";
  81343. export * from "babylonjs/Navigation/index";
  81344. export * from "babylonjs/node";
  81345. export * from "babylonjs/Offline/index";
  81346. export * from "babylonjs/Particles/index";
  81347. export * from "babylonjs/Physics/index";
  81348. export * from "babylonjs/PostProcesses/index";
  81349. export * from "babylonjs/Probes/index";
  81350. export * from "babylonjs/Rendering/index";
  81351. export * from "babylonjs/scene";
  81352. export * from "babylonjs/sceneComponent";
  81353. export * from "babylonjs/Sprites/index";
  81354. export * from "babylonjs/States/index";
  81355. export * from "babylonjs/Misc/index";
  81356. export * from "babylonjs/XR/index";
  81357. export * from "babylonjs/types";
  81358. }
  81359. declare module "babylonjs/Animations/pathCursor" {
  81360. import { Vector3 } from "babylonjs/Maths/math.vector";
  81361. import { Path2 } from "babylonjs/Maths/math.path";
  81362. /**
  81363. * A cursor which tracks a point on a path
  81364. */
  81365. export class PathCursor {
  81366. private path;
  81367. /**
  81368. * Stores path cursor callbacks for when an onchange event is triggered
  81369. */
  81370. private _onchange;
  81371. /**
  81372. * The value of the path cursor
  81373. */
  81374. value: number;
  81375. /**
  81376. * The animation array of the path cursor
  81377. */
  81378. animations: Animation[];
  81379. /**
  81380. * Initializes the path cursor
  81381. * @param path The path to track
  81382. */
  81383. constructor(path: Path2);
  81384. /**
  81385. * Gets the cursor point on the path
  81386. * @returns A point on the path cursor at the cursor location
  81387. */
  81388. getPoint(): Vector3;
  81389. /**
  81390. * Moves the cursor ahead by the step amount
  81391. * @param step The amount to move the cursor forward
  81392. * @returns This path cursor
  81393. */
  81394. moveAhead(step?: number): PathCursor;
  81395. /**
  81396. * Moves the cursor behind by the step amount
  81397. * @param step The amount to move the cursor back
  81398. * @returns This path cursor
  81399. */
  81400. moveBack(step?: number): PathCursor;
  81401. /**
  81402. * Moves the cursor by the step amount
  81403. * If the step amount is greater than one, an exception is thrown
  81404. * @param step The amount to move the cursor
  81405. * @returns This path cursor
  81406. */
  81407. move(step: number): PathCursor;
  81408. /**
  81409. * Ensures that the value is limited between zero and one
  81410. * @returns This path cursor
  81411. */
  81412. private ensureLimits;
  81413. /**
  81414. * Runs onchange callbacks on change (used by the animation engine)
  81415. * @returns This path cursor
  81416. */
  81417. private raiseOnChange;
  81418. /**
  81419. * Executes a function on change
  81420. * @param f A path cursor onchange callback
  81421. * @returns This path cursor
  81422. */
  81423. onchange(f: (cursor: PathCursor) => void): PathCursor;
  81424. }
  81425. }
  81426. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  81427. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  81428. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  81429. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  81430. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  81431. }
  81432. declare module "babylonjs/Engines/Processors/Expressions/index" {
  81433. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  81434. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  81435. }
  81436. declare module "babylonjs/Engines/Processors/index" {
  81437. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  81438. export * from "babylonjs/Engines/Processors/Expressions/index";
  81439. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  81440. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  81441. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  81442. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  81443. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  81444. export * from "babylonjs/Engines/Processors/shaderProcessor";
  81445. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  81446. }
  81447. declare module "babylonjs/Legacy/legacy" {
  81448. import * as Babylon from "babylonjs/index";
  81449. export * from "babylonjs/index";
  81450. }
  81451. declare module "babylonjs/Shaders/blur.fragment" {
  81452. /** @hidden */
  81453. export var blurPixelShader: {
  81454. name: string;
  81455. shader: string;
  81456. };
  81457. }
  81458. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  81459. /** @hidden */
  81460. export var pointCloudVertexDeclaration: {
  81461. name: string;
  81462. shader: string;
  81463. };
  81464. }
  81465. declare module "babylonjs" {
  81466. export * from "babylonjs/Legacy/legacy";
  81467. }
  81468. declare module BABYLON {
  81469. /** Alias type for value that can be null */
  81470. export type Nullable<T> = T | null;
  81471. /**
  81472. * Alias type for number that are floats
  81473. * @ignorenaming
  81474. */
  81475. export type float = number;
  81476. /**
  81477. * Alias type for number that are doubles.
  81478. * @ignorenaming
  81479. */
  81480. export type double = number;
  81481. /**
  81482. * Alias type for number that are integer
  81483. * @ignorenaming
  81484. */
  81485. export type int = number;
  81486. /** Alias type for number array or Float32Array */
  81487. export type FloatArray = number[] | Float32Array;
  81488. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  81489. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  81490. /**
  81491. * Alias for types that can be used by a Buffer or VertexBuffer.
  81492. */
  81493. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  81494. /**
  81495. * Alias type for primitive types
  81496. * @ignorenaming
  81497. */
  81498. type Primitive = undefined | null | boolean | string | number | Function;
  81499. /**
  81500. * Type modifier to make all the properties of an object Readonly
  81501. */
  81502. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  81503. /**
  81504. * Type modifier to make all the properties of an object Readonly recursively
  81505. */
  81506. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  81507. /**
  81508. * Type modifier to make object properties readonly.
  81509. */
  81510. export type DeepImmutableObject<T> = {
  81511. readonly [K in keyof T]: DeepImmutable<T[K]>;
  81512. };
  81513. /** @hidden */
  81514. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  81515. }
  81516. }
  81517. declare module BABYLON {
  81518. /**
  81519. * A class serves as a medium between the observable and its observers
  81520. */
  81521. export class EventState {
  81522. /**
  81523. * Create a new EventState
  81524. * @param mask defines the mask associated with this state
  81525. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  81526. * @param target defines the original target of the state
  81527. * @param currentTarget defines the current target of the state
  81528. */
  81529. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  81530. /**
  81531. * Initialize the current event state
  81532. * @param mask defines the mask associated with this state
  81533. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  81534. * @param target defines the original target of the state
  81535. * @param currentTarget defines the current target of the state
  81536. * @returns the current event state
  81537. */
  81538. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  81539. /**
  81540. * An Observer can set this property to true to prevent subsequent observers of being notified
  81541. */
  81542. skipNextObservers: boolean;
  81543. /**
  81544. * Get the mask value that were used to trigger the event corresponding to this EventState object
  81545. */
  81546. mask: number;
  81547. /**
  81548. * The object that originally notified the event
  81549. */
  81550. target?: any;
  81551. /**
  81552. * The current object in the bubbling phase
  81553. */
  81554. currentTarget?: any;
  81555. /**
  81556. * This will be populated with the return value of the last function that was executed.
  81557. * If it is the first function in the callback chain it will be the event data.
  81558. */
  81559. lastReturnValue?: any;
  81560. /**
  81561. * User defined information that will be sent to observers
  81562. */
  81563. userInfo?: any;
  81564. }
  81565. /**
  81566. * Represent an Observer registered to a given Observable object.
  81567. */
  81568. export class Observer<T> {
  81569. /**
  81570. * Defines the callback to call when the observer is notified
  81571. */
  81572. callback: (eventData: T, eventState: EventState) => void;
  81573. /**
  81574. * Defines the mask of the observer (used to filter notifications)
  81575. */
  81576. mask: number;
  81577. /**
  81578. * Defines the current scope used to restore the JS context
  81579. */
  81580. scope: any;
  81581. /** @hidden */
  81582. _willBeUnregistered: boolean;
  81583. /**
  81584. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  81585. */
  81586. unregisterOnNextCall: boolean;
  81587. /**
  81588. * Creates a new observer
  81589. * @param callback defines the callback to call when the observer is notified
  81590. * @param mask defines the mask of the observer (used to filter notifications)
  81591. * @param scope defines the current scope used to restore the JS context
  81592. */
  81593. constructor(
  81594. /**
  81595. * Defines the callback to call when the observer is notified
  81596. */
  81597. callback: (eventData: T, eventState: EventState) => void,
  81598. /**
  81599. * Defines the mask of the observer (used to filter notifications)
  81600. */
  81601. mask: number,
  81602. /**
  81603. * Defines the current scope used to restore the JS context
  81604. */
  81605. scope?: any);
  81606. }
  81607. /**
  81608. * Represent a list of observers registered to multiple Observables object.
  81609. */
  81610. export class MultiObserver<T> {
  81611. private _observers;
  81612. private _observables;
  81613. /**
  81614. * Release associated resources
  81615. */
  81616. dispose(): void;
  81617. /**
  81618. * Raise a callback when one of the observable will notify
  81619. * @param observables defines a list of observables to watch
  81620. * @param callback defines the callback to call on notification
  81621. * @param mask defines the mask used to filter notifications
  81622. * @param scope defines the current scope used to restore the JS context
  81623. * @returns the new MultiObserver
  81624. */
  81625. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  81626. }
  81627. /**
  81628. * The Observable class is a simple implementation of the Observable pattern.
  81629. *
  81630. * 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.
  81631. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  81632. * 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).
  81633. * 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.
  81634. */
  81635. export class Observable<T> {
  81636. private _observers;
  81637. private _eventState;
  81638. private _onObserverAdded;
  81639. /**
  81640. * Gets the list of observers
  81641. */
  81642. get observers(): Array<Observer<T>>;
  81643. /**
  81644. * Creates a new observable
  81645. * @param onObserverAdded defines a callback to call when a new observer is added
  81646. */
  81647. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  81648. /**
  81649. * Create a new Observer with the specified callback
  81650. * @param callback the callback that will be executed for that Observer
  81651. * @param mask the mask used to filter observers
  81652. * @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.
  81653. * @param scope optional scope for the callback to be called from
  81654. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  81655. * @returns the new observer created for the callback
  81656. */
  81657. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  81658. /**
  81659. * Create a new Observer with the specified callback and unregisters after the next notification
  81660. * @param callback the callback that will be executed for that Observer
  81661. * @returns the new observer created for the callback
  81662. */
  81663. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  81664. /**
  81665. * Remove an Observer from the Observable object
  81666. * @param observer the instance of the Observer to remove
  81667. * @returns false if it doesn't belong to this Observable
  81668. */
  81669. remove(observer: Nullable<Observer<T>>): boolean;
  81670. /**
  81671. * Remove a callback from the Observable object
  81672. * @param callback the callback to remove
  81673. * @param scope optional scope. If used only the callbacks with this scope will be removed
  81674. * @returns false if it doesn't belong to this Observable
  81675. */
  81676. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  81677. private _deferUnregister;
  81678. private _remove;
  81679. /**
  81680. * Moves the observable to the top of the observer list making it get called first when notified
  81681. * @param observer the observer to move
  81682. */
  81683. makeObserverTopPriority(observer: Observer<T>): void;
  81684. /**
  81685. * Moves the observable to the bottom of the observer list making it get called last when notified
  81686. * @param observer the observer to move
  81687. */
  81688. makeObserverBottomPriority(observer: Observer<T>): void;
  81689. /**
  81690. * Notify all Observers by calling their respective callback with the given data
  81691. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  81692. * @param eventData defines the data to send to all observers
  81693. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  81694. * @param target defines the original target of the state
  81695. * @param currentTarget defines the current target of the state
  81696. * @param userInfo defines any user info to send to observers
  81697. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  81698. */
  81699. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  81700. /**
  81701. * Calling this will execute each callback, expecting it to be a promise or return a value.
  81702. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  81703. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  81704. * and it is crucial that all callbacks will be executed.
  81705. * The order of the callbacks is kept, callbacks are not executed parallel.
  81706. *
  81707. * @param eventData The data to be sent to each callback
  81708. * @param mask is used to filter observers defaults to -1
  81709. * @param target defines the callback target (see EventState)
  81710. * @param currentTarget defines he current object in the bubbling phase
  81711. * @param userInfo defines any user info to send to observers
  81712. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  81713. */
  81714. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  81715. /**
  81716. * Notify a specific observer
  81717. * @param observer defines the observer to notify
  81718. * @param eventData defines the data to be sent to each callback
  81719. * @param mask is used to filter observers defaults to -1
  81720. */
  81721. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  81722. /**
  81723. * Gets a boolean indicating if the observable has at least one observer
  81724. * @returns true is the Observable has at least one Observer registered
  81725. */
  81726. hasObservers(): boolean;
  81727. /**
  81728. * Clear the list of observers
  81729. */
  81730. clear(): void;
  81731. /**
  81732. * Clone the current observable
  81733. * @returns a new observable
  81734. */
  81735. clone(): Observable<T>;
  81736. /**
  81737. * Does this observable handles observer registered with a given mask
  81738. * @param mask defines the mask to be tested
  81739. * @return whether or not one observer registered with the given mask is handeled
  81740. **/
  81741. hasSpecificMask(mask?: number): boolean;
  81742. }
  81743. }
  81744. declare module BABYLON {
  81745. /**
  81746. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  81747. * Babylon.js
  81748. */
  81749. export class DomManagement {
  81750. /**
  81751. * Checks if the window object exists
  81752. * @returns true if the window object exists
  81753. */
  81754. static IsWindowObjectExist(): boolean;
  81755. /**
  81756. * Checks if the navigator object exists
  81757. * @returns true if the navigator object exists
  81758. */
  81759. static IsNavigatorAvailable(): boolean;
  81760. /**
  81761. * Check if the document object exists
  81762. * @returns true if the document object exists
  81763. */
  81764. static IsDocumentAvailable(): boolean;
  81765. /**
  81766. * Extracts text content from a DOM element hierarchy
  81767. * @param element defines the root element
  81768. * @returns a string
  81769. */
  81770. static GetDOMTextContent(element: HTMLElement): string;
  81771. }
  81772. }
  81773. declare module BABYLON {
  81774. /**
  81775. * Logger used througouht the application to allow configuration of
  81776. * the log level required for the messages.
  81777. */
  81778. export class Logger {
  81779. /**
  81780. * No log
  81781. */
  81782. static readonly NoneLogLevel: number;
  81783. /**
  81784. * Only message logs
  81785. */
  81786. static readonly MessageLogLevel: number;
  81787. /**
  81788. * Only warning logs
  81789. */
  81790. static readonly WarningLogLevel: number;
  81791. /**
  81792. * Only error logs
  81793. */
  81794. static readonly ErrorLogLevel: number;
  81795. /**
  81796. * All logs
  81797. */
  81798. static readonly AllLogLevel: number;
  81799. private static _LogCache;
  81800. /**
  81801. * Gets a value indicating the number of loading errors
  81802. * @ignorenaming
  81803. */
  81804. static errorsCount: number;
  81805. /**
  81806. * Callback called when a new log is added
  81807. */
  81808. static OnNewCacheEntry: (entry: string) => void;
  81809. private static _AddLogEntry;
  81810. private static _FormatMessage;
  81811. private static _LogDisabled;
  81812. private static _LogEnabled;
  81813. private static _WarnDisabled;
  81814. private static _WarnEnabled;
  81815. private static _ErrorDisabled;
  81816. private static _ErrorEnabled;
  81817. /**
  81818. * Log a message to the console
  81819. */
  81820. static Log: (message: string) => void;
  81821. /**
  81822. * Write a warning message to the console
  81823. */
  81824. static Warn: (message: string) => void;
  81825. /**
  81826. * Write an error message to the console
  81827. */
  81828. static Error: (message: string) => void;
  81829. /**
  81830. * Gets current log cache (list of logs)
  81831. */
  81832. static get LogCache(): string;
  81833. /**
  81834. * Clears the log cache
  81835. */
  81836. static ClearLogCache(): void;
  81837. /**
  81838. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  81839. */
  81840. static set LogLevels(level: number);
  81841. }
  81842. }
  81843. declare module BABYLON {
  81844. /** @hidden */
  81845. export class _TypeStore {
  81846. /** @hidden */
  81847. static RegisteredTypes: {
  81848. [key: string]: Object;
  81849. };
  81850. /** @hidden */
  81851. static GetClass(fqdn: string): any;
  81852. }
  81853. }
  81854. declare module BABYLON {
  81855. /**
  81856. * Helper to manipulate strings
  81857. */
  81858. export class StringTools {
  81859. /**
  81860. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  81861. * @param str Source string
  81862. * @param suffix Suffix to search for in the source string
  81863. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81864. */
  81865. static EndsWith(str: string, suffix: string): boolean;
  81866. /**
  81867. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  81868. * @param str Source string
  81869. * @param suffix Suffix to search for in the source string
  81870. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81871. */
  81872. static StartsWith(str: string, suffix: string): boolean;
  81873. /**
  81874. * Decodes a buffer into a string
  81875. * @param buffer The buffer to decode
  81876. * @returns The decoded string
  81877. */
  81878. static Decode(buffer: Uint8Array | Uint16Array): string;
  81879. /**
  81880. * Encode a buffer to a base64 string
  81881. * @param buffer defines the buffer to encode
  81882. * @returns the encoded string
  81883. */
  81884. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  81885. /**
  81886. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  81887. * @param num the number to convert and pad
  81888. * @param length the expected length of the string
  81889. * @returns the padded string
  81890. */
  81891. static PadNumber(num: number, length: number): string;
  81892. }
  81893. }
  81894. declare module BABYLON {
  81895. /**
  81896. * Class containing a set of static utilities functions for deep copy.
  81897. */
  81898. export class DeepCopier {
  81899. /**
  81900. * Tries to copy an object by duplicating every property
  81901. * @param source defines the source object
  81902. * @param destination defines the target object
  81903. * @param doNotCopyList defines a list of properties to avoid
  81904. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  81905. */
  81906. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  81907. }
  81908. }
  81909. declare module BABYLON {
  81910. /**
  81911. * Class containing a set of static utilities functions for precision date
  81912. */
  81913. export class PrecisionDate {
  81914. /**
  81915. * Gets either window.performance.now() if supported or Date.now() else
  81916. */
  81917. static get Now(): number;
  81918. }
  81919. }
  81920. declare module BABYLON {
  81921. /** @hidden */
  81922. export class _DevTools {
  81923. static WarnImport(name: string): string;
  81924. }
  81925. }
  81926. declare module BABYLON {
  81927. /**
  81928. * Interface used to define the mechanism to get data from the network
  81929. */
  81930. export interface IWebRequest {
  81931. /**
  81932. * Returns client's response url
  81933. */
  81934. responseURL: string;
  81935. /**
  81936. * Returns client's status
  81937. */
  81938. status: number;
  81939. /**
  81940. * Returns client's status as a text
  81941. */
  81942. statusText: string;
  81943. }
  81944. }
  81945. declare module BABYLON {
  81946. /**
  81947. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  81948. */
  81949. export class WebRequest implements IWebRequest {
  81950. private readonly _xhr;
  81951. /**
  81952. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  81953. * i.e. when loading files, where the server/service expects an Authorization header
  81954. */
  81955. static CustomRequestHeaders: {
  81956. [key: string]: string;
  81957. };
  81958. /**
  81959. * Add callback functions in this array to update all the requests before they get sent to the network
  81960. */
  81961. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  81962. private _injectCustomRequestHeaders;
  81963. /**
  81964. * Gets or sets a function to be called when loading progress changes
  81965. */
  81966. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  81967. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  81968. /**
  81969. * Returns client's state
  81970. */
  81971. get readyState(): number;
  81972. /**
  81973. * Returns client's status
  81974. */
  81975. get status(): number;
  81976. /**
  81977. * Returns client's status as a text
  81978. */
  81979. get statusText(): string;
  81980. /**
  81981. * Returns client's response
  81982. */
  81983. get response(): any;
  81984. /**
  81985. * Returns client's response url
  81986. */
  81987. get responseURL(): string;
  81988. /**
  81989. * Returns client's response as text
  81990. */
  81991. get responseText(): string;
  81992. /**
  81993. * Gets or sets the expected response type
  81994. */
  81995. get responseType(): XMLHttpRequestResponseType;
  81996. set responseType(value: XMLHttpRequestResponseType);
  81997. /** @hidden */
  81998. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  81999. /** @hidden */
  82000. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  82001. /**
  82002. * Cancels any network activity
  82003. */
  82004. abort(): void;
  82005. /**
  82006. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  82007. * @param body defines an optional request body
  82008. */
  82009. send(body?: Document | BodyInit | null): void;
  82010. /**
  82011. * Sets the request method, request URL
  82012. * @param method defines the method to use (GET, POST, etc..)
  82013. * @param url defines the url to connect with
  82014. */
  82015. open(method: string, url: string): void;
  82016. /**
  82017. * Sets the value of a request header.
  82018. * @param name The name of the header whose value is to be set
  82019. * @param value The value to set as the body of the header
  82020. */
  82021. setRequestHeader(name: string, value: string): void;
  82022. /**
  82023. * Get the string containing the text of a particular header's value.
  82024. * @param name The name of the header
  82025. * @returns The string containing the text of the given header name
  82026. */
  82027. getResponseHeader(name: string): Nullable<string>;
  82028. }
  82029. }
  82030. declare module BABYLON {
  82031. /**
  82032. * File request interface
  82033. */
  82034. export interface IFileRequest {
  82035. /**
  82036. * Raised when the request is complete (success or error).
  82037. */
  82038. onCompleteObservable: Observable<IFileRequest>;
  82039. /**
  82040. * Aborts the request for a file.
  82041. */
  82042. abort: () => void;
  82043. }
  82044. }
  82045. declare module BABYLON {
  82046. /**
  82047. * Define options used to create a render target texture
  82048. */
  82049. export class RenderTargetCreationOptions {
  82050. /**
  82051. * Specifies is mipmaps must be generated
  82052. */
  82053. generateMipMaps?: boolean;
  82054. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  82055. generateDepthBuffer?: boolean;
  82056. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  82057. generateStencilBuffer?: boolean;
  82058. /** Defines texture type (int by default) */
  82059. type?: number;
  82060. /** Defines sampling mode (trilinear by default) */
  82061. samplingMode?: number;
  82062. /** Defines format (RGBA by default) */
  82063. format?: number;
  82064. }
  82065. }
  82066. declare module BABYLON {
  82067. /** Defines the cross module used constants to avoid circular dependncies */
  82068. export class Constants {
  82069. /** Defines that alpha blending is disabled */
  82070. static readonly ALPHA_DISABLE: number;
  82071. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  82072. static readonly ALPHA_ADD: number;
  82073. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  82074. static readonly ALPHA_COMBINE: number;
  82075. /** Defines that alpha blending is DEST - SRC * DEST */
  82076. static readonly ALPHA_SUBTRACT: number;
  82077. /** Defines that alpha blending is SRC * DEST */
  82078. static readonly ALPHA_MULTIPLY: number;
  82079. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  82080. static readonly ALPHA_MAXIMIZED: number;
  82081. /** Defines that alpha blending is SRC + DEST */
  82082. static readonly ALPHA_ONEONE: number;
  82083. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  82084. static readonly ALPHA_PREMULTIPLIED: number;
  82085. /**
  82086. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  82087. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  82088. */
  82089. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  82090. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  82091. static readonly ALPHA_INTERPOLATE: number;
  82092. /**
  82093. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  82094. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  82095. */
  82096. static readonly ALPHA_SCREENMODE: number;
  82097. /**
  82098. * Defines that alpha blending is SRC + DST
  82099. * Alpha will be set to SRC ALPHA + DST ALPHA
  82100. */
  82101. static readonly ALPHA_ONEONE_ONEONE: number;
  82102. /**
  82103. * Defines that alpha blending is SRC * DST ALPHA + DST
  82104. * Alpha will be set to 0
  82105. */
  82106. static readonly ALPHA_ALPHATOCOLOR: number;
  82107. /**
  82108. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  82109. */
  82110. static readonly ALPHA_REVERSEONEMINUS: number;
  82111. /**
  82112. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  82113. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  82114. */
  82115. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  82116. /**
  82117. * Defines that alpha blending is SRC + DST
  82118. * Alpha will be set to SRC ALPHA
  82119. */
  82120. static readonly ALPHA_ONEONE_ONEZERO: number;
  82121. /**
  82122. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  82123. * Alpha will be set to DST ALPHA
  82124. */
  82125. static readonly ALPHA_EXCLUSION: number;
  82126. /** Defines that alpha blending equation a SUM */
  82127. static readonly ALPHA_EQUATION_ADD: number;
  82128. /** Defines that alpha blending equation a SUBSTRACTION */
  82129. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  82130. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  82131. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  82132. /** Defines that alpha blending equation a MAX operation */
  82133. static readonly ALPHA_EQUATION_MAX: number;
  82134. /** Defines that alpha blending equation a MIN operation */
  82135. static readonly ALPHA_EQUATION_MIN: number;
  82136. /**
  82137. * Defines that alpha blending equation a DARKEN operation:
  82138. * It takes the min of the src and sums the alpha channels.
  82139. */
  82140. static readonly ALPHA_EQUATION_DARKEN: number;
  82141. /** Defines that the ressource is not delayed*/
  82142. static readonly DELAYLOADSTATE_NONE: number;
  82143. /** Defines that the ressource was successfully delay loaded */
  82144. static readonly DELAYLOADSTATE_LOADED: number;
  82145. /** Defines that the ressource is currently delay loading */
  82146. static readonly DELAYLOADSTATE_LOADING: number;
  82147. /** Defines that the ressource is delayed and has not started loading */
  82148. static readonly DELAYLOADSTATE_NOTLOADED: number;
  82149. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  82150. static readonly NEVER: number;
  82151. /** 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 */
  82152. static readonly ALWAYS: number;
  82153. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  82154. static readonly LESS: number;
  82155. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  82156. static readonly EQUAL: number;
  82157. /** 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 */
  82158. static readonly LEQUAL: number;
  82159. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  82160. static readonly GREATER: number;
  82161. /** 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 */
  82162. static readonly GEQUAL: number;
  82163. /** 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 */
  82164. static readonly NOTEQUAL: number;
  82165. /** Passed to stencilOperation to specify that stencil value must be kept */
  82166. static readonly KEEP: number;
  82167. /** Passed to stencilOperation to specify that stencil value must be replaced */
  82168. static readonly REPLACE: number;
  82169. /** Passed to stencilOperation to specify that stencil value must be incremented */
  82170. static readonly INCR: number;
  82171. /** Passed to stencilOperation to specify that stencil value must be decremented */
  82172. static readonly DECR: number;
  82173. /** Passed to stencilOperation to specify that stencil value must be inverted */
  82174. static readonly INVERT: number;
  82175. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  82176. static readonly INCR_WRAP: number;
  82177. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  82178. static readonly DECR_WRAP: number;
  82179. /** Texture is not repeating outside of 0..1 UVs */
  82180. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  82181. /** Texture is repeating outside of 0..1 UVs */
  82182. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  82183. /** Texture is repeating and mirrored */
  82184. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  82185. /** ALPHA */
  82186. static readonly TEXTUREFORMAT_ALPHA: number;
  82187. /** LUMINANCE */
  82188. static readonly TEXTUREFORMAT_LUMINANCE: number;
  82189. /** LUMINANCE_ALPHA */
  82190. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  82191. /** RGB */
  82192. static readonly TEXTUREFORMAT_RGB: number;
  82193. /** RGBA */
  82194. static readonly TEXTUREFORMAT_RGBA: number;
  82195. /** RED */
  82196. static readonly TEXTUREFORMAT_RED: number;
  82197. /** RED (2nd reference) */
  82198. static readonly TEXTUREFORMAT_R: number;
  82199. /** RG */
  82200. static readonly TEXTUREFORMAT_RG: number;
  82201. /** RED_INTEGER */
  82202. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  82203. /** RED_INTEGER (2nd reference) */
  82204. static readonly TEXTUREFORMAT_R_INTEGER: number;
  82205. /** RG_INTEGER */
  82206. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  82207. /** RGB_INTEGER */
  82208. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  82209. /** RGBA_INTEGER */
  82210. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  82211. /** UNSIGNED_BYTE */
  82212. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  82213. /** UNSIGNED_BYTE (2nd reference) */
  82214. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  82215. /** FLOAT */
  82216. static readonly TEXTURETYPE_FLOAT: number;
  82217. /** HALF_FLOAT */
  82218. static readonly TEXTURETYPE_HALF_FLOAT: number;
  82219. /** BYTE */
  82220. static readonly TEXTURETYPE_BYTE: number;
  82221. /** SHORT */
  82222. static readonly TEXTURETYPE_SHORT: number;
  82223. /** UNSIGNED_SHORT */
  82224. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  82225. /** INT */
  82226. static readonly TEXTURETYPE_INT: number;
  82227. /** UNSIGNED_INT */
  82228. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  82229. /** UNSIGNED_SHORT_4_4_4_4 */
  82230. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  82231. /** UNSIGNED_SHORT_5_5_5_1 */
  82232. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  82233. /** UNSIGNED_SHORT_5_6_5 */
  82234. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  82235. /** UNSIGNED_INT_2_10_10_10_REV */
  82236. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  82237. /** UNSIGNED_INT_24_8 */
  82238. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  82239. /** UNSIGNED_INT_10F_11F_11F_REV */
  82240. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  82241. /** UNSIGNED_INT_5_9_9_9_REV */
  82242. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  82243. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  82244. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  82245. /** nearest is mag = nearest and min = nearest and no mip */
  82246. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  82247. /** mag = nearest and min = nearest and mip = none */
  82248. static readonly TEXTURE_NEAREST_NEAREST: number;
  82249. /** Bilinear is mag = linear and min = linear and no mip */
  82250. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  82251. /** mag = linear and min = linear and mip = none */
  82252. static readonly TEXTURE_LINEAR_LINEAR: number;
  82253. /** Trilinear is mag = linear and min = linear and mip = linear */
  82254. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  82255. /** Trilinear is mag = linear and min = linear and mip = linear */
  82256. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  82257. /** mag = nearest and min = nearest and mip = nearest */
  82258. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  82259. /** mag = nearest and min = linear and mip = nearest */
  82260. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  82261. /** mag = nearest and min = linear and mip = linear */
  82262. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  82263. /** mag = nearest and min = linear and mip = none */
  82264. static readonly TEXTURE_NEAREST_LINEAR: number;
  82265. /** nearest is mag = nearest and min = nearest and mip = linear */
  82266. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  82267. /** mag = linear and min = nearest and mip = nearest */
  82268. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  82269. /** mag = linear and min = nearest and mip = linear */
  82270. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  82271. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82272. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  82273. /** mag = linear and min = nearest and mip = none */
  82274. static readonly TEXTURE_LINEAR_NEAREST: number;
  82275. /** Explicit coordinates mode */
  82276. static readonly TEXTURE_EXPLICIT_MODE: number;
  82277. /** Spherical coordinates mode */
  82278. static readonly TEXTURE_SPHERICAL_MODE: number;
  82279. /** Planar coordinates mode */
  82280. static readonly TEXTURE_PLANAR_MODE: number;
  82281. /** Cubic coordinates mode */
  82282. static readonly TEXTURE_CUBIC_MODE: number;
  82283. /** Projection coordinates mode */
  82284. static readonly TEXTURE_PROJECTION_MODE: number;
  82285. /** Skybox coordinates mode */
  82286. static readonly TEXTURE_SKYBOX_MODE: number;
  82287. /** Inverse Cubic coordinates mode */
  82288. static readonly TEXTURE_INVCUBIC_MODE: number;
  82289. /** Equirectangular coordinates mode */
  82290. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  82291. /** Equirectangular Fixed coordinates mode */
  82292. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  82293. /** Equirectangular Fixed Mirrored coordinates mode */
  82294. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82295. /** Offline (baking) quality for texture filtering */
  82296. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  82297. /** High quality for texture filtering */
  82298. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  82299. /** Medium quality for texture filtering */
  82300. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  82301. /** Low quality for texture filtering */
  82302. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  82303. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  82304. static readonly SCALEMODE_FLOOR: number;
  82305. /** Defines that texture rescaling will look for the nearest power of 2 size */
  82306. static readonly SCALEMODE_NEAREST: number;
  82307. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  82308. static readonly SCALEMODE_CEILING: number;
  82309. /**
  82310. * The dirty texture flag value
  82311. */
  82312. static readonly MATERIAL_TextureDirtyFlag: number;
  82313. /**
  82314. * The dirty light flag value
  82315. */
  82316. static readonly MATERIAL_LightDirtyFlag: number;
  82317. /**
  82318. * The dirty fresnel flag value
  82319. */
  82320. static readonly MATERIAL_FresnelDirtyFlag: number;
  82321. /**
  82322. * The dirty attribute flag value
  82323. */
  82324. static readonly MATERIAL_AttributesDirtyFlag: number;
  82325. /**
  82326. * The dirty misc flag value
  82327. */
  82328. static readonly MATERIAL_MiscDirtyFlag: number;
  82329. /**
  82330. * The dirty prepass flag value
  82331. */
  82332. static readonly MATERIAL_PrePassDirtyFlag: number;
  82333. /**
  82334. * The all dirty flag value
  82335. */
  82336. static readonly MATERIAL_AllDirtyFlag: number;
  82337. /**
  82338. * Returns the triangle fill mode
  82339. */
  82340. static readonly MATERIAL_TriangleFillMode: number;
  82341. /**
  82342. * Returns the wireframe mode
  82343. */
  82344. static readonly MATERIAL_WireFrameFillMode: number;
  82345. /**
  82346. * Returns the point fill mode
  82347. */
  82348. static readonly MATERIAL_PointFillMode: number;
  82349. /**
  82350. * Returns the point list draw mode
  82351. */
  82352. static readonly MATERIAL_PointListDrawMode: number;
  82353. /**
  82354. * Returns the line list draw mode
  82355. */
  82356. static readonly MATERIAL_LineListDrawMode: number;
  82357. /**
  82358. * Returns the line loop draw mode
  82359. */
  82360. static readonly MATERIAL_LineLoopDrawMode: number;
  82361. /**
  82362. * Returns the line strip draw mode
  82363. */
  82364. static readonly MATERIAL_LineStripDrawMode: number;
  82365. /**
  82366. * Returns the triangle strip draw mode
  82367. */
  82368. static readonly MATERIAL_TriangleStripDrawMode: number;
  82369. /**
  82370. * Returns the triangle fan draw mode
  82371. */
  82372. static readonly MATERIAL_TriangleFanDrawMode: number;
  82373. /**
  82374. * Stores the clock-wise side orientation
  82375. */
  82376. static readonly MATERIAL_ClockWiseSideOrientation: number;
  82377. /**
  82378. * Stores the counter clock-wise side orientation
  82379. */
  82380. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  82381. /**
  82382. * Nothing
  82383. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82384. */
  82385. static readonly ACTION_NothingTrigger: number;
  82386. /**
  82387. * On pick
  82388. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82389. */
  82390. static readonly ACTION_OnPickTrigger: number;
  82391. /**
  82392. * On left pick
  82393. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82394. */
  82395. static readonly ACTION_OnLeftPickTrigger: number;
  82396. /**
  82397. * On right pick
  82398. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82399. */
  82400. static readonly ACTION_OnRightPickTrigger: number;
  82401. /**
  82402. * On center pick
  82403. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82404. */
  82405. static readonly ACTION_OnCenterPickTrigger: number;
  82406. /**
  82407. * On pick down
  82408. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82409. */
  82410. static readonly ACTION_OnPickDownTrigger: number;
  82411. /**
  82412. * On double pick
  82413. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82414. */
  82415. static readonly ACTION_OnDoublePickTrigger: number;
  82416. /**
  82417. * On pick up
  82418. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82419. */
  82420. static readonly ACTION_OnPickUpTrigger: number;
  82421. /**
  82422. * On pick out.
  82423. * This trigger will only be raised if you also declared a OnPickDown
  82424. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82425. */
  82426. static readonly ACTION_OnPickOutTrigger: number;
  82427. /**
  82428. * On long press
  82429. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82430. */
  82431. static readonly ACTION_OnLongPressTrigger: number;
  82432. /**
  82433. * On pointer over
  82434. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82435. */
  82436. static readonly ACTION_OnPointerOverTrigger: number;
  82437. /**
  82438. * On pointer out
  82439. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82440. */
  82441. static readonly ACTION_OnPointerOutTrigger: number;
  82442. /**
  82443. * On every frame
  82444. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82445. */
  82446. static readonly ACTION_OnEveryFrameTrigger: number;
  82447. /**
  82448. * On intersection enter
  82449. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82450. */
  82451. static readonly ACTION_OnIntersectionEnterTrigger: number;
  82452. /**
  82453. * On intersection exit
  82454. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82455. */
  82456. static readonly ACTION_OnIntersectionExitTrigger: number;
  82457. /**
  82458. * On key down
  82459. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82460. */
  82461. static readonly ACTION_OnKeyDownTrigger: number;
  82462. /**
  82463. * On key up
  82464. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82465. */
  82466. static readonly ACTION_OnKeyUpTrigger: number;
  82467. /**
  82468. * Billboard mode will only apply to Y axis
  82469. */
  82470. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  82471. /**
  82472. * Billboard mode will apply to all axes
  82473. */
  82474. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  82475. /**
  82476. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82477. */
  82478. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  82479. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  82480. * Test order :
  82481. * Is the bounding sphere outside the frustum ?
  82482. * If not, are the bounding box vertices outside the frustum ?
  82483. * It not, then the cullable object is in the frustum.
  82484. */
  82485. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  82486. /** Culling strategy : Bounding Sphere Only.
  82487. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  82488. * It's also less accurate than the standard because some not visible objects can still be selected.
  82489. * Test : is the bounding sphere outside the frustum ?
  82490. * If not, then the cullable object is in the frustum.
  82491. */
  82492. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  82493. /** Culling strategy : Optimistic Inclusion.
  82494. * This in an inclusion test first, then the standard exclusion test.
  82495. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  82496. * 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.
  82497. * Anyway, it's as accurate as the standard strategy.
  82498. * Test :
  82499. * Is the cullable object bounding sphere center in the frustum ?
  82500. * If not, apply the default culling strategy.
  82501. */
  82502. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  82503. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  82504. * This in an inclusion test first, then the bounding sphere only exclusion test.
  82505. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  82506. * 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.
  82507. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  82508. * Test :
  82509. * Is the cullable object bounding sphere center in the frustum ?
  82510. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  82511. */
  82512. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  82513. /**
  82514. * No logging while loading
  82515. */
  82516. static readonly SCENELOADER_NO_LOGGING: number;
  82517. /**
  82518. * Minimal logging while loading
  82519. */
  82520. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  82521. /**
  82522. * Summary logging while loading
  82523. */
  82524. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  82525. /**
  82526. * Detailled logging while loading
  82527. */
  82528. static readonly SCENELOADER_DETAILED_LOGGING: number;
  82529. /**
  82530. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  82531. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  82532. */
  82533. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  82534. /**
  82535. * Constant used to retrieve the position texture index in the textures array in the prepass
  82536. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  82537. */
  82538. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  82539. /**
  82540. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  82541. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  82542. */
  82543. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  82544. /**
  82545. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  82546. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  82547. */
  82548. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  82549. /**
  82550. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  82551. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  82552. */
  82553. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  82554. /**
  82555. * Constant used to retrieve depth + normal index in the textures array in the prepass
  82556. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  82557. */
  82558. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  82559. /**
  82560. * Constant used to retrieve albedo index in the textures array in the prepass
  82561. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  82562. */
  82563. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  82564. }
  82565. }
  82566. declare module BABYLON {
  82567. /**
  82568. * This represents the required contract to create a new type of texture loader.
  82569. */
  82570. export interface IInternalTextureLoader {
  82571. /**
  82572. * Defines wether the loader supports cascade loading the different faces.
  82573. */
  82574. supportCascades: boolean;
  82575. /**
  82576. * This returns if the loader support the current file information.
  82577. * @param extension defines the file extension of the file being loaded
  82578. * @param mimeType defines the optional mime type of the file being loaded
  82579. * @returns true if the loader can load the specified file
  82580. */
  82581. canLoad(extension: string, mimeType?: string): boolean;
  82582. /**
  82583. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  82584. * @param data contains the texture data
  82585. * @param texture defines the BabylonJS internal texture
  82586. * @param createPolynomials will be true if polynomials have been requested
  82587. * @param onLoad defines the callback to trigger once the texture is ready
  82588. * @param onError defines the callback to trigger in case of error
  82589. * @param options options to be passed to the loader
  82590. */
  82591. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  82592. /**
  82593. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  82594. * @param data contains the texture data
  82595. * @param texture defines the BabylonJS internal texture
  82596. * @param callback defines the method to call once ready to upload
  82597. * @param options options to be passed to the loader
  82598. */
  82599. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  82600. }
  82601. }
  82602. declare module BABYLON {
  82603. /**
  82604. * Class used to store and describe the pipeline context associated with an effect
  82605. */
  82606. export interface IPipelineContext {
  82607. /**
  82608. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  82609. */
  82610. isAsync: boolean;
  82611. /**
  82612. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  82613. */
  82614. isReady: boolean;
  82615. /** @hidden */
  82616. _getVertexShaderCode(): string | null;
  82617. /** @hidden */
  82618. _getFragmentShaderCode(): string | null;
  82619. /** @hidden */
  82620. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  82621. }
  82622. }
  82623. declare module BABYLON {
  82624. /**
  82625. * Class used to store gfx data (like WebGLBuffer)
  82626. */
  82627. export class DataBuffer {
  82628. /**
  82629. * Gets or sets the number of objects referencing this buffer
  82630. */
  82631. references: number;
  82632. /** Gets or sets the size of the underlying buffer */
  82633. capacity: number;
  82634. /**
  82635. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  82636. */
  82637. is32Bits: boolean;
  82638. /**
  82639. * Gets the underlying buffer
  82640. */
  82641. get underlyingResource(): any;
  82642. }
  82643. }
  82644. declare module BABYLON {
  82645. /** @hidden */
  82646. export interface IShaderProcessor {
  82647. attributeProcessor?: (attribute: string) => string;
  82648. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  82649. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  82650. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  82651. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  82652. lineProcessor?: (line: string, isFragment: boolean) => string;
  82653. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  82654. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  82655. }
  82656. }
  82657. declare module BABYLON {
  82658. /** @hidden */
  82659. export interface ProcessingOptions {
  82660. defines: string[];
  82661. indexParameters: any;
  82662. isFragment: boolean;
  82663. shouldUseHighPrecisionShader: boolean;
  82664. supportsUniformBuffers: boolean;
  82665. shadersRepository: string;
  82666. includesShadersStore: {
  82667. [key: string]: string;
  82668. };
  82669. processor?: IShaderProcessor;
  82670. version: string;
  82671. platformName: string;
  82672. lookForClosingBracketForUniformBuffer?: boolean;
  82673. }
  82674. }
  82675. declare module BABYLON {
  82676. /** @hidden */
  82677. export class ShaderCodeNode {
  82678. line: string;
  82679. children: ShaderCodeNode[];
  82680. additionalDefineKey?: string;
  82681. additionalDefineValue?: string;
  82682. isValid(preprocessors: {
  82683. [key: string]: string;
  82684. }): boolean;
  82685. process(preprocessors: {
  82686. [key: string]: string;
  82687. }, options: ProcessingOptions): string;
  82688. }
  82689. }
  82690. declare module BABYLON {
  82691. /** @hidden */
  82692. export class ShaderCodeCursor {
  82693. private _lines;
  82694. lineIndex: number;
  82695. get currentLine(): string;
  82696. get canRead(): boolean;
  82697. set lines(value: string[]);
  82698. }
  82699. }
  82700. declare module BABYLON {
  82701. /** @hidden */
  82702. export class ShaderCodeConditionNode extends ShaderCodeNode {
  82703. process(preprocessors: {
  82704. [key: string]: string;
  82705. }, options: ProcessingOptions): string;
  82706. }
  82707. }
  82708. declare module BABYLON {
  82709. /** @hidden */
  82710. export class ShaderDefineExpression {
  82711. isTrue(preprocessors: {
  82712. [key: string]: string;
  82713. }): boolean;
  82714. private static _OperatorPriority;
  82715. private static _Stack;
  82716. static postfixToInfix(postfix: string[]): string;
  82717. static infixToPostfix(infix: string): string[];
  82718. }
  82719. }
  82720. declare module BABYLON {
  82721. /** @hidden */
  82722. export class ShaderCodeTestNode extends ShaderCodeNode {
  82723. testExpression: ShaderDefineExpression;
  82724. isValid(preprocessors: {
  82725. [key: string]: string;
  82726. }): boolean;
  82727. }
  82728. }
  82729. declare module BABYLON {
  82730. /** @hidden */
  82731. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  82732. define: string;
  82733. not: boolean;
  82734. constructor(define: string, not?: boolean);
  82735. isTrue(preprocessors: {
  82736. [key: string]: string;
  82737. }): boolean;
  82738. }
  82739. }
  82740. declare module BABYLON {
  82741. /** @hidden */
  82742. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  82743. leftOperand: ShaderDefineExpression;
  82744. rightOperand: ShaderDefineExpression;
  82745. isTrue(preprocessors: {
  82746. [key: string]: string;
  82747. }): boolean;
  82748. }
  82749. }
  82750. declare module BABYLON {
  82751. /** @hidden */
  82752. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  82753. leftOperand: ShaderDefineExpression;
  82754. rightOperand: ShaderDefineExpression;
  82755. isTrue(preprocessors: {
  82756. [key: string]: string;
  82757. }): boolean;
  82758. }
  82759. }
  82760. declare module BABYLON {
  82761. /** @hidden */
  82762. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  82763. define: string;
  82764. operand: string;
  82765. testValue: string;
  82766. constructor(define: string, operand: string, testValue: string);
  82767. isTrue(preprocessors: {
  82768. [key: string]: string;
  82769. }): boolean;
  82770. }
  82771. }
  82772. declare module BABYLON {
  82773. /**
  82774. * Class used to enable access to offline support
  82775. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  82776. */
  82777. export interface IOfflineProvider {
  82778. /**
  82779. * Gets a boolean indicating if scene must be saved in the database
  82780. */
  82781. enableSceneOffline: boolean;
  82782. /**
  82783. * Gets a boolean indicating if textures must be saved in the database
  82784. */
  82785. enableTexturesOffline: boolean;
  82786. /**
  82787. * Open the offline support and make it available
  82788. * @param successCallback defines the callback to call on success
  82789. * @param errorCallback defines the callback to call on error
  82790. */
  82791. open(successCallback: () => void, errorCallback: () => void): void;
  82792. /**
  82793. * Loads an image from the offline support
  82794. * @param url defines the url to load from
  82795. * @param image defines the target DOM image
  82796. */
  82797. loadImage(url: string, image: HTMLImageElement): void;
  82798. /**
  82799. * Loads a file from offline support
  82800. * @param url defines the URL to load from
  82801. * @param sceneLoaded defines a callback to call on success
  82802. * @param progressCallBack defines a callback to call when progress changed
  82803. * @param errorCallback defines a callback to call on error
  82804. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  82805. */
  82806. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  82807. }
  82808. }
  82809. declare module BABYLON {
  82810. /**
  82811. * Class used to help managing file picking and drag'n'drop
  82812. * File Storage
  82813. */
  82814. export class FilesInputStore {
  82815. /**
  82816. * List of files ready to be loaded
  82817. */
  82818. static FilesToLoad: {
  82819. [key: string]: File;
  82820. };
  82821. }
  82822. }
  82823. declare module BABYLON {
  82824. /**
  82825. * Class used to define a retry strategy when error happens while loading assets
  82826. */
  82827. export class RetryStrategy {
  82828. /**
  82829. * Function used to defines an exponential back off strategy
  82830. * @param maxRetries defines the maximum number of retries (3 by default)
  82831. * @param baseInterval defines the interval between retries
  82832. * @returns the strategy function to use
  82833. */
  82834. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  82835. }
  82836. }
  82837. declare module BABYLON {
  82838. /**
  82839. * @ignore
  82840. * Application error to support additional information when loading a file
  82841. */
  82842. export abstract class BaseError extends Error {
  82843. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  82844. }
  82845. }
  82846. declare module BABYLON {
  82847. /** @ignore */
  82848. export class LoadFileError extends BaseError {
  82849. request?: WebRequest;
  82850. file?: File;
  82851. /**
  82852. * Creates a new LoadFileError
  82853. * @param message defines the message of the error
  82854. * @param request defines the optional web request
  82855. * @param file defines the optional file
  82856. */
  82857. constructor(message: string, object?: WebRequest | File);
  82858. }
  82859. /** @ignore */
  82860. export class RequestFileError extends BaseError {
  82861. request: WebRequest;
  82862. /**
  82863. * Creates a new LoadFileError
  82864. * @param message defines the message of the error
  82865. * @param request defines the optional web request
  82866. */
  82867. constructor(message: string, request: WebRequest);
  82868. }
  82869. /** @ignore */
  82870. export class ReadFileError extends BaseError {
  82871. file: File;
  82872. /**
  82873. * Creates a new ReadFileError
  82874. * @param message defines the message of the error
  82875. * @param file defines the optional file
  82876. */
  82877. constructor(message: string, file: File);
  82878. }
  82879. /**
  82880. * @hidden
  82881. */
  82882. export class FileTools {
  82883. /**
  82884. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  82885. */
  82886. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  82887. /**
  82888. * Gets or sets the base URL to use to load assets
  82889. */
  82890. static BaseUrl: string;
  82891. /**
  82892. * Default behaviour for cors in the application.
  82893. * It can be a string if the expected behavior is identical in the entire app.
  82894. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  82895. */
  82896. static CorsBehavior: string | ((url: string | string[]) => string);
  82897. /**
  82898. * Gets or sets a function used to pre-process url before using them to load assets
  82899. */
  82900. static PreprocessUrl: (url: string) => string;
  82901. /**
  82902. * Removes unwanted characters from an url
  82903. * @param url defines the url to clean
  82904. * @returns the cleaned url
  82905. */
  82906. private static _CleanUrl;
  82907. /**
  82908. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  82909. * @param url define the url we are trying
  82910. * @param element define the dom element where to configure the cors policy
  82911. */
  82912. static SetCorsBehavior(url: string | string[], element: {
  82913. crossOrigin: string | null;
  82914. }): void;
  82915. /**
  82916. * Loads an image as an HTMLImageElement.
  82917. * @param input url string, ArrayBuffer, or Blob to load
  82918. * @param onLoad callback called when the image successfully loads
  82919. * @param onError callback called when the image fails to load
  82920. * @param offlineProvider offline provider for caching
  82921. * @param mimeType optional mime type
  82922. * @returns the HTMLImageElement of the loaded image
  82923. */
  82924. 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>;
  82925. /**
  82926. * Reads a file from a File object
  82927. * @param file defines the file to load
  82928. * @param onSuccess defines the callback to call when data is loaded
  82929. * @param onProgress defines the callback to call during loading process
  82930. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  82931. * @param onError defines the callback to call when an error occurs
  82932. * @returns a file request object
  82933. */
  82934. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  82935. /**
  82936. * Loads a file from a url
  82937. * @param url url to load
  82938. * @param onSuccess callback called when the file successfully loads
  82939. * @param onProgress callback called while file is loading (if the server supports this mode)
  82940. * @param offlineProvider defines the offline provider for caching
  82941. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82942. * @param onError callback called when the file fails to load
  82943. * @returns a file request object
  82944. */
  82945. 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;
  82946. /**
  82947. * Loads a file
  82948. * @param url url to load
  82949. * @param onSuccess callback called when the file successfully loads
  82950. * @param onProgress callback called while file is loading (if the server supports this mode)
  82951. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82952. * @param onError callback called when the file fails to load
  82953. * @param onOpened callback called when the web request is opened
  82954. * @returns a file request object
  82955. */
  82956. 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;
  82957. /**
  82958. * Checks if the loaded document was accessed via `file:`-Protocol.
  82959. * @returns boolean
  82960. */
  82961. static IsFileURL(): boolean;
  82962. }
  82963. }
  82964. declare module BABYLON {
  82965. /** @hidden */
  82966. export class ShaderProcessor {
  82967. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  82968. private static _ProcessPrecision;
  82969. private static _ExtractOperation;
  82970. private static _BuildSubExpression;
  82971. private static _BuildExpression;
  82972. private static _MoveCursorWithinIf;
  82973. private static _MoveCursor;
  82974. private static _EvaluatePreProcessors;
  82975. private static _PreparePreProcessors;
  82976. private static _ProcessShaderConversion;
  82977. private static _ProcessIncludes;
  82978. /**
  82979. * Loads a file from a url
  82980. * @param url url to load
  82981. * @param onSuccess callback called when the file successfully loads
  82982. * @param onProgress callback called while file is loading (if the server supports this mode)
  82983. * @param offlineProvider defines the offline provider for caching
  82984. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82985. * @param onError callback called when the file fails to load
  82986. * @returns a file request object
  82987. * @hidden
  82988. */
  82989. 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;
  82990. }
  82991. }
  82992. declare module BABYLON {
  82993. /**
  82994. * @hidden
  82995. */
  82996. export interface IColor4Like {
  82997. r: float;
  82998. g: float;
  82999. b: float;
  83000. a: float;
  83001. }
  83002. /**
  83003. * @hidden
  83004. */
  83005. export interface IColor3Like {
  83006. r: float;
  83007. g: float;
  83008. b: float;
  83009. }
  83010. /**
  83011. * @hidden
  83012. */
  83013. export interface IVector4Like {
  83014. x: float;
  83015. y: float;
  83016. z: float;
  83017. w: float;
  83018. }
  83019. /**
  83020. * @hidden
  83021. */
  83022. export interface IVector3Like {
  83023. x: float;
  83024. y: float;
  83025. z: float;
  83026. }
  83027. /**
  83028. * @hidden
  83029. */
  83030. export interface IVector2Like {
  83031. x: float;
  83032. y: float;
  83033. }
  83034. /**
  83035. * @hidden
  83036. */
  83037. export interface IMatrixLike {
  83038. toArray(): DeepImmutable<Float32Array | Array<number>>;
  83039. updateFlag: int;
  83040. }
  83041. /**
  83042. * @hidden
  83043. */
  83044. export interface IViewportLike {
  83045. x: float;
  83046. y: float;
  83047. width: float;
  83048. height: float;
  83049. }
  83050. /**
  83051. * @hidden
  83052. */
  83053. export interface IPlaneLike {
  83054. normal: IVector3Like;
  83055. d: float;
  83056. normalize(): void;
  83057. }
  83058. }
  83059. declare module BABYLON {
  83060. /**
  83061. * Interface used to define common properties for effect fallbacks
  83062. */
  83063. export interface IEffectFallbacks {
  83064. /**
  83065. * Removes the defines that should be removed when falling back.
  83066. * @param currentDefines defines the current define statements for the shader.
  83067. * @param effect defines the current effect we try to compile
  83068. * @returns The resulting defines with defines of the current rank removed.
  83069. */
  83070. reduce(currentDefines: string, effect: Effect): string;
  83071. /**
  83072. * Removes the fallback from the bound mesh.
  83073. */
  83074. unBindMesh(): void;
  83075. /**
  83076. * Checks to see if more fallbacks are still availible.
  83077. */
  83078. hasMoreFallbacks: boolean;
  83079. }
  83080. }
  83081. declare module BABYLON {
  83082. /**
  83083. * Interface for the size containing width and height
  83084. */
  83085. export interface ISize {
  83086. /**
  83087. * Width
  83088. */
  83089. width: number;
  83090. /**
  83091. * Heighht
  83092. */
  83093. height: number;
  83094. }
  83095. /**
  83096. * Size containing widht and height
  83097. */
  83098. export class Size implements ISize {
  83099. /**
  83100. * Width
  83101. */
  83102. width: number;
  83103. /**
  83104. * Height
  83105. */
  83106. height: number;
  83107. /**
  83108. * Creates a Size object from the given width and height (floats).
  83109. * @param width width of the new size
  83110. * @param height height of the new size
  83111. */
  83112. constructor(width: number, height: number);
  83113. /**
  83114. * Returns a string with the Size width and height
  83115. * @returns a string with the Size width and height
  83116. */
  83117. toString(): string;
  83118. /**
  83119. * "Size"
  83120. * @returns the string "Size"
  83121. */
  83122. getClassName(): string;
  83123. /**
  83124. * Returns the Size hash code.
  83125. * @returns a hash code for a unique width and height
  83126. */
  83127. getHashCode(): number;
  83128. /**
  83129. * Updates the current size from the given one.
  83130. * @param src the given size
  83131. */
  83132. copyFrom(src: Size): void;
  83133. /**
  83134. * Updates in place the current Size from the given floats.
  83135. * @param width width of the new size
  83136. * @param height height of the new size
  83137. * @returns the updated Size.
  83138. */
  83139. copyFromFloats(width: number, height: number): Size;
  83140. /**
  83141. * Updates in place the current Size from the given floats.
  83142. * @param width width to set
  83143. * @param height height to set
  83144. * @returns the updated Size.
  83145. */
  83146. set(width: number, height: number): Size;
  83147. /**
  83148. * Multiplies the width and height by numbers
  83149. * @param w factor to multiple the width by
  83150. * @param h factor to multiple the height by
  83151. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83152. */
  83153. multiplyByFloats(w: number, h: number): Size;
  83154. /**
  83155. * Clones the size
  83156. * @returns a new Size copied from the given one.
  83157. */
  83158. clone(): Size;
  83159. /**
  83160. * True if the current Size and the given one width and height are strictly equal.
  83161. * @param other the other size to compare against
  83162. * @returns True if the current Size and the given one width and height are strictly equal.
  83163. */
  83164. equals(other: Size): boolean;
  83165. /**
  83166. * The surface of the Size : width * height (float).
  83167. */
  83168. get surface(): number;
  83169. /**
  83170. * Create a new size of zero
  83171. * @returns a new Size set to (0.0, 0.0)
  83172. */
  83173. static Zero(): Size;
  83174. /**
  83175. * Sums the width and height of two sizes
  83176. * @param otherSize size to add to this size
  83177. * @returns a new Size set as the addition result of the current Size and the given one.
  83178. */
  83179. add(otherSize: Size): Size;
  83180. /**
  83181. * Subtracts the width and height of two
  83182. * @param otherSize size to subtract to this size
  83183. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83184. */
  83185. subtract(otherSize: Size): Size;
  83186. /**
  83187. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83188. * @param start starting size to lerp between
  83189. * @param end end size to lerp between
  83190. * @param amount amount to lerp between the start and end values
  83191. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83192. */
  83193. static Lerp(start: Size, end: Size, amount: number): Size;
  83194. }
  83195. }
  83196. declare module BABYLON {
  83197. /**
  83198. * Base class of all the textures in babylon.
  83199. * It groups all the common properties required to work with Thin Engine.
  83200. */
  83201. export class ThinTexture {
  83202. protected _wrapU: number;
  83203. /**
  83204. * | Value | Type | Description |
  83205. * | ----- | ------------------ | ----------- |
  83206. * | 0 | CLAMP_ADDRESSMODE | |
  83207. * | 1 | WRAP_ADDRESSMODE | |
  83208. * | 2 | MIRROR_ADDRESSMODE | |
  83209. */
  83210. get wrapU(): number;
  83211. set wrapU(value: number);
  83212. protected _wrapV: number;
  83213. /**
  83214. * | Value | Type | Description |
  83215. * | ----- | ------------------ | ----------- |
  83216. * | 0 | CLAMP_ADDRESSMODE | |
  83217. * | 1 | WRAP_ADDRESSMODE | |
  83218. * | 2 | MIRROR_ADDRESSMODE | |
  83219. */
  83220. get wrapV(): number;
  83221. set wrapV(value: number);
  83222. /**
  83223. * | Value | Type | Description |
  83224. * | ----- | ------------------ | ----------- |
  83225. * | 0 | CLAMP_ADDRESSMODE | |
  83226. * | 1 | WRAP_ADDRESSMODE | |
  83227. * | 2 | MIRROR_ADDRESSMODE | |
  83228. */
  83229. wrapR: number;
  83230. /**
  83231. * With compliant hardware and browser (supporting anisotropic filtering)
  83232. * this defines the level of anisotropic filtering in the texture.
  83233. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  83234. */
  83235. anisotropicFilteringLevel: number;
  83236. /**
  83237. * Define the current state of the loading sequence when in delayed load mode.
  83238. */
  83239. delayLoadState: number;
  83240. /**
  83241. * How a texture is mapped.
  83242. * Unused in thin texture mode.
  83243. */
  83244. get coordinatesMode(): number;
  83245. /**
  83246. * Define if the texture is a cube texture or if false a 2d texture.
  83247. */
  83248. get isCube(): boolean;
  83249. set isCube(value: boolean);
  83250. /**
  83251. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  83252. */
  83253. get is3D(): boolean;
  83254. set is3D(value: boolean);
  83255. /**
  83256. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  83257. */
  83258. get is2DArray(): boolean;
  83259. set is2DArray(value: boolean);
  83260. /**
  83261. * Get the class name of the texture.
  83262. * @returns "ThinTexture"
  83263. */
  83264. getClassName(): string;
  83265. /** @hidden */
  83266. _texture: Nullable<InternalTexture>;
  83267. protected _engine: Nullable<ThinEngine>;
  83268. private _cachedSize;
  83269. private _cachedBaseSize;
  83270. /**
  83271. * Instantiates a new ThinTexture.
  83272. * Base class of all the textures in babylon.
  83273. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  83274. * @param internalTexture Define the internalTexture to wrap
  83275. */
  83276. constructor(internalTexture: Nullable<InternalTexture>);
  83277. /**
  83278. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  83279. * @returns true if fully ready
  83280. */
  83281. isReady(): boolean;
  83282. /**
  83283. * Triggers the load sequence in delayed load mode.
  83284. */
  83285. delayLoad(): void;
  83286. /**
  83287. * Get the underlying lower level texture from Babylon.
  83288. * @returns the insternal texture
  83289. */
  83290. getInternalTexture(): Nullable<InternalTexture>;
  83291. /**
  83292. * Get the size of the texture.
  83293. * @returns the texture size.
  83294. */
  83295. getSize(): ISize;
  83296. /**
  83297. * Get the base size of the texture.
  83298. * It can be different from the size if the texture has been resized for POT for instance
  83299. * @returns the base size
  83300. */
  83301. getBaseSize(): ISize;
  83302. /**
  83303. * Update the sampling mode of the texture.
  83304. * Default is Trilinear mode.
  83305. *
  83306. * | Value | Type | Description |
  83307. * | ----- | ------------------ | ----------- |
  83308. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  83309. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  83310. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  83311. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  83312. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  83313. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  83314. * | 7 | NEAREST_LINEAR | |
  83315. * | 8 | NEAREST_NEAREST | |
  83316. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  83317. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  83318. * | 11 | LINEAR_LINEAR | |
  83319. * | 12 | LINEAR_NEAREST | |
  83320. *
  83321. * > _mag_: magnification filter (close to the viewer)
  83322. * > _min_: minification filter (far from the viewer)
  83323. * > _mip_: filter used between mip map levels
  83324. *@param samplingMode Define the new sampling mode of the texture
  83325. */
  83326. updateSamplingMode(samplingMode: number): void;
  83327. /**
  83328. * Release and destroy the underlying lower level texture aka internalTexture.
  83329. */
  83330. releaseInternalTexture(): void;
  83331. /**
  83332. * Dispose the texture and release its associated resources.
  83333. */
  83334. dispose(): void;
  83335. }
  83336. }
  83337. declare module BABYLON {
  83338. /**
  83339. * Defines an array and its length.
  83340. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  83341. */
  83342. export interface ISmartArrayLike<T> {
  83343. /**
  83344. * The data of the array.
  83345. */
  83346. data: Array<T>;
  83347. /**
  83348. * The active length of the array.
  83349. */
  83350. length: number;
  83351. }
  83352. /**
  83353. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83354. */
  83355. export class SmartArray<T> implements ISmartArrayLike<T> {
  83356. /**
  83357. * The full set of data from the array.
  83358. */
  83359. data: Array<T>;
  83360. /**
  83361. * The active length of the array.
  83362. */
  83363. length: number;
  83364. protected _id: number;
  83365. /**
  83366. * Instantiates a Smart Array.
  83367. * @param capacity defines the default capacity of the array.
  83368. */
  83369. constructor(capacity: number);
  83370. /**
  83371. * Pushes a value at the end of the active data.
  83372. * @param value defines the object to push in the array.
  83373. */
  83374. push(value: T): void;
  83375. /**
  83376. * Iterates over the active data and apply the lambda to them.
  83377. * @param func defines the action to apply on each value.
  83378. */
  83379. forEach(func: (content: T) => void): void;
  83380. /**
  83381. * Sorts the full sets of data.
  83382. * @param compareFn defines the comparison function to apply.
  83383. */
  83384. sort(compareFn: (a: T, b: T) => number): void;
  83385. /**
  83386. * Resets the active data to an empty array.
  83387. */
  83388. reset(): void;
  83389. /**
  83390. * Releases all the data from the array as well as the array.
  83391. */
  83392. dispose(): void;
  83393. /**
  83394. * Concats the active data with a given array.
  83395. * @param array defines the data to concatenate with.
  83396. */
  83397. concat(array: any): void;
  83398. /**
  83399. * Returns the position of a value in the active data.
  83400. * @param value defines the value to find the index for
  83401. * @returns the index if found in the active data otherwise -1
  83402. */
  83403. indexOf(value: T): number;
  83404. /**
  83405. * Returns whether an element is part of the active data.
  83406. * @param value defines the value to look for
  83407. * @returns true if found in the active data otherwise false
  83408. */
  83409. contains(value: T): boolean;
  83410. private static _GlobalId;
  83411. }
  83412. /**
  83413. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83414. * The data in this array can only be present once
  83415. */
  83416. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  83417. private _duplicateId;
  83418. /**
  83419. * Pushes a value at the end of the active data.
  83420. * THIS DOES NOT PREVENT DUPPLICATE DATA
  83421. * @param value defines the object to push in the array.
  83422. */
  83423. push(value: T): void;
  83424. /**
  83425. * Pushes a value at the end of the active data.
  83426. * If the data is already present, it won t be added again
  83427. * @param value defines the object to push in the array.
  83428. * @returns true if added false if it was already present
  83429. */
  83430. pushNoDuplicate(value: T): boolean;
  83431. /**
  83432. * Resets the active data to an empty array.
  83433. */
  83434. reset(): void;
  83435. /**
  83436. * Concats the active data with a given array.
  83437. * This ensures no dupplicate will be present in the result.
  83438. * @param array defines the data to concatenate with.
  83439. */
  83440. concatWithNoDuplicate(array: any): void;
  83441. }
  83442. }
  83443. declare module BABYLON {
  83444. /**
  83445. * Class used to evalaute queries containing `and` and `or` operators
  83446. */
  83447. export class AndOrNotEvaluator {
  83448. /**
  83449. * Evaluate a query
  83450. * @param query defines the query to evaluate
  83451. * @param evaluateCallback defines the callback used to filter result
  83452. * @returns true if the query matches
  83453. */
  83454. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  83455. private static _HandleParenthesisContent;
  83456. private static _SimplifyNegation;
  83457. }
  83458. }
  83459. declare module BABYLON {
  83460. /**
  83461. * Class used to store custom tags
  83462. */
  83463. export class Tags {
  83464. /**
  83465. * Adds support for tags on the given object
  83466. * @param obj defines the object to use
  83467. */
  83468. static EnableFor(obj: any): void;
  83469. /**
  83470. * Removes tags support
  83471. * @param obj defines the object to use
  83472. */
  83473. static DisableFor(obj: any): void;
  83474. /**
  83475. * Gets a boolean indicating if the given object has tags
  83476. * @param obj defines the object to use
  83477. * @returns a boolean
  83478. */
  83479. static HasTags(obj: any): boolean;
  83480. /**
  83481. * Gets the tags available on a given object
  83482. * @param obj defines the object to use
  83483. * @param asString defines if the tags must be returned as a string instead of an array of strings
  83484. * @returns the tags
  83485. */
  83486. static GetTags(obj: any, asString?: boolean): any;
  83487. /**
  83488. * Adds tags to an object
  83489. * @param obj defines the object to use
  83490. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  83491. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  83492. */
  83493. static AddTagsTo(obj: any, tagsString: string): void;
  83494. /**
  83495. * @hidden
  83496. */
  83497. static _AddTagTo(obj: any, tag: string): void;
  83498. /**
  83499. * Removes specific tags from a specific object
  83500. * @param obj defines the object to use
  83501. * @param tagsString defines the tags to remove
  83502. */
  83503. static RemoveTagsFrom(obj: any, tagsString: string): void;
  83504. /**
  83505. * @hidden
  83506. */
  83507. static _RemoveTagFrom(obj: any, tag: string): void;
  83508. /**
  83509. * Defines if tags hosted on an object match a given query
  83510. * @param obj defines the object to use
  83511. * @param tagsQuery defines the tag query
  83512. * @returns a boolean
  83513. */
  83514. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  83515. }
  83516. }
  83517. declare module BABYLON {
  83518. /**
  83519. * Scalar computation library
  83520. */
  83521. export class Scalar {
  83522. /**
  83523. * Two pi constants convenient for computation.
  83524. */
  83525. static TwoPi: number;
  83526. /**
  83527. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  83528. * @param a number
  83529. * @param b number
  83530. * @param epsilon (default = 1.401298E-45)
  83531. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  83532. */
  83533. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  83534. /**
  83535. * Returns a string : the upper case translation of the number i to hexadecimal.
  83536. * @param i number
  83537. * @returns the upper case translation of the number i to hexadecimal.
  83538. */
  83539. static ToHex(i: number): string;
  83540. /**
  83541. * Returns -1 if value is negative and +1 is value is positive.
  83542. * @param value the value
  83543. * @returns the value itself if it's equal to zero.
  83544. */
  83545. static Sign(value: number): number;
  83546. /**
  83547. * Returns the value itself if it's between min and max.
  83548. * Returns min if the value is lower than min.
  83549. * Returns max if the value is greater than max.
  83550. * @param value the value to clmap
  83551. * @param min the min value to clamp to (default: 0)
  83552. * @param max the max value to clamp to (default: 1)
  83553. * @returns the clamped value
  83554. */
  83555. static Clamp(value: number, min?: number, max?: number): number;
  83556. /**
  83557. * the log2 of value.
  83558. * @param value the value to compute log2 of
  83559. * @returns the log2 of value.
  83560. */
  83561. static Log2(value: number): number;
  83562. /**
  83563. * Loops the value, so that it is never larger than length and never smaller than 0.
  83564. *
  83565. * This is similar to the modulo operator but it works with floating point numbers.
  83566. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  83567. * With t = 5 and length = 2.5, the result would be 0.0.
  83568. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  83569. * @param value the value
  83570. * @param length the length
  83571. * @returns the looped value
  83572. */
  83573. static Repeat(value: number, length: number): number;
  83574. /**
  83575. * Normalize the value between 0.0 and 1.0 using min and max values
  83576. * @param value value to normalize
  83577. * @param min max to normalize between
  83578. * @param max min to normalize between
  83579. * @returns the normalized value
  83580. */
  83581. static Normalize(value: number, min: number, max: number): number;
  83582. /**
  83583. * Denormalize the value from 0.0 and 1.0 using min and max values
  83584. * @param normalized value to denormalize
  83585. * @param min max to denormalize between
  83586. * @param max min to denormalize between
  83587. * @returns the denormalized value
  83588. */
  83589. static Denormalize(normalized: number, min: number, max: number): number;
  83590. /**
  83591. * Calculates the shortest difference between two given angles given in degrees.
  83592. * @param current current angle in degrees
  83593. * @param target target angle in degrees
  83594. * @returns the delta
  83595. */
  83596. static DeltaAngle(current: number, target: number): number;
  83597. /**
  83598. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  83599. * @param tx value
  83600. * @param length length
  83601. * @returns The returned value will move back and forth between 0 and length
  83602. */
  83603. static PingPong(tx: number, length: number): number;
  83604. /**
  83605. * Interpolates between min and max with smoothing at the limits.
  83606. *
  83607. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  83608. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  83609. * @param from from
  83610. * @param to to
  83611. * @param tx value
  83612. * @returns the smooth stepped value
  83613. */
  83614. static SmoothStep(from: number, to: number, tx: number): number;
  83615. /**
  83616. * Moves a value current towards target.
  83617. *
  83618. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  83619. * Negative values of maxDelta pushes the value away from target.
  83620. * @param current current value
  83621. * @param target target value
  83622. * @param maxDelta max distance to move
  83623. * @returns resulting value
  83624. */
  83625. static MoveTowards(current: number, target: number, maxDelta: number): number;
  83626. /**
  83627. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  83628. *
  83629. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  83630. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  83631. * @param current current value
  83632. * @param target target value
  83633. * @param maxDelta max distance to move
  83634. * @returns resulting angle
  83635. */
  83636. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  83637. /**
  83638. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  83639. * @param start start value
  83640. * @param end target value
  83641. * @param amount amount to lerp between
  83642. * @returns the lerped value
  83643. */
  83644. static Lerp(start: number, end: number, amount: number): number;
  83645. /**
  83646. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  83647. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  83648. * @param start start value
  83649. * @param end target value
  83650. * @param amount amount to lerp between
  83651. * @returns the lerped value
  83652. */
  83653. static LerpAngle(start: number, end: number, amount: number): number;
  83654. /**
  83655. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  83656. * @param a start value
  83657. * @param b target value
  83658. * @param value value between a and b
  83659. * @returns the inverseLerp value
  83660. */
  83661. static InverseLerp(a: number, b: number, value: number): number;
  83662. /**
  83663. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  83664. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  83665. * @param value1 spline value
  83666. * @param tangent1 spline value
  83667. * @param value2 spline value
  83668. * @param tangent2 spline value
  83669. * @param amount input value
  83670. * @returns hermite result
  83671. */
  83672. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  83673. /**
  83674. * Returns a random float number between and min and max values
  83675. * @param min min value of random
  83676. * @param max max value of random
  83677. * @returns random value
  83678. */
  83679. static RandomRange(min: number, max: number): number;
  83680. /**
  83681. * This function returns percentage of a number in a given range.
  83682. *
  83683. * RangeToPercent(40,20,60) will return 0.5 (50%)
  83684. * RangeToPercent(34,0,100) will return 0.34 (34%)
  83685. * @param number to convert to percentage
  83686. * @param min min range
  83687. * @param max max range
  83688. * @returns the percentage
  83689. */
  83690. static RangeToPercent(number: number, min: number, max: number): number;
  83691. /**
  83692. * This function returns number that corresponds to the percentage in a given range.
  83693. *
  83694. * PercentToRange(0.34,0,100) will return 34.
  83695. * @param percent to convert to number
  83696. * @param min min range
  83697. * @param max max range
  83698. * @returns the number
  83699. */
  83700. static PercentToRange(percent: number, min: number, max: number): number;
  83701. /**
  83702. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  83703. * @param angle The angle to normalize in radian.
  83704. * @return The converted angle.
  83705. */
  83706. static NormalizeRadians(angle: number): number;
  83707. }
  83708. }
  83709. declare module BABYLON {
  83710. /**
  83711. * Constant used to convert a value to gamma space
  83712. * @ignorenaming
  83713. */
  83714. export const ToGammaSpace: number;
  83715. /**
  83716. * Constant used to convert a value to linear space
  83717. * @ignorenaming
  83718. */
  83719. export const ToLinearSpace = 2.2;
  83720. /**
  83721. * Constant used to define the minimal number value in Babylon.js
  83722. * @ignorenaming
  83723. */
  83724. let Epsilon: number;
  83725. }
  83726. declare module BABYLON {
  83727. /**
  83728. * Class used to represent a viewport on screen
  83729. */
  83730. export class Viewport {
  83731. /** viewport left coordinate */
  83732. x: number;
  83733. /** viewport top coordinate */
  83734. y: number;
  83735. /**viewport width */
  83736. width: number;
  83737. /** viewport height */
  83738. height: number;
  83739. /**
  83740. * Creates a Viewport object located at (x, y) and sized (width, height)
  83741. * @param x defines viewport left coordinate
  83742. * @param y defines viewport top coordinate
  83743. * @param width defines the viewport width
  83744. * @param height defines the viewport height
  83745. */
  83746. constructor(
  83747. /** viewport left coordinate */
  83748. x: number,
  83749. /** viewport top coordinate */
  83750. y: number,
  83751. /**viewport width */
  83752. width: number,
  83753. /** viewport height */
  83754. height: number);
  83755. /**
  83756. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  83757. * @param renderWidth defines the rendering width
  83758. * @param renderHeight defines the rendering height
  83759. * @returns a new Viewport
  83760. */
  83761. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  83762. /**
  83763. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  83764. * @param renderWidth defines the rendering width
  83765. * @param renderHeight defines the rendering height
  83766. * @param ref defines the target viewport
  83767. * @returns the current viewport
  83768. */
  83769. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  83770. /**
  83771. * Returns a new Viewport copied from the current one
  83772. * @returns a new Viewport
  83773. */
  83774. clone(): Viewport;
  83775. }
  83776. }
  83777. declare module BABYLON {
  83778. /**
  83779. * Class containing a set of static utilities functions for arrays.
  83780. */
  83781. export class ArrayTools {
  83782. /**
  83783. * Returns an array of the given size filled with element built from the given constructor and the paramters
  83784. * @param size the number of element to construct and put in the array
  83785. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  83786. * @returns a new array filled with new objects
  83787. */
  83788. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  83789. }
  83790. }
  83791. declare module BABYLON {
  83792. /**
  83793. * Represents a plane by the equation ax + by + cz + d = 0
  83794. */
  83795. export class Plane {
  83796. private static _TmpMatrix;
  83797. /**
  83798. * Normal of the plane (a,b,c)
  83799. */
  83800. normal: Vector3;
  83801. /**
  83802. * d component of the plane
  83803. */
  83804. d: number;
  83805. /**
  83806. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  83807. * @param a a component of the plane
  83808. * @param b b component of the plane
  83809. * @param c c component of the plane
  83810. * @param d d component of the plane
  83811. */
  83812. constructor(a: number, b: number, c: number, d: number);
  83813. /**
  83814. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  83815. */
  83816. asArray(): number[];
  83817. /**
  83818. * @returns a new plane copied from the current Plane.
  83819. */
  83820. clone(): Plane;
  83821. /**
  83822. * @returns the string "Plane".
  83823. */
  83824. getClassName(): string;
  83825. /**
  83826. * @returns the Plane hash code.
  83827. */
  83828. getHashCode(): number;
  83829. /**
  83830. * Normalize the current Plane in place.
  83831. * @returns the updated Plane.
  83832. */
  83833. normalize(): Plane;
  83834. /**
  83835. * Applies a transformation the plane and returns the result
  83836. * @param transformation the transformation matrix to be applied to the plane
  83837. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  83838. */
  83839. transform(transformation: DeepImmutable<Matrix>): Plane;
  83840. /**
  83841. * Compute the dot product between the point and the plane normal
  83842. * @param point point to calculate the dot product with
  83843. * @returns the dot product (float) of the point coordinates and the plane normal.
  83844. */
  83845. dotCoordinate(point: DeepImmutable<Vector3>): number;
  83846. /**
  83847. * Updates the current Plane from the plane defined by the three given points.
  83848. * @param point1 one of the points used to contruct the plane
  83849. * @param point2 one of the points used to contruct the plane
  83850. * @param point3 one of the points used to contruct the plane
  83851. * @returns the updated Plane.
  83852. */
  83853. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  83854. /**
  83855. * Checks if the plane is facing a given direction
  83856. * @param direction the direction to check if the plane is facing
  83857. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  83858. * @returns True is the vector "direction" is the same side than the plane normal.
  83859. */
  83860. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  83861. /**
  83862. * Calculates the distance to a point
  83863. * @param point point to calculate distance to
  83864. * @returns the signed distance (float) from the given point to the Plane.
  83865. */
  83866. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  83867. /**
  83868. * Creates a plane from an array
  83869. * @param array the array to create a plane from
  83870. * @returns a new Plane from the given array.
  83871. */
  83872. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  83873. /**
  83874. * Creates a plane from three points
  83875. * @param point1 point used to create the plane
  83876. * @param point2 point used to create the plane
  83877. * @param point3 point used to create the plane
  83878. * @returns a new Plane defined by the three given points.
  83879. */
  83880. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  83881. /**
  83882. * Creates a plane from an origin point and a normal
  83883. * @param origin origin of the plane to be constructed
  83884. * @param normal normal of the plane to be constructed
  83885. * @returns a new Plane the normal vector to this plane at the given origin point.
  83886. * Note : the vector "normal" is updated because normalized.
  83887. */
  83888. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  83889. /**
  83890. * Calculates the distance from a plane and a point
  83891. * @param origin origin of the plane to be constructed
  83892. * @param normal normal of the plane to be constructed
  83893. * @param point point to calculate distance to
  83894. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  83895. */
  83896. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  83897. }
  83898. }
  83899. declare module BABYLON {
  83900. /** @hidden */
  83901. export class PerformanceConfigurator {
  83902. /** @hidden */
  83903. static MatrixUse64Bits: boolean;
  83904. /** @hidden */
  83905. static MatrixTrackPrecisionChange: boolean;
  83906. /** @hidden */
  83907. static MatrixCurrentType: any;
  83908. /** @hidden */
  83909. static MatrixTrackedMatrices: Array<any> | null;
  83910. /** @hidden */
  83911. static SetMatrixPrecision(use64bits: boolean): void;
  83912. }
  83913. }
  83914. declare module BABYLON {
  83915. /**
  83916. * Class representing a vector containing 2 coordinates
  83917. */
  83918. export class Vector2 {
  83919. /** defines the first coordinate */
  83920. x: number;
  83921. /** defines the second coordinate */
  83922. y: number;
  83923. /**
  83924. * Creates a new Vector2 from the given x and y coordinates
  83925. * @param x defines the first coordinate
  83926. * @param y defines the second coordinate
  83927. */
  83928. constructor(
  83929. /** defines the first coordinate */
  83930. x?: number,
  83931. /** defines the second coordinate */
  83932. y?: number);
  83933. /**
  83934. * Gets a string with the Vector2 coordinates
  83935. * @returns a string with the Vector2 coordinates
  83936. */
  83937. toString(): string;
  83938. /**
  83939. * Gets class name
  83940. * @returns the string "Vector2"
  83941. */
  83942. getClassName(): string;
  83943. /**
  83944. * Gets current vector hash code
  83945. * @returns the Vector2 hash code as a number
  83946. */
  83947. getHashCode(): number;
  83948. /**
  83949. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  83950. * @param array defines the source array
  83951. * @param index defines the offset in source array
  83952. * @returns the current Vector2
  83953. */
  83954. toArray(array: FloatArray, index?: number): Vector2;
  83955. /**
  83956. * Update the current vector from an array
  83957. * @param array defines the destination array
  83958. * @param index defines the offset in the destination array
  83959. * @returns the current Vector3
  83960. */
  83961. fromArray(array: FloatArray, index?: number): Vector2;
  83962. /**
  83963. * Copy the current vector to an array
  83964. * @returns a new array with 2 elements: the Vector2 coordinates.
  83965. */
  83966. asArray(): number[];
  83967. /**
  83968. * Sets the Vector2 coordinates with the given Vector2 coordinates
  83969. * @param source defines the source Vector2
  83970. * @returns the current updated Vector2
  83971. */
  83972. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  83973. /**
  83974. * Sets the Vector2 coordinates with the given floats
  83975. * @param x defines the first coordinate
  83976. * @param y defines the second coordinate
  83977. * @returns the current updated Vector2
  83978. */
  83979. copyFromFloats(x: number, y: number): Vector2;
  83980. /**
  83981. * Sets the Vector2 coordinates with the given floats
  83982. * @param x defines the first coordinate
  83983. * @param y defines the second coordinate
  83984. * @returns the current updated Vector2
  83985. */
  83986. set(x: number, y: number): Vector2;
  83987. /**
  83988. * Add another vector with the current one
  83989. * @param otherVector defines the other vector
  83990. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  83991. */
  83992. add(otherVector: DeepImmutable<Vector2>): Vector2;
  83993. /**
  83994. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  83995. * @param otherVector defines the other vector
  83996. * @param result defines the target vector
  83997. * @returns the unmodified current Vector2
  83998. */
  83999. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  84000. /**
  84001. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  84002. * @param otherVector defines the other vector
  84003. * @returns the current updated Vector2
  84004. */
  84005. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  84006. /**
  84007. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  84008. * @param otherVector defines the other vector
  84009. * @returns a new Vector2
  84010. */
  84011. addVector3(otherVector: Vector3): Vector2;
  84012. /**
  84013. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  84014. * @param otherVector defines the other vector
  84015. * @returns a new Vector2
  84016. */
  84017. subtract(otherVector: Vector2): Vector2;
  84018. /**
  84019. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  84020. * @param otherVector defines the other vector
  84021. * @param result defines the target vector
  84022. * @returns the unmodified current Vector2
  84023. */
  84024. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  84025. /**
  84026. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  84027. * @param otherVector defines the other vector
  84028. * @returns the current updated Vector2
  84029. */
  84030. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  84031. /**
  84032. * Multiplies in place the current Vector2 coordinates by the given ones
  84033. * @param otherVector defines the other vector
  84034. * @returns the current updated Vector2
  84035. */
  84036. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  84037. /**
  84038. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  84039. * @param otherVector defines the other vector
  84040. * @returns a new Vector2
  84041. */
  84042. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  84043. /**
  84044. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  84045. * @param otherVector defines the other vector
  84046. * @param result defines the target vector
  84047. * @returns the unmodified current Vector2
  84048. */
  84049. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  84050. /**
  84051. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  84052. * @param x defines the first coordinate
  84053. * @param y defines the second coordinate
  84054. * @returns a new Vector2
  84055. */
  84056. multiplyByFloats(x: number, y: number): Vector2;
  84057. /**
  84058. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  84059. * @param otherVector defines the other vector
  84060. * @returns a new Vector2
  84061. */
  84062. divide(otherVector: Vector2): Vector2;
  84063. /**
  84064. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  84065. * @param otherVector defines the other vector
  84066. * @param result defines the target vector
  84067. * @returns the unmodified current Vector2
  84068. */
  84069. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  84070. /**
  84071. * Divides the current Vector2 coordinates by the given ones
  84072. * @param otherVector defines the other vector
  84073. * @returns the current updated Vector2
  84074. */
  84075. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  84076. /**
  84077. * Gets a new Vector2 with current Vector2 negated coordinates
  84078. * @returns a new Vector2
  84079. */
  84080. negate(): Vector2;
  84081. /**
  84082. * Negate this vector in place
  84083. * @returns this
  84084. */
  84085. negateInPlace(): Vector2;
  84086. /**
  84087. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  84088. * @param result defines the Vector3 object where to store the result
  84089. * @returns the current Vector2
  84090. */
  84091. negateToRef(result: Vector2): Vector2;
  84092. /**
  84093. * Multiply the Vector2 coordinates by scale
  84094. * @param scale defines the scaling factor
  84095. * @returns the current updated Vector2
  84096. */
  84097. scaleInPlace(scale: number): Vector2;
  84098. /**
  84099. * Returns a new Vector2 scaled by "scale" from the current Vector2
  84100. * @param scale defines the scaling factor
  84101. * @returns a new Vector2
  84102. */
  84103. scale(scale: number): Vector2;
  84104. /**
  84105. * Scale the current Vector2 values by a factor to a given Vector2
  84106. * @param scale defines the scale factor
  84107. * @param result defines the Vector2 object where to store the result
  84108. * @returns the unmodified current Vector2
  84109. */
  84110. scaleToRef(scale: number, result: Vector2): Vector2;
  84111. /**
  84112. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  84113. * @param scale defines the scale factor
  84114. * @param result defines the Vector2 object where to store the result
  84115. * @returns the unmodified current Vector2
  84116. */
  84117. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  84118. /**
  84119. * Gets a boolean if two vectors are equals
  84120. * @param otherVector defines the other vector
  84121. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  84122. */
  84123. equals(otherVector: DeepImmutable<Vector2>): boolean;
  84124. /**
  84125. * Gets a boolean if two vectors are equals (using an epsilon value)
  84126. * @param otherVector defines the other vector
  84127. * @param epsilon defines the minimal distance to consider equality
  84128. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  84129. */
  84130. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  84131. /**
  84132. * Gets a new Vector2 from current Vector2 floored values
  84133. * @returns a new Vector2
  84134. */
  84135. floor(): Vector2;
  84136. /**
  84137. * Gets a new Vector2 from current Vector2 floored values
  84138. * @returns a new Vector2
  84139. */
  84140. fract(): Vector2;
  84141. /**
  84142. * Gets the length of the vector
  84143. * @returns the vector length (float)
  84144. */
  84145. length(): number;
  84146. /**
  84147. * Gets the vector squared length
  84148. * @returns the vector squared length (float)
  84149. */
  84150. lengthSquared(): number;
  84151. /**
  84152. * Normalize the vector
  84153. * @returns the current updated Vector2
  84154. */
  84155. normalize(): Vector2;
  84156. /**
  84157. * Gets a new Vector2 copied from the Vector2
  84158. * @returns a new Vector2
  84159. */
  84160. clone(): Vector2;
  84161. /**
  84162. * Gets a new Vector2(0, 0)
  84163. * @returns a new Vector2
  84164. */
  84165. static Zero(): Vector2;
  84166. /**
  84167. * Gets a new Vector2(1, 1)
  84168. * @returns a new Vector2
  84169. */
  84170. static One(): Vector2;
  84171. /**
  84172. * Gets a new Vector2 set from the given index element of the given array
  84173. * @param array defines the data source
  84174. * @param offset defines the offset in the data source
  84175. * @returns a new Vector2
  84176. */
  84177. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  84178. /**
  84179. * Sets "result" from the given index element of the given array
  84180. * @param array defines the data source
  84181. * @param offset defines the offset in the data source
  84182. * @param result defines the target vector
  84183. */
  84184. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  84185. /**
  84186. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  84187. * @param value1 defines 1st point of control
  84188. * @param value2 defines 2nd point of control
  84189. * @param value3 defines 3rd point of control
  84190. * @param value4 defines 4th point of control
  84191. * @param amount defines the interpolation factor
  84192. * @returns a new Vector2
  84193. */
  84194. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  84195. /**
  84196. * 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".
  84197. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  84198. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  84199. * @param value defines the value to clamp
  84200. * @param min defines the lower limit
  84201. * @param max defines the upper limit
  84202. * @returns a new Vector2
  84203. */
  84204. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  84205. /**
  84206. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  84207. * @param value1 defines the 1st control point
  84208. * @param tangent1 defines the outgoing tangent
  84209. * @param value2 defines the 2nd control point
  84210. * @param tangent2 defines the incoming tangent
  84211. * @param amount defines the interpolation factor
  84212. * @returns a new Vector2
  84213. */
  84214. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  84215. /**
  84216. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  84217. * @param start defines the start vector
  84218. * @param end defines the end vector
  84219. * @param amount defines the interpolation factor
  84220. * @returns a new Vector2
  84221. */
  84222. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  84223. /**
  84224. * Gets the dot product of the vector "left" and the vector "right"
  84225. * @param left defines first vector
  84226. * @param right defines second vector
  84227. * @returns the dot product (float)
  84228. */
  84229. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  84230. /**
  84231. * Returns a new Vector2 equal to the normalized given vector
  84232. * @param vector defines the vector to normalize
  84233. * @returns a new Vector2
  84234. */
  84235. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  84236. /**
  84237. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  84238. * @param left defines 1st vector
  84239. * @param right defines 2nd vector
  84240. * @returns a new Vector2
  84241. */
  84242. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  84243. /**
  84244. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  84245. * @param left defines 1st vector
  84246. * @param right defines 2nd vector
  84247. * @returns a new Vector2
  84248. */
  84249. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  84250. /**
  84251. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  84252. * @param vector defines the vector to transform
  84253. * @param transformation defines the matrix to apply
  84254. * @returns a new Vector2
  84255. */
  84256. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  84257. /**
  84258. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  84259. * @param vector defines the vector to transform
  84260. * @param transformation defines the matrix to apply
  84261. * @param result defines the target vector
  84262. */
  84263. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  84264. /**
  84265. * Determines if a given vector is included in a triangle
  84266. * @param p defines the vector to test
  84267. * @param p0 defines 1st triangle point
  84268. * @param p1 defines 2nd triangle point
  84269. * @param p2 defines 3rd triangle point
  84270. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  84271. */
  84272. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  84273. /**
  84274. * Gets the distance between the vectors "value1" and "value2"
  84275. * @param value1 defines first vector
  84276. * @param value2 defines second vector
  84277. * @returns the distance between vectors
  84278. */
  84279. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  84280. /**
  84281. * Returns the squared distance between the vectors "value1" and "value2"
  84282. * @param value1 defines first vector
  84283. * @param value2 defines second vector
  84284. * @returns the squared distance between vectors
  84285. */
  84286. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  84287. /**
  84288. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  84289. * @param value1 defines first vector
  84290. * @param value2 defines second vector
  84291. * @returns a new Vector2
  84292. */
  84293. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  84294. /**
  84295. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  84296. * @param p defines the middle point
  84297. * @param segA defines one point of the segment
  84298. * @param segB defines the other point of the segment
  84299. * @returns the shortest distance
  84300. */
  84301. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  84302. }
  84303. /**
  84304. * Class used to store (x,y,z) vector representation
  84305. * A Vector3 is the main object used in 3D geometry
  84306. * It can represent etiher the coordinates of a point the space, either a direction
  84307. * Reminder: js uses a left handed forward facing system
  84308. */
  84309. export class Vector3 {
  84310. private static _UpReadOnly;
  84311. private static _ZeroReadOnly;
  84312. /** @hidden */
  84313. _x: number;
  84314. /** @hidden */
  84315. _y: number;
  84316. /** @hidden */
  84317. _z: number;
  84318. /** @hidden */
  84319. _isDirty: boolean;
  84320. /** Gets or sets the x coordinate */
  84321. get x(): number;
  84322. set x(value: number);
  84323. /** Gets or sets the y coordinate */
  84324. get y(): number;
  84325. set y(value: number);
  84326. /** Gets or sets the z coordinate */
  84327. get z(): number;
  84328. set z(value: number);
  84329. /**
  84330. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  84331. * @param x defines the first coordinates (on X axis)
  84332. * @param y defines the second coordinates (on Y axis)
  84333. * @param z defines the third coordinates (on Z axis)
  84334. */
  84335. constructor(x?: number, y?: number, z?: number);
  84336. /**
  84337. * Creates a string representation of the Vector3
  84338. * @returns a string with the Vector3 coordinates.
  84339. */
  84340. toString(): string;
  84341. /**
  84342. * Gets the class name
  84343. * @returns the string "Vector3"
  84344. */
  84345. getClassName(): string;
  84346. /**
  84347. * Creates the Vector3 hash code
  84348. * @returns a number which tends to be unique between Vector3 instances
  84349. */
  84350. getHashCode(): number;
  84351. /**
  84352. * Creates an array containing three elements : the coordinates of the Vector3
  84353. * @returns a new array of numbers
  84354. */
  84355. asArray(): number[];
  84356. /**
  84357. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  84358. * @param array defines the destination array
  84359. * @param index defines the offset in the destination array
  84360. * @returns the current Vector3
  84361. */
  84362. toArray(array: FloatArray, index?: number): Vector3;
  84363. /**
  84364. * Update the current vector from an array
  84365. * @param array defines the destination array
  84366. * @param index defines the offset in the destination array
  84367. * @returns the current Vector3
  84368. */
  84369. fromArray(array: FloatArray, index?: number): Vector3;
  84370. /**
  84371. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  84372. * @returns a new Quaternion object, computed from the Vector3 coordinates
  84373. */
  84374. toQuaternion(): Quaternion;
  84375. /**
  84376. * Adds the given vector to the current Vector3
  84377. * @param otherVector defines the second operand
  84378. * @returns the current updated Vector3
  84379. */
  84380. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  84381. /**
  84382. * Adds the given coordinates to the current Vector3
  84383. * @param x defines the x coordinate of the operand
  84384. * @param y defines the y coordinate of the operand
  84385. * @param z defines the z coordinate of the operand
  84386. * @returns the current updated Vector3
  84387. */
  84388. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  84389. /**
  84390. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  84391. * @param otherVector defines the second operand
  84392. * @returns the resulting Vector3
  84393. */
  84394. add(otherVector: DeepImmutable<Vector3>): Vector3;
  84395. /**
  84396. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  84397. * @param otherVector defines the second operand
  84398. * @param result defines the Vector3 object where to store the result
  84399. * @returns the current Vector3
  84400. */
  84401. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84402. /**
  84403. * Subtract the given vector from the current Vector3
  84404. * @param otherVector defines the second operand
  84405. * @returns the current updated Vector3
  84406. */
  84407. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  84408. /**
  84409. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  84410. * @param otherVector defines the second operand
  84411. * @returns the resulting Vector3
  84412. */
  84413. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  84414. /**
  84415. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  84416. * @param otherVector defines the second operand
  84417. * @param result defines the Vector3 object where to store the result
  84418. * @returns the current Vector3
  84419. */
  84420. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84421. /**
  84422. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  84423. * @param x defines the x coordinate of the operand
  84424. * @param y defines the y coordinate of the operand
  84425. * @param z defines the z coordinate of the operand
  84426. * @returns the resulting Vector3
  84427. */
  84428. subtractFromFloats(x: number, y: number, z: number): Vector3;
  84429. /**
  84430. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  84431. * @param x defines the x coordinate of the operand
  84432. * @param y defines the y coordinate of the operand
  84433. * @param z defines the z coordinate of the operand
  84434. * @param result defines the Vector3 object where to store the result
  84435. * @returns the current Vector3
  84436. */
  84437. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  84438. /**
  84439. * Gets a new Vector3 set with the current Vector3 negated coordinates
  84440. * @returns a new Vector3
  84441. */
  84442. negate(): Vector3;
  84443. /**
  84444. * Negate this vector in place
  84445. * @returns this
  84446. */
  84447. negateInPlace(): Vector3;
  84448. /**
  84449. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  84450. * @param result defines the Vector3 object where to store the result
  84451. * @returns the current Vector3
  84452. */
  84453. negateToRef(result: Vector3): Vector3;
  84454. /**
  84455. * Multiplies the Vector3 coordinates by the float "scale"
  84456. * @param scale defines the multiplier factor
  84457. * @returns the current updated Vector3
  84458. */
  84459. scaleInPlace(scale: number): Vector3;
  84460. /**
  84461. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  84462. * @param scale defines the multiplier factor
  84463. * @returns a new Vector3
  84464. */
  84465. scale(scale: number): Vector3;
  84466. /**
  84467. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  84468. * @param scale defines the multiplier factor
  84469. * @param result defines the Vector3 object where to store the result
  84470. * @returns the current Vector3
  84471. */
  84472. scaleToRef(scale: number, result: Vector3): Vector3;
  84473. /**
  84474. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  84475. * @param scale defines the scale factor
  84476. * @param result defines the Vector3 object where to store the result
  84477. * @returns the unmodified current Vector3
  84478. */
  84479. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  84480. /**
  84481. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  84482. * @param origin defines the origin of the projection ray
  84483. * @param plane defines the plane to project to
  84484. * @returns the projected vector3
  84485. */
  84486. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  84487. /**
  84488. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  84489. * @param origin defines the origin of the projection ray
  84490. * @param plane defines the plane to project to
  84491. * @param result defines the Vector3 where to store the result
  84492. */
  84493. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  84494. /**
  84495. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  84496. * @param otherVector defines the second operand
  84497. * @returns true if both vectors are equals
  84498. */
  84499. equals(otherVector: DeepImmutable<Vector3>): boolean;
  84500. /**
  84501. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  84502. * @param otherVector defines the second operand
  84503. * @param epsilon defines the minimal distance to define values as equals
  84504. * @returns true if both vectors are distant less than epsilon
  84505. */
  84506. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  84507. /**
  84508. * Returns true if the current Vector3 coordinates equals the given floats
  84509. * @param x defines the x coordinate of the operand
  84510. * @param y defines the y coordinate of the operand
  84511. * @param z defines the z coordinate of the operand
  84512. * @returns true if both vectors are equals
  84513. */
  84514. equalsToFloats(x: number, y: number, z: number): boolean;
  84515. /**
  84516. * Multiplies the current Vector3 coordinates by the given ones
  84517. * @param otherVector defines the second operand
  84518. * @returns the current updated Vector3
  84519. */
  84520. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  84521. /**
  84522. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  84523. * @param otherVector defines the second operand
  84524. * @returns the new Vector3
  84525. */
  84526. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  84527. /**
  84528. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  84529. * @param otherVector defines the second operand
  84530. * @param result defines the Vector3 object where to store the result
  84531. * @returns the current Vector3
  84532. */
  84533. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84534. /**
  84535. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  84536. * @param x defines the x coordinate of the operand
  84537. * @param y defines the y coordinate of the operand
  84538. * @param z defines the z coordinate of the operand
  84539. * @returns the new Vector3
  84540. */
  84541. multiplyByFloats(x: number, y: number, z: number): Vector3;
  84542. /**
  84543. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  84544. * @param otherVector defines the second operand
  84545. * @returns the new Vector3
  84546. */
  84547. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  84548. /**
  84549. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  84550. * @param otherVector defines the second operand
  84551. * @param result defines the Vector3 object where to store the result
  84552. * @returns the current Vector3
  84553. */
  84554. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84555. /**
  84556. * Divides the current Vector3 coordinates by the given ones.
  84557. * @param otherVector defines the second operand
  84558. * @returns the current updated Vector3
  84559. */
  84560. divideInPlace(otherVector: Vector3): Vector3;
  84561. /**
  84562. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  84563. * @param other defines the second operand
  84564. * @returns the current updated Vector3
  84565. */
  84566. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  84567. /**
  84568. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  84569. * @param other defines the second operand
  84570. * @returns the current updated Vector3
  84571. */
  84572. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  84573. /**
  84574. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  84575. * @param x defines the x coordinate of the operand
  84576. * @param y defines the y coordinate of the operand
  84577. * @param z defines the z coordinate of the operand
  84578. * @returns the current updated Vector3
  84579. */
  84580. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  84581. /**
  84582. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  84583. * @param x defines the x coordinate of the operand
  84584. * @param y defines the y coordinate of the operand
  84585. * @param z defines the z coordinate of the operand
  84586. * @returns the current updated Vector3
  84587. */
  84588. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  84589. /**
  84590. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  84591. * Check if is non uniform within a certain amount of decimal places to account for this
  84592. * @param epsilon the amount the values can differ
  84593. * @returns if the the vector is non uniform to a certain number of decimal places
  84594. */
  84595. isNonUniformWithinEpsilon(epsilon: number): boolean;
  84596. /**
  84597. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  84598. */
  84599. get isNonUniform(): boolean;
  84600. /**
  84601. * Gets a new Vector3 from current Vector3 floored values
  84602. * @returns a new Vector3
  84603. */
  84604. floor(): Vector3;
  84605. /**
  84606. * Gets a new Vector3 from current Vector3 floored values
  84607. * @returns a new Vector3
  84608. */
  84609. fract(): Vector3;
  84610. /**
  84611. * Gets the length of the Vector3
  84612. * @returns the length of the Vector3
  84613. */
  84614. length(): number;
  84615. /**
  84616. * Gets the squared length of the Vector3
  84617. * @returns squared length of the Vector3
  84618. */
  84619. lengthSquared(): number;
  84620. /**
  84621. * Normalize the current Vector3.
  84622. * Please note that this is an in place operation.
  84623. * @returns the current updated Vector3
  84624. */
  84625. normalize(): Vector3;
  84626. /**
  84627. * Reorders the x y z properties of the vector in place
  84628. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  84629. * @returns the current updated vector
  84630. */
  84631. reorderInPlace(order: string): this;
  84632. /**
  84633. * Rotates the vector around 0,0,0 by a quaternion
  84634. * @param quaternion the rotation quaternion
  84635. * @param result vector to store the result
  84636. * @returns the resulting vector
  84637. */
  84638. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  84639. /**
  84640. * Rotates a vector around a given point
  84641. * @param quaternion the rotation quaternion
  84642. * @param point the point to rotate around
  84643. * @param result vector to store the result
  84644. * @returns the resulting vector
  84645. */
  84646. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  84647. /**
  84648. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  84649. * The cross product is then orthogonal to both current and "other"
  84650. * @param other defines the right operand
  84651. * @returns the cross product
  84652. */
  84653. cross(other: Vector3): Vector3;
  84654. /**
  84655. * Normalize the current Vector3 with the given input length.
  84656. * Please note that this is an in place operation.
  84657. * @param len the length of the vector
  84658. * @returns the current updated Vector3
  84659. */
  84660. normalizeFromLength(len: number): Vector3;
  84661. /**
  84662. * Normalize the current Vector3 to a new vector
  84663. * @returns the new Vector3
  84664. */
  84665. normalizeToNew(): Vector3;
  84666. /**
  84667. * Normalize the current Vector3 to the reference
  84668. * @param reference define the Vector3 to update
  84669. * @returns the updated Vector3
  84670. */
  84671. normalizeToRef(reference: Vector3): Vector3;
  84672. /**
  84673. * Creates a new Vector3 copied from the current Vector3
  84674. * @returns the new Vector3
  84675. */
  84676. clone(): Vector3;
  84677. /**
  84678. * Copies the given vector coordinates to the current Vector3 ones
  84679. * @param source defines the source Vector3
  84680. * @returns the current updated Vector3
  84681. */
  84682. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  84683. /**
  84684. * Copies the given floats to the current Vector3 coordinates
  84685. * @param x defines the x coordinate of the operand
  84686. * @param y defines the y coordinate of the operand
  84687. * @param z defines the z coordinate of the operand
  84688. * @returns the current updated Vector3
  84689. */
  84690. copyFromFloats(x: number, y: number, z: number): Vector3;
  84691. /**
  84692. * Copies the given floats to the current Vector3 coordinates
  84693. * @param x defines the x coordinate of the operand
  84694. * @param y defines the y coordinate of the operand
  84695. * @param z defines the z coordinate of the operand
  84696. * @returns the current updated Vector3
  84697. */
  84698. set(x: number, y: number, z: number): Vector3;
  84699. /**
  84700. * Copies the given float to the current Vector3 coordinates
  84701. * @param v defines the x, y and z coordinates of the operand
  84702. * @returns the current updated Vector3
  84703. */
  84704. setAll(v: number): Vector3;
  84705. /**
  84706. * Get the clip factor between two vectors
  84707. * @param vector0 defines the first operand
  84708. * @param vector1 defines the second operand
  84709. * @param axis defines the axis to use
  84710. * @param size defines the size along the axis
  84711. * @returns the clip factor
  84712. */
  84713. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  84714. /**
  84715. * Get angle between two vectors
  84716. * @param vector0 angle between vector0 and vector1
  84717. * @param vector1 angle between vector0 and vector1
  84718. * @param normal direction of the normal
  84719. * @return the angle between vector0 and vector1
  84720. */
  84721. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  84722. /**
  84723. * Returns a new Vector3 set from the index "offset" of the given array
  84724. * @param array defines the source array
  84725. * @param offset defines the offset in the source array
  84726. * @returns the new Vector3
  84727. */
  84728. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  84729. /**
  84730. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  84731. * @param array defines the source array
  84732. * @param offset defines the offset in the source array
  84733. * @returns the new Vector3
  84734. * @deprecated Please use FromArray instead.
  84735. */
  84736. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  84737. /**
  84738. * Sets the given vector "result" with the element values from the index "offset" of the given array
  84739. * @param array defines the source array
  84740. * @param offset defines the offset in the source array
  84741. * @param result defines the Vector3 where to store the result
  84742. */
  84743. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  84744. /**
  84745. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  84746. * @param array defines the source array
  84747. * @param offset defines the offset in the source array
  84748. * @param result defines the Vector3 where to store the result
  84749. * @deprecated Please use FromArrayToRef instead.
  84750. */
  84751. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  84752. /**
  84753. * Sets the given vector "result" with the given floats.
  84754. * @param x defines the x coordinate of the source
  84755. * @param y defines the y coordinate of the source
  84756. * @param z defines the z coordinate of the source
  84757. * @param result defines the Vector3 where to store the result
  84758. */
  84759. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  84760. /**
  84761. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  84762. * @returns a new empty Vector3
  84763. */
  84764. static Zero(): Vector3;
  84765. /**
  84766. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  84767. * @returns a new unit Vector3
  84768. */
  84769. static One(): Vector3;
  84770. /**
  84771. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  84772. * @returns a new up Vector3
  84773. */
  84774. static Up(): Vector3;
  84775. /**
  84776. * Gets a up Vector3 that must not be updated
  84777. */
  84778. static get UpReadOnly(): DeepImmutable<Vector3>;
  84779. /**
  84780. * Gets a zero Vector3 that must not be updated
  84781. */
  84782. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  84783. /**
  84784. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  84785. * @returns a new down Vector3
  84786. */
  84787. static Down(): Vector3;
  84788. /**
  84789. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  84790. * @param rightHandedSystem is the scene right-handed (negative z)
  84791. * @returns a new forward Vector3
  84792. */
  84793. static Forward(rightHandedSystem?: boolean): Vector3;
  84794. /**
  84795. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  84796. * @param rightHandedSystem is the scene right-handed (negative-z)
  84797. * @returns a new forward Vector3
  84798. */
  84799. static Backward(rightHandedSystem?: boolean): Vector3;
  84800. /**
  84801. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  84802. * @returns a new right Vector3
  84803. */
  84804. static Right(): Vector3;
  84805. /**
  84806. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  84807. * @returns a new left Vector3
  84808. */
  84809. static Left(): Vector3;
  84810. /**
  84811. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  84812. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  84813. * @param vector defines the Vector3 to transform
  84814. * @param transformation defines the transformation matrix
  84815. * @returns the transformed Vector3
  84816. */
  84817. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  84818. /**
  84819. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  84820. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  84821. * @param vector defines the Vector3 to transform
  84822. * @param transformation defines the transformation matrix
  84823. * @param result defines the Vector3 where to store the result
  84824. */
  84825. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84826. /**
  84827. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  84828. * This method computes tranformed coordinates only, not transformed direction vectors
  84829. * @param x define the x coordinate of the source vector
  84830. * @param y define the y coordinate of the source vector
  84831. * @param z define the z coordinate of the source vector
  84832. * @param transformation defines the transformation matrix
  84833. * @param result defines the Vector3 where to store the result
  84834. */
  84835. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84836. /**
  84837. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  84838. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84839. * @param vector defines the Vector3 to transform
  84840. * @param transformation defines the transformation matrix
  84841. * @returns the new Vector3
  84842. */
  84843. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  84844. /**
  84845. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  84846. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84847. * @param vector defines the Vector3 to transform
  84848. * @param transformation defines the transformation matrix
  84849. * @param result defines the Vector3 where to store the result
  84850. */
  84851. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84852. /**
  84853. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  84854. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84855. * @param x define the x coordinate of the source vector
  84856. * @param y define the y coordinate of the source vector
  84857. * @param z define the z coordinate of the source vector
  84858. * @param transformation defines the transformation matrix
  84859. * @param result defines the Vector3 where to store the result
  84860. */
  84861. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84862. /**
  84863. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  84864. * @param value1 defines the first control point
  84865. * @param value2 defines the second control point
  84866. * @param value3 defines the third control point
  84867. * @param value4 defines the fourth control point
  84868. * @param amount defines the amount on the spline to use
  84869. * @returns the new Vector3
  84870. */
  84871. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  84872. /**
  84873. * 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"
  84874. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  84875. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  84876. * @param value defines the current value
  84877. * @param min defines the lower range value
  84878. * @param max defines the upper range value
  84879. * @returns the new Vector3
  84880. */
  84881. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  84882. /**
  84883. * 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"
  84884. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  84885. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  84886. * @param value defines the current value
  84887. * @param min defines the lower range value
  84888. * @param max defines the upper range value
  84889. * @param result defines the Vector3 where to store the result
  84890. */
  84891. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  84892. /**
  84893. * Checks if a given vector is inside a specific range
  84894. * @param v defines the vector to test
  84895. * @param min defines the minimum range
  84896. * @param max defines the maximum range
  84897. */
  84898. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  84899. /**
  84900. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  84901. * @param value1 defines the first control point
  84902. * @param tangent1 defines the first tangent vector
  84903. * @param value2 defines the second control point
  84904. * @param tangent2 defines the second tangent vector
  84905. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  84906. * @returns the new Vector3
  84907. */
  84908. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  84909. /**
  84910. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  84911. * @param start defines the start value
  84912. * @param end defines the end value
  84913. * @param amount max defines amount between both (between 0 and 1)
  84914. * @returns the new Vector3
  84915. */
  84916. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  84917. /**
  84918. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  84919. * @param start defines the start value
  84920. * @param end defines the end value
  84921. * @param amount max defines amount between both (between 0 and 1)
  84922. * @param result defines the Vector3 where to store the result
  84923. */
  84924. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  84925. /**
  84926. * Returns the dot product (float) between the vectors "left" and "right"
  84927. * @param left defines the left operand
  84928. * @param right defines the right operand
  84929. * @returns the dot product
  84930. */
  84931. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  84932. /**
  84933. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  84934. * The cross product is then orthogonal to both "left" and "right"
  84935. * @param left defines the left operand
  84936. * @param right defines the right operand
  84937. * @returns the cross product
  84938. */
  84939. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  84940. /**
  84941. * Sets the given vector "result" with the cross product of "left" and "right"
  84942. * The cross product is then orthogonal to both "left" and "right"
  84943. * @param left defines the left operand
  84944. * @param right defines the right operand
  84945. * @param result defines the Vector3 where to store the result
  84946. */
  84947. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  84948. /**
  84949. * Returns a new Vector3 as the normalization of the given vector
  84950. * @param vector defines the Vector3 to normalize
  84951. * @returns the new Vector3
  84952. */
  84953. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  84954. /**
  84955. * Sets the given vector "result" with the normalization of the given first vector
  84956. * @param vector defines the Vector3 to normalize
  84957. * @param result defines the Vector3 where to store the result
  84958. */
  84959. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  84960. /**
  84961. * Project a Vector3 onto screen space
  84962. * @param vector defines the Vector3 to project
  84963. * @param world defines the world matrix to use
  84964. * @param transform defines the transform (view x projection) matrix to use
  84965. * @param viewport defines the screen viewport to use
  84966. * @returns the new Vector3
  84967. */
  84968. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  84969. /**
  84970. * Project a Vector3 onto screen space to reference
  84971. * @param vector defines the Vector3 to project
  84972. * @param world defines the world matrix to use
  84973. * @param transform defines the transform (view x projection) matrix to use
  84974. * @param viewport defines the screen viewport to use
  84975. * @param result the vector in which the screen space will be stored
  84976. * @returns the new Vector3
  84977. */
  84978. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  84979. /** @hidden */
  84980. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  84981. /**
  84982. * Unproject from screen space to object space
  84983. * @param source defines the screen space Vector3 to use
  84984. * @param viewportWidth defines the current width of the viewport
  84985. * @param viewportHeight defines the current height of the viewport
  84986. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84987. * @param transform defines the transform (view x projection) matrix to use
  84988. * @returns the new Vector3
  84989. */
  84990. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  84991. /**
  84992. * Unproject from screen space to object space
  84993. * @param source defines the screen space Vector3 to use
  84994. * @param viewportWidth defines the current width of the viewport
  84995. * @param viewportHeight defines the current height of the viewport
  84996. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84997. * @param view defines the view matrix to use
  84998. * @param projection defines the projection matrix to use
  84999. * @returns the new Vector3
  85000. */
  85001. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  85002. /**
  85003. * Unproject from screen space to object space
  85004. * @param source defines the screen space Vector3 to use
  85005. * @param viewportWidth defines the current width of the viewport
  85006. * @param viewportHeight defines the current height of the viewport
  85007. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85008. * @param view defines the view matrix to use
  85009. * @param projection defines the projection matrix to use
  85010. * @param result defines the Vector3 where to store the result
  85011. */
  85012. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  85013. /**
  85014. * Unproject from screen space to object space
  85015. * @param sourceX defines the screen space x coordinate to use
  85016. * @param sourceY defines the screen space y coordinate to use
  85017. * @param sourceZ defines the screen space z coordinate to use
  85018. * @param viewportWidth defines the current width of the viewport
  85019. * @param viewportHeight defines the current height of the viewport
  85020. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85021. * @param view defines the view matrix to use
  85022. * @param projection defines the projection matrix to use
  85023. * @param result defines the Vector3 where to store the result
  85024. */
  85025. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  85026. /**
  85027. * Gets the minimal coordinate values between two Vector3
  85028. * @param left defines the first operand
  85029. * @param right defines the second operand
  85030. * @returns the new Vector3
  85031. */
  85032. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  85033. /**
  85034. * Gets the maximal coordinate values between two Vector3
  85035. * @param left defines the first operand
  85036. * @param right defines the second operand
  85037. * @returns the new Vector3
  85038. */
  85039. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  85040. /**
  85041. * Returns the distance between the vectors "value1" and "value2"
  85042. * @param value1 defines the first operand
  85043. * @param value2 defines the second operand
  85044. * @returns the distance
  85045. */
  85046. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  85047. /**
  85048. * Returns the squared distance between the vectors "value1" and "value2"
  85049. * @param value1 defines the first operand
  85050. * @param value2 defines the second operand
  85051. * @returns the squared distance
  85052. */
  85053. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  85054. /**
  85055. * Returns a new Vector3 located at the center between "value1" and "value2"
  85056. * @param value1 defines the first operand
  85057. * @param value2 defines the second operand
  85058. * @returns the new Vector3
  85059. */
  85060. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  85061. /**
  85062. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  85063. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  85064. * to something in order to rotate it from its local system to the given target system
  85065. * Note: axis1, axis2 and axis3 are normalized during this operation
  85066. * @param axis1 defines the first axis
  85067. * @param axis2 defines the second axis
  85068. * @param axis3 defines the third axis
  85069. * @returns a new Vector3
  85070. */
  85071. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  85072. /**
  85073. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  85074. * @param axis1 defines the first axis
  85075. * @param axis2 defines the second axis
  85076. * @param axis3 defines the third axis
  85077. * @param ref defines the Vector3 where to store the result
  85078. */
  85079. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  85080. }
  85081. /**
  85082. * Vector4 class created for EulerAngle class conversion to Quaternion
  85083. */
  85084. export class Vector4 {
  85085. /** x value of the vector */
  85086. x: number;
  85087. /** y value of the vector */
  85088. y: number;
  85089. /** z value of the vector */
  85090. z: number;
  85091. /** w value of the vector */
  85092. w: number;
  85093. /**
  85094. * Creates a Vector4 object from the given floats.
  85095. * @param x x value of the vector
  85096. * @param y y value of the vector
  85097. * @param z z value of the vector
  85098. * @param w w value of the vector
  85099. */
  85100. constructor(
  85101. /** x value of the vector */
  85102. x: number,
  85103. /** y value of the vector */
  85104. y: number,
  85105. /** z value of the vector */
  85106. z: number,
  85107. /** w value of the vector */
  85108. w: number);
  85109. /**
  85110. * Returns the string with the Vector4 coordinates.
  85111. * @returns a string containing all the vector values
  85112. */
  85113. toString(): string;
  85114. /**
  85115. * Returns the string "Vector4".
  85116. * @returns "Vector4"
  85117. */
  85118. getClassName(): string;
  85119. /**
  85120. * Returns the Vector4 hash code.
  85121. * @returns a unique hash code
  85122. */
  85123. getHashCode(): number;
  85124. /**
  85125. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  85126. * @returns the resulting array
  85127. */
  85128. asArray(): number[];
  85129. /**
  85130. * Populates the given array from the given index with the Vector4 coordinates.
  85131. * @param array array to populate
  85132. * @param index index of the array to start at (default: 0)
  85133. * @returns the Vector4.
  85134. */
  85135. toArray(array: FloatArray, index?: number): Vector4;
  85136. /**
  85137. * Update the current vector from an array
  85138. * @param array defines the destination array
  85139. * @param index defines the offset in the destination array
  85140. * @returns the current Vector3
  85141. */
  85142. fromArray(array: FloatArray, index?: number): Vector4;
  85143. /**
  85144. * Adds the given vector to the current Vector4.
  85145. * @param otherVector the vector to add
  85146. * @returns the updated Vector4.
  85147. */
  85148. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  85149. /**
  85150. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  85151. * @param otherVector the vector to add
  85152. * @returns the resulting vector
  85153. */
  85154. add(otherVector: DeepImmutable<Vector4>): Vector4;
  85155. /**
  85156. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  85157. * @param otherVector the vector to add
  85158. * @param result the vector to store the result
  85159. * @returns the current Vector4.
  85160. */
  85161. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85162. /**
  85163. * Subtract in place the given vector from the current Vector4.
  85164. * @param otherVector the vector to subtract
  85165. * @returns the updated Vector4.
  85166. */
  85167. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  85168. /**
  85169. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  85170. * @param otherVector the vector to add
  85171. * @returns the new vector with the result
  85172. */
  85173. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  85174. /**
  85175. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  85176. * @param otherVector the vector to subtract
  85177. * @param result the vector to store the result
  85178. * @returns the current Vector4.
  85179. */
  85180. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85181. /**
  85182. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  85183. */
  85184. /**
  85185. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  85186. * @param x value to subtract
  85187. * @param y value to subtract
  85188. * @param z value to subtract
  85189. * @param w value to subtract
  85190. * @returns new vector containing the result
  85191. */
  85192. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  85193. /**
  85194. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  85195. * @param x value to subtract
  85196. * @param y value to subtract
  85197. * @param z value to subtract
  85198. * @param w value to subtract
  85199. * @param result the vector to store the result in
  85200. * @returns the current Vector4.
  85201. */
  85202. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  85203. /**
  85204. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  85205. * @returns a new vector with the negated values
  85206. */
  85207. negate(): Vector4;
  85208. /**
  85209. * Negate this vector in place
  85210. * @returns this
  85211. */
  85212. negateInPlace(): Vector4;
  85213. /**
  85214. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  85215. * @param result defines the Vector3 object where to store the result
  85216. * @returns the current Vector4
  85217. */
  85218. negateToRef(result: Vector4): Vector4;
  85219. /**
  85220. * Multiplies the current Vector4 coordinates by scale (float).
  85221. * @param scale the number to scale with
  85222. * @returns the updated Vector4.
  85223. */
  85224. scaleInPlace(scale: number): Vector4;
  85225. /**
  85226. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  85227. * @param scale the number to scale with
  85228. * @returns a new vector with the result
  85229. */
  85230. scale(scale: number): Vector4;
  85231. /**
  85232. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  85233. * @param scale the number to scale with
  85234. * @param result a vector to store the result in
  85235. * @returns the current Vector4.
  85236. */
  85237. scaleToRef(scale: number, result: Vector4): Vector4;
  85238. /**
  85239. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  85240. * @param scale defines the scale factor
  85241. * @param result defines the Vector4 object where to store the result
  85242. * @returns the unmodified current Vector4
  85243. */
  85244. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  85245. /**
  85246. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  85247. * @param otherVector the vector to compare against
  85248. * @returns true if they are equal
  85249. */
  85250. equals(otherVector: DeepImmutable<Vector4>): boolean;
  85251. /**
  85252. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  85253. * @param otherVector vector to compare against
  85254. * @param epsilon (Default: very small number)
  85255. * @returns true if they are equal
  85256. */
  85257. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  85258. /**
  85259. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  85260. * @param x x value to compare against
  85261. * @param y y value to compare against
  85262. * @param z z value to compare against
  85263. * @param w w value to compare against
  85264. * @returns true if equal
  85265. */
  85266. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  85267. /**
  85268. * Multiplies in place the current Vector4 by the given one.
  85269. * @param otherVector vector to multiple with
  85270. * @returns the updated Vector4.
  85271. */
  85272. multiplyInPlace(otherVector: Vector4): Vector4;
  85273. /**
  85274. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  85275. * @param otherVector vector to multiple with
  85276. * @returns resulting new vector
  85277. */
  85278. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  85279. /**
  85280. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  85281. * @param otherVector vector to multiple with
  85282. * @param result vector to store the result
  85283. * @returns the current Vector4.
  85284. */
  85285. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85286. /**
  85287. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  85288. * @param x x value multiply with
  85289. * @param y y value multiply with
  85290. * @param z z value multiply with
  85291. * @param w w value multiply with
  85292. * @returns resulting new vector
  85293. */
  85294. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  85295. /**
  85296. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  85297. * @param otherVector vector to devide with
  85298. * @returns resulting new vector
  85299. */
  85300. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  85301. /**
  85302. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  85303. * @param otherVector vector to devide with
  85304. * @param result vector to store the result
  85305. * @returns the current Vector4.
  85306. */
  85307. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85308. /**
  85309. * Divides the current Vector3 coordinates by the given ones.
  85310. * @param otherVector vector to devide with
  85311. * @returns the updated Vector3.
  85312. */
  85313. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  85314. /**
  85315. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  85316. * @param other defines the second operand
  85317. * @returns the current updated Vector4
  85318. */
  85319. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  85320. /**
  85321. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  85322. * @param other defines the second operand
  85323. * @returns the current updated Vector4
  85324. */
  85325. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  85326. /**
  85327. * Gets a new Vector4 from current Vector4 floored values
  85328. * @returns a new Vector4
  85329. */
  85330. floor(): Vector4;
  85331. /**
  85332. * Gets a new Vector4 from current Vector3 floored values
  85333. * @returns a new Vector4
  85334. */
  85335. fract(): Vector4;
  85336. /**
  85337. * Returns the Vector4 length (float).
  85338. * @returns the length
  85339. */
  85340. length(): number;
  85341. /**
  85342. * Returns the Vector4 squared length (float).
  85343. * @returns the length squared
  85344. */
  85345. lengthSquared(): number;
  85346. /**
  85347. * Normalizes in place the Vector4.
  85348. * @returns the updated Vector4.
  85349. */
  85350. normalize(): Vector4;
  85351. /**
  85352. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  85353. * @returns this converted to a new vector3
  85354. */
  85355. toVector3(): Vector3;
  85356. /**
  85357. * Returns a new Vector4 copied from the current one.
  85358. * @returns the new cloned vector
  85359. */
  85360. clone(): Vector4;
  85361. /**
  85362. * Updates the current Vector4 with the given one coordinates.
  85363. * @param source the source vector to copy from
  85364. * @returns the updated Vector4.
  85365. */
  85366. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  85367. /**
  85368. * Updates the current Vector4 coordinates with the given floats.
  85369. * @param x float to copy from
  85370. * @param y float to copy from
  85371. * @param z float to copy from
  85372. * @param w float to copy from
  85373. * @returns the updated Vector4.
  85374. */
  85375. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  85376. /**
  85377. * Updates the current Vector4 coordinates with the given floats.
  85378. * @param x float to set from
  85379. * @param y float to set from
  85380. * @param z float to set from
  85381. * @param w float to set from
  85382. * @returns the updated Vector4.
  85383. */
  85384. set(x: number, y: number, z: number, w: number): Vector4;
  85385. /**
  85386. * Copies the given float to the current Vector3 coordinates
  85387. * @param v defines the x, y, z and w coordinates of the operand
  85388. * @returns the current updated Vector3
  85389. */
  85390. setAll(v: number): Vector4;
  85391. /**
  85392. * Returns a new Vector4 set from the starting index of the given array.
  85393. * @param array the array to pull values from
  85394. * @param offset the offset into the array to start at
  85395. * @returns the new vector
  85396. */
  85397. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  85398. /**
  85399. * Updates the given vector "result" from the starting index of the given array.
  85400. * @param array the array to pull values from
  85401. * @param offset the offset into the array to start at
  85402. * @param result the vector to store the result in
  85403. */
  85404. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  85405. /**
  85406. * Updates the given vector "result" from the starting index of the given Float32Array.
  85407. * @param array the array to pull values from
  85408. * @param offset the offset into the array to start at
  85409. * @param result the vector to store the result in
  85410. */
  85411. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  85412. /**
  85413. * Updates the given vector "result" coordinates from the given floats.
  85414. * @param x float to set from
  85415. * @param y float to set from
  85416. * @param z float to set from
  85417. * @param w float to set from
  85418. * @param result the vector to the floats in
  85419. */
  85420. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  85421. /**
  85422. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  85423. * @returns the new vector
  85424. */
  85425. static Zero(): Vector4;
  85426. /**
  85427. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  85428. * @returns the new vector
  85429. */
  85430. static One(): Vector4;
  85431. /**
  85432. * Returns a new normalized Vector4 from the given one.
  85433. * @param vector the vector to normalize
  85434. * @returns the vector
  85435. */
  85436. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  85437. /**
  85438. * Updates the given vector "result" from the normalization of the given one.
  85439. * @param vector the vector to normalize
  85440. * @param result the vector to store the result in
  85441. */
  85442. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  85443. /**
  85444. * Returns a vector with the minimum values from the left and right vectors
  85445. * @param left left vector to minimize
  85446. * @param right right vector to minimize
  85447. * @returns a new vector with the minimum of the left and right vector values
  85448. */
  85449. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  85450. /**
  85451. * Returns a vector with the maximum values from the left and right vectors
  85452. * @param left left vector to maximize
  85453. * @param right right vector to maximize
  85454. * @returns a new vector with the maximum of the left and right vector values
  85455. */
  85456. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  85457. /**
  85458. * Returns the distance (float) between the vectors "value1" and "value2".
  85459. * @param value1 value to calulate the distance between
  85460. * @param value2 value to calulate the distance between
  85461. * @return the distance between the two vectors
  85462. */
  85463. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  85464. /**
  85465. * Returns the squared distance (float) between the vectors "value1" and "value2".
  85466. * @param value1 value to calulate the distance between
  85467. * @param value2 value to calulate the distance between
  85468. * @return the distance between the two vectors squared
  85469. */
  85470. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  85471. /**
  85472. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  85473. * @param value1 value to calulate the center between
  85474. * @param value2 value to calulate the center between
  85475. * @return the center between the two vectors
  85476. */
  85477. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  85478. /**
  85479. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  85480. * This methods computes transformed normalized direction vectors only.
  85481. * @param vector the vector to transform
  85482. * @param transformation the transformation matrix to apply
  85483. * @returns the new vector
  85484. */
  85485. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  85486. /**
  85487. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  85488. * This methods computes transformed normalized direction vectors only.
  85489. * @param vector the vector to transform
  85490. * @param transformation the transformation matrix to apply
  85491. * @param result the vector to store the result in
  85492. */
  85493. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  85494. /**
  85495. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  85496. * This methods computes transformed normalized direction vectors only.
  85497. * @param x value to transform
  85498. * @param y value to transform
  85499. * @param z value to transform
  85500. * @param w value to transform
  85501. * @param transformation the transformation matrix to apply
  85502. * @param result the vector to store the results in
  85503. */
  85504. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  85505. /**
  85506. * Creates a new Vector4 from a Vector3
  85507. * @param source defines the source data
  85508. * @param w defines the 4th component (default is 0)
  85509. * @returns a new Vector4
  85510. */
  85511. static FromVector3(source: Vector3, w?: number): Vector4;
  85512. }
  85513. /**
  85514. * Class used to store quaternion data
  85515. * @see https://en.wikipedia.org/wiki/Quaternion
  85516. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  85517. */
  85518. export class Quaternion {
  85519. /** @hidden */
  85520. _x: number;
  85521. /** @hidden */
  85522. _y: number;
  85523. /** @hidden */
  85524. _z: number;
  85525. /** @hidden */
  85526. _w: number;
  85527. /** @hidden */
  85528. _isDirty: boolean;
  85529. /** Gets or sets the x coordinate */
  85530. get x(): number;
  85531. set x(value: number);
  85532. /** Gets or sets the y coordinate */
  85533. get y(): number;
  85534. set y(value: number);
  85535. /** Gets or sets the z coordinate */
  85536. get z(): number;
  85537. set z(value: number);
  85538. /** Gets or sets the w coordinate */
  85539. get w(): number;
  85540. set w(value: number);
  85541. /**
  85542. * Creates a new Quaternion from the given floats
  85543. * @param x defines the first component (0 by default)
  85544. * @param y defines the second component (0 by default)
  85545. * @param z defines the third component (0 by default)
  85546. * @param w defines the fourth component (1.0 by default)
  85547. */
  85548. constructor(x?: number, y?: number, z?: number, w?: number);
  85549. /**
  85550. * Gets a string representation for the current quaternion
  85551. * @returns a string with the Quaternion coordinates
  85552. */
  85553. toString(): string;
  85554. /**
  85555. * Gets the class name of the quaternion
  85556. * @returns the string "Quaternion"
  85557. */
  85558. getClassName(): string;
  85559. /**
  85560. * Gets a hash code for this quaternion
  85561. * @returns the quaternion hash code
  85562. */
  85563. getHashCode(): number;
  85564. /**
  85565. * Copy the quaternion to an array
  85566. * @returns a new array populated with 4 elements from the quaternion coordinates
  85567. */
  85568. asArray(): number[];
  85569. /**
  85570. * Check if two quaternions are equals
  85571. * @param otherQuaternion defines the second operand
  85572. * @return true if the current quaternion and the given one coordinates are strictly equals
  85573. */
  85574. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  85575. /**
  85576. * Gets a boolean if two quaternions are equals (using an epsilon value)
  85577. * @param otherQuaternion defines the other quaternion
  85578. * @param epsilon defines the minimal distance to consider equality
  85579. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  85580. */
  85581. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  85582. /**
  85583. * Clone the current quaternion
  85584. * @returns a new quaternion copied from the current one
  85585. */
  85586. clone(): Quaternion;
  85587. /**
  85588. * Copy a quaternion to the current one
  85589. * @param other defines the other quaternion
  85590. * @returns the updated current quaternion
  85591. */
  85592. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  85593. /**
  85594. * Updates the current quaternion with the given float coordinates
  85595. * @param x defines the x coordinate
  85596. * @param y defines the y coordinate
  85597. * @param z defines the z coordinate
  85598. * @param w defines the w coordinate
  85599. * @returns the updated current quaternion
  85600. */
  85601. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  85602. /**
  85603. * Updates the current quaternion from the given float coordinates
  85604. * @param x defines the x coordinate
  85605. * @param y defines the y coordinate
  85606. * @param z defines the z coordinate
  85607. * @param w defines the w coordinate
  85608. * @returns the updated current quaternion
  85609. */
  85610. set(x: number, y: number, z: number, w: number): Quaternion;
  85611. /**
  85612. * Adds two quaternions
  85613. * @param other defines the second operand
  85614. * @returns a new quaternion as the addition result of the given one and the current quaternion
  85615. */
  85616. add(other: DeepImmutable<Quaternion>): Quaternion;
  85617. /**
  85618. * Add a quaternion to the current one
  85619. * @param other defines the quaternion to add
  85620. * @returns the current quaternion
  85621. */
  85622. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  85623. /**
  85624. * Subtract two quaternions
  85625. * @param other defines the second operand
  85626. * @returns a new quaternion as the subtraction result of the given one from the current one
  85627. */
  85628. subtract(other: Quaternion): Quaternion;
  85629. /**
  85630. * Multiplies the current quaternion by a scale factor
  85631. * @param value defines the scale factor
  85632. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  85633. */
  85634. scale(value: number): Quaternion;
  85635. /**
  85636. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  85637. * @param scale defines the scale factor
  85638. * @param result defines the Quaternion object where to store the result
  85639. * @returns the unmodified current quaternion
  85640. */
  85641. scaleToRef(scale: number, result: Quaternion): Quaternion;
  85642. /**
  85643. * Multiplies in place the current quaternion by a scale factor
  85644. * @param value defines the scale factor
  85645. * @returns the current modified quaternion
  85646. */
  85647. scaleInPlace(value: number): Quaternion;
  85648. /**
  85649. * Scale the current quaternion values by a factor and add the result to a given quaternion
  85650. * @param scale defines the scale factor
  85651. * @param result defines the Quaternion object where to store the result
  85652. * @returns the unmodified current quaternion
  85653. */
  85654. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  85655. /**
  85656. * Multiplies two quaternions
  85657. * @param q1 defines the second operand
  85658. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  85659. */
  85660. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  85661. /**
  85662. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  85663. * @param q1 defines the second operand
  85664. * @param result defines the target quaternion
  85665. * @returns the current quaternion
  85666. */
  85667. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  85668. /**
  85669. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  85670. * @param q1 defines the second operand
  85671. * @returns the currentupdated quaternion
  85672. */
  85673. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  85674. /**
  85675. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  85676. * @param ref defines the target quaternion
  85677. * @returns the current quaternion
  85678. */
  85679. conjugateToRef(ref: Quaternion): Quaternion;
  85680. /**
  85681. * Conjugates in place (1-q) the current quaternion
  85682. * @returns the current updated quaternion
  85683. */
  85684. conjugateInPlace(): Quaternion;
  85685. /**
  85686. * Conjugates in place (1-q) the current quaternion
  85687. * @returns a new quaternion
  85688. */
  85689. conjugate(): Quaternion;
  85690. /**
  85691. * Gets length of current quaternion
  85692. * @returns the quaternion length (float)
  85693. */
  85694. length(): number;
  85695. /**
  85696. * Normalize in place the current quaternion
  85697. * @returns the current updated quaternion
  85698. */
  85699. normalize(): Quaternion;
  85700. /**
  85701. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  85702. * @param order is a reserved parameter and is ignored for now
  85703. * @returns a new Vector3 containing the Euler angles
  85704. */
  85705. toEulerAngles(order?: string): Vector3;
  85706. /**
  85707. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  85708. * @param result defines the vector which will be filled with the Euler angles
  85709. * @returns the current unchanged quaternion
  85710. */
  85711. toEulerAnglesToRef(result: Vector3): Quaternion;
  85712. /**
  85713. * Updates the given rotation matrix with the current quaternion values
  85714. * @param result defines the target matrix
  85715. * @returns the current unchanged quaternion
  85716. */
  85717. toRotationMatrix(result: Matrix): Quaternion;
  85718. /**
  85719. * Updates the current quaternion from the given rotation matrix values
  85720. * @param matrix defines the source matrix
  85721. * @returns the current updated quaternion
  85722. */
  85723. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  85724. /**
  85725. * Creates a new quaternion from a rotation matrix
  85726. * @param matrix defines the source matrix
  85727. * @returns a new quaternion created from the given rotation matrix values
  85728. */
  85729. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  85730. /**
  85731. * Updates the given quaternion with the given rotation matrix values
  85732. * @param matrix defines the source matrix
  85733. * @param result defines the target quaternion
  85734. */
  85735. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  85736. /**
  85737. * Returns the dot product (float) between the quaternions "left" and "right"
  85738. * @param left defines the left operand
  85739. * @param right defines the right operand
  85740. * @returns the dot product
  85741. */
  85742. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  85743. /**
  85744. * Checks if the two quaternions are close to each other
  85745. * @param quat0 defines the first quaternion to check
  85746. * @param quat1 defines the second quaternion to check
  85747. * @returns true if the two quaternions are close to each other
  85748. */
  85749. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  85750. /**
  85751. * Creates an empty quaternion
  85752. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  85753. */
  85754. static Zero(): Quaternion;
  85755. /**
  85756. * Inverse a given quaternion
  85757. * @param q defines the source quaternion
  85758. * @returns a new quaternion as the inverted current quaternion
  85759. */
  85760. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  85761. /**
  85762. * Inverse a given quaternion
  85763. * @param q defines the source quaternion
  85764. * @param result the quaternion the result will be stored in
  85765. * @returns the result quaternion
  85766. */
  85767. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  85768. /**
  85769. * Creates an identity quaternion
  85770. * @returns the identity quaternion
  85771. */
  85772. static Identity(): Quaternion;
  85773. /**
  85774. * Gets a boolean indicating if the given quaternion is identity
  85775. * @param quaternion defines the quaternion to check
  85776. * @returns true if the quaternion is identity
  85777. */
  85778. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  85779. /**
  85780. * Creates a quaternion from a rotation around an axis
  85781. * @param axis defines the axis to use
  85782. * @param angle defines the angle to use
  85783. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  85784. */
  85785. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  85786. /**
  85787. * Creates a rotation around an axis and stores it into the given quaternion
  85788. * @param axis defines the axis to use
  85789. * @param angle defines the angle to use
  85790. * @param result defines the target quaternion
  85791. * @returns the target quaternion
  85792. */
  85793. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  85794. /**
  85795. * Creates a new quaternion from data stored into an array
  85796. * @param array defines the data source
  85797. * @param offset defines the offset in the source array where the data starts
  85798. * @returns a new quaternion
  85799. */
  85800. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  85801. /**
  85802. * Updates the given quaternion "result" from the starting index of the given array.
  85803. * @param array the array to pull values from
  85804. * @param offset the offset into the array to start at
  85805. * @param result the quaternion to store the result in
  85806. */
  85807. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  85808. /**
  85809. * Create a quaternion from Euler rotation angles
  85810. * @param x Pitch
  85811. * @param y Yaw
  85812. * @param z Roll
  85813. * @returns the new Quaternion
  85814. */
  85815. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  85816. /**
  85817. * Updates a quaternion from Euler rotation angles
  85818. * @param x Pitch
  85819. * @param y Yaw
  85820. * @param z Roll
  85821. * @param result the quaternion to store the result
  85822. * @returns the updated quaternion
  85823. */
  85824. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  85825. /**
  85826. * Create a quaternion from Euler rotation vector
  85827. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  85828. * @returns the new Quaternion
  85829. */
  85830. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  85831. /**
  85832. * Updates a quaternion from Euler rotation vector
  85833. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  85834. * @param result the quaternion to store the result
  85835. * @returns the updated quaternion
  85836. */
  85837. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  85838. /**
  85839. * Creates a new quaternion from the given Euler float angles (y, x, z)
  85840. * @param yaw defines the rotation around Y axis
  85841. * @param pitch defines the rotation around X axis
  85842. * @param roll defines the rotation around Z axis
  85843. * @returns the new quaternion
  85844. */
  85845. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  85846. /**
  85847. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  85848. * @param yaw defines the rotation around Y axis
  85849. * @param pitch defines the rotation around X axis
  85850. * @param roll defines the rotation around Z axis
  85851. * @param result defines the target quaternion
  85852. */
  85853. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  85854. /**
  85855. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  85856. * @param alpha defines the rotation around first axis
  85857. * @param beta defines the rotation around second axis
  85858. * @param gamma defines the rotation around third axis
  85859. * @returns the new quaternion
  85860. */
  85861. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  85862. /**
  85863. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  85864. * @param alpha defines the rotation around first axis
  85865. * @param beta defines the rotation around second axis
  85866. * @param gamma defines the rotation around third axis
  85867. * @param result defines the target quaternion
  85868. */
  85869. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  85870. /**
  85871. * 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)
  85872. * @param axis1 defines the first axis
  85873. * @param axis2 defines the second axis
  85874. * @param axis3 defines the third axis
  85875. * @returns the new quaternion
  85876. */
  85877. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  85878. /**
  85879. * 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
  85880. * @param axis1 defines the first axis
  85881. * @param axis2 defines the second axis
  85882. * @param axis3 defines the third axis
  85883. * @param ref defines the target quaternion
  85884. */
  85885. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  85886. /**
  85887. * Interpolates between two quaternions
  85888. * @param left defines first quaternion
  85889. * @param right defines second quaternion
  85890. * @param amount defines the gradient to use
  85891. * @returns the new interpolated quaternion
  85892. */
  85893. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  85894. /**
  85895. * Interpolates between two quaternions and stores it into a target quaternion
  85896. * @param left defines first quaternion
  85897. * @param right defines second quaternion
  85898. * @param amount defines the gradient to use
  85899. * @param result defines the target quaternion
  85900. */
  85901. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  85902. /**
  85903. * Interpolate between two quaternions using Hermite interpolation
  85904. * @param value1 defines first quaternion
  85905. * @param tangent1 defines the incoming tangent
  85906. * @param value2 defines second quaternion
  85907. * @param tangent2 defines the outgoing tangent
  85908. * @param amount defines the target quaternion
  85909. * @returns the new interpolated quaternion
  85910. */
  85911. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  85912. }
  85913. /**
  85914. * Class used to store matrix data (4x4)
  85915. */
  85916. export class Matrix {
  85917. /**
  85918. * Gets the precision of matrix computations
  85919. */
  85920. static get Use64Bits(): boolean;
  85921. private static _updateFlagSeed;
  85922. private static _identityReadOnly;
  85923. private _isIdentity;
  85924. private _isIdentityDirty;
  85925. private _isIdentity3x2;
  85926. private _isIdentity3x2Dirty;
  85927. /**
  85928. * Gets the update flag of the matrix which is an unique number for the matrix.
  85929. * It will be incremented every time the matrix data change.
  85930. * You can use it to speed the comparison between two versions of the same matrix.
  85931. */
  85932. updateFlag: number;
  85933. private readonly _m;
  85934. /**
  85935. * Gets the internal data of the matrix
  85936. */
  85937. get m(): DeepImmutable<Float32Array | Array<number>>;
  85938. /** @hidden */
  85939. _markAsUpdated(): void;
  85940. /** @hidden */
  85941. private _updateIdentityStatus;
  85942. /**
  85943. * Creates an empty matrix (filled with zeros)
  85944. */
  85945. constructor();
  85946. /**
  85947. * Check if the current matrix is identity
  85948. * @returns true is the matrix is the identity matrix
  85949. */
  85950. isIdentity(): boolean;
  85951. /**
  85952. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  85953. * @returns true is the matrix is the identity matrix
  85954. */
  85955. isIdentityAs3x2(): boolean;
  85956. /**
  85957. * Gets the determinant of the matrix
  85958. * @returns the matrix determinant
  85959. */
  85960. determinant(): number;
  85961. /**
  85962. * Returns the matrix as a Float32Array or Array<number>
  85963. * @returns the matrix underlying array
  85964. */
  85965. toArray(): DeepImmutable<Float32Array | Array<number>>;
  85966. /**
  85967. * Returns the matrix as a Float32Array or Array<number>
  85968. * @returns the matrix underlying array.
  85969. */
  85970. asArray(): DeepImmutable<Float32Array | Array<number>>;
  85971. /**
  85972. * Inverts the current matrix in place
  85973. * @returns the current inverted matrix
  85974. */
  85975. invert(): Matrix;
  85976. /**
  85977. * Sets all the matrix elements to zero
  85978. * @returns the current matrix
  85979. */
  85980. reset(): Matrix;
  85981. /**
  85982. * Adds the current matrix with a second one
  85983. * @param other defines the matrix to add
  85984. * @returns a new matrix as the addition of the current matrix and the given one
  85985. */
  85986. add(other: DeepImmutable<Matrix>): Matrix;
  85987. /**
  85988. * Sets the given matrix "result" to the addition of the current matrix and the given one
  85989. * @param other defines the matrix to add
  85990. * @param result defines the target matrix
  85991. * @returns the current matrix
  85992. */
  85993. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  85994. /**
  85995. * Adds in place the given matrix to the current matrix
  85996. * @param other defines the second operand
  85997. * @returns the current updated matrix
  85998. */
  85999. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  86000. /**
  86001. * Sets the given matrix to the current inverted Matrix
  86002. * @param other defines the target matrix
  86003. * @returns the unmodified current matrix
  86004. */
  86005. invertToRef(other: Matrix): Matrix;
  86006. /**
  86007. * add a value at the specified position in the current Matrix
  86008. * @param index the index of the value within the matrix. between 0 and 15.
  86009. * @param value the value to be added
  86010. * @returns the current updated matrix
  86011. */
  86012. addAtIndex(index: number, value: number): Matrix;
  86013. /**
  86014. * mutiply the specified position in the current Matrix by a value
  86015. * @param index the index of the value within the matrix. between 0 and 15.
  86016. * @param value the value to be added
  86017. * @returns the current updated matrix
  86018. */
  86019. multiplyAtIndex(index: number, value: number): Matrix;
  86020. /**
  86021. * Inserts the translation vector (using 3 floats) in the current matrix
  86022. * @param x defines the 1st component of the translation
  86023. * @param y defines the 2nd component of the translation
  86024. * @param z defines the 3rd component of the translation
  86025. * @returns the current updated matrix
  86026. */
  86027. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  86028. /**
  86029. * Adds the translation vector (using 3 floats) in the current matrix
  86030. * @param x defines the 1st component of the translation
  86031. * @param y defines the 2nd component of the translation
  86032. * @param z defines the 3rd component of the translation
  86033. * @returns the current updated matrix
  86034. */
  86035. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  86036. /**
  86037. * Inserts the translation vector in the current matrix
  86038. * @param vector3 defines the translation to insert
  86039. * @returns the current updated matrix
  86040. */
  86041. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  86042. /**
  86043. * Gets the translation value of the current matrix
  86044. * @returns a new Vector3 as the extracted translation from the matrix
  86045. */
  86046. getTranslation(): Vector3;
  86047. /**
  86048. * Fill a Vector3 with the extracted translation from the matrix
  86049. * @param result defines the Vector3 where to store the translation
  86050. * @returns the current matrix
  86051. */
  86052. getTranslationToRef(result: Vector3): Matrix;
  86053. /**
  86054. * Remove rotation and scaling part from the matrix
  86055. * @returns the updated matrix
  86056. */
  86057. removeRotationAndScaling(): Matrix;
  86058. /**
  86059. * Multiply two matrices
  86060. * @param other defines the second operand
  86061. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  86062. */
  86063. multiply(other: DeepImmutable<Matrix>): Matrix;
  86064. /**
  86065. * Copy the current matrix from the given one
  86066. * @param other defines the source matrix
  86067. * @returns the current updated matrix
  86068. */
  86069. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  86070. /**
  86071. * Populates the given array from the starting index with the current matrix values
  86072. * @param array defines the target array
  86073. * @param offset defines the offset in the target array where to start storing values
  86074. * @returns the current matrix
  86075. */
  86076. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  86077. /**
  86078. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  86079. * @param other defines the second operand
  86080. * @param result defines the matrix where to store the multiplication
  86081. * @returns the current matrix
  86082. */
  86083. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  86084. /**
  86085. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  86086. * @param other defines the second operand
  86087. * @param result defines the array where to store the multiplication
  86088. * @param offset defines the offset in the target array where to start storing values
  86089. * @returns the current matrix
  86090. */
  86091. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  86092. /**
  86093. * Check equality between this matrix and a second one
  86094. * @param value defines the second matrix to compare
  86095. * @returns true is the current matrix and the given one values are strictly equal
  86096. */
  86097. equals(value: DeepImmutable<Matrix>): boolean;
  86098. /**
  86099. * Clone the current matrix
  86100. * @returns a new matrix from the current matrix
  86101. */
  86102. clone(): Matrix;
  86103. /**
  86104. * Returns the name of the current matrix class
  86105. * @returns the string "Matrix"
  86106. */
  86107. getClassName(): string;
  86108. /**
  86109. * Gets the hash code of the current matrix
  86110. * @returns the hash code
  86111. */
  86112. getHashCode(): number;
  86113. /**
  86114. * Decomposes the current Matrix into a translation, rotation and scaling components
  86115. * @param scale defines the scale vector3 given as a reference to update
  86116. * @param rotation defines the rotation quaternion given as a reference to update
  86117. * @param translation defines the translation vector3 given as a reference to update
  86118. * @returns true if operation was successful
  86119. */
  86120. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  86121. /**
  86122. * Gets specific row of the matrix
  86123. * @param index defines the number of the row to get
  86124. * @returns the index-th row of the current matrix as a new Vector4
  86125. */
  86126. getRow(index: number): Nullable<Vector4>;
  86127. /**
  86128. * Sets the index-th row of the current matrix to the vector4 values
  86129. * @param index defines the number of the row to set
  86130. * @param row defines the target vector4
  86131. * @returns the updated current matrix
  86132. */
  86133. setRow(index: number, row: Vector4): Matrix;
  86134. /**
  86135. * Compute the transpose of the matrix
  86136. * @returns the new transposed matrix
  86137. */
  86138. transpose(): Matrix;
  86139. /**
  86140. * Compute the transpose of the matrix and store it in a given matrix
  86141. * @param result defines the target matrix
  86142. * @returns the current matrix
  86143. */
  86144. transposeToRef(result: Matrix): Matrix;
  86145. /**
  86146. * Sets the index-th row of the current matrix with the given 4 x float values
  86147. * @param index defines the row index
  86148. * @param x defines the x component to set
  86149. * @param y defines the y component to set
  86150. * @param z defines the z component to set
  86151. * @param w defines the w component to set
  86152. * @returns the updated current matrix
  86153. */
  86154. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  86155. /**
  86156. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  86157. * @param scale defines the scale factor
  86158. * @returns a new matrix
  86159. */
  86160. scale(scale: number): Matrix;
  86161. /**
  86162. * Scale the current matrix values by a factor to a given result matrix
  86163. * @param scale defines the scale factor
  86164. * @param result defines the matrix to store the result
  86165. * @returns the current matrix
  86166. */
  86167. scaleToRef(scale: number, result: Matrix): Matrix;
  86168. /**
  86169. * Scale the current matrix values by a factor and add the result to a given matrix
  86170. * @param scale defines the scale factor
  86171. * @param result defines the Matrix to store the result
  86172. * @returns the current matrix
  86173. */
  86174. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  86175. /**
  86176. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  86177. * @param ref matrix to store the result
  86178. */
  86179. toNormalMatrix(ref: Matrix): void;
  86180. /**
  86181. * Gets only rotation part of the current matrix
  86182. * @returns a new matrix sets to the extracted rotation matrix from the current one
  86183. */
  86184. getRotationMatrix(): Matrix;
  86185. /**
  86186. * Extracts the rotation matrix from the current one and sets it as the given "result"
  86187. * @param result defines the target matrix to store data to
  86188. * @returns the current matrix
  86189. */
  86190. getRotationMatrixToRef(result: Matrix): Matrix;
  86191. /**
  86192. * Toggles model matrix from being right handed to left handed in place and vice versa
  86193. */
  86194. toggleModelMatrixHandInPlace(): void;
  86195. /**
  86196. * Toggles projection matrix from being right handed to left handed in place and vice versa
  86197. */
  86198. toggleProjectionMatrixHandInPlace(): void;
  86199. /**
  86200. * Creates a matrix from an array
  86201. * @param array defines the source array
  86202. * @param offset defines an offset in the source array
  86203. * @returns a new Matrix set from the starting index of the given array
  86204. */
  86205. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  86206. /**
  86207. * Copy the content of an array into a given matrix
  86208. * @param array defines the source array
  86209. * @param offset defines an offset in the source array
  86210. * @param result defines the target matrix
  86211. */
  86212. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  86213. /**
  86214. * Stores an array into a matrix after having multiplied each component by a given factor
  86215. * @param array defines the source array
  86216. * @param offset defines the offset in the source array
  86217. * @param scale defines the scaling factor
  86218. * @param result defines the target matrix
  86219. */
  86220. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  86221. /**
  86222. * Gets an identity matrix that must not be updated
  86223. */
  86224. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  86225. /**
  86226. * Stores a list of values (16) inside a given matrix
  86227. * @param initialM11 defines 1st value of 1st row
  86228. * @param initialM12 defines 2nd value of 1st row
  86229. * @param initialM13 defines 3rd value of 1st row
  86230. * @param initialM14 defines 4th value of 1st row
  86231. * @param initialM21 defines 1st value of 2nd row
  86232. * @param initialM22 defines 2nd value of 2nd row
  86233. * @param initialM23 defines 3rd value of 2nd row
  86234. * @param initialM24 defines 4th value of 2nd row
  86235. * @param initialM31 defines 1st value of 3rd row
  86236. * @param initialM32 defines 2nd value of 3rd row
  86237. * @param initialM33 defines 3rd value of 3rd row
  86238. * @param initialM34 defines 4th value of 3rd row
  86239. * @param initialM41 defines 1st value of 4th row
  86240. * @param initialM42 defines 2nd value of 4th row
  86241. * @param initialM43 defines 3rd value of 4th row
  86242. * @param initialM44 defines 4th value of 4th row
  86243. * @param result defines the target matrix
  86244. */
  86245. 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;
  86246. /**
  86247. * Creates new matrix from a list of values (16)
  86248. * @param initialM11 defines 1st value of 1st row
  86249. * @param initialM12 defines 2nd value of 1st row
  86250. * @param initialM13 defines 3rd value of 1st row
  86251. * @param initialM14 defines 4th value of 1st row
  86252. * @param initialM21 defines 1st value of 2nd row
  86253. * @param initialM22 defines 2nd value of 2nd row
  86254. * @param initialM23 defines 3rd value of 2nd row
  86255. * @param initialM24 defines 4th value of 2nd row
  86256. * @param initialM31 defines 1st value of 3rd row
  86257. * @param initialM32 defines 2nd value of 3rd row
  86258. * @param initialM33 defines 3rd value of 3rd row
  86259. * @param initialM34 defines 4th value of 3rd row
  86260. * @param initialM41 defines 1st value of 4th row
  86261. * @param initialM42 defines 2nd value of 4th row
  86262. * @param initialM43 defines 3rd value of 4th row
  86263. * @param initialM44 defines 4th value of 4th row
  86264. * @returns the new matrix
  86265. */
  86266. 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;
  86267. /**
  86268. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  86269. * @param scale defines the scale vector3
  86270. * @param rotation defines the rotation quaternion
  86271. * @param translation defines the translation vector3
  86272. * @returns a new matrix
  86273. */
  86274. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  86275. /**
  86276. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  86277. * @param scale defines the scale vector3
  86278. * @param rotation defines the rotation quaternion
  86279. * @param translation defines the translation vector3
  86280. * @param result defines the target matrix
  86281. */
  86282. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  86283. /**
  86284. * Creates a new identity matrix
  86285. * @returns a new identity matrix
  86286. */
  86287. static Identity(): Matrix;
  86288. /**
  86289. * Creates a new identity matrix and stores the result in a given matrix
  86290. * @param result defines the target matrix
  86291. */
  86292. static IdentityToRef(result: Matrix): void;
  86293. /**
  86294. * Creates a new zero matrix
  86295. * @returns a new zero matrix
  86296. */
  86297. static Zero(): Matrix;
  86298. /**
  86299. * Creates a new rotation matrix for "angle" radians around the X axis
  86300. * @param angle defines the angle (in radians) to use
  86301. * @return the new matrix
  86302. */
  86303. static RotationX(angle: number): Matrix;
  86304. /**
  86305. * Creates a new matrix as the invert of a given matrix
  86306. * @param source defines the source matrix
  86307. * @returns the new matrix
  86308. */
  86309. static Invert(source: DeepImmutable<Matrix>): Matrix;
  86310. /**
  86311. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  86312. * @param angle defines the angle (in radians) to use
  86313. * @param result defines the target matrix
  86314. */
  86315. static RotationXToRef(angle: number, result: Matrix): void;
  86316. /**
  86317. * Creates a new rotation matrix for "angle" radians around the Y axis
  86318. * @param angle defines the angle (in radians) to use
  86319. * @return the new matrix
  86320. */
  86321. static RotationY(angle: number): Matrix;
  86322. /**
  86323. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  86324. * @param angle defines the angle (in radians) to use
  86325. * @param result defines the target matrix
  86326. */
  86327. static RotationYToRef(angle: number, result: Matrix): void;
  86328. /**
  86329. * Creates a new rotation matrix for "angle" radians around the Z axis
  86330. * @param angle defines the angle (in radians) to use
  86331. * @return the new matrix
  86332. */
  86333. static RotationZ(angle: number): Matrix;
  86334. /**
  86335. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  86336. * @param angle defines the angle (in radians) to use
  86337. * @param result defines the target matrix
  86338. */
  86339. static RotationZToRef(angle: number, result: Matrix): void;
  86340. /**
  86341. * Creates a new rotation matrix for "angle" radians around the given axis
  86342. * @param axis defines the axis to use
  86343. * @param angle defines the angle (in radians) to use
  86344. * @return the new matrix
  86345. */
  86346. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  86347. /**
  86348. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  86349. * @param axis defines the axis to use
  86350. * @param angle defines the angle (in radians) to use
  86351. * @param result defines the target matrix
  86352. */
  86353. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  86354. /**
  86355. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  86356. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  86357. * @param from defines the vector to align
  86358. * @param to defines the vector to align to
  86359. * @param result defines the target matrix
  86360. */
  86361. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  86362. /**
  86363. * Creates a rotation matrix
  86364. * @param yaw defines the yaw angle in radians (Y axis)
  86365. * @param pitch defines the pitch angle in radians (X axis)
  86366. * @param roll defines the roll angle in radians (Z axis)
  86367. * @returns the new rotation matrix
  86368. */
  86369. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  86370. /**
  86371. * Creates a rotation matrix and stores it in a given matrix
  86372. * @param yaw defines the yaw angle in radians (Y axis)
  86373. * @param pitch defines the pitch angle in radians (X axis)
  86374. * @param roll defines the roll angle in radians (Z axis)
  86375. * @param result defines the target matrix
  86376. */
  86377. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  86378. /**
  86379. * Creates a scaling matrix
  86380. * @param x defines the scale factor on X axis
  86381. * @param y defines the scale factor on Y axis
  86382. * @param z defines the scale factor on Z axis
  86383. * @returns the new matrix
  86384. */
  86385. static Scaling(x: number, y: number, z: number): Matrix;
  86386. /**
  86387. * Creates a scaling matrix and stores it in a given matrix
  86388. * @param x defines the scale factor on X axis
  86389. * @param y defines the scale factor on Y axis
  86390. * @param z defines the scale factor on Z axis
  86391. * @param result defines the target matrix
  86392. */
  86393. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  86394. /**
  86395. * Creates a translation matrix
  86396. * @param x defines the translation on X axis
  86397. * @param y defines the translation on Y axis
  86398. * @param z defines the translationon Z axis
  86399. * @returns the new matrix
  86400. */
  86401. static Translation(x: number, y: number, z: number): Matrix;
  86402. /**
  86403. * Creates a translation matrix and stores it in a given matrix
  86404. * @param x defines the translation on X axis
  86405. * @param y defines the translation on Y axis
  86406. * @param z defines the translationon Z axis
  86407. * @param result defines the target matrix
  86408. */
  86409. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  86410. /**
  86411. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  86412. * @param startValue defines the start value
  86413. * @param endValue defines the end value
  86414. * @param gradient defines the gradient factor
  86415. * @returns the new matrix
  86416. */
  86417. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  86418. /**
  86419. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  86420. * @param startValue defines the start value
  86421. * @param endValue defines the end value
  86422. * @param gradient defines the gradient factor
  86423. * @param result defines the Matrix object where to store data
  86424. */
  86425. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  86426. /**
  86427. * Builds a new matrix whose values are computed by:
  86428. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  86429. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  86430. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  86431. * @param startValue defines the first matrix
  86432. * @param endValue defines the second matrix
  86433. * @param gradient defines the gradient between the two matrices
  86434. * @returns the new matrix
  86435. */
  86436. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  86437. /**
  86438. * Update a matrix to values which are computed by:
  86439. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  86440. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  86441. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  86442. * @param startValue defines the first matrix
  86443. * @param endValue defines the second matrix
  86444. * @param gradient defines the gradient between the two matrices
  86445. * @param result defines the target matrix
  86446. */
  86447. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  86448. /**
  86449. * 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"
  86450. * This function works in left handed mode
  86451. * @param eye defines the final position of the entity
  86452. * @param target defines where the entity should look at
  86453. * @param up defines the up vector for the entity
  86454. * @returns the new matrix
  86455. */
  86456. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  86457. /**
  86458. * 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".
  86459. * This function works in left handed mode
  86460. * @param eye defines the final position of the entity
  86461. * @param target defines where the entity should look at
  86462. * @param up defines the up vector for the entity
  86463. * @param result defines the target matrix
  86464. */
  86465. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  86466. /**
  86467. * 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"
  86468. * This function works in right handed mode
  86469. * @param eye defines the final position of the entity
  86470. * @param target defines where the entity should look at
  86471. * @param up defines the up vector for the entity
  86472. * @returns the new matrix
  86473. */
  86474. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  86475. /**
  86476. * 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".
  86477. * This function works in right handed mode
  86478. * @param eye defines the final position of the entity
  86479. * @param target defines where the entity should look at
  86480. * @param up defines the up vector for the entity
  86481. * @param result defines the target matrix
  86482. */
  86483. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  86484. /**
  86485. * Create a left-handed orthographic projection matrix
  86486. * @param width defines the viewport width
  86487. * @param height defines the viewport height
  86488. * @param znear defines the near clip plane
  86489. * @param zfar defines the far clip plane
  86490. * @returns a new matrix as a left-handed orthographic projection matrix
  86491. */
  86492. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  86493. /**
  86494. * Store a left-handed orthographic projection to a given matrix
  86495. * @param width defines the viewport width
  86496. * @param height defines the viewport height
  86497. * @param znear defines the near clip plane
  86498. * @param zfar defines the far clip plane
  86499. * @param result defines the target matrix
  86500. */
  86501. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  86502. /**
  86503. * Create a left-handed orthographic projection matrix
  86504. * @param left defines the viewport left coordinate
  86505. * @param right defines the viewport right coordinate
  86506. * @param bottom defines the viewport bottom coordinate
  86507. * @param top defines the viewport top coordinate
  86508. * @param znear defines the near clip plane
  86509. * @param zfar defines the far clip plane
  86510. * @returns a new matrix as a left-handed orthographic projection matrix
  86511. */
  86512. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  86513. /**
  86514. * Stores a left-handed orthographic projection into a given matrix
  86515. * @param left defines the viewport left coordinate
  86516. * @param right defines the viewport right coordinate
  86517. * @param bottom defines the viewport bottom coordinate
  86518. * @param top defines the viewport top coordinate
  86519. * @param znear defines the near clip plane
  86520. * @param zfar defines the far clip plane
  86521. * @param result defines the target matrix
  86522. */
  86523. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  86524. /**
  86525. * Creates a right-handed orthographic projection matrix
  86526. * @param left defines the viewport left coordinate
  86527. * @param right defines the viewport right coordinate
  86528. * @param bottom defines the viewport bottom coordinate
  86529. * @param top defines the viewport top coordinate
  86530. * @param znear defines the near clip plane
  86531. * @param zfar defines the far clip plane
  86532. * @returns a new matrix as a right-handed orthographic projection matrix
  86533. */
  86534. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  86535. /**
  86536. * Stores a right-handed orthographic projection into a given matrix
  86537. * @param left defines the viewport left coordinate
  86538. * @param right defines the viewport right coordinate
  86539. * @param bottom defines the viewport bottom coordinate
  86540. * @param top defines the viewport top coordinate
  86541. * @param znear defines the near clip plane
  86542. * @param zfar defines the far clip plane
  86543. * @param result defines the target matrix
  86544. */
  86545. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  86546. /**
  86547. * Creates a left-handed perspective projection matrix
  86548. * @param width defines the viewport width
  86549. * @param height defines the viewport height
  86550. * @param znear defines the near clip plane
  86551. * @param zfar defines the far clip plane
  86552. * @returns a new matrix as a left-handed perspective projection matrix
  86553. */
  86554. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  86555. /**
  86556. * Creates a left-handed perspective projection matrix
  86557. * @param fov defines the horizontal field of view
  86558. * @param aspect defines the aspect ratio
  86559. * @param znear defines the near clip plane
  86560. * @param zfar defines the far clip plane
  86561. * @returns a new matrix as a left-handed perspective projection matrix
  86562. */
  86563. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  86564. /**
  86565. * Stores a left-handed perspective projection into a given matrix
  86566. * @param fov defines the horizontal field of view
  86567. * @param aspect defines the aspect ratio
  86568. * @param znear defines the near clip plane
  86569. * @param zfar defines the far clip plane
  86570. * @param result defines the target matrix
  86571. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86572. */
  86573. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86574. /**
  86575. * Stores a left-handed perspective projection into a given matrix with depth reversed
  86576. * @param fov defines the horizontal field of view
  86577. * @param aspect defines the aspect ratio
  86578. * @param znear defines the near clip plane
  86579. * @param zfar not used as infinity is used as far clip
  86580. * @param result defines the target matrix
  86581. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86582. */
  86583. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86584. /**
  86585. * Creates a right-handed perspective projection matrix
  86586. * @param fov defines the horizontal field of view
  86587. * @param aspect defines the aspect ratio
  86588. * @param znear defines the near clip plane
  86589. * @param zfar defines the far clip plane
  86590. * @returns a new matrix as a right-handed perspective projection matrix
  86591. */
  86592. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  86593. /**
  86594. * Stores a right-handed perspective projection into a given matrix
  86595. * @param fov defines the horizontal field of view
  86596. * @param aspect defines the aspect ratio
  86597. * @param znear defines the near clip plane
  86598. * @param zfar defines the far clip plane
  86599. * @param result defines the target matrix
  86600. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86601. */
  86602. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86603. /**
  86604. * Stores a right-handed perspective projection into a given matrix
  86605. * @param fov defines the horizontal field of view
  86606. * @param aspect defines the aspect ratio
  86607. * @param znear defines the near clip plane
  86608. * @param zfar not used as infinity is used as far clip
  86609. * @param result defines the target matrix
  86610. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86611. */
  86612. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86613. /**
  86614. * Stores a perspective projection for WebVR info a given matrix
  86615. * @param fov defines the field of view
  86616. * @param znear defines the near clip plane
  86617. * @param zfar defines the far clip plane
  86618. * @param result defines the target matrix
  86619. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  86620. */
  86621. static PerspectiveFovWebVRToRef(fov: {
  86622. upDegrees: number;
  86623. downDegrees: number;
  86624. leftDegrees: number;
  86625. rightDegrees: number;
  86626. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  86627. /**
  86628. * Computes a complete transformation matrix
  86629. * @param viewport defines the viewport to use
  86630. * @param world defines the world matrix
  86631. * @param view defines the view matrix
  86632. * @param projection defines the projection matrix
  86633. * @param zmin defines the near clip plane
  86634. * @param zmax defines the far clip plane
  86635. * @returns the transformation matrix
  86636. */
  86637. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  86638. /**
  86639. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  86640. * @param matrix defines the matrix to use
  86641. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  86642. */
  86643. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  86644. /**
  86645. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  86646. * @param matrix defines the matrix to use
  86647. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  86648. */
  86649. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  86650. /**
  86651. * Compute the transpose of a given matrix
  86652. * @param matrix defines the matrix to transpose
  86653. * @returns the new matrix
  86654. */
  86655. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  86656. /**
  86657. * Compute the transpose of a matrix and store it in a target matrix
  86658. * @param matrix defines the matrix to transpose
  86659. * @param result defines the target matrix
  86660. */
  86661. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  86662. /**
  86663. * Computes a reflection matrix from a plane
  86664. * @param plane defines the reflection plane
  86665. * @returns a new matrix
  86666. */
  86667. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  86668. /**
  86669. * Computes a reflection matrix from a plane
  86670. * @param plane defines the reflection plane
  86671. * @param result defines the target matrix
  86672. */
  86673. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  86674. /**
  86675. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  86676. * @param xaxis defines the value of the 1st axis
  86677. * @param yaxis defines the value of the 2nd axis
  86678. * @param zaxis defines the value of the 3rd axis
  86679. * @param result defines the target matrix
  86680. */
  86681. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  86682. /**
  86683. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  86684. * @param quat defines the quaternion to use
  86685. * @param result defines the target matrix
  86686. */
  86687. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  86688. }
  86689. /**
  86690. * @hidden
  86691. */
  86692. export class TmpVectors {
  86693. static Vector2: Vector2[];
  86694. static Vector3: Vector3[];
  86695. static Vector4: Vector4[];
  86696. static Quaternion: Quaternion[];
  86697. static Matrix: Matrix[];
  86698. }
  86699. }
  86700. declare module BABYLON {
  86701. /**
  86702. * Defines potential orientation for back face culling
  86703. */
  86704. export enum Orientation {
  86705. /**
  86706. * Clockwise
  86707. */
  86708. CW = 0,
  86709. /** Counter clockwise */
  86710. CCW = 1
  86711. }
  86712. /** Class used to represent a Bezier curve */
  86713. export class BezierCurve {
  86714. /**
  86715. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  86716. * @param t defines the time
  86717. * @param x1 defines the left coordinate on X axis
  86718. * @param y1 defines the left coordinate on Y axis
  86719. * @param x2 defines the right coordinate on X axis
  86720. * @param y2 defines the right coordinate on Y axis
  86721. * @returns the interpolated value
  86722. */
  86723. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  86724. }
  86725. /**
  86726. * Defines angle representation
  86727. */
  86728. export class Angle {
  86729. private _radians;
  86730. /**
  86731. * Creates an Angle object of "radians" radians (float).
  86732. * @param radians the angle in radians
  86733. */
  86734. constructor(radians: number);
  86735. /**
  86736. * Get value in degrees
  86737. * @returns the Angle value in degrees (float)
  86738. */
  86739. degrees(): number;
  86740. /**
  86741. * Get value in radians
  86742. * @returns the Angle value in radians (float)
  86743. */
  86744. radians(): number;
  86745. /**
  86746. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  86747. * @param a defines first point as the origin
  86748. * @param b defines point
  86749. * @returns a new Angle
  86750. */
  86751. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  86752. /**
  86753. * Gets a new Angle object from the given float in radians
  86754. * @param radians defines the angle value in radians
  86755. * @returns a new Angle
  86756. */
  86757. static FromRadians(radians: number): Angle;
  86758. /**
  86759. * Gets a new Angle object from the given float in degrees
  86760. * @param degrees defines the angle value in degrees
  86761. * @returns a new Angle
  86762. */
  86763. static FromDegrees(degrees: number): Angle;
  86764. }
  86765. /**
  86766. * This represents an arc in a 2d space.
  86767. */
  86768. export class Arc2 {
  86769. /** Defines the start point of the arc */
  86770. startPoint: Vector2;
  86771. /** Defines the mid point of the arc */
  86772. midPoint: Vector2;
  86773. /** Defines the end point of the arc */
  86774. endPoint: Vector2;
  86775. /**
  86776. * Defines the center point of the arc.
  86777. */
  86778. centerPoint: Vector2;
  86779. /**
  86780. * Defines the radius of the arc.
  86781. */
  86782. radius: number;
  86783. /**
  86784. * Defines the angle of the arc (from mid point to end point).
  86785. */
  86786. angle: Angle;
  86787. /**
  86788. * Defines the start angle of the arc (from start point to middle point).
  86789. */
  86790. startAngle: Angle;
  86791. /**
  86792. * Defines the orientation of the arc (clock wise/counter clock wise).
  86793. */
  86794. orientation: Orientation;
  86795. /**
  86796. * Creates an Arc object from the three given points : start, middle and end.
  86797. * @param startPoint Defines the start point of the arc
  86798. * @param midPoint Defines the midlle point of the arc
  86799. * @param endPoint Defines the end point of the arc
  86800. */
  86801. constructor(
  86802. /** Defines the start point of the arc */
  86803. startPoint: Vector2,
  86804. /** Defines the mid point of the arc */
  86805. midPoint: Vector2,
  86806. /** Defines the end point of the arc */
  86807. endPoint: Vector2);
  86808. }
  86809. /**
  86810. * Represents a 2D path made up of multiple 2D points
  86811. */
  86812. export class Path2 {
  86813. private _points;
  86814. private _length;
  86815. /**
  86816. * If the path start and end point are the same
  86817. */
  86818. closed: boolean;
  86819. /**
  86820. * Creates a Path2 object from the starting 2D coordinates x and y.
  86821. * @param x the starting points x value
  86822. * @param y the starting points y value
  86823. */
  86824. constructor(x: number, y: number);
  86825. /**
  86826. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  86827. * @param x the added points x value
  86828. * @param y the added points y value
  86829. * @returns the updated Path2.
  86830. */
  86831. addLineTo(x: number, y: number): Path2;
  86832. /**
  86833. * 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.
  86834. * @param midX middle point x value
  86835. * @param midY middle point y value
  86836. * @param endX end point x value
  86837. * @param endY end point y value
  86838. * @param numberOfSegments (default: 36)
  86839. * @returns the updated Path2.
  86840. */
  86841. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  86842. /**
  86843. * Closes the Path2.
  86844. * @returns the Path2.
  86845. */
  86846. close(): Path2;
  86847. /**
  86848. * Gets the sum of the distance between each sequential point in the path
  86849. * @returns the Path2 total length (float).
  86850. */
  86851. length(): number;
  86852. /**
  86853. * Gets the points which construct the path
  86854. * @returns the Path2 internal array of points.
  86855. */
  86856. getPoints(): Vector2[];
  86857. /**
  86858. * Retreives the point at the distance aways from the starting point
  86859. * @param normalizedLengthPosition the length along the path to retreive the point from
  86860. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  86861. */
  86862. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  86863. /**
  86864. * Creates a new path starting from an x and y position
  86865. * @param x starting x value
  86866. * @param y starting y value
  86867. * @returns a new Path2 starting at the coordinates (x, y).
  86868. */
  86869. static StartingAt(x: number, y: number): Path2;
  86870. }
  86871. /**
  86872. * Represents a 3D path made up of multiple 3D points
  86873. */
  86874. export class Path3D {
  86875. /**
  86876. * an array of Vector3, the curve axis of the Path3D
  86877. */
  86878. path: Vector3[];
  86879. private _curve;
  86880. private _distances;
  86881. private _tangents;
  86882. private _normals;
  86883. private _binormals;
  86884. private _raw;
  86885. private _alignTangentsWithPath;
  86886. private readonly _pointAtData;
  86887. /**
  86888. * new Path3D(path, normal, raw)
  86889. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  86890. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  86891. * @param path an array of Vector3, the curve axis of the Path3D
  86892. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  86893. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  86894. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  86895. */
  86896. constructor(
  86897. /**
  86898. * an array of Vector3, the curve axis of the Path3D
  86899. */
  86900. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  86901. /**
  86902. * Returns the Path3D array of successive Vector3 designing its curve.
  86903. * @returns the Path3D array of successive Vector3 designing its curve.
  86904. */
  86905. getCurve(): Vector3[];
  86906. /**
  86907. * Returns the Path3D array of successive Vector3 designing its curve.
  86908. * @returns the Path3D array of successive Vector3 designing its curve.
  86909. */
  86910. getPoints(): Vector3[];
  86911. /**
  86912. * @returns the computed length (float) of the path.
  86913. */
  86914. length(): number;
  86915. /**
  86916. * Returns an array populated with tangent vectors on each Path3D curve point.
  86917. * @returns an array populated with tangent vectors on each Path3D curve point.
  86918. */
  86919. getTangents(): Vector3[];
  86920. /**
  86921. * Returns an array populated with normal vectors on each Path3D curve point.
  86922. * @returns an array populated with normal vectors on each Path3D curve point.
  86923. */
  86924. getNormals(): Vector3[];
  86925. /**
  86926. * Returns an array populated with binormal vectors on each Path3D curve point.
  86927. * @returns an array populated with binormal vectors on each Path3D curve point.
  86928. */
  86929. getBinormals(): Vector3[];
  86930. /**
  86931. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  86932. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  86933. */
  86934. getDistances(): number[];
  86935. /**
  86936. * Returns an interpolated point along this path
  86937. * @param position the position of the point along this path, from 0.0 to 1.0
  86938. * @returns a new Vector3 as the point
  86939. */
  86940. getPointAt(position: number): Vector3;
  86941. /**
  86942. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  86943. * @param position the position of the point along this path, from 0.0 to 1.0
  86944. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  86945. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  86946. */
  86947. getTangentAt(position: number, interpolated?: boolean): Vector3;
  86948. /**
  86949. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  86950. * @param position the position of the point along this path, from 0.0 to 1.0
  86951. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  86952. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  86953. */
  86954. getNormalAt(position: number, interpolated?: boolean): Vector3;
  86955. /**
  86956. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  86957. * @param position the position of the point along this path, from 0.0 to 1.0
  86958. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  86959. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  86960. */
  86961. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  86962. /**
  86963. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  86964. * @param position the position of the point along this path, from 0.0 to 1.0
  86965. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  86966. */
  86967. getDistanceAt(position: number): number;
  86968. /**
  86969. * Returns the array index of the previous point of an interpolated point along this path
  86970. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  86971. * @returns the array index
  86972. */
  86973. getPreviousPointIndexAt(position: number): number;
  86974. /**
  86975. * 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)
  86976. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  86977. * @returns the sub position
  86978. */
  86979. getSubPositionAt(position: number): number;
  86980. /**
  86981. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  86982. * @param target the vector of which to get the closest position to
  86983. * @returns the position of the closest virtual point on this path to the target vector
  86984. */
  86985. getClosestPositionTo(target: Vector3): number;
  86986. /**
  86987. * Returns a sub path (slice) of this path
  86988. * @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
  86989. * @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
  86990. * @returns a sub path (slice) of this path
  86991. */
  86992. slice(start?: number, end?: number): Path3D;
  86993. /**
  86994. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  86995. * @param path path which all values are copied into the curves points
  86996. * @param firstNormal which should be projected onto the curve
  86997. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  86998. * @returns the same object updated.
  86999. */
  87000. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  87001. private _compute;
  87002. private _getFirstNonNullVector;
  87003. private _getLastNonNullVector;
  87004. private _normalVector;
  87005. /**
  87006. * Updates the point at data for an interpolated point along this curve
  87007. * @param position the position of the point along this curve, from 0.0 to 1.0
  87008. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  87009. * @returns the (updated) point at data
  87010. */
  87011. private _updatePointAtData;
  87012. /**
  87013. * Updates the point at data from the specified parameters
  87014. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  87015. * @param point the interpolated point
  87016. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  87017. */
  87018. private _setPointAtData;
  87019. /**
  87020. * Updates the point at interpolation matrix for the tangents, normals and binormals
  87021. */
  87022. private _updateInterpolationMatrix;
  87023. }
  87024. /**
  87025. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  87026. * A Curve3 is designed from a series of successive Vector3.
  87027. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  87028. */
  87029. export class Curve3 {
  87030. private _points;
  87031. private _length;
  87032. /**
  87033. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  87034. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  87035. * @param v1 (Vector3) the control point
  87036. * @param v2 (Vector3) the end point of the Quadratic Bezier
  87037. * @param nbPoints (integer) the wanted number of points in the curve
  87038. * @returns the created Curve3
  87039. */
  87040. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  87041. /**
  87042. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  87043. * @param v0 (Vector3) the origin point of the Cubic Bezier
  87044. * @param v1 (Vector3) the first control point
  87045. * @param v2 (Vector3) the second control point
  87046. * @param v3 (Vector3) the end point of the Cubic Bezier
  87047. * @param nbPoints (integer) the wanted number of points in the curve
  87048. * @returns the created Curve3
  87049. */
  87050. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  87051. /**
  87052. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  87053. * @param p1 (Vector3) the origin point of the Hermite Spline
  87054. * @param t1 (Vector3) the tangent vector at the origin point
  87055. * @param p2 (Vector3) the end point of the Hermite Spline
  87056. * @param t2 (Vector3) the tangent vector at the end point
  87057. * @param nbPoints (integer) the wanted number of points in the curve
  87058. * @returns the created Curve3
  87059. */
  87060. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  87061. /**
  87062. * Returns a Curve3 object along a CatmullRom Spline curve :
  87063. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  87064. * @param nbPoints (integer) the wanted number of points between each curve control points
  87065. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  87066. * @returns the created Curve3
  87067. */
  87068. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  87069. /**
  87070. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  87071. * A Curve3 is designed from a series of successive Vector3.
  87072. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  87073. * @param points points which make up the curve
  87074. */
  87075. constructor(points: Vector3[]);
  87076. /**
  87077. * @returns the Curve3 stored array of successive Vector3
  87078. */
  87079. getPoints(): Vector3[];
  87080. /**
  87081. * @returns the computed length (float) of the curve.
  87082. */
  87083. length(): number;
  87084. /**
  87085. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  87086. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  87087. * curveA and curveB keep unchanged.
  87088. * @param curve the curve to continue from this curve
  87089. * @returns the newly constructed curve
  87090. */
  87091. continue(curve: DeepImmutable<Curve3>): Curve3;
  87092. private _computeLength;
  87093. }
  87094. }
  87095. declare module BABYLON {
  87096. /**
  87097. * This represents the main contract an easing function should follow.
  87098. * Easing functions are used throughout the animation system.
  87099. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87100. */
  87101. export interface IEasingFunction {
  87102. /**
  87103. * Given an input gradient between 0 and 1, this returns the corrseponding value
  87104. * of the easing function.
  87105. * The link below provides some of the most common examples of easing functions.
  87106. * @see https://easings.net/
  87107. * @param gradient Defines the value between 0 and 1 we want the easing value for
  87108. * @returns the corresponding value on the curve defined by the easing function
  87109. */
  87110. ease(gradient: number): number;
  87111. }
  87112. /**
  87113. * Base class used for every default easing function.
  87114. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87115. */
  87116. export class EasingFunction implements IEasingFunction {
  87117. /**
  87118. * Interpolation follows the mathematical formula associated with the easing function.
  87119. */
  87120. static readonly EASINGMODE_EASEIN: number;
  87121. /**
  87122. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  87123. */
  87124. static readonly EASINGMODE_EASEOUT: number;
  87125. /**
  87126. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  87127. */
  87128. static readonly EASINGMODE_EASEINOUT: number;
  87129. private _easingMode;
  87130. /**
  87131. * Sets the easing mode of the current function.
  87132. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  87133. */
  87134. setEasingMode(easingMode: number): void;
  87135. /**
  87136. * Gets the current easing mode.
  87137. * @returns the easing mode
  87138. */
  87139. getEasingMode(): number;
  87140. /**
  87141. * @hidden
  87142. */
  87143. easeInCore(gradient: number): number;
  87144. /**
  87145. * Given an input gradient between 0 and 1, this returns the corresponding value
  87146. * of the easing function.
  87147. * @param gradient Defines the value between 0 and 1 we want the easing value for
  87148. * @returns the corresponding value on the curve defined by the easing function
  87149. */
  87150. ease(gradient: number): number;
  87151. }
  87152. /**
  87153. * Easing function with a circle shape (see link below).
  87154. * @see https://easings.net/#easeInCirc
  87155. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87156. */
  87157. export class CircleEase extends EasingFunction implements IEasingFunction {
  87158. /** @hidden */
  87159. easeInCore(gradient: number): number;
  87160. }
  87161. /**
  87162. * Easing function with a ease back shape (see link below).
  87163. * @see https://easings.net/#easeInBack
  87164. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87165. */
  87166. export class BackEase extends EasingFunction implements IEasingFunction {
  87167. /** Defines the amplitude of the function */
  87168. amplitude: number;
  87169. /**
  87170. * Instantiates a back ease easing
  87171. * @see https://easings.net/#easeInBack
  87172. * @param amplitude Defines the amplitude of the function
  87173. */
  87174. constructor(
  87175. /** Defines the amplitude of the function */
  87176. amplitude?: number);
  87177. /** @hidden */
  87178. easeInCore(gradient: number): number;
  87179. }
  87180. /**
  87181. * Easing function with a bouncing shape (see link below).
  87182. * @see https://easings.net/#easeInBounce
  87183. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87184. */
  87185. export class BounceEase extends EasingFunction implements IEasingFunction {
  87186. /** Defines the number of bounces */
  87187. bounces: number;
  87188. /** Defines the amplitude of the bounce */
  87189. bounciness: number;
  87190. /**
  87191. * Instantiates a bounce easing
  87192. * @see https://easings.net/#easeInBounce
  87193. * @param bounces Defines the number of bounces
  87194. * @param bounciness Defines the amplitude of the bounce
  87195. */
  87196. constructor(
  87197. /** Defines the number of bounces */
  87198. bounces?: number,
  87199. /** Defines the amplitude of the bounce */
  87200. bounciness?: number);
  87201. /** @hidden */
  87202. easeInCore(gradient: number): number;
  87203. }
  87204. /**
  87205. * Easing function with a power of 3 shape (see link below).
  87206. * @see https://easings.net/#easeInCubic
  87207. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87208. */
  87209. export class CubicEase extends EasingFunction implements IEasingFunction {
  87210. /** @hidden */
  87211. easeInCore(gradient: number): number;
  87212. }
  87213. /**
  87214. * Easing function with an elastic shape (see link below).
  87215. * @see https://easings.net/#easeInElastic
  87216. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87217. */
  87218. export class ElasticEase extends EasingFunction implements IEasingFunction {
  87219. /** Defines the number of oscillations*/
  87220. oscillations: number;
  87221. /** Defines the amplitude of the oscillations*/
  87222. springiness: number;
  87223. /**
  87224. * Instantiates an elastic easing function
  87225. * @see https://easings.net/#easeInElastic
  87226. * @param oscillations Defines the number of oscillations
  87227. * @param springiness Defines the amplitude of the oscillations
  87228. */
  87229. constructor(
  87230. /** Defines the number of oscillations*/
  87231. oscillations?: number,
  87232. /** Defines the amplitude of the oscillations*/
  87233. springiness?: number);
  87234. /** @hidden */
  87235. easeInCore(gradient: number): number;
  87236. }
  87237. /**
  87238. * Easing function with an exponential shape (see link below).
  87239. * @see https://easings.net/#easeInExpo
  87240. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87241. */
  87242. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  87243. /** Defines the exponent of the function */
  87244. exponent: number;
  87245. /**
  87246. * Instantiates an exponential easing function
  87247. * @see https://easings.net/#easeInExpo
  87248. * @param exponent Defines the exponent of the function
  87249. */
  87250. constructor(
  87251. /** Defines the exponent of the function */
  87252. exponent?: number);
  87253. /** @hidden */
  87254. easeInCore(gradient: number): number;
  87255. }
  87256. /**
  87257. * Easing function with a power shape (see link below).
  87258. * @see https://easings.net/#easeInQuad
  87259. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87260. */
  87261. export class PowerEase extends EasingFunction implements IEasingFunction {
  87262. /** Defines the power of the function */
  87263. power: number;
  87264. /**
  87265. * Instantiates an power base easing function
  87266. * @see https://easings.net/#easeInQuad
  87267. * @param power Defines the power of the function
  87268. */
  87269. constructor(
  87270. /** Defines the power of the function */
  87271. power?: number);
  87272. /** @hidden */
  87273. easeInCore(gradient: number): number;
  87274. }
  87275. /**
  87276. * Easing function with a power of 2 shape (see link below).
  87277. * @see https://easings.net/#easeInQuad
  87278. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87279. */
  87280. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  87281. /** @hidden */
  87282. easeInCore(gradient: number): number;
  87283. }
  87284. /**
  87285. * Easing function with a power of 4 shape (see link below).
  87286. * @see https://easings.net/#easeInQuart
  87287. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87288. */
  87289. export class QuarticEase extends EasingFunction implements IEasingFunction {
  87290. /** @hidden */
  87291. easeInCore(gradient: number): number;
  87292. }
  87293. /**
  87294. * Easing function with a power of 5 shape (see link below).
  87295. * @see https://easings.net/#easeInQuint
  87296. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87297. */
  87298. export class QuinticEase extends EasingFunction implements IEasingFunction {
  87299. /** @hidden */
  87300. easeInCore(gradient: number): number;
  87301. }
  87302. /**
  87303. * Easing function with a sin shape (see link below).
  87304. * @see https://easings.net/#easeInSine
  87305. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87306. */
  87307. export class SineEase extends EasingFunction implements IEasingFunction {
  87308. /** @hidden */
  87309. easeInCore(gradient: number): number;
  87310. }
  87311. /**
  87312. * Easing function with a bezier shape (see link below).
  87313. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  87314. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87315. */
  87316. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  87317. /** Defines the x component of the start tangent in the bezier curve */
  87318. x1: number;
  87319. /** Defines the y component of the start tangent in the bezier curve */
  87320. y1: number;
  87321. /** Defines the x component of the end tangent in the bezier curve */
  87322. x2: number;
  87323. /** Defines the y component of the end tangent in the bezier curve */
  87324. y2: number;
  87325. /**
  87326. * Instantiates a bezier function
  87327. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  87328. * @param x1 Defines the x component of the start tangent in the bezier curve
  87329. * @param y1 Defines the y component of the start tangent in the bezier curve
  87330. * @param x2 Defines the x component of the end tangent in the bezier curve
  87331. * @param y2 Defines the y component of the end tangent in the bezier curve
  87332. */
  87333. constructor(
  87334. /** Defines the x component of the start tangent in the bezier curve */
  87335. x1?: number,
  87336. /** Defines the y component of the start tangent in the bezier curve */
  87337. y1?: number,
  87338. /** Defines the x component of the end tangent in the bezier curve */
  87339. x2?: number,
  87340. /** Defines the y component of the end tangent in the bezier curve */
  87341. y2?: number);
  87342. /** @hidden */
  87343. easeInCore(gradient: number): number;
  87344. }
  87345. }
  87346. declare module BABYLON {
  87347. /**
  87348. * Class used to hold a RBG color
  87349. */
  87350. export class Color3 {
  87351. /**
  87352. * Defines the red component (between 0 and 1, default is 0)
  87353. */
  87354. r: number;
  87355. /**
  87356. * Defines the green component (between 0 and 1, default is 0)
  87357. */
  87358. g: number;
  87359. /**
  87360. * Defines the blue component (between 0 and 1, default is 0)
  87361. */
  87362. b: number;
  87363. /**
  87364. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  87365. * @param r defines the red component (between 0 and 1, default is 0)
  87366. * @param g defines the green component (between 0 and 1, default is 0)
  87367. * @param b defines the blue component (between 0 and 1, default is 0)
  87368. */
  87369. constructor(
  87370. /**
  87371. * Defines the red component (between 0 and 1, default is 0)
  87372. */
  87373. r?: number,
  87374. /**
  87375. * Defines the green component (between 0 and 1, default is 0)
  87376. */
  87377. g?: number,
  87378. /**
  87379. * Defines the blue component (between 0 and 1, default is 0)
  87380. */
  87381. b?: number);
  87382. /**
  87383. * Creates a string with the Color3 current values
  87384. * @returns the string representation of the Color3 object
  87385. */
  87386. toString(): string;
  87387. /**
  87388. * Returns the string "Color3"
  87389. * @returns "Color3"
  87390. */
  87391. getClassName(): string;
  87392. /**
  87393. * Compute the Color3 hash code
  87394. * @returns an unique number that can be used to hash Color3 objects
  87395. */
  87396. getHashCode(): number;
  87397. /**
  87398. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  87399. * @param array defines the array where to store the r,g,b components
  87400. * @param index defines an optional index in the target array to define where to start storing values
  87401. * @returns the current Color3 object
  87402. */
  87403. toArray(array: FloatArray, index?: number): Color3;
  87404. /**
  87405. * Update the current color with values stored in an array from the starting index of the given array
  87406. * @param array defines the source array
  87407. * @param offset defines an offset in the source array
  87408. * @returns the current Color3 object
  87409. */
  87410. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  87411. /**
  87412. * Returns a new Color4 object from the current Color3 and the given alpha
  87413. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  87414. * @returns a new Color4 object
  87415. */
  87416. toColor4(alpha?: number): Color4;
  87417. /**
  87418. * Returns a new array populated with 3 numeric elements : red, green and blue values
  87419. * @returns the new array
  87420. */
  87421. asArray(): number[];
  87422. /**
  87423. * Returns the luminance value
  87424. * @returns a float value
  87425. */
  87426. toLuminance(): number;
  87427. /**
  87428. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  87429. * @param otherColor defines the second operand
  87430. * @returns the new Color3 object
  87431. */
  87432. multiply(otherColor: DeepImmutable<Color3>): Color3;
  87433. /**
  87434. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  87435. * @param otherColor defines the second operand
  87436. * @param result defines the Color3 object where to store the result
  87437. * @returns the current Color3
  87438. */
  87439. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  87440. /**
  87441. * Determines equality between Color3 objects
  87442. * @param otherColor defines the second operand
  87443. * @returns true if the rgb values are equal to the given ones
  87444. */
  87445. equals(otherColor: DeepImmutable<Color3>): boolean;
  87446. /**
  87447. * Determines equality between the current Color3 object and a set of r,b,g values
  87448. * @param r defines the red component to check
  87449. * @param g defines the green component to check
  87450. * @param b defines the blue component to check
  87451. * @returns true if the rgb values are equal to the given ones
  87452. */
  87453. equalsFloats(r: number, g: number, b: number): boolean;
  87454. /**
  87455. * Multiplies in place each rgb value by scale
  87456. * @param scale defines the scaling factor
  87457. * @returns the updated Color3
  87458. */
  87459. scale(scale: number): Color3;
  87460. /**
  87461. * Multiplies the rgb values by scale and stores the result into "result"
  87462. * @param scale defines the scaling factor
  87463. * @param result defines the Color3 object where to store the result
  87464. * @returns the unmodified current Color3
  87465. */
  87466. scaleToRef(scale: number, result: Color3): Color3;
  87467. /**
  87468. * Scale the current Color3 values by a factor and add the result to a given Color3
  87469. * @param scale defines the scale factor
  87470. * @param result defines color to store the result into
  87471. * @returns the unmodified current Color3
  87472. */
  87473. scaleAndAddToRef(scale: number, result: Color3): Color3;
  87474. /**
  87475. * Clamps the rgb values by the min and max values and stores the result into "result"
  87476. * @param min defines minimum clamping value (default is 0)
  87477. * @param max defines maximum clamping value (default is 1)
  87478. * @param result defines color to store the result into
  87479. * @returns the original Color3
  87480. */
  87481. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  87482. /**
  87483. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  87484. * @param otherColor defines the second operand
  87485. * @returns the new Color3
  87486. */
  87487. add(otherColor: DeepImmutable<Color3>): Color3;
  87488. /**
  87489. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  87490. * @param otherColor defines the second operand
  87491. * @param result defines Color3 object to store the result into
  87492. * @returns the unmodified current Color3
  87493. */
  87494. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  87495. /**
  87496. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  87497. * @param otherColor defines the second operand
  87498. * @returns the new Color3
  87499. */
  87500. subtract(otherColor: DeepImmutable<Color3>): Color3;
  87501. /**
  87502. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  87503. * @param otherColor defines the second operand
  87504. * @param result defines Color3 object to store the result into
  87505. * @returns the unmodified current Color3
  87506. */
  87507. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  87508. /**
  87509. * Copy the current object
  87510. * @returns a new Color3 copied the current one
  87511. */
  87512. clone(): Color3;
  87513. /**
  87514. * Copies the rgb values from the source in the current Color3
  87515. * @param source defines the source Color3 object
  87516. * @returns the updated Color3 object
  87517. */
  87518. copyFrom(source: DeepImmutable<Color3>): Color3;
  87519. /**
  87520. * Updates the Color3 rgb values from the given floats
  87521. * @param r defines the red component to read from
  87522. * @param g defines the green component to read from
  87523. * @param b defines the blue component to read from
  87524. * @returns the current Color3 object
  87525. */
  87526. copyFromFloats(r: number, g: number, b: number): Color3;
  87527. /**
  87528. * Updates the Color3 rgb values from the given floats
  87529. * @param r defines the red component to read from
  87530. * @param g defines the green component to read from
  87531. * @param b defines the blue component to read from
  87532. * @returns the current Color3 object
  87533. */
  87534. set(r: number, g: number, b: number): Color3;
  87535. /**
  87536. * Compute the Color3 hexadecimal code as a string
  87537. * @returns a string containing the hexadecimal representation of the Color3 object
  87538. */
  87539. toHexString(): string;
  87540. /**
  87541. * Computes a new Color3 converted from the current one to linear space
  87542. * @returns a new Color3 object
  87543. */
  87544. toLinearSpace(): Color3;
  87545. /**
  87546. * Converts current color in rgb space to HSV values
  87547. * @returns a new color3 representing the HSV values
  87548. */
  87549. toHSV(): Color3;
  87550. /**
  87551. * Converts current color in rgb space to HSV values
  87552. * @param result defines the Color3 where to store the HSV values
  87553. */
  87554. toHSVToRef(result: Color3): void;
  87555. /**
  87556. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  87557. * @param convertedColor defines the Color3 object where to store the linear space version
  87558. * @returns the unmodified Color3
  87559. */
  87560. toLinearSpaceToRef(convertedColor: Color3): Color3;
  87561. /**
  87562. * Computes a new Color3 converted from the current one to gamma space
  87563. * @returns a new Color3 object
  87564. */
  87565. toGammaSpace(): Color3;
  87566. /**
  87567. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  87568. * @param convertedColor defines the Color3 object where to store the gamma space version
  87569. * @returns the unmodified Color3
  87570. */
  87571. toGammaSpaceToRef(convertedColor: Color3): Color3;
  87572. private static _BlackReadOnly;
  87573. /**
  87574. * Convert Hue, saturation and value to a Color3 (RGB)
  87575. * @param hue defines the hue
  87576. * @param saturation defines the saturation
  87577. * @param value defines the value
  87578. * @param result defines the Color3 where to store the RGB values
  87579. */
  87580. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  87581. /**
  87582. * Creates a new Color3 from the string containing valid hexadecimal values
  87583. * @param hex defines a string containing valid hexadecimal values
  87584. * @returns a new Color3 object
  87585. */
  87586. static FromHexString(hex: string): Color3;
  87587. /**
  87588. * Creates a new Color3 from the starting index of the given array
  87589. * @param array defines the source array
  87590. * @param offset defines an offset in the source array
  87591. * @returns a new Color3 object
  87592. */
  87593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  87594. /**
  87595. * Creates a new Color3 from the starting index element of the given array
  87596. * @param array defines the source array to read from
  87597. * @param offset defines the offset in the source array
  87598. * @param result defines the target Color3 object
  87599. */
  87600. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  87601. /**
  87602. * Creates a new Color3 from integer values (< 256)
  87603. * @param r defines the red component to read from (value between 0 and 255)
  87604. * @param g defines the green component to read from (value between 0 and 255)
  87605. * @param b defines the blue component to read from (value between 0 and 255)
  87606. * @returns a new Color3 object
  87607. */
  87608. static FromInts(r: number, g: number, b: number): Color3;
  87609. /**
  87610. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  87611. * @param start defines the start Color3 value
  87612. * @param end defines the end Color3 value
  87613. * @param amount defines the gradient value between start and end
  87614. * @returns a new Color3 object
  87615. */
  87616. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  87617. /**
  87618. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  87619. * @param left defines the start value
  87620. * @param right defines the end value
  87621. * @param amount defines the gradient factor
  87622. * @param result defines the Color3 object where to store the result
  87623. */
  87624. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  87625. /**
  87626. * Returns a Color3 value containing a red color
  87627. * @returns a new Color3 object
  87628. */
  87629. static Red(): Color3;
  87630. /**
  87631. * Returns a Color3 value containing a green color
  87632. * @returns a new Color3 object
  87633. */
  87634. static Green(): Color3;
  87635. /**
  87636. * Returns a Color3 value containing a blue color
  87637. * @returns a new Color3 object
  87638. */
  87639. static Blue(): Color3;
  87640. /**
  87641. * Returns a Color3 value containing a black color
  87642. * @returns a new Color3 object
  87643. */
  87644. static Black(): Color3;
  87645. /**
  87646. * Gets a Color3 value containing a black color that must not be updated
  87647. */
  87648. static get BlackReadOnly(): DeepImmutable<Color3>;
  87649. /**
  87650. * Returns a Color3 value containing a white color
  87651. * @returns a new Color3 object
  87652. */
  87653. static White(): Color3;
  87654. /**
  87655. * Returns a Color3 value containing a purple color
  87656. * @returns a new Color3 object
  87657. */
  87658. static Purple(): Color3;
  87659. /**
  87660. * Returns a Color3 value containing a magenta color
  87661. * @returns a new Color3 object
  87662. */
  87663. static Magenta(): Color3;
  87664. /**
  87665. * Returns a Color3 value containing a yellow color
  87666. * @returns a new Color3 object
  87667. */
  87668. static Yellow(): Color3;
  87669. /**
  87670. * Returns a Color3 value containing a gray color
  87671. * @returns a new Color3 object
  87672. */
  87673. static Gray(): Color3;
  87674. /**
  87675. * Returns a Color3 value containing a teal color
  87676. * @returns a new Color3 object
  87677. */
  87678. static Teal(): Color3;
  87679. /**
  87680. * Returns a Color3 value containing a random color
  87681. * @returns a new Color3 object
  87682. */
  87683. static Random(): Color3;
  87684. }
  87685. /**
  87686. * Class used to hold a RBGA color
  87687. */
  87688. export class Color4 {
  87689. /**
  87690. * Defines the red component (between 0 and 1, default is 0)
  87691. */
  87692. r: number;
  87693. /**
  87694. * Defines the green component (between 0 and 1, default is 0)
  87695. */
  87696. g: number;
  87697. /**
  87698. * Defines the blue component (between 0 and 1, default is 0)
  87699. */
  87700. b: number;
  87701. /**
  87702. * Defines the alpha component (between 0 and 1, default is 1)
  87703. */
  87704. a: number;
  87705. /**
  87706. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  87707. * @param r defines the red component (between 0 and 1, default is 0)
  87708. * @param g defines the green component (between 0 and 1, default is 0)
  87709. * @param b defines the blue component (between 0 and 1, default is 0)
  87710. * @param a defines the alpha component (between 0 and 1, default is 1)
  87711. */
  87712. constructor(
  87713. /**
  87714. * Defines the red component (between 0 and 1, default is 0)
  87715. */
  87716. r?: number,
  87717. /**
  87718. * Defines the green component (between 0 and 1, default is 0)
  87719. */
  87720. g?: number,
  87721. /**
  87722. * Defines the blue component (between 0 and 1, default is 0)
  87723. */
  87724. b?: number,
  87725. /**
  87726. * Defines the alpha component (between 0 and 1, default is 1)
  87727. */
  87728. a?: number);
  87729. /**
  87730. * Adds in place the given Color4 values to the current Color4 object
  87731. * @param right defines the second operand
  87732. * @returns the current updated Color4 object
  87733. */
  87734. addInPlace(right: DeepImmutable<Color4>): Color4;
  87735. /**
  87736. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  87737. * @returns the new array
  87738. */
  87739. asArray(): number[];
  87740. /**
  87741. * Stores from the starting index in the given array the Color4 successive values
  87742. * @param array defines the array where to store the r,g,b components
  87743. * @param index defines an optional index in the target array to define where to start storing values
  87744. * @returns the current Color4 object
  87745. */
  87746. toArray(array: number[], index?: number): Color4;
  87747. /**
  87748. * Update the current color with values stored in an array from the starting index of the given array
  87749. * @param array defines the source array
  87750. * @param offset defines an offset in the source array
  87751. * @returns the current Color4 object
  87752. */
  87753. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  87754. /**
  87755. * Determines equality between Color4 objects
  87756. * @param otherColor defines the second operand
  87757. * @returns true if the rgba values are equal to the given ones
  87758. */
  87759. equals(otherColor: DeepImmutable<Color4>): boolean;
  87760. /**
  87761. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  87762. * @param right defines the second operand
  87763. * @returns a new Color4 object
  87764. */
  87765. add(right: DeepImmutable<Color4>): Color4;
  87766. /**
  87767. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  87768. * @param right defines the second operand
  87769. * @returns a new Color4 object
  87770. */
  87771. subtract(right: DeepImmutable<Color4>): Color4;
  87772. /**
  87773. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  87774. * @param right defines the second operand
  87775. * @param result defines the Color4 object where to store the result
  87776. * @returns the current Color4 object
  87777. */
  87778. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  87779. /**
  87780. * Creates a new Color4 with the current Color4 values multiplied by scale
  87781. * @param scale defines the scaling factor to apply
  87782. * @returns a new Color4 object
  87783. */
  87784. scale(scale: number): Color4;
  87785. /**
  87786. * Multiplies the current Color4 values by scale and stores the result in "result"
  87787. * @param scale defines the scaling factor to apply
  87788. * @param result defines the Color4 object where to store the result
  87789. * @returns the current unmodified Color4
  87790. */
  87791. scaleToRef(scale: number, result: Color4): Color4;
  87792. /**
  87793. * Scale the current Color4 values by a factor and add the result to a given Color4
  87794. * @param scale defines the scale factor
  87795. * @param result defines the Color4 object where to store the result
  87796. * @returns the unmodified current Color4
  87797. */
  87798. scaleAndAddToRef(scale: number, result: Color4): Color4;
  87799. /**
  87800. * Clamps the rgb values by the min and max values and stores the result into "result"
  87801. * @param min defines minimum clamping value (default is 0)
  87802. * @param max defines maximum clamping value (default is 1)
  87803. * @param result defines color to store the result into.
  87804. * @returns the cuurent Color4
  87805. */
  87806. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  87807. /**
  87808. * Multipy an Color4 value by another and return a new Color4 object
  87809. * @param color defines the Color4 value to multiply by
  87810. * @returns a new Color4 object
  87811. */
  87812. multiply(color: Color4): Color4;
  87813. /**
  87814. * Multipy a Color4 value by another and push the result in a reference value
  87815. * @param color defines the Color4 value to multiply by
  87816. * @param result defines the Color4 to fill the result in
  87817. * @returns the result Color4
  87818. */
  87819. multiplyToRef(color: Color4, result: Color4): Color4;
  87820. /**
  87821. * Creates a string with the Color4 current values
  87822. * @returns the string representation of the Color4 object
  87823. */
  87824. toString(): string;
  87825. /**
  87826. * Returns the string "Color4"
  87827. * @returns "Color4"
  87828. */
  87829. getClassName(): string;
  87830. /**
  87831. * Compute the Color4 hash code
  87832. * @returns an unique number that can be used to hash Color4 objects
  87833. */
  87834. getHashCode(): number;
  87835. /**
  87836. * Creates a new Color4 copied from the current one
  87837. * @returns a new Color4 object
  87838. */
  87839. clone(): Color4;
  87840. /**
  87841. * Copies the given Color4 values into the current one
  87842. * @param source defines the source Color4 object
  87843. * @returns the current updated Color4 object
  87844. */
  87845. copyFrom(source: Color4): Color4;
  87846. /**
  87847. * Copies the given float values into the current one
  87848. * @param r defines the red component to read from
  87849. * @param g defines the green component to read from
  87850. * @param b defines the blue component to read from
  87851. * @param a defines the alpha component to read from
  87852. * @returns the current updated Color4 object
  87853. */
  87854. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  87855. /**
  87856. * Copies the given float values into the current one
  87857. * @param r defines the red component to read from
  87858. * @param g defines the green component to read from
  87859. * @param b defines the blue component to read from
  87860. * @param a defines the alpha component to read from
  87861. * @returns the current updated Color4 object
  87862. */
  87863. set(r: number, g: number, b: number, a: number): Color4;
  87864. /**
  87865. * Compute the Color4 hexadecimal code as a string
  87866. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  87867. * @returns a string containing the hexadecimal representation of the Color4 object
  87868. */
  87869. toHexString(returnAsColor3?: boolean): string;
  87870. /**
  87871. * Computes a new Color4 converted from the current one to linear space
  87872. * @returns a new Color4 object
  87873. */
  87874. toLinearSpace(): Color4;
  87875. /**
  87876. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  87877. * @param convertedColor defines the Color4 object where to store the linear space version
  87878. * @returns the unmodified Color4
  87879. */
  87880. toLinearSpaceToRef(convertedColor: Color4): Color4;
  87881. /**
  87882. * Computes a new Color4 converted from the current one to gamma space
  87883. * @returns a new Color4 object
  87884. */
  87885. toGammaSpace(): Color4;
  87886. /**
  87887. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  87888. * @param convertedColor defines the Color4 object where to store the gamma space version
  87889. * @returns the unmodified Color4
  87890. */
  87891. toGammaSpaceToRef(convertedColor: Color4): Color4;
  87892. /**
  87893. * Creates a new Color4 from the string containing valid hexadecimal values
  87894. * @param hex defines a string containing valid hexadecimal values
  87895. * @returns a new Color4 object
  87896. */
  87897. static FromHexString(hex: string): Color4;
  87898. /**
  87899. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  87900. * @param left defines the start value
  87901. * @param right defines the end value
  87902. * @param amount defines the gradient factor
  87903. * @returns a new Color4 object
  87904. */
  87905. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  87906. /**
  87907. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  87908. * @param left defines the start value
  87909. * @param right defines the end value
  87910. * @param amount defines the gradient factor
  87911. * @param result defines the Color4 object where to store data
  87912. */
  87913. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  87914. /**
  87915. * Creates a new Color4 from a Color3 and an alpha value
  87916. * @param color3 defines the source Color3 to read from
  87917. * @param alpha defines the alpha component (1.0 by default)
  87918. * @returns a new Color4 object
  87919. */
  87920. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  87921. /**
  87922. * Creates a new Color4 from the starting index element of the given array
  87923. * @param array defines the source array to read from
  87924. * @param offset defines the offset in the source array
  87925. * @returns a new Color4 object
  87926. */
  87927. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  87928. /**
  87929. * Creates a new Color4 from the starting index element of the given array
  87930. * @param array defines the source array to read from
  87931. * @param offset defines the offset in the source array
  87932. * @param result defines the target Color4 object
  87933. */
  87934. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  87935. /**
  87936. * Creates a new Color3 from integer values (< 256)
  87937. * @param r defines the red component to read from (value between 0 and 255)
  87938. * @param g defines the green component to read from (value between 0 and 255)
  87939. * @param b defines the blue component to read from (value between 0 and 255)
  87940. * @param a defines the alpha component to read from (value between 0 and 255)
  87941. * @returns a new Color3 object
  87942. */
  87943. static FromInts(r: number, g: number, b: number, a: number): Color4;
  87944. /**
  87945. * Check the content of a given array and convert it to an array containing RGBA data
  87946. * If the original array was already containing count * 4 values then it is returned directly
  87947. * @param colors defines the array to check
  87948. * @param count defines the number of RGBA data to expect
  87949. * @returns an array containing count * 4 values (RGBA)
  87950. */
  87951. static CheckColors4(colors: number[], count: number): number[];
  87952. }
  87953. /**
  87954. * @hidden
  87955. */
  87956. export class TmpColors {
  87957. static Color3: Color3[];
  87958. static Color4: Color4[];
  87959. }
  87960. }
  87961. declare module BABYLON {
  87962. /**
  87963. * Defines an interface which represents an animation key frame
  87964. */
  87965. export interface IAnimationKey {
  87966. /**
  87967. * Frame of the key frame
  87968. */
  87969. frame: number;
  87970. /**
  87971. * Value at the specifies key frame
  87972. */
  87973. value: any;
  87974. /**
  87975. * The input tangent for the cubic hermite spline
  87976. */
  87977. inTangent?: any;
  87978. /**
  87979. * The output tangent for the cubic hermite spline
  87980. */
  87981. outTangent?: any;
  87982. /**
  87983. * The animation interpolation type
  87984. */
  87985. interpolation?: AnimationKeyInterpolation;
  87986. }
  87987. /**
  87988. * Enum for the animation key frame interpolation type
  87989. */
  87990. export enum AnimationKeyInterpolation {
  87991. /**
  87992. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  87993. */
  87994. STEP = 1
  87995. }
  87996. }
  87997. declare module BABYLON {
  87998. /**
  87999. * Represents the range of an animation
  88000. */
  88001. export class AnimationRange {
  88002. /**The name of the animation range**/
  88003. name: string;
  88004. /**The starting frame of the animation */
  88005. from: number;
  88006. /**The ending frame of the animation*/
  88007. to: number;
  88008. /**
  88009. * Initializes the range of an animation
  88010. * @param name The name of the animation range
  88011. * @param from The starting frame of the animation
  88012. * @param to The ending frame of the animation
  88013. */
  88014. constructor(
  88015. /**The name of the animation range**/
  88016. name: string,
  88017. /**The starting frame of the animation */
  88018. from: number,
  88019. /**The ending frame of the animation*/
  88020. to: number);
  88021. /**
  88022. * Makes a copy of the animation range
  88023. * @returns A copy of the animation range
  88024. */
  88025. clone(): AnimationRange;
  88026. }
  88027. }
  88028. declare module BABYLON {
  88029. /**
  88030. * Composed of a frame, and an action function
  88031. */
  88032. export class AnimationEvent {
  88033. /** The frame for which the event is triggered **/
  88034. frame: number;
  88035. /** The event to perform when triggered **/
  88036. action: (currentFrame: number) => void;
  88037. /** Specifies if the event should be triggered only once**/
  88038. onlyOnce?: boolean | undefined;
  88039. /**
  88040. * Specifies if the animation event is done
  88041. */
  88042. isDone: boolean;
  88043. /**
  88044. * Initializes the animation event
  88045. * @param frame The frame for which the event is triggered
  88046. * @param action The event to perform when triggered
  88047. * @param onlyOnce Specifies if the event should be triggered only once
  88048. */
  88049. constructor(
  88050. /** The frame for which the event is triggered **/
  88051. frame: number,
  88052. /** The event to perform when triggered **/
  88053. action: (currentFrame: number) => void,
  88054. /** Specifies if the event should be triggered only once**/
  88055. onlyOnce?: boolean | undefined);
  88056. /** @hidden */
  88057. _clone(): AnimationEvent;
  88058. }
  88059. }
  88060. declare module BABYLON {
  88061. /**
  88062. * Interface used to define a behavior
  88063. */
  88064. export interface Behavior<T> {
  88065. /** gets or sets behavior's name */
  88066. name: string;
  88067. /**
  88068. * Function called when the behavior needs to be initialized (after attaching it to a target)
  88069. */
  88070. init(): void;
  88071. /**
  88072. * Called when the behavior is attached to a target
  88073. * @param target defines the target where the behavior is attached to
  88074. */
  88075. attach(target: T): void;
  88076. /**
  88077. * Called when the behavior is detached from its target
  88078. */
  88079. detach(): void;
  88080. }
  88081. /**
  88082. * Interface implemented by classes supporting behaviors
  88083. */
  88084. export interface IBehaviorAware<T> {
  88085. /**
  88086. * Attach a behavior
  88087. * @param behavior defines the behavior to attach
  88088. * @returns the current host
  88089. */
  88090. addBehavior(behavior: Behavior<T>): T;
  88091. /**
  88092. * Remove a behavior from the current object
  88093. * @param behavior defines the behavior to detach
  88094. * @returns the current host
  88095. */
  88096. removeBehavior(behavior: Behavior<T>): T;
  88097. /**
  88098. * Gets a behavior using its name to search
  88099. * @param name defines the name to search
  88100. * @returns the behavior or null if not found
  88101. */
  88102. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  88103. }
  88104. }
  88105. declare module BABYLON {
  88106. /**
  88107. * Class used to store data that will be store in GPU memory
  88108. */
  88109. export class Buffer {
  88110. private _engine;
  88111. private _buffer;
  88112. /** @hidden */
  88113. _data: Nullable<DataArray>;
  88114. private _updatable;
  88115. private _instanced;
  88116. private _divisor;
  88117. /**
  88118. * Gets the byte stride.
  88119. */
  88120. readonly byteStride: number;
  88121. /**
  88122. * Constructor
  88123. * @param engine the engine
  88124. * @param data the data to use for this buffer
  88125. * @param updatable whether the data is updatable
  88126. * @param stride the stride (optional)
  88127. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  88128. * @param instanced whether the buffer is instanced (optional)
  88129. * @param useBytes set to true if the stride in in bytes (optional)
  88130. * @param divisor sets an optional divisor for instances (1 by default)
  88131. */
  88132. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  88133. /**
  88134. * Create a new VertexBuffer based on the current buffer
  88135. * @param kind defines the vertex buffer kind (position, normal, etc.)
  88136. * @param offset defines offset in the buffer (0 by default)
  88137. * @param size defines the size in floats of attributes (position is 3 for instance)
  88138. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  88139. * @param instanced defines if the vertex buffer contains indexed data
  88140. * @param useBytes defines if the offset and stride are in bytes *
  88141. * @param divisor sets an optional divisor for instances (1 by default)
  88142. * @returns the new vertex buffer
  88143. */
  88144. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  88145. /**
  88146. * Gets a boolean indicating if the Buffer is updatable?
  88147. * @returns true if the buffer is updatable
  88148. */
  88149. isUpdatable(): boolean;
  88150. /**
  88151. * Gets current buffer's data
  88152. * @returns a DataArray or null
  88153. */
  88154. getData(): Nullable<DataArray>;
  88155. /**
  88156. * Gets underlying native buffer
  88157. * @returns underlying native buffer
  88158. */
  88159. getBuffer(): Nullable<DataBuffer>;
  88160. /**
  88161. * Gets the stride in float32 units (i.e. byte stride / 4).
  88162. * May not be an integer if the byte stride is not divisible by 4.
  88163. * @returns the stride in float32 units
  88164. * @deprecated Please use byteStride instead.
  88165. */
  88166. getStrideSize(): number;
  88167. /**
  88168. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  88169. * @param data defines the data to store
  88170. */
  88171. create(data?: Nullable<DataArray>): void;
  88172. /** @hidden */
  88173. _rebuild(): void;
  88174. /**
  88175. * Update current buffer data
  88176. * @param data defines the data to store
  88177. */
  88178. update(data: DataArray): void;
  88179. /**
  88180. * Updates the data directly.
  88181. * @param data the new data
  88182. * @param offset the new offset
  88183. * @param vertexCount the vertex count (optional)
  88184. * @param useBytes set to true if the offset is in bytes
  88185. */
  88186. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  88187. /**
  88188. * Release all resources
  88189. */
  88190. dispose(): void;
  88191. }
  88192. /**
  88193. * Specialized buffer used to store vertex data
  88194. */
  88195. export class VertexBuffer {
  88196. /** @hidden */
  88197. _buffer: Buffer;
  88198. private _kind;
  88199. private _size;
  88200. private _ownsBuffer;
  88201. private _instanced;
  88202. private _instanceDivisor;
  88203. /**
  88204. * The byte type.
  88205. */
  88206. static readonly BYTE: number;
  88207. /**
  88208. * The unsigned byte type.
  88209. */
  88210. static readonly UNSIGNED_BYTE: number;
  88211. /**
  88212. * The short type.
  88213. */
  88214. static readonly SHORT: number;
  88215. /**
  88216. * The unsigned short type.
  88217. */
  88218. static readonly UNSIGNED_SHORT: number;
  88219. /**
  88220. * The integer type.
  88221. */
  88222. static readonly INT: number;
  88223. /**
  88224. * The unsigned integer type.
  88225. */
  88226. static readonly UNSIGNED_INT: number;
  88227. /**
  88228. * The float type.
  88229. */
  88230. static readonly FLOAT: number;
  88231. /**
  88232. * Gets or sets the instance divisor when in instanced mode
  88233. */
  88234. get instanceDivisor(): number;
  88235. set instanceDivisor(value: number);
  88236. /**
  88237. * Gets the byte stride.
  88238. */
  88239. readonly byteStride: number;
  88240. /**
  88241. * Gets the byte offset.
  88242. */
  88243. readonly byteOffset: number;
  88244. /**
  88245. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  88246. */
  88247. readonly normalized: boolean;
  88248. /**
  88249. * Gets the data type of each component in the array.
  88250. */
  88251. readonly type: number;
  88252. /**
  88253. * Constructor
  88254. * @param engine the engine
  88255. * @param data the data to use for this vertex buffer
  88256. * @param kind the vertex buffer kind
  88257. * @param updatable whether the data is updatable
  88258. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  88259. * @param stride the stride (optional)
  88260. * @param instanced whether the buffer is instanced (optional)
  88261. * @param offset the offset of the data (optional)
  88262. * @param size the number of components (optional)
  88263. * @param type the type of the component (optional)
  88264. * @param normalized whether the data contains normalized data (optional)
  88265. * @param useBytes set to true if stride and offset are in bytes (optional)
  88266. * @param divisor defines the instance divisor to use (1 by default)
  88267. */
  88268. 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);
  88269. /** @hidden */
  88270. _rebuild(): void;
  88271. /**
  88272. * Returns the kind of the VertexBuffer (string)
  88273. * @returns a string
  88274. */
  88275. getKind(): string;
  88276. /**
  88277. * Gets a boolean indicating if the VertexBuffer is updatable?
  88278. * @returns true if the buffer is updatable
  88279. */
  88280. isUpdatable(): boolean;
  88281. /**
  88282. * Gets current buffer's data
  88283. * @returns a DataArray or null
  88284. */
  88285. getData(): Nullable<DataArray>;
  88286. /**
  88287. * Gets underlying native buffer
  88288. * @returns underlying native buffer
  88289. */
  88290. getBuffer(): Nullable<DataBuffer>;
  88291. /**
  88292. * Gets the stride in float32 units (i.e. byte stride / 4).
  88293. * May not be an integer if the byte stride is not divisible by 4.
  88294. * @returns the stride in float32 units
  88295. * @deprecated Please use byteStride instead.
  88296. */
  88297. getStrideSize(): number;
  88298. /**
  88299. * Returns the offset as a multiple of the type byte length.
  88300. * @returns the offset in bytes
  88301. * @deprecated Please use byteOffset instead.
  88302. */
  88303. getOffset(): number;
  88304. /**
  88305. * Returns the number of components per vertex attribute (integer)
  88306. * @returns the size in float
  88307. */
  88308. getSize(): number;
  88309. /**
  88310. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  88311. * @returns true if this buffer is instanced
  88312. */
  88313. getIsInstanced(): boolean;
  88314. /**
  88315. * Returns the instancing divisor, zero for non-instanced (integer).
  88316. * @returns a number
  88317. */
  88318. getInstanceDivisor(): number;
  88319. /**
  88320. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  88321. * @param data defines the data to store
  88322. */
  88323. create(data?: DataArray): void;
  88324. /**
  88325. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  88326. * This function will create a new buffer if the current one is not updatable
  88327. * @param data defines the data to store
  88328. */
  88329. update(data: DataArray): void;
  88330. /**
  88331. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  88332. * Returns the directly updated WebGLBuffer.
  88333. * @param data the new data
  88334. * @param offset the new offset
  88335. * @param useBytes set to true if the offset is in bytes
  88336. */
  88337. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  88338. /**
  88339. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  88340. */
  88341. dispose(): void;
  88342. /**
  88343. * Enumerates each value of this vertex buffer as numbers.
  88344. * @param count the number of values to enumerate
  88345. * @param callback the callback function called for each value
  88346. */
  88347. forEach(count: number, callback: (value: number, index: number) => void): void;
  88348. /**
  88349. * Positions
  88350. */
  88351. static readonly PositionKind: string;
  88352. /**
  88353. * Normals
  88354. */
  88355. static readonly NormalKind: string;
  88356. /**
  88357. * Tangents
  88358. */
  88359. static readonly TangentKind: string;
  88360. /**
  88361. * Texture coordinates
  88362. */
  88363. static readonly UVKind: string;
  88364. /**
  88365. * Texture coordinates 2
  88366. */
  88367. static readonly UV2Kind: string;
  88368. /**
  88369. * Texture coordinates 3
  88370. */
  88371. static readonly UV3Kind: string;
  88372. /**
  88373. * Texture coordinates 4
  88374. */
  88375. static readonly UV4Kind: string;
  88376. /**
  88377. * Texture coordinates 5
  88378. */
  88379. static readonly UV5Kind: string;
  88380. /**
  88381. * Texture coordinates 6
  88382. */
  88383. static readonly UV6Kind: string;
  88384. /**
  88385. * Colors
  88386. */
  88387. static readonly ColorKind: string;
  88388. /**
  88389. * Matrix indices (for bones)
  88390. */
  88391. static readonly MatricesIndicesKind: string;
  88392. /**
  88393. * Matrix weights (for bones)
  88394. */
  88395. static readonly MatricesWeightsKind: string;
  88396. /**
  88397. * Additional matrix indices (for bones)
  88398. */
  88399. static readonly MatricesIndicesExtraKind: string;
  88400. /**
  88401. * Additional matrix weights (for bones)
  88402. */
  88403. static readonly MatricesWeightsExtraKind: string;
  88404. /**
  88405. * Deduces the stride given a kind.
  88406. * @param kind The kind string to deduce
  88407. * @returns The deduced stride
  88408. */
  88409. static DeduceStride(kind: string): number;
  88410. /**
  88411. * Gets the byte length of the given type.
  88412. * @param type the type
  88413. * @returns the number of bytes
  88414. */
  88415. static GetTypeByteLength(type: number): number;
  88416. /**
  88417. * Enumerates each value of the given parameters as numbers.
  88418. * @param data the data to enumerate
  88419. * @param byteOffset the byte offset of the data
  88420. * @param byteStride the byte stride of the data
  88421. * @param componentCount the number of components per element
  88422. * @param componentType the type of the component
  88423. * @param count the number of values to enumerate
  88424. * @param normalized whether the data is normalized
  88425. * @param callback the callback function called for each value
  88426. */
  88427. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  88428. private static _GetFloatValue;
  88429. }
  88430. }
  88431. declare module BABYLON {
  88432. /**
  88433. * @hidden
  88434. */
  88435. export class IntersectionInfo {
  88436. bu: Nullable<number>;
  88437. bv: Nullable<number>;
  88438. distance: number;
  88439. faceId: number;
  88440. subMeshId: number;
  88441. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  88442. }
  88443. }
  88444. declare module BABYLON {
  88445. /**
  88446. * Class used to store bounding sphere information
  88447. */
  88448. export class BoundingSphere {
  88449. /**
  88450. * Gets the center of the bounding sphere in local space
  88451. */
  88452. readonly center: Vector3;
  88453. /**
  88454. * Radius of the bounding sphere in local space
  88455. */
  88456. radius: number;
  88457. /**
  88458. * Gets the center of the bounding sphere in world space
  88459. */
  88460. readonly centerWorld: Vector3;
  88461. /**
  88462. * Radius of the bounding sphere in world space
  88463. */
  88464. radiusWorld: number;
  88465. /**
  88466. * Gets the minimum vector in local space
  88467. */
  88468. readonly minimum: Vector3;
  88469. /**
  88470. * Gets the maximum vector in local space
  88471. */
  88472. readonly maximum: Vector3;
  88473. private _worldMatrix;
  88474. private static readonly TmpVector3;
  88475. /**
  88476. * Creates a new bounding sphere
  88477. * @param min defines the minimum vector (in local space)
  88478. * @param max defines the maximum vector (in local space)
  88479. * @param worldMatrix defines the new world matrix
  88480. */
  88481. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88482. /**
  88483. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  88484. * @param min defines the new minimum vector (in local space)
  88485. * @param max defines the new maximum vector (in local space)
  88486. * @param worldMatrix defines the new world matrix
  88487. */
  88488. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88489. /**
  88490. * Scale the current bounding sphere by applying a scale factor
  88491. * @param factor defines the scale factor to apply
  88492. * @returns the current bounding box
  88493. */
  88494. scale(factor: number): BoundingSphere;
  88495. /**
  88496. * Gets the world matrix of the bounding box
  88497. * @returns a matrix
  88498. */
  88499. getWorldMatrix(): DeepImmutable<Matrix>;
  88500. /** @hidden */
  88501. _update(worldMatrix: DeepImmutable<Matrix>): void;
  88502. /**
  88503. * Tests if the bounding sphere is intersecting the frustum planes
  88504. * @param frustumPlanes defines the frustum planes to test
  88505. * @returns true if there is an intersection
  88506. */
  88507. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88508. /**
  88509. * Tests if the bounding sphere center is in between the frustum planes.
  88510. * Used for optimistic fast inclusion.
  88511. * @param frustumPlanes defines the frustum planes to test
  88512. * @returns true if the sphere center is in between the frustum planes
  88513. */
  88514. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88515. /**
  88516. * Tests if a point is inside the bounding sphere
  88517. * @param point defines the point to test
  88518. * @returns true if the point is inside the bounding sphere
  88519. */
  88520. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88521. /**
  88522. * Checks if two sphere intersct
  88523. * @param sphere0 sphere 0
  88524. * @param sphere1 sphere 1
  88525. * @returns true if the speres intersect
  88526. */
  88527. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  88528. }
  88529. }
  88530. declare module BABYLON {
  88531. /**
  88532. * Class used to store bounding box information
  88533. */
  88534. export class BoundingBox implements ICullable {
  88535. /**
  88536. * Gets the 8 vectors representing the bounding box in local space
  88537. */
  88538. readonly vectors: Vector3[];
  88539. /**
  88540. * Gets the center of the bounding box in local space
  88541. */
  88542. readonly center: Vector3;
  88543. /**
  88544. * Gets the center of the bounding box in world space
  88545. */
  88546. readonly centerWorld: Vector3;
  88547. /**
  88548. * Gets the extend size in local space
  88549. */
  88550. readonly extendSize: Vector3;
  88551. /**
  88552. * Gets the extend size in world space
  88553. */
  88554. readonly extendSizeWorld: Vector3;
  88555. /**
  88556. * Gets the OBB (object bounding box) directions
  88557. */
  88558. readonly directions: Vector3[];
  88559. /**
  88560. * Gets the 8 vectors representing the bounding box in world space
  88561. */
  88562. readonly vectorsWorld: Vector3[];
  88563. /**
  88564. * Gets the minimum vector in world space
  88565. */
  88566. readonly minimumWorld: Vector3;
  88567. /**
  88568. * Gets the maximum vector in world space
  88569. */
  88570. readonly maximumWorld: Vector3;
  88571. /**
  88572. * Gets the minimum vector in local space
  88573. */
  88574. readonly minimum: Vector3;
  88575. /**
  88576. * Gets the maximum vector in local space
  88577. */
  88578. readonly maximum: Vector3;
  88579. private _worldMatrix;
  88580. private static readonly TmpVector3;
  88581. /**
  88582. * @hidden
  88583. */
  88584. _tag: number;
  88585. /**
  88586. * Creates a new bounding box
  88587. * @param min defines the minimum vector (in local space)
  88588. * @param max defines the maximum vector (in local space)
  88589. * @param worldMatrix defines the new world matrix
  88590. */
  88591. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88592. /**
  88593. * Recreates the entire bounding box from scratch as if we call the constructor in place
  88594. * @param min defines the new minimum vector (in local space)
  88595. * @param max defines the new maximum vector (in local space)
  88596. * @param worldMatrix defines the new world matrix
  88597. */
  88598. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88599. /**
  88600. * Scale the current bounding box by applying a scale factor
  88601. * @param factor defines the scale factor to apply
  88602. * @returns the current bounding box
  88603. */
  88604. scale(factor: number): BoundingBox;
  88605. /**
  88606. * Gets the world matrix of the bounding box
  88607. * @returns a matrix
  88608. */
  88609. getWorldMatrix(): DeepImmutable<Matrix>;
  88610. /** @hidden */
  88611. _update(world: DeepImmutable<Matrix>): void;
  88612. /**
  88613. * Tests if the bounding box is intersecting the frustum planes
  88614. * @param frustumPlanes defines the frustum planes to test
  88615. * @returns true if there is an intersection
  88616. */
  88617. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88618. /**
  88619. * Tests if the bounding box is entirely inside the frustum planes
  88620. * @param frustumPlanes defines the frustum planes to test
  88621. * @returns true if there is an inclusion
  88622. */
  88623. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88624. /**
  88625. * Tests if a point is inside the bounding box
  88626. * @param point defines the point to test
  88627. * @returns true if the point is inside the bounding box
  88628. */
  88629. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88630. /**
  88631. * Tests if the bounding box intersects with a bounding sphere
  88632. * @param sphere defines the sphere to test
  88633. * @returns true if there is an intersection
  88634. */
  88635. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  88636. /**
  88637. * Tests if the bounding box intersects with a box defined by a min and max vectors
  88638. * @param min defines the min vector to use
  88639. * @param max defines the max vector to use
  88640. * @returns true if there is an intersection
  88641. */
  88642. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  88643. /**
  88644. * Tests if two bounding boxes are intersections
  88645. * @param box0 defines the first box to test
  88646. * @param box1 defines the second box to test
  88647. * @returns true if there is an intersection
  88648. */
  88649. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  88650. /**
  88651. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  88652. * @param minPoint defines the minimum vector of the bounding box
  88653. * @param maxPoint defines the maximum vector of the bounding box
  88654. * @param sphereCenter defines the sphere center
  88655. * @param sphereRadius defines the sphere radius
  88656. * @returns true if there is an intersection
  88657. */
  88658. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  88659. /**
  88660. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  88661. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  88662. * @param frustumPlanes defines the frustum planes to test
  88663. * @return true if there is an inclusion
  88664. */
  88665. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88666. /**
  88667. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  88668. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  88669. * @param frustumPlanes defines the frustum planes to test
  88670. * @return true if there is an intersection
  88671. */
  88672. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88673. }
  88674. }
  88675. declare module BABYLON {
  88676. /** @hidden */
  88677. export class Collider {
  88678. /** Define if a collision was found */
  88679. collisionFound: boolean;
  88680. /**
  88681. * Define last intersection point in local space
  88682. */
  88683. intersectionPoint: Vector3;
  88684. /**
  88685. * Define last collided mesh
  88686. */
  88687. collidedMesh: Nullable<AbstractMesh>;
  88688. private _collisionPoint;
  88689. private _planeIntersectionPoint;
  88690. private _tempVector;
  88691. private _tempVector2;
  88692. private _tempVector3;
  88693. private _tempVector4;
  88694. private _edge;
  88695. private _baseToVertex;
  88696. private _destinationPoint;
  88697. private _slidePlaneNormal;
  88698. private _displacementVector;
  88699. /** @hidden */
  88700. _radius: Vector3;
  88701. /** @hidden */
  88702. _retry: number;
  88703. private _velocity;
  88704. private _basePoint;
  88705. private _epsilon;
  88706. /** @hidden */
  88707. _velocityWorldLength: number;
  88708. /** @hidden */
  88709. _basePointWorld: Vector3;
  88710. private _velocityWorld;
  88711. private _normalizedVelocity;
  88712. /** @hidden */
  88713. _initialVelocity: Vector3;
  88714. /** @hidden */
  88715. _initialPosition: Vector3;
  88716. private _nearestDistance;
  88717. private _collisionMask;
  88718. get collisionMask(): number;
  88719. set collisionMask(mask: number);
  88720. /**
  88721. * Gets the plane normal used to compute the sliding response (in local space)
  88722. */
  88723. get slidePlaneNormal(): Vector3;
  88724. /** @hidden */
  88725. _initialize(source: Vector3, dir: Vector3, e: number): void;
  88726. /** @hidden */
  88727. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  88728. /** @hidden */
  88729. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  88730. /** @hidden */
  88731. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88732. /** @hidden */
  88733. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88734. /** @hidden */
  88735. _getResponse(pos: Vector3, vel: Vector3): void;
  88736. }
  88737. }
  88738. declare module BABYLON {
  88739. /**
  88740. * Interface for cullable objects
  88741. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  88742. */
  88743. export interface ICullable {
  88744. /**
  88745. * Checks if the object or part of the object is in the frustum
  88746. * @param frustumPlanes Camera near/planes
  88747. * @returns true if the object is in frustum otherwise false
  88748. */
  88749. isInFrustum(frustumPlanes: Plane[]): boolean;
  88750. /**
  88751. * Checks if a cullable object (mesh...) is in the camera frustum
  88752. * Unlike isInFrustum this cheks the full bounding box
  88753. * @param frustumPlanes Camera near/planes
  88754. * @returns true if the object is in frustum otherwise false
  88755. */
  88756. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88757. }
  88758. /**
  88759. * Info for a bounding data of a mesh
  88760. */
  88761. export class BoundingInfo implements ICullable {
  88762. /**
  88763. * Bounding box for the mesh
  88764. */
  88765. readonly boundingBox: BoundingBox;
  88766. /**
  88767. * Bounding sphere for the mesh
  88768. */
  88769. readonly boundingSphere: BoundingSphere;
  88770. private _isLocked;
  88771. private static readonly TmpVector3;
  88772. /**
  88773. * Constructs bounding info
  88774. * @param minimum min vector of the bounding box/sphere
  88775. * @param maximum max vector of the bounding box/sphere
  88776. * @param worldMatrix defines the new world matrix
  88777. */
  88778. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88779. /**
  88780. * Recreates the entire bounding info from scratch as if we call the constructor in place
  88781. * @param min defines the new minimum vector (in local space)
  88782. * @param max defines the new maximum vector (in local space)
  88783. * @param worldMatrix defines the new world matrix
  88784. */
  88785. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88786. /**
  88787. * min vector of the bounding box/sphere
  88788. */
  88789. get minimum(): Vector3;
  88790. /**
  88791. * max vector of the bounding box/sphere
  88792. */
  88793. get maximum(): Vector3;
  88794. /**
  88795. * If the info is locked and won't be updated to avoid perf overhead
  88796. */
  88797. get isLocked(): boolean;
  88798. set isLocked(value: boolean);
  88799. /**
  88800. * Updates the bounding sphere and box
  88801. * @param world world matrix to be used to update
  88802. */
  88803. update(world: DeepImmutable<Matrix>): void;
  88804. /**
  88805. * Recreate the bounding info to be centered around a specific point given a specific extend.
  88806. * @param center New center of the bounding info
  88807. * @param extend New extend of the bounding info
  88808. * @returns the current bounding info
  88809. */
  88810. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  88811. /**
  88812. * Scale the current bounding info by applying a scale factor
  88813. * @param factor defines the scale factor to apply
  88814. * @returns the current bounding info
  88815. */
  88816. scale(factor: number): BoundingInfo;
  88817. /**
  88818. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  88819. * @param frustumPlanes defines the frustum to test
  88820. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  88821. * @returns true if the bounding info is in the frustum planes
  88822. */
  88823. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  88824. /**
  88825. * Gets the world distance between the min and max points of the bounding box
  88826. */
  88827. get diagonalLength(): number;
  88828. /**
  88829. * Checks if a cullable object (mesh...) is in the camera frustum
  88830. * Unlike isInFrustum this cheks the full bounding box
  88831. * @param frustumPlanes Camera near/planes
  88832. * @returns true if the object is in frustum otherwise false
  88833. */
  88834. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88835. /** @hidden */
  88836. _checkCollision(collider: Collider): boolean;
  88837. /**
  88838. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  88839. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88840. * @param point the point to check intersection with
  88841. * @returns if the point intersects
  88842. */
  88843. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88844. /**
  88845. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  88846. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88847. * @param boundingInfo the bounding info to check intersection with
  88848. * @param precise if the intersection should be done using OBB
  88849. * @returns if the bounding info intersects
  88850. */
  88851. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  88852. }
  88853. }
  88854. declare module BABYLON {
  88855. /**
  88856. * Extracts minimum and maximum values from a list of indexed positions
  88857. * @param positions defines the positions to use
  88858. * @param indices defines the indices to the positions
  88859. * @param indexStart defines the start index
  88860. * @param indexCount defines the end index
  88861. * @param bias defines bias value to add to the result
  88862. * @return minimum and maximum values
  88863. */
  88864. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  88865. minimum: Vector3;
  88866. maximum: Vector3;
  88867. };
  88868. /**
  88869. * Extracts minimum and maximum values from a list of positions
  88870. * @param positions defines the positions to use
  88871. * @param start defines the start index in the positions array
  88872. * @param count defines the number of positions to handle
  88873. * @param bias defines bias value to add to the result
  88874. * @param stride defines the stride size to use (distance between two positions in the positions array)
  88875. * @return minimum and maximum values
  88876. */
  88877. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  88878. minimum: Vector3;
  88879. maximum: Vector3;
  88880. };
  88881. }
  88882. declare module BABYLON {
  88883. /**
  88884. * Class used to manipulate GUIDs
  88885. */
  88886. export class GUID {
  88887. /**
  88888. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88889. * Be aware Math.random() could cause collisions, but:
  88890. * "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"
  88891. * @returns a pseudo random id
  88892. */
  88893. static RandomId(): string;
  88894. }
  88895. }
  88896. declare module BABYLON {
  88897. /**
  88898. * Base class of all the textures in babylon.
  88899. * It groups all the common properties the materials, post process, lights... might need
  88900. * in order to make a correct use of the texture.
  88901. */
  88902. export class BaseTexture extends ThinTexture implements IAnimatable {
  88903. /**
  88904. * Default anisotropic filtering level for the application.
  88905. * It is set to 4 as a good tradeoff between perf and quality.
  88906. */
  88907. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  88908. /**
  88909. * Gets or sets the unique id of the texture
  88910. */
  88911. uniqueId: number;
  88912. /**
  88913. * Define the name of the texture.
  88914. */
  88915. name: string;
  88916. /**
  88917. * Gets or sets an object used to store user defined information.
  88918. */
  88919. metadata: any;
  88920. /**
  88921. * For internal use only. Please do not use.
  88922. */
  88923. reservedDataStore: any;
  88924. private _hasAlpha;
  88925. /**
  88926. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  88927. */
  88928. set hasAlpha(value: boolean);
  88929. get hasAlpha(): boolean;
  88930. /**
  88931. * Defines if the alpha value should be determined via the rgb values.
  88932. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  88933. */
  88934. getAlphaFromRGB: boolean;
  88935. /**
  88936. * Intensity or strength of the texture.
  88937. * It is commonly used by materials to fine tune the intensity of the texture
  88938. */
  88939. level: number;
  88940. /**
  88941. * Define the UV chanel to use starting from 0 and defaulting to 0.
  88942. * This is part of the texture as textures usually maps to one uv set.
  88943. */
  88944. coordinatesIndex: number;
  88945. protected _coordinatesMode: number;
  88946. /**
  88947. * How a texture is mapped.
  88948. *
  88949. * | Value | Type | Description |
  88950. * | ----- | ----------------------------------- | ----------- |
  88951. * | 0 | EXPLICIT_MODE | |
  88952. * | 1 | SPHERICAL_MODE | |
  88953. * | 2 | PLANAR_MODE | |
  88954. * | 3 | CUBIC_MODE | |
  88955. * | 4 | PROJECTION_MODE | |
  88956. * | 5 | SKYBOX_MODE | |
  88957. * | 6 | INVCUBIC_MODE | |
  88958. * | 7 | EQUIRECTANGULAR_MODE | |
  88959. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  88960. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  88961. */
  88962. set coordinatesMode(value: number);
  88963. get coordinatesMode(): number;
  88964. /**
  88965. * | Value | Type | Description |
  88966. * | ----- | ------------------ | ----------- |
  88967. * | 0 | CLAMP_ADDRESSMODE | |
  88968. * | 1 | WRAP_ADDRESSMODE | |
  88969. * | 2 | MIRROR_ADDRESSMODE | |
  88970. */
  88971. get wrapU(): number;
  88972. set wrapU(value: number);
  88973. /**
  88974. * | Value | Type | Description |
  88975. * | ----- | ------------------ | ----------- |
  88976. * | 0 | CLAMP_ADDRESSMODE | |
  88977. * | 1 | WRAP_ADDRESSMODE | |
  88978. * | 2 | MIRROR_ADDRESSMODE | |
  88979. */
  88980. get wrapV(): number;
  88981. set wrapV(value: number);
  88982. /**
  88983. * | Value | Type | Description |
  88984. * | ----- | ------------------ | ----------- |
  88985. * | 0 | CLAMP_ADDRESSMODE | |
  88986. * | 1 | WRAP_ADDRESSMODE | |
  88987. * | 2 | MIRROR_ADDRESSMODE | |
  88988. */
  88989. wrapR: number;
  88990. /**
  88991. * With compliant hardware and browser (supporting anisotropic filtering)
  88992. * this defines the level of anisotropic filtering in the texture.
  88993. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  88994. */
  88995. anisotropicFilteringLevel: number;
  88996. private _isCube;
  88997. /**
  88998. * Define if the texture is a cube texture or if false a 2d texture.
  88999. */
  89000. get isCube(): boolean;
  89001. set isCube(value: boolean);
  89002. /**
  89003. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  89004. */
  89005. get is3D(): boolean;
  89006. set is3D(value: boolean);
  89007. /**
  89008. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  89009. */
  89010. get is2DArray(): boolean;
  89011. set is2DArray(value: boolean);
  89012. private _gammaSpace;
  89013. /**
  89014. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  89015. * HDR texture are usually stored in linear space.
  89016. * This only impacts the PBR and Background materials
  89017. */
  89018. get gammaSpace(): boolean;
  89019. set gammaSpace(gamma: boolean);
  89020. /**
  89021. * Gets or sets whether or not the texture contains RGBD data.
  89022. */
  89023. get isRGBD(): boolean;
  89024. set isRGBD(value: boolean);
  89025. /**
  89026. * Is Z inverted in the texture (useful in a cube texture).
  89027. */
  89028. invertZ: boolean;
  89029. /**
  89030. * Are mip maps generated for this texture or not.
  89031. */
  89032. get noMipmap(): boolean;
  89033. /**
  89034. * @hidden
  89035. */
  89036. lodLevelInAlpha: boolean;
  89037. /**
  89038. * With prefiltered texture, defined the offset used during the prefiltering steps.
  89039. */
  89040. get lodGenerationOffset(): number;
  89041. set lodGenerationOffset(value: number);
  89042. /**
  89043. * With prefiltered texture, defined the scale used during the prefiltering steps.
  89044. */
  89045. get lodGenerationScale(): number;
  89046. set lodGenerationScale(value: number);
  89047. /**
  89048. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  89049. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  89050. * average roughness values.
  89051. */
  89052. get linearSpecularLOD(): boolean;
  89053. set linearSpecularLOD(value: boolean);
  89054. /**
  89055. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  89056. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  89057. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  89058. */
  89059. get irradianceTexture(): Nullable<BaseTexture>;
  89060. set irradianceTexture(value: Nullable<BaseTexture>);
  89061. /**
  89062. * Define if the texture is a render target.
  89063. */
  89064. isRenderTarget: boolean;
  89065. /**
  89066. * Define the unique id of the texture in the scene.
  89067. */
  89068. get uid(): string;
  89069. /** @hidden */
  89070. _prefiltered: boolean;
  89071. /**
  89072. * Return a string representation of the texture.
  89073. * @returns the texture as a string
  89074. */
  89075. toString(): string;
  89076. /**
  89077. * Get the class name of the texture.
  89078. * @returns "BaseTexture"
  89079. */
  89080. getClassName(): string;
  89081. /**
  89082. * Define the list of animation attached to the texture.
  89083. */
  89084. animations: Animation[];
  89085. /**
  89086. * An event triggered when the texture is disposed.
  89087. */
  89088. onDisposeObservable: Observable<BaseTexture>;
  89089. private _onDisposeObserver;
  89090. /**
  89091. * Callback triggered when the texture has been disposed.
  89092. * Kept for back compatibility, you can use the onDisposeObservable instead.
  89093. */
  89094. set onDispose(callback: () => void);
  89095. protected _scene: Nullable<Scene>;
  89096. /** @hidden */
  89097. _texture: Nullable<InternalTexture>;
  89098. private _uid;
  89099. /**
  89100. * Define if the texture is preventinga material to render or not.
  89101. * If not and the texture is not ready, the engine will use a default black texture instead.
  89102. */
  89103. get isBlocking(): boolean;
  89104. /**
  89105. * Instantiates a new BaseTexture.
  89106. * Base class of all the textures in babylon.
  89107. * It groups all the common properties the materials, post process, lights... might need
  89108. * in order to make a correct use of the texture.
  89109. * @param sceneOrEngine Define the scene or engine the texture blongs to
  89110. */
  89111. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  89112. /**
  89113. * Get the scene the texture belongs to.
  89114. * @returns the scene or null if undefined
  89115. */
  89116. getScene(): Nullable<Scene>;
  89117. /** @hidden */
  89118. protected _getEngine(): Nullable<ThinEngine>;
  89119. /**
  89120. * Checks if the texture has the same transform matrix than another texture
  89121. * @param texture texture to check against
  89122. * @returns true if the transforms are the same, else false
  89123. */
  89124. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  89125. /**
  89126. * Get the texture transform matrix used to offset tile the texture for istance.
  89127. * @returns the transformation matrix
  89128. */
  89129. getTextureMatrix(): Matrix;
  89130. /**
  89131. * Get the texture reflection matrix used to rotate/transform the reflection.
  89132. * @returns the reflection matrix
  89133. */
  89134. getReflectionTextureMatrix(): Matrix;
  89135. /**
  89136. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  89137. * @returns true if ready or not blocking
  89138. */
  89139. isReadyOrNotBlocking(): boolean;
  89140. /**
  89141. * Scales the texture if is `canRescale()`
  89142. * @param ratio the resize factor we want to use to rescale
  89143. */
  89144. scale(ratio: number): void;
  89145. /**
  89146. * Get if the texture can rescale.
  89147. */
  89148. get canRescale(): boolean;
  89149. /** @hidden */
  89150. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  89151. /** @hidden */
  89152. _rebuild(): void;
  89153. /**
  89154. * Clones the texture.
  89155. * @returns the cloned texture
  89156. */
  89157. clone(): Nullable<BaseTexture>;
  89158. /**
  89159. * Get the texture underlying type (INT, FLOAT...)
  89160. */
  89161. get textureType(): number;
  89162. /**
  89163. * Get the texture underlying format (RGB, RGBA...)
  89164. */
  89165. get textureFormat(): number;
  89166. /**
  89167. * Indicates that textures need to be re-calculated for all materials
  89168. */
  89169. protected _markAllSubMeshesAsTexturesDirty(): void;
  89170. /**
  89171. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  89172. * This will returns an RGBA array buffer containing either in values (0-255) or
  89173. * float values (0-1) depending of the underlying buffer type.
  89174. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  89175. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  89176. * @param buffer defines a user defined buffer to fill with data (can be null)
  89177. * @returns The Array buffer containing the pixels data.
  89178. */
  89179. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  89180. /** @hidden */
  89181. get _lodTextureHigh(): Nullable<BaseTexture>;
  89182. /** @hidden */
  89183. get _lodTextureMid(): Nullable<BaseTexture>;
  89184. /** @hidden */
  89185. get _lodTextureLow(): Nullable<BaseTexture>;
  89186. /**
  89187. * Dispose the texture and release its associated resources.
  89188. */
  89189. dispose(): void;
  89190. /**
  89191. * Serialize the texture into a JSON representation that can be parsed later on.
  89192. * @returns the JSON representation of the texture
  89193. */
  89194. serialize(): any;
  89195. /**
  89196. * Helper function to be called back once a list of texture contains only ready textures.
  89197. * @param textures Define the list of textures to wait for
  89198. * @param callback Define the callback triggered once the entire list will be ready
  89199. */
  89200. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  89201. private static _isScene;
  89202. }
  89203. }
  89204. declare module BABYLON {
  89205. /** @hidden */
  89206. export class WebGLDataBuffer extends DataBuffer {
  89207. private _buffer;
  89208. constructor(resource: WebGLBuffer);
  89209. get underlyingResource(): any;
  89210. }
  89211. }
  89212. declare module BABYLON {
  89213. /** @hidden */
  89214. export class WebGLPipelineContext implements IPipelineContext {
  89215. engine: ThinEngine;
  89216. program: Nullable<WebGLProgram>;
  89217. context?: WebGLRenderingContext;
  89218. vertexShader?: WebGLShader;
  89219. fragmentShader?: WebGLShader;
  89220. isParallelCompiled: boolean;
  89221. onCompiled?: () => void;
  89222. transformFeedback?: WebGLTransformFeedback | null;
  89223. vertexCompilationError: Nullable<string>;
  89224. fragmentCompilationError: Nullable<string>;
  89225. programLinkError: Nullable<string>;
  89226. programValidationError: Nullable<string>;
  89227. get isAsync(): boolean;
  89228. get isReady(): boolean;
  89229. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  89230. _getVertexShaderCode(): string | null;
  89231. _getFragmentShaderCode(): string | null;
  89232. }
  89233. }
  89234. declare module BABYLON {
  89235. interface ThinEngine {
  89236. /**
  89237. * Create an uniform buffer
  89238. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  89239. * @param elements defines the content of the uniform buffer
  89240. * @returns the webGL uniform buffer
  89241. */
  89242. createUniformBuffer(elements: FloatArray): DataBuffer;
  89243. /**
  89244. * Create a dynamic uniform buffer
  89245. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  89246. * @param elements defines the content of the uniform buffer
  89247. * @returns the webGL uniform buffer
  89248. */
  89249. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  89250. /**
  89251. * Update an existing uniform buffer
  89252. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  89253. * @param uniformBuffer defines the target uniform buffer
  89254. * @param elements defines the content to update
  89255. * @param offset defines the offset in the uniform buffer where update should start
  89256. * @param count defines the size of the data to update
  89257. */
  89258. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  89259. /**
  89260. * Bind an uniform buffer to the current webGL context
  89261. * @param buffer defines the buffer to bind
  89262. */
  89263. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  89264. /**
  89265. * Bind a buffer to the current webGL context at a given location
  89266. * @param buffer defines the buffer to bind
  89267. * @param location defines the index where to bind the buffer
  89268. */
  89269. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  89270. /**
  89271. * Bind a specific block at a given index in a specific shader program
  89272. * @param pipelineContext defines the pipeline context to use
  89273. * @param blockName defines the block name
  89274. * @param index defines the index where to bind the block
  89275. */
  89276. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  89277. }
  89278. }
  89279. declare module BABYLON {
  89280. /**
  89281. * Uniform buffer objects.
  89282. *
  89283. * Handles blocks of uniform on the GPU.
  89284. *
  89285. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89286. *
  89287. * For more information, please refer to :
  89288. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89289. */
  89290. export class UniformBuffer {
  89291. private _engine;
  89292. private _buffer;
  89293. private _data;
  89294. private _bufferData;
  89295. private _dynamic?;
  89296. private _uniformLocations;
  89297. private _uniformSizes;
  89298. private _uniformLocationPointer;
  89299. private _needSync;
  89300. private _noUBO;
  89301. private _currentEffect;
  89302. /** @hidden */
  89303. _alreadyBound: boolean;
  89304. private static _MAX_UNIFORM_SIZE;
  89305. private static _tempBuffer;
  89306. /**
  89307. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  89308. * This is dynamic to allow compat with webgl 1 and 2.
  89309. * You will need to pass the name of the uniform as well as the value.
  89310. */
  89311. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  89312. /**
  89313. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  89314. * This is dynamic to allow compat with webgl 1 and 2.
  89315. * You will need to pass the name of the uniform as well as the value.
  89316. */
  89317. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  89318. /**
  89319. * Lambda to Update a single float in a uniform buffer.
  89320. * This is dynamic to allow compat with webgl 1 and 2.
  89321. * You will need to pass the name of the uniform as well as the value.
  89322. */
  89323. updateFloat: (name: string, x: number) => void;
  89324. /**
  89325. * Lambda to Update a vec2 of float in a uniform buffer.
  89326. * This is dynamic to allow compat with webgl 1 and 2.
  89327. * You will need to pass the name of the uniform as well as the value.
  89328. */
  89329. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  89330. /**
  89331. * Lambda to Update a vec3 of float in a uniform buffer.
  89332. * This is dynamic to allow compat with webgl 1 and 2.
  89333. * You will need to pass the name of the uniform as well as the value.
  89334. */
  89335. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  89336. /**
  89337. * Lambda to Update a vec4 of float in a uniform buffer.
  89338. * This is dynamic to allow compat with webgl 1 and 2.
  89339. * You will need to pass the name of the uniform as well as the value.
  89340. */
  89341. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  89342. /**
  89343. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  89344. * This is dynamic to allow compat with webgl 1 and 2.
  89345. * You will need to pass the name of the uniform as well as the value.
  89346. */
  89347. updateMatrix: (name: string, mat: Matrix) => void;
  89348. /**
  89349. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  89350. * This is dynamic to allow compat with webgl 1 and 2.
  89351. * You will need to pass the name of the uniform as well as the value.
  89352. */
  89353. updateVector3: (name: string, vector: Vector3) => void;
  89354. /**
  89355. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  89356. * This is dynamic to allow compat with webgl 1 and 2.
  89357. * You will need to pass the name of the uniform as well as the value.
  89358. */
  89359. updateVector4: (name: string, vector: Vector4) => void;
  89360. /**
  89361. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  89362. * This is dynamic to allow compat with webgl 1 and 2.
  89363. * You will need to pass the name of the uniform as well as the value.
  89364. */
  89365. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  89366. /**
  89367. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  89368. * This is dynamic to allow compat with webgl 1 and 2.
  89369. * You will need to pass the name of the uniform as well as the value.
  89370. */
  89371. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  89372. /**
  89373. * Instantiates a new Uniform buffer objects.
  89374. *
  89375. * Handles blocks of uniform on the GPU.
  89376. *
  89377. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89378. *
  89379. * For more information, please refer to :
  89380. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89381. * @param engine Define the engine the buffer is associated with
  89382. * @param data Define the data contained in the buffer
  89383. * @param dynamic Define if the buffer is updatable
  89384. */
  89385. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  89386. /**
  89387. * Indicates if the buffer is using the WebGL2 UBO implementation,
  89388. * or just falling back on setUniformXXX calls.
  89389. */
  89390. get useUbo(): boolean;
  89391. /**
  89392. * Indicates if the WebGL underlying uniform buffer is in sync
  89393. * with the javascript cache data.
  89394. */
  89395. get isSync(): boolean;
  89396. /**
  89397. * Indicates if the WebGL underlying uniform buffer is dynamic.
  89398. * Also, a dynamic UniformBuffer will disable cache verification and always
  89399. * update the underlying WebGL uniform buffer to the GPU.
  89400. * @returns if Dynamic, otherwise false
  89401. */
  89402. isDynamic(): boolean;
  89403. /**
  89404. * The data cache on JS side.
  89405. * @returns the underlying data as a float array
  89406. */
  89407. getData(): Float32Array;
  89408. /**
  89409. * The underlying WebGL Uniform buffer.
  89410. * @returns the webgl buffer
  89411. */
  89412. getBuffer(): Nullable<DataBuffer>;
  89413. /**
  89414. * std140 layout specifies how to align data within an UBO structure.
  89415. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  89416. * for specs.
  89417. */
  89418. private _fillAlignment;
  89419. /**
  89420. * Adds an uniform in the buffer.
  89421. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  89422. * for the layout to be correct !
  89423. * @param name Name of the uniform, as used in the uniform block in the shader.
  89424. * @param size Data size, or data directly.
  89425. */
  89426. addUniform(name: string, size: number | number[]): void;
  89427. /**
  89428. * Adds a Matrix 4x4 to the uniform buffer.
  89429. * @param name Name of the uniform, as used in the uniform block in the shader.
  89430. * @param mat A 4x4 matrix.
  89431. */
  89432. addMatrix(name: string, mat: Matrix): void;
  89433. /**
  89434. * Adds a vec2 to the uniform buffer.
  89435. * @param name Name of the uniform, as used in the uniform block in the shader.
  89436. * @param x Define the x component value of the vec2
  89437. * @param y Define the y component value of the vec2
  89438. */
  89439. addFloat2(name: string, x: number, y: number): void;
  89440. /**
  89441. * Adds a vec3 to the uniform buffer.
  89442. * @param name Name of the uniform, as used in the uniform block in the shader.
  89443. * @param x Define the x component value of the vec3
  89444. * @param y Define the y component value of the vec3
  89445. * @param z Define the z component value of the vec3
  89446. */
  89447. addFloat3(name: string, x: number, y: number, z: number): void;
  89448. /**
  89449. * Adds a vec3 to the uniform buffer.
  89450. * @param name Name of the uniform, as used in the uniform block in the shader.
  89451. * @param color Define the vec3 from a Color
  89452. */
  89453. addColor3(name: string, color: Color3): void;
  89454. /**
  89455. * Adds a vec4 to the uniform buffer.
  89456. * @param name Name of the uniform, as used in the uniform block in the shader.
  89457. * @param color Define the rgb components from a Color
  89458. * @param alpha Define the a component of the vec4
  89459. */
  89460. addColor4(name: string, color: Color3, alpha: number): void;
  89461. /**
  89462. * Adds a vec3 to the uniform buffer.
  89463. * @param name Name of the uniform, as used in the uniform block in the shader.
  89464. * @param vector Define the vec3 components from a Vector
  89465. */
  89466. addVector3(name: string, vector: Vector3): void;
  89467. /**
  89468. * Adds a Matrix 3x3 to the uniform buffer.
  89469. * @param name Name of the uniform, as used in the uniform block in the shader.
  89470. */
  89471. addMatrix3x3(name: string): void;
  89472. /**
  89473. * Adds a Matrix 2x2 to the uniform buffer.
  89474. * @param name Name of the uniform, as used in the uniform block in the shader.
  89475. */
  89476. addMatrix2x2(name: string): void;
  89477. /**
  89478. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  89479. */
  89480. create(): void;
  89481. /** @hidden */
  89482. _rebuild(): void;
  89483. /**
  89484. * Updates the WebGL Uniform Buffer on the GPU.
  89485. * If the `dynamic` flag is set to true, no cache comparison is done.
  89486. * Otherwise, the buffer will be updated only if the cache differs.
  89487. */
  89488. update(): void;
  89489. /**
  89490. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  89491. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89492. * @param data Define the flattened data
  89493. * @param size Define the size of the data.
  89494. */
  89495. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  89496. private _valueCache;
  89497. private _cacheMatrix;
  89498. private _updateMatrix3x3ForUniform;
  89499. private _updateMatrix3x3ForEffect;
  89500. private _updateMatrix2x2ForEffect;
  89501. private _updateMatrix2x2ForUniform;
  89502. private _updateFloatForEffect;
  89503. private _updateFloatForUniform;
  89504. private _updateFloat2ForEffect;
  89505. private _updateFloat2ForUniform;
  89506. private _updateFloat3ForEffect;
  89507. private _updateFloat3ForUniform;
  89508. private _updateFloat4ForEffect;
  89509. private _updateFloat4ForUniform;
  89510. private _updateMatrixForEffect;
  89511. private _updateMatrixForUniform;
  89512. private _updateVector3ForEffect;
  89513. private _updateVector3ForUniform;
  89514. private _updateVector4ForEffect;
  89515. private _updateVector4ForUniform;
  89516. private _updateColor3ForEffect;
  89517. private _updateColor3ForUniform;
  89518. private _updateColor4ForEffect;
  89519. private _updateColor4ForUniform;
  89520. /**
  89521. * Sets a sampler uniform on the effect.
  89522. * @param name Define the name of the sampler.
  89523. * @param texture Define the texture to set in the sampler
  89524. */
  89525. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  89526. /**
  89527. * Directly updates the value of the uniform in the cache AND on the GPU.
  89528. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89529. * @param data Define the flattened data
  89530. */
  89531. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  89532. /**
  89533. * Binds this uniform buffer to an effect.
  89534. * @param effect Define the effect to bind the buffer to
  89535. * @param name Name of the uniform block in the shader.
  89536. */
  89537. bindToEffect(effect: Effect, name: string): void;
  89538. /**
  89539. * Disposes the uniform buffer.
  89540. */
  89541. dispose(): void;
  89542. }
  89543. }
  89544. declare module BABYLON {
  89545. /**
  89546. * Manages the defines for the Material
  89547. */
  89548. export class MaterialDefines {
  89549. /** @hidden */
  89550. protected _keys: string[];
  89551. private _isDirty;
  89552. /** @hidden */
  89553. _renderId: number;
  89554. /** @hidden */
  89555. _areLightsDirty: boolean;
  89556. /** @hidden */
  89557. _areLightsDisposed: boolean;
  89558. /** @hidden */
  89559. _areAttributesDirty: boolean;
  89560. /** @hidden */
  89561. _areTexturesDirty: boolean;
  89562. /** @hidden */
  89563. _areFresnelDirty: boolean;
  89564. /** @hidden */
  89565. _areMiscDirty: boolean;
  89566. /** @hidden */
  89567. _arePrePassDirty: boolean;
  89568. /** @hidden */
  89569. _areImageProcessingDirty: boolean;
  89570. /** @hidden */
  89571. _normals: boolean;
  89572. /** @hidden */
  89573. _uvs: boolean;
  89574. /** @hidden */
  89575. _needNormals: boolean;
  89576. /** @hidden */
  89577. _needUVs: boolean;
  89578. [id: string]: any;
  89579. /**
  89580. * Specifies if the material needs to be re-calculated
  89581. */
  89582. get isDirty(): boolean;
  89583. /**
  89584. * Marks the material to indicate that it has been re-calculated
  89585. */
  89586. markAsProcessed(): void;
  89587. /**
  89588. * Marks the material to indicate that it needs to be re-calculated
  89589. */
  89590. markAsUnprocessed(): void;
  89591. /**
  89592. * Marks the material to indicate all of its defines need to be re-calculated
  89593. */
  89594. markAllAsDirty(): void;
  89595. /**
  89596. * Marks the material to indicate that image processing needs to be re-calculated
  89597. */
  89598. markAsImageProcessingDirty(): void;
  89599. /**
  89600. * Marks the material to indicate the lights need to be re-calculated
  89601. * @param disposed Defines whether the light is dirty due to dispose or not
  89602. */
  89603. markAsLightDirty(disposed?: boolean): void;
  89604. /**
  89605. * Marks the attribute state as changed
  89606. */
  89607. markAsAttributesDirty(): void;
  89608. /**
  89609. * Marks the texture state as changed
  89610. */
  89611. markAsTexturesDirty(): void;
  89612. /**
  89613. * Marks the fresnel state as changed
  89614. */
  89615. markAsFresnelDirty(): void;
  89616. /**
  89617. * Marks the misc state as changed
  89618. */
  89619. markAsMiscDirty(): void;
  89620. /**
  89621. * Marks the prepass state as changed
  89622. */
  89623. markAsPrePassDirty(): void;
  89624. /**
  89625. * Rebuilds the material defines
  89626. */
  89627. rebuild(): void;
  89628. /**
  89629. * Specifies if two material defines are equal
  89630. * @param other - A material define instance to compare to
  89631. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  89632. */
  89633. isEqual(other: MaterialDefines): boolean;
  89634. /**
  89635. * Clones this instance's defines to another instance
  89636. * @param other - material defines to clone values to
  89637. */
  89638. cloneTo(other: MaterialDefines): void;
  89639. /**
  89640. * Resets the material define values
  89641. */
  89642. reset(): void;
  89643. /**
  89644. * Converts the material define values to a string
  89645. * @returns - String of material define information
  89646. */
  89647. toString(): string;
  89648. }
  89649. }
  89650. declare module BABYLON {
  89651. /**
  89652. * Enum that determines the text-wrapping mode to use.
  89653. */
  89654. export enum InspectableType {
  89655. /**
  89656. * Checkbox for booleans
  89657. */
  89658. Checkbox = 0,
  89659. /**
  89660. * Sliders for numbers
  89661. */
  89662. Slider = 1,
  89663. /**
  89664. * Vector3
  89665. */
  89666. Vector3 = 2,
  89667. /**
  89668. * Quaternions
  89669. */
  89670. Quaternion = 3,
  89671. /**
  89672. * Color3
  89673. */
  89674. Color3 = 4,
  89675. /**
  89676. * String
  89677. */
  89678. String = 5
  89679. }
  89680. /**
  89681. * Interface used to define custom inspectable properties.
  89682. * This interface is used by the inspector to display custom property grids
  89683. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89684. */
  89685. export interface IInspectable {
  89686. /**
  89687. * Gets the label to display
  89688. */
  89689. label: string;
  89690. /**
  89691. * Gets the name of the property to edit
  89692. */
  89693. propertyName: string;
  89694. /**
  89695. * Gets the type of the editor to use
  89696. */
  89697. type: InspectableType;
  89698. /**
  89699. * Gets the minimum value of the property when using in "slider" mode
  89700. */
  89701. min?: number;
  89702. /**
  89703. * Gets the maximum value of the property when using in "slider" mode
  89704. */
  89705. max?: number;
  89706. /**
  89707. * Gets the setp to use when using in "slider" mode
  89708. */
  89709. step?: number;
  89710. }
  89711. }
  89712. declare module BABYLON {
  89713. /**
  89714. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  89715. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  89716. * 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.
  89717. */
  89718. export abstract class Light extends Node {
  89719. /**
  89720. * Falloff Default: light is falling off following the material specification:
  89721. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  89722. */
  89723. static readonly FALLOFF_DEFAULT: number;
  89724. /**
  89725. * Falloff Physical: light is falling off following the inverse squared distance law.
  89726. */
  89727. static readonly FALLOFF_PHYSICAL: number;
  89728. /**
  89729. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  89730. * to enhance interoperability with other engines.
  89731. */
  89732. static readonly FALLOFF_GLTF: number;
  89733. /**
  89734. * Falloff Standard: light is falling off like in the standard material
  89735. * to enhance interoperability with other materials.
  89736. */
  89737. static readonly FALLOFF_STANDARD: number;
  89738. /**
  89739. * If every light affecting the material is in this lightmapMode,
  89740. * material.lightmapTexture adds or multiplies
  89741. * (depends on material.useLightmapAsShadowmap)
  89742. * after every other light calculations.
  89743. */
  89744. static readonly LIGHTMAP_DEFAULT: number;
  89745. /**
  89746. * material.lightmapTexture as only diffuse lighting from this light
  89747. * adds only specular lighting from this light
  89748. * adds dynamic shadows
  89749. */
  89750. static readonly LIGHTMAP_SPECULAR: number;
  89751. /**
  89752. * material.lightmapTexture as only lighting
  89753. * no light calculation from this light
  89754. * only adds dynamic shadows from this light
  89755. */
  89756. static readonly LIGHTMAP_SHADOWSONLY: number;
  89757. /**
  89758. * Each light type uses the default quantity according to its type:
  89759. * point/spot lights use luminous intensity
  89760. * directional lights use illuminance
  89761. */
  89762. static readonly INTENSITYMODE_AUTOMATIC: number;
  89763. /**
  89764. * lumen (lm)
  89765. */
  89766. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  89767. /**
  89768. * candela (lm/sr)
  89769. */
  89770. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  89771. /**
  89772. * lux (lm/m^2)
  89773. */
  89774. static readonly INTENSITYMODE_ILLUMINANCE: number;
  89775. /**
  89776. * nit (cd/m^2)
  89777. */
  89778. static readonly INTENSITYMODE_LUMINANCE: number;
  89779. /**
  89780. * Light type const id of the point light.
  89781. */
  89782. static readonly LIGHTTYPEID_POINTLIGHT: number;
  89783. /**
  89784. * Light type const id of the directional light.
  89785. */
  89786. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  89787. /**
  89788. * Light type const id of the spot light.
  89789. */
  89790. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  89791. /**
  89792. * Light type const id of the hemispheric light.
  89793. */
  89794. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  89795. /**
  89796. * Diffuse gives the basic color to an object.
  89797. */
  89798. diffuse: Color3;
  89799. /**
  89800. * Specular produces a highlight color on an object.
  89801. * Note: This is note affecting PBR materials.
  89802. */
  89803. specular: Color3;
  89804. /**
  89805. * Defines the falloff type for this light. This lets overrriding how punctual light are
  89806. * falling off base on range or angle.
  89807. * This can be set to any values in Light.FALLOFF_x.
  89808. *
  89809. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  89810. * other types of materials.
  89811. */
  89812. falloffType: number;
  89813. /**
  89814. * Strength of the light.
  89815. * Note: By default it is define in the framework own unit.
  89816. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  89817. */
  89818. intensity: number;
  89819. private _range;
  89820. protected _inverseSquaredRange: number;
  89821. /**
  89822. * Defines how far from the source the light is impacting in scene units.
  89823. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  89824. */
  89825. get range(): number;
  89826. /**
  89827. * Defines how far from the source the light is impacting in scene units.
  89828. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  89829. */
  89830. set range(value: number);
  89831. /**
  89832. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  89833. * of light.
  89834. */
  89835. private _photometricScale;
  89836. private _intensityMode;
  89837. /**
  89838. * Gets the photometric scale used to interpret the intensity.
  89839. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  89840. */
  89841. get intensityMode(): number;
  89842. /**
  89843. * Sets the photometric scale used to interpret the intensity.
  89844. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  89845. */
  89846. set intensityMode(value: number);
  89847. private _radius;
  89848. /**
  89849. * Gets the light radius used by PBR Materials to simulate soft area lights.
  89850. */
  89851. get radius(): number;
  89852. /**
  89853. * sets the light radius used by PBR Materials to simulate soft area lights.
  89854. */
  89855. set radius(value: number);
  89856. private _renderPriority;
  89857. /**
  89858. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  89859. * exceeding the number allowed of the materials.
  89860. */
  89861. renderPriority: number;
  89862. private _shadowEnabled;
  89863. /**
  89864. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  89865. * the current shadow generator.
  89866. */
  89867. get shadowEnabled(): boolean;
  89868. /**
  89869. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  89870. * the current shadow generator.
  89871. */
  89872. set shadowEnabled(value: boolean);
  89873. private _includedOnlyMeshes;
  89874. /**
  89875. * Gets the only meshes impacted by this light.
  89876. */
  89877. get includedOnlyMeshes(): AbstractMesh[];
  89878. /**
  89879. * Sets the only meshes impacted by this light.
  89880. */
  89881. set includedOnlyMeshes(value: AbstractMesh[]);
  89882. private _excludedMeshes;
  89883. /**
  89884. * Gets the meshes not impacted by this light.
  89885. */
  89886. get excludedMeshes(): AbstractMesh[];
  89887. /**
  89888. * Sets the meshes not impacted by this light.
  89889. */
  89890. set excludedMeshes(value: AbstractMesh[]);
  89891. private _excludeWithLayerMask;
  89892. /**
  89893. * Gets the layer id use to find what meshes are not impacted by the light.
  89894. * Inactive if 0
  89895. */
  89896. get excludeWithLayerMask(): number;
  89897. /**
  89898. * Sets the layer id use to find what meshes are not impacted by the light.
  89899. * Inactive if 0
  89900. */
  89901. set excludeWithLayerMask(value: number);
  89902. private _includeOnlyWithLayerMask;
  89903. /**
  89904. * Gets the layer id use to find what meshes are impacted by the light.
  89905. * Inactive if 0
  89906. */
  89907. get includeOnlyWithLayerMask(): number;
  89908. /**
  89909. * Sets the layer id use to find what meshes are impacted by the light.
  89910. * Inactive if 0
  89911. */
  89912. set includeOnlyWithLayerMask(value: number);
  89913. private _lightmapMode;
  89914. /**
  89915. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  89916. */
  89917. get lightmapMode(): number;
  89918. /**
  89919. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  89920. */
  89921. set lightmapMode(value: number);
  89922. /**
  89923. * Shadow generator associted to the light.
  89924. * @hidden Internal use only.
  89925. */
  89926. _shadowGenerator: Nullable<IShadowGenerator>;
  89927. /**
  89928. * @hidden Internal use only.
  89929. */
  89930. _excludedMeshesIds: string[];
  89931. /**
  89932. * @hidden Internal use only.
  89933. */
  89934. _includedOnlyMeshesIds: string[];
  89935. /**
  89936. * The current light unifom buffer.
  89937. * @hidden Internal use only.
  89938. */
  89939. _uniformBuffer: UniformBuffer;
  89940. /** @hidden */
  89941. _renderId: number;
  89942. /**
  89943. * Creates a Light object in the scene.
  89944. * Documentation : https://doc.babylonjs.com/babylon101/lights
  89945. * @param name The firendly name of the light
  89946. * @param scene The scene the light belongs too
  89947. */
  89948. constructor(name: string, scene: Scene);
  89949. protected abstract _buildUniformLayout(): void;
  89950. /**
  89951. * Sets the passed Effect "effect" with the Light information.
  89952. * @param effect The effect to update
  89953. * @param lightIndex The index of the light in the effect to update
  89954. * @returns The light
  89955. */
  89956. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  89957. /**
  89958. * Sets the passed Effect "effect" with the Light textures.
  89959. * @param effect The effect to update
  89960. * @param lightIndex The index of the light in the effect to update
  89961. * @returns The light
  89962. */
  89963. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  89964. /**
  89965. * Binds the lights information from the scene to the effect for the given mesh.
  89966. * @param lightIndex Light index
  89967. * @param scene The scene where the light belongs to
  89968. * @param effect The effect we are binding the data to
  89969. * @param useSpecular Defines if specular is supported
  89970. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  89971. */
  89972. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  89973. /**
  89974. * Sets the passed Effect "effect" with the Light information.
  89975. * @param effect The effect to update
  89976. * @param lightDataUniformName The uniform used to store light data (position or direction)
  89977. * @returns The light
  89978. */
  89979. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  89980. /**
  89981. * Returns the string "Light".
  89982. * @returns the class name
  89983. */
  89984. getClassName(): string;
  89985. /** @hidden */
  89986. readonly _isLight: boolean;
  89987. /**
  89988. * Converts the light information to a readable string for debug purpose.
  89989. * @param fullDetails Supports for multiple levels of logging within scene loading
  89990. * @returns the human readable light info
  89991. */
  89992. toString(fullDetails?: boolean): string;
  89993. /** @hidden */
  89994. protected _syncParentEnabledState(): void;
  89995. /**
  89996. * Set the enabled state of this node.
  89997. * @param value - the new enabled state
  89998. */
  89999. setEnabled(value: boolean): void;
  90000. /**
  90001. * Returns the Light associated shadow generator if any.
  90002. * @return the associated shadow generator.
  90003. */
  90004. getShadowGenerator(): Nullable<IShadowGenerator>;
  90005. /**
  90006. * Returns a Vector3, the absolute light position in the World.
  90007. * @returns the world space position of the light
  90008. */
  90009. getAbsolutePosition(): Vector3;
  90010. /**
  90011. * Specifies if the light will affect the passed mesh.
  90012. * @param mesh The mesh to test against the light
  90013. * @return true the mesh is affected otherwise, false.
  90014. */
  90015. canAffectMesh(mesh: AbstractMesh): boolean;
  90016. /**
  90017. * Sort function to order lights for rendering.
  90018. * @param a First Light object to compare to second.
  90019. * @param b Second Light object to compare first.
  90020. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90021. */
  90022. static CompareLightsPriority(a: Light, b: Light): number;
  90023. /**
  90024. * Releases resources associated with this node.
  90025. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90026. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90027. */
  90028. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90029. /**
  90030. * Returns the light type ID (integer).
  90031. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90032. */
  90033. getTypeID(): number;
  90034. /**
  90035. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90036. * @returns the scaled intensity in intensity mode unit
  90037. */
  90038. getScaledIntensity(): number;
  90039. /**
  90040. * Returns a new Light object, named "name", from the current one.
  90041. * @param name The name of the cloned light
  90042. * @param newParent The parent of this light, if it has one
  90043. * @returns the new created light
  90044. */
  90045. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  90046. /**
  90047. * Serializes the current light into a Serialization object.
  90048. * @returns the serialized object.
  90049. */
  90050. serialize(): any;
  90051. /**
  90052. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90053. * This new light is named "name" and added to the passed scene.
  90054. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90055. * @param name The friendly name of the light
  90056. * @param scene The scene the new light will belong to
  90057. * @returns the constructor function
  90058. */
  90059. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90060. /**
  90061. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90062. * @param parsedLight The JSON representation of the light
  90063. * @param scene The scene to create the parsed light in
  90064. * @returns the created light after parsing
  90065. */
  90066. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90067. private _hookArrayForExcluded;
  90068. private _hookArrayForIncludedOnly;
  90069. private _resyncMeshes;
  90070. /**
  90071. * Forces the meshes to update their light related information in their rendering used effects
  90072. * @hidden Internal Use Only
  90073. */
  90074. _markMeshesAsLightDirty(): void;
  90075. /**
  90076. * Recomputes the cached photometric scale if needed.
  90077. */
  90078. private _computePhotometricScale;
  90079. /**
  90080. * Returns the Photometric Scale according to the light type and intensity mode.
  90081. */
  90082. private _getPhotometricScale;
  90083. /**
  90084. * Reorder the light in the scene according to their defined priority.
  90085. * @hidden Internal Use Only
  90086. */
  90087. _reorderLightsInScene(): void;
  90088. /**
  90089. * Prepares the list of defines specific to the light type.
  90090. * @param defines the list of defines
  90091. * @param lightIndex defines the index of the light for the effect
  90092. */
  90093. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90094. }
  90095. }
  90096. declare module BABYLON {
  90097. /** Defines supported spaces */
  90098. export enum Space {
  90099. /** Local (object) space */
  90100. LOCAL = 0,
  90101. /** World space */
  90102. WORLD = 1,
  90103. /** Bone space */
  90104. BONE = 2
  90105. }
  90106. /** Defines the 3 main axes */
  90107. export class Axis {
  90108. /** X axis */
  90109. static X: Vector3;
  90110. /** Y axis */
  90111. static Y: Vector3;
  90112. /** Z axis */
  90113. static Z: Vector3;
  90114. }
  90115. /**
  90116. * Defines cartesian components.
  90117. */
  90118. export enum Coordinate {
  90119. /** X axis */
  90120. X = 0,
  90121. /** Y axis */
  90122. Y = 1,
  90123. /** Z axis */
  90124. Z = 2
  90125. }
  90126. }
  90127. declare module BABYLON {
  90128. /**
  90129. * Interface describing all the common properties and methods a shadow light needs to implement.
  90130. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  90131. * as well as binding the different shadow properties to the effects.
  90132. */
  90133. export interface IShadowLight extends Light {
  90134. /**
  90135. * The light id in the scene (used in scene.findLighById for instance)
  90136. */
  90137. id: string;
  90138. /**
  90139. * The position the shdow will be casted from.
  90140. */
  90141. position: Vector3;
  90142. /**
  90143. * In 2d mode (needCube being false), the direction used to cast the shadow.
  90144. */
  90145. direction: Vector3;
  90146. /**
  90147. * The transformed position. Position of the light in world space taking parenting in account.
  90148. */
  90149. transformedPosition: Vector3;
  90150. /**
  90151. * The transformed direction. Direction of the light in world space taking parenting in account.
  90152. */
  90153. transformedDirection: Vector3;
  90154. /**
  90155. * The friendly name of the light in the scene.
  90156. */
  90157. name: string;
  90158. /**
  90159. * Defines the shadow projection clipping minimum z value.
  90160. */
  90161. shadowMinZ: number;
  90162. /**
  90163. * Defines the shadow projection clipping maximum z value.
  90164. */
  90165. shadowMaxZ: number;
  90166. /**
  90167. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  90168. * @returns true if the information has been computed, false if it does not need to (no parenting)
  90169. */
  90170. computeTransformedInformation(): boolean;
  90171. /**
  90172. * Gets the scene the light belongs to.
  90173. * @returns The scene
  90174. */
  90175. getScene(): Scene;
  90176. /**
  90177. * Callback defining a custom Projection Matrix Builder.
  90178. * This can be used to override the default projection matrix computation.
  90179. */
  90180. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  90181. /**
  90182. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90183. * @param matrix The materix to updated with the projection information
  90184. * @param viewMatrix The transform matrix of the light
  90185. * @param renderList The list of mesh to render in the map
  90186. * @returns The current light
  90187. */
  90188. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90189. /**
  90190. * Gets the current depth scale used in ESM.
  90191. * @returns The scale
  90192. */
  90193. getDepthScale(): number;
  90194. /**
  90195. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  90196. * @returns true if a cube texture needs to be use
  90197. */
  90198. needCube(): boolean;
  90199. /**
  90200. * Detects if the projection matrix requires to be recomputed this frame.
  90201. * @returns true if it requires to be recomputed otherwise, false.
  90202. */
  90203. needProjectionMatrixCompute(): boolean;
  90204. /**
  90205. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  90206. */
  90207. forceProjectionMatrixCompute(): void;
  90208. /**
  90209. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  90210. * @param faceIndex The index of the face we are computed the direction to generate shadow
  90211. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  90212. */
  90213. getShadowDirection(faceIndex?: number): Vector3;
  90214. /**
  90215. * Gets the minZ used for shadow according to both the scene and the light.
  90216. * @param activeCamera The camera we are returning the min for
  90217. * @returns the depth min z
  90218. */
  90219. getDepthMinZ(activeCamera: Camera): number;
  90220. /**
  90221. * Gets the maxZ used for shadow according to both the scene and the light.
  90222. * @param activeCamera The camera we are returning the max for
  90223. * @returns the depth max z
  90224. */
  90225. getDepthMaxZ(activeCamera: Camera): number;
  90226. }
  90227. /**
  90228. * Base implementation IShadowLight
  90229. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  90230. */
  90231. export abstract class ShadowLight extends Light implements IShadowLight {
  90232. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  90233. protected _position: Vector3;
  90234. protected _setPosition(value: Vector3): void;
  90235. /**
  90236. * Sets the position the shadow will be casted from. Also use as the light position for both
  90237. * point and spot lights.
  90238. */
  90239. get position(): Vector3;
  90240. /**
  90241. * Sets the position the shadow will be casted from. Also use as the light position for both
  90242. * point and spot lights.
  90243. */
  90244. set position(value: Vector3);
  90245. protected _direction: Vector3;
  90246. protected _setDirection(value: Vector3): void;
  90247. /**
  90248. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  90249. * Also use as the light direction on spot and directional lights.
  90250. */
  90251. get direction(): Vector3;
  90252. /**
  90253. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  90254. * Also use as the light direction on spot and directional lights.
  90255. */
  90256. set direction(value: Vector3);
  90257. protected _shadowMinZ: number;
  90258. /**
  90259. * Gets the shadow projection clipping minimum z value.
  90260. */
  90261. get shadowMinZ(): number;
  90262. /**
  90263. * Sets the shadow projection clipping minimum z value.
  90264. */
  90265. set shadowMinZ(value: number);
  90266. protected _shadowMaxZ: number;
  90267. /**
  90268. * Sets the shadow projection clipping maximum z value.
  90269. */
  90270. get shadowMaxZ(): number;
  90271. /**
  90272. * Gets the shadow projection clipping maximum z value.
  90273. */
  90274. set shadowMaxZ(value: number);
  90275. /**
  90276. * Callback defining a custom Projection Matrix Builder.
  90277. * This can be used to override the default projection matrix computation.
  90278. */
  90279. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  90280. /**
  90281. * The transformed position. Position of the light in world space taking parenting in account.
  90282. */
  90283. transformedPosition: Vector3;
  90284. /**
  90285. * The transformed direction. Direction of the light in world space taking parenting in account.
  90286. */
  90287. transformedDirection: Vector3;
  90288. private _needProjectionMatrixCompute;
  90289. /**
  90290. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  90291. * @returns true if the information has been computed, false if it does not need to (no parenting)
  90292. */
  90293. computeTransformedInformation(): boolean;
  90294. /**
  90295. * Return the depth scale used for the shadow map.
  90296. * @returns the depth scale.
  90297. */
  90298. getDepthScale(): number;
  90299. /**
  90300. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  90301. * @param faceIndex The index of the face we are computed the direction to generate shadow
  90302. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  90303. */
  90304. getShadowDirection(faceIndex?: number): Vector3;
  90305. /**
  90306. * Returns the ShadowLight absolute position in the World.
  90307. * @returns the position vector in world space
  90308. */
  90309. getAbsolutePosition(): Vector3;
  90310. /**
  90311. * Sets the ShadowLight direction toward the passed target.
  90312. * @param target The point to target in local space
  90313. * @returns the updated ShadowLight direction
  90314. */
  90315. setDirectionToTarget(target: Vector3): Vector3;
  90316. /**
  90317. * Returns the light rotation in euler definition.
  90318. * @returns the x y z rotation in local space.
  90319. */
  90320. getRotation(): Vector3;
  90321. /**
  90322. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  90323. * @returns true if a cube texture needs to be use
  90324. */
  90325. needCube(): boolean;
  90326. /**
  90327. * Detects if the projection matrix requires to be recomputed this frame.
  90328. * @returns true if it requires to be recomputed otherwise, false.
  90329. */
  90330. needProjectionMatrixCompute(): boolean;
  90331. /**
  90332. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  90333. */
  90334. forceProjectionMatrixCompute(): void;
  90335. /** @hidden */
  90336. _initCache(): void;
  90337. /** @hidden */
  90338. _isSynchronized(): boolean;
  90339. /**
  90340. * Computes the world matrix of the node
  90341. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90342. * @returns the world matrix
  90343. */
  90344. computeWorldMatrix(force?: boolean): Matrix;
  90345. /**
  90346. * Gets the minZ used for shadow according to both the scene and the light.
  90347. * @param activeCamera The camera we are returning the min for
  90348. * @returns the depth min z
  90349. */
  90350. getDepthMinZ(activeCamera: Camera): number;
  90351. /**
  90352. * Gets the maxZ used for shadow according to both the scene and the light.
  90353. * @param activeCamera The camera we are returning the max for
  90354. * @returns the depth max z
  90355. */
  90356. getDepthMaxZ(activeCamera: Camera): number;
  90357. /**
  90358. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90359. * @param matrix The materix to updated with the projection information
  90360. * @param viewMatrix The transform matrix of the light
  90361. * @param renderList The list of mesh to render in the map
  90362. * @returns The current light
  90363. */
  90364. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90365. }
  90366. }
  90367. declare module BABYLON {
  90368. /**
  90369. * Configuration needed for prepass-capable materials
  90370. */
  90371. export class PrePassConfiguration {
  90372. /**
  90373. * Previous world matrices of meshes carrying this material
  90374. * Used for computing velocity
  90375. */
  90376. previousWorldMatrices: {
  90377. [index: number]: Matrix;
  90378. };
  90379. /**
  90380. * Previous view project matrix
  90381. * Used for computing velocity
  90382. */
  90383. previousViewProjection: Matrix;
  90384. /**
  90385. * Previous bones of meshes carrying this material
  90386. * Used for computing velocity
  90387. */
  90388. previousBones: {
  90389. [index: number]: Float32Array;
  90390. };
  90391. /**
  90392. * Add the required uniforms to the current list.
  90393. * @param uniforms defines the current uniform list.
  90394. */
  90395. static AddUniforms(uniforms: string[]): void;
  90396. /**
  90397. * Add the required samplers to the current list.
  90398. * @param samplers defines the current sampler list.
  90399. */
  90400. static AddSamplers(samplers: string[]): void;
  90401. /**
  90402. * Binds the material data.
  90403. * @param effect defines the effect to update
  90404. * @param scene defines the scene the material belongs to.
  90405. * @param mesh The mesh
  90406. * @param world World matrix of this mesh
  90407. * @param isFrozen Is the material frozen
  90408. */
  90409. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  90410. }
  90411. }
  90412. declare module BABYLON {
  90413. /**
  90414. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  90415. * This is the base of the follow, arc rotate cameras and Free camera
  90416. * @see https://doc.babylonjs.com/features/cameras
  90417. */
  90418. export class TargetCamera extends Camera {
  90419. private static _RigCamTransformMatrix;
  90420. private static _TargetTransformMatrix;
  90421. private static _TargetFocalPoint;
  90422. private _tmpUpVector;
  90423. private _tmpTargetVector;
  90424. /**
  90425. * Define the current direction the camera is moving to
  90426. */
  90427. cameraDirection: Vector3;
  90428. /**
  90429. * Define the current rotation the camera is rotating to
  90430. */
  90431. cameraRotation: Vector2;
  90432. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  90433. ignoreParentScaling: boolean;
  90434. /**
  90435. * When set, the up vector of the camera will be updated by the rotation of the camera
  90436. */
  90437. updateUpVectorFromRotation: boolean;
  90438. private _tmpQuaternion;
  90439. /**
  90440. * Define the current rotation of the camera
  90441. */
  90442. rotation: Vector3;
  90443. /**
  90444. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  90445. */
  90446. rotationQuaternion: Quaternion;
  90447. /**
  90448. * Define the current speed of the camera
  90449. */
  90450. speed: number;
  90451. /**
  90452. * Add constraint to the camera to prevent it to move freely in all directions and
  90453. * around all axis.
  90454. */
  90455. noRotationConstraint: boolean;
  90456. /**
  90457. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  90458. * panning
  90459. */
  90460. invertRotation: boolean;
  90461. /**
  90462. * Speed multiplier for inverse camera panning
  90463. */
  90464. inverseRotationSpeed: number;
  90465. /**
  90466. * Define the current target of the camera as an object or a position.
  90467. */
  90468. lockedTarget: any;
  90469. /** @hidden */
  90470. _currentTarget: Vector3;
  90471. /** @hidden */
  90472. _initialFocalDistance: number;
  90473. /** @hidden */
  90474. _viewMatrix: Matrix;
  90475. /** @hidden */
  90476. _camMatrix: Matrix;
  90477. /** @hidden */
  90478. _cameraTransformMatrix: Matrix;
  90479. /** @hidden */
  90480. _cameraRotationMatrix: Matrix;
  90481. /** @hidden */
  90482. _referencePoint: Vector3;
  90483. /** @hidden */
  90484. _transformedReferencePoint: Vector3;
  90485. /** @hidden */
  90486. _reset: () => void;
  90487. private _defaultUp;
  90488. /**
  90489. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  90490. * This is the base of the follow, arc rotate cameras and Free camera
  90491. * @see https://doc.babylonjs.com/features/cameras
  90492. * @param name Defines the name of the camera in the scene
  90493. * @param position Defines the start position of the camera in the scene
  90494. * @param scene Defines the scene the camera belongs to
  90495. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  90496. */
  90497. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90498. /**
  90499. * Gets the position in front of the camera at a given distance.
  90500. * @param distance The distance from the camera we want the position to be
  90501. * @returns the position
  90502. */
  90503. getFrontPosition(distance: number): Vector3;
  90504. /** @hidden */
  90505. _getLockedTargetPosition(): Nullable<Vector3>;
  90506. private _storedPosition;
  90507. private _storedRotation;
  90508. private _storedRotationQuaternion;
  90509. /**
  90510. * Store current camera state of the camera (fov, position, rotation, etc..)
  90511. * @returns the camera
  90512. */
  90513. storeState(): Camera;
  90514. /**
  90515. * Restored camera state. You must call storeState() first
  90516. * @returns whether it was successful or not
  90517. * @hidden
  90518. */
  90519. _restoreStateValues(): boolean;
  90520. /** @hidden */
  90521. _initCache(): void;
  90522. /** @hidden */
  90523. _updateCache(ignoreParentClass?: boolean): void;
  90524. /** @hidden */
  90525. _isSynchronizedViewMatrix(): boolean;
  90526. /** @hidden */
  90527. _computeLocalCameraSpeed(): number;
  90528. /**
  90529. * Defines the target the camera should look at.
  90530. * @param target Defines the new target as a Vector or a mesh
  90531. */
  90532. setTarget(target: Vector3): void;
  90533. /**
  90534. * Defines the target point of the camera.
  90535. * The camera looks towards it form the radius distance.
  90536. */
  90537. get target(): Vector3;
  90538. set target(value: Vector3);
  90539. /**
  90540. * Return the current target position of the camera. This value is expressed in local space.
  90541. * @returns the target position
  90542. */
  90543. getTarget(): Vector3;
  90544. /** @hidden */
  90545. _decideIfNeedsToMove(): boolean;
  90546. /** @hidden */
  90547. _updatePosition(): void;
  90548. /** @hidden */
  90549. _checkInputs(): void;
  90550. protected _updateCameraRotationMatrix(): void;
  90551. /**
  90552. * 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)
  90553. * @returns the current camera
  90554. */
  90555. private _rotateUpVectorWithCameraRotationMatrix;
  90556. private _cachedRotationZ;
  90557. private _cachedQuaternionRotationZ;
  90558. /** @hidden */
  90559. _getViewMatrix(): Matrix;
  90560. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  90561. /**
  90562. * @hidden
  90563. */
  90564. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90565. /**
  90566. * @hidden
  90567. */
  90568. _updateRigCameras(): void;
  90569. private _getRigCamPositionAndTarget;
  90570. /**
  90571. * Gets the current object class name.
  90572. * @return the class name
  90573. */
  90574. getClassName(): string;
  90575. }
  90576. }
  90577. declare module BABYLON {
  90578. /**
  90579. * @ignore
  90580. * This is a list of all the different input types that are available in the application.
  90581. * Fo instance: ArcRotateCameraGamepadInput...
  90582. */
  90583. export var CameraInputTypes: {};
  90584. /**
  90585. * This is the contract to implement in order to create a new input class.
  90586. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  90587. */
  90588. export interface ICameraInput<TCamera extends Camera> {
  90589. /**
  90590. * Defines the camera the input is attached to.
  90591. */
  90592. camera: Nullable<TCamera>;
  90593. /**
  90594. * Gets the class name of the current intput.
  90595. * @returns the class name
  90596. */
  90597. getClassName(): string;
  90598. /**
  90599. * Get the friendly name associated with the input class.
  90600. * @returns the input friendly name
  90601. */
  90602. getSimpleName(): string;
  90603. /**
  90604. * Attach the input controls to a specific dom element to get the input from.
  90605. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90606. */
  90607. attachControl(noPreventDefault?: boolean): void;
  90608. /**
  90609. * Detach the current controls from the specified dom element.
  90610. */
  90611. detachControl(): void;
  90612. /**
  90613. * Update the current camera state depending on the inputs that have been used this frame.
  90614. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90615. */
  90616. checkInputs?: () => void;
  90617. }
  90618. /**
  90619. * Represents a map of input types to input instance or input index to input instance.
  90620. */
  90621. export interface CameraInputsMap<TCamera extends Camera> {
  90622. /**
  90623. * Accessor to the input by input type.
  90624. */
  90625. [name: string]: ICameraInput<TCamera>;
  90626. /**
  90627. * Accessor to the input by input index.
  90628. */
  90629. [idx: number]: ICameraInput<TCamera>;
  90630. }
  90631. /**
  90632. * This represents the input manager used within a camera.
  90633. * It helps dealing with all the different kind of input attached to a camera.
  90634. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  90635. */
  90636. export class CameraInputsManager<TCamera extends Camera> {
  90637. /**
  90638. * Defines the list of inputs attahed to the camera.
  90639. */
  90640. attached: CameraInputsMap<TCamera>;
  90641. /**
  90642. * Defines the dom element the camera is collecting inputs from.
  90643. * This is null if the controls have not been attached.
  90644. */
  90645. attachedToElement: boolean;
  90646. /**
  90647. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90648. */
  90649. noPreventDefault: boolean;
  90650. /**
  90651. * Defined the camera the input manager belongs to.
  90652. */
  90653. camera: TCamera;
  90654. /**
  90655. * Update the current camera state depending on the inputs that have been used this frame.
  90656. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90657. */
  90658. checkInputs: () => void;
  90659. /**
  90660. * Instantiate a new Camera Input Manager.
  90661. * @param camera Defines the camera the input manager blongs to
  90662. */
  90663. constructor(camera: TCamera);
  90664. /**
  90665. * Add an input method to a camera
  90666. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  90667. * @param input camera input method
  90668. */
  90669. add(input: ICameraInput<TCamera>): void;
  90670. /**
  90671. * Remove a specific input method from a camera
  90672. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  90673. * @param inputToRemove camera input method
  90674. */
  90675. remove(inputToRemove: ICameraInput<TCamera>): void;
  90676. /**
  90677. * Remove a specific input type from a camera
  90678. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  90679. * @param inputType the type of the input to remove
  90680. */
  90681. removeByType(inputType: string): void;
  90682. private _addCheckInputs;
  90683. /**
  90684. * Attach the input controls to the currently attached dom element to listen the events from.
  90685. * @param input Defines the input to attach
  90686. */
  90687. attachInput(input: ICameraInput<TCamera>): void;
  90688. /**
  90689. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  90690. * @param element Defines the dom element to collect the events from
  90691. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90692. */
  90693. attachElement(noPreventDefault?: boolean): void;
  90694. /**
  90695. * Detach the current manager inputs controls from a specific dom element.
  90696. * @param element Defines the dom element to collect the events from
  90697. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  90698. */
  90699. detachElement(disconnect?: boolean): void;
  90700. /**
  90701. * Rebuild the dynamic inputCheck function from the current list of
  90702. * defined inputs in the manager.
  90703. */
  90704. rebuildInputCheck(): void;
  90705. /**
  90706. * Remove all attached input methods from a camera
  90707. */
  90708. clear(): void;
  90709. /**
  90710. * Serialize the current input manager attached to a camera.
  90711. * This ensures than once parsed,
  90712. * the input associated to the camera will be identical to the current ones
  90713. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  90714. */
  90715. serialize(serializedCamera: any): void;
  90716. /**
  90717. * Parses an input manager serialized JSON to restore the previous list of inputs
  90718. * and states associated to a camera.
  90719. * @param parsedCamera Defines the JSON to parse
  90720. */
  90721. parse(parsedCamera: any): void;
  90722. }
  90723. }
  90724. declare module BABYLON {
  90725. /**
  90726. * Gather the list of keyboard event types as constants.
  90727. */
  90728. export class KeyboardEventTypes {
  90729. /**
  90730. * The keydown event is fired when a key becomes active (pressed).
  90731. */
  90732. static readonly KEYDOWN: number;
  90733. /**
  90734. * The keyup event is fired when a key has been released.
  90735. */
  90736. static readonly KEYUP: number;
  90737. }
  90738. /**
  90739. * This class is used to store keyboard related info for the onKeyboardObservable event.
  90740. */
  90741. export class KeyboardInfo {
  90742. /**
  90743. * Defines the type of event (KeyboardEventTypes)
  90744. */
  90745. type: number;
  90746. /**
  90747. * Defines the related dom event
  90748. */
  90749. event: KeyboardEvent;
  90750. /**
  90751. * Instantiates a new keyboard info.
  90752. * This class is used to store keyboard related info for the onKeyboardObservable event.
  90753. * @param type Defines the type of event (KeyboardEventTypes)
  90754. * @param event Defines the related dom event
  90755. */
  90756. constructor(
  90757. /**
  90758. * Defines the type of event (KeyboardEventTypes)
  90759. */
  90760. type: number,
  90761. /**
  90762. * Defines the related dom event
  90763. */
  90764. event: KeyboardEvent);
  90765. }
  90766. /**
  90767. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  90768. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  90769. */
  90770. export class KeyboardInfoPre extends KeyboardInfo {
  90771. /**
  90772. * Defines the type of event (KeyboardEventTypes)
  90773. */
  90774. type: number;
  90775. /**
  90776. * Defines the related dom event
  90777. */
  90778. event: KeyboardEvent;
  90779. /**
  90780. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  90781. */
  90782. skipOnPointerObservable: boolean;
  90783. /**
  90784. * Instantiates a new keyboard pre info.
  90785. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  90786. * @param type Defines the type of event (KeyboardEventTypes)
  90787. * @param event Defines the related dom event
  90788. */
  90789. constructor(
  90790. /**
  90791. * Defines the type of event (KeyboardEventTypes)
  90792. */
  90793. type: number,
  90794. /**
  90795. * Defines the related dom event
  90796. */
  90797. event: KeyboardEvent);
  90798. }
  90799. }
  90800. declare module BABYLON {
  90801. /**
  90802. * Manage the keyboard inputs to control the movement of a free camera.
  90803. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  90804. */
  90805. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  90806. /**
  90807. * Defines the camera the input is attached to.
  90808. */
  90809. camera: FreeCamera;
  90810. /**
  90811. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  90812. */
  90813. keysUp: number[];
  90814. /**
  90815. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  90816. */
  90817. keysUpward: number[];
  90818. /**
  90819. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  90820. */
  90821. keysDown: number[];
  90822. /**
  90823. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  90824. */
  90825. keysDownward: number[];
  90826. /**
  90827. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  90828. */
  90829. keysLeft: number[];
  90830. /**
  90831. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  90832. */
  90833. keysRight: number[];
  90834. private _keys;
  90835. private _onCanvasBlurObserver;
  90836. private _onKeyboardObserver;
  90837. private _engine;
  90838. private _scene;
  90839. /**
  90840. * Attach the input controls to a specific dom element to get the input from.
  90841. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90842. */
  90843. attachControl(noPreventDefault?: boolean): void;
  90844. /**
  90845. * Detach the current controls from the specified dom element.
  90846. */
  90847. detachControl(): void;
  90848. /**
  90849. * Update the current camera state depending on the inputs that have been used this frame.
  90850. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90851. */
  90852. checkInputs(): void;
  90853. /**
  90854. * Gets the class name of the current intput.
  90855. * @returns the class name
  90856. */
  90857. getClassName(): string;
  90858. /** @hidden */
  90859. _onLostFocus(): void;
  90860. /**
  90861. * Get the friendly name associated with the input class.
  90862. * @returns the input friendly name
  90863. */
  90864. getSimpleName(): string;
  90865. }
  90866. }
  90867. declare module BABYLON {
  90868. /**
  90869. * Interface used to define Action
  90870. */
  90871. export interface IAction {
  90872. /**
  90873. * Trigger for the action
  90874. */
  90875. trigger: number;
  90876. /** Options of the trigger */
  90877. triggerOptions: any;
  90878. /**
  90879. * Gets the trigger parameters
  90880. * @returns the trigger parameters
  90881. */
  90882. getTriggerParameter(): any;
  90883. /**
  90884. * Internal only - executes current action event
  90885. * @hidden
  90886. */
  90887. _executeCurrent(evt?: ActionEvent): void;
  90888. /**
  90889. * Serialize placeholder for child classes
  90890. * @param parent of child
  90891. * @returns the serialized object
  90892. */
  90893. serialize(parent: any): any;
  90894. /**
  90895. * Internal only
  90896. * @hidden
  90897. */
  90898. _prepare(): void;
  90899. /**
  90900. * Internal only - manager for action
  90901. * @hidden
  90902. */
  90903. _actionManager: Nullable<AbstractActionManager>;
  90904. /**
  90905. * Adds action to chain of actions, may be a DoNothingAction
  90906. * @param action defines the next action to execute
  90907. * @returns The action passed in
  90908. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90909. */
  90910. then(action: IAction): IAction;
  90911. }
  90912. /**
  90913. * The action to be carried out following a trigger
  90914. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90915. */
  90916. export class Action implements IAction {
  90917. /** the trigger, with or without parameters, for the action */
  90918. triggerOptions: any;
  90919. /**
  90920. * Trigger for the action
  90921. */
  90922. trigger: number;
  90923. /**
  90924. * Internal only - manager for action
  90925. * @hidden
  90926. */
  90927. _actionManager: ActionManager;
  90928. private _nextActiveAction;
  90929. private _child;
  90930. private _condition?;
  90931. private _triggerParameter;
  90932. /**
  90933. * An event triggered prior to action being executed.
  90934. */
  90935. onBeforeExecuteObservable: Observable<Action>;
  90936. /**
  90937. * Creates a new Action
  90938. * @param triggerOptions the trigger, with or without parameters, for the action
  90939. * @param condition an optional determinant of action
  90940. */
  90941. constructor(
  90942. /** the trigger, with or without parameters, for the action */
  90943. triggerOptions: any, condition?: Condition);
  90944. /**
  90945. * Internal only
  90946. * @hidden
  90947. */
  90948. _prepare(): void;
  90949. /**
  90950. * Gets the trigger parameters
  90951. * @returns the trigger parameters
  90952. */
  90953. getTriggerParameter(): any;
  90954. /**
  90955. * Internal only - executes current action event
  90956. * @hidden
  90957. */
  90958. _executeCurrent(evt?: ActionEvent): void;
  90959. /**
  90960. * Execute placeholder for child classes
  90961. * @param evt optional action event
  90962. */
  90963. execute(evt?: ActionEvent): void;
  90964. /**
  90965. * Skips to next active action
  90966. */
  90967. skipToNextActiveAction(): void;
  90968. /**
  90969. * Adds action to chain of actions, may be a DoNothingAction
  90970. * @param action defines the next action to execute
  90971. * @returns The action passed in
  90972. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90973. */
  90974. then(action: Action): Action;
  90975. /**
  90976. * Internal only
  90977. * @hidden
  90978. */
  90979. _getProperty(propertyPath: string): string;
  90980. /**
  90981. * Internal only
  90982. * @hidden
  90983. */
  90984. _getEffectiveTarget(target: any, propertyPath: string): any;
  90985. /**
  90986. * Serialize placeholder for child classes
  90987. * @param parent of child
  90988. * @returns the serialized object
  90989. */
  90990. serialize(parent: any): any;
  90991. /**
  90992. * Internal only called by serialize
  90993. * @hidden
  90994. */
  90995. protected _serialize(serializedAction: any, parent?: any): any;
  90996. /**
  90997. * Internal only
  90998. * @hidden
  90999. */
  91000. static _SerializeValueAsString: (value: any) => string;
  91001. /**
  91002. * Internal only
  91003. * @hidden
  91004. */
  91005. static _GetTargetProperty: (target: Scene | Node) => {
  91006. name: string;
  91007. targetType: string;
  91008. value: string;
  91009. };
  91010. }
  91011. }
  91012. declare module BABYLON {
  91013. /**
  91014. * A Condition applied to an Action
  91015. */
  91016. export class Condition {
  91017. /**
  91018. * Internal only - manager for action
  91019. * @hidden
  91020. */
  91021. _actionManager: ActionManager;
  91022. /**
  91023. * Internal only
  91024. * @hidden
  91025. */
  91026. _evaluationId: number;
  91027. /**
  91028. * Internal only
  91029. * @hidden
  91030. */
  91031. _currentResult: boolean;
  91032. /**
  91033. * Creates a new Condition
  91034. * @param actionManager the manager of the action the condition is applied to
  91035. */
  91036. constructor(actionManager: ActionManager);
  91037. /**
  91038. * Check if the current condition is valid
  91039. * @returns a boolean
  91040. */
  91041. isValid(): boolean;
  91042. /**
  91043. * Internal only
  91044. * @hidden
  91045. */
  91046. _getProperty(propertyPath: string): string;
  91047. /**
  91048. * Internal only
  91049. * @hidden
  91050. */
  91051. _getEffectiveTarget(target: any, propertyPath: string): any;
  91052. /**
  91053. * Serialize placeholder for child classes
  91054. * @returns the serialized object
  91055. */
  91056. serialize(): any;
  91057. /**
  91058. * Internal only
  91059. * @hidden
  91060. */
  91061. protected _serialize(serializedCondition: any): any;
  91062. }
  91063. /**
  91064. * Defines specific conditional operators as extensions of Condition
  91065. */
  91066. export class ValueCondition extends Condition {
  91067. /** path to specify the property of the target the conditional operator uses */
  91068. propertyPath: string;
  91069. /** the value compared by the conditional operator against the current value of the property */
  91070. value: any;
  91071. /** the conditional operator, default ValueCondition.IsEqual */
  91072. operator: number;
  91073. /**
  91074. * Internal only
  91075. * @hidden
  91076. */
  91077. private static _IsEqual;
  91078. /**
  91079. * Internal only
  91080. * @hidden
  91081. */
  91082. private static _IsDifferent;
  91083. /**
  91084. * Internal only
  91085. * @hidden
  91086. */
  91087. private static _IsGreater;
  91088. /**
  91089. * Internal only
  91090. * @hidden
  91091. */
  91092. private static _IsLesser;
  91093. /**
  91094. * returns the number for IsEqual
  91095. */
  91096. static get IsEqual(): number;
  91097. /**
  91098. * Returns the number for IsDifferent
  91099. */
  91100. static get IsDifferent(): number;
  91101. /**
  91102. * Returns the number for IsGreater
  91103. */
  91104. static get IsGreater(): number;
  91105. /**
  91106. * Returns the number for IsLesser
  91107. */
  91108. static get IsLesser(): number;
  91109. /**
  91110. * Internal only The action manager for the condition
  91111. * @hidden
  91112. */
  91113. _actionManager: ActionManager;
  91114. /**
  91115. * Internal only
  91116. * @hidden
  91117. */
  91118. private _target;
  91119. /**
  91120. * Internal only
  91121. * @hidden
  91122. */
  91123. private _effectiveTarget;
  91124. /**
  91125. * Internal only
  91126. * @hidden
  91127. */
  91128. private _property;
  91129. /**
  91130. * Creates a new ValueCondition
  91131. * @param actionManager manager for the action the condition applies to
  91132. * @param target for the action
  91133. * @param propertyPath path to specify the property of the target the conditional operator uses
  91134. * @param value the value compared by the conditional operator against the current value of the property
  91135. * @param operator the conditional operator, default ValueCondition.IsEqual
  91136. */
  91137. constructor(actionManager: ActionManager, target: any,
  91138. /** path to specify the property of the target the conditional operator uses */
  91139. propertyPath: string,
  91140. /** the value compared by the conditional operator against the current value of the property */
  91141. value: any,
  91142. /** the conditional operator, default ValueCondition.IsEqual */
  91143. operator?: number);
  91144. /**
  91145. * Compares the given value with the property value for the specified conditional operator
  91146. * @returns the result of the comparison
  91147. */
  91148. isValid(): boolean;
  91149. /**
  91150. * Serialize the ValueCondition into a JSON compatible object
  91151. * @returns serialization object
  91152. */
  91153. serialize(): any;
  91154. /**
  91155. * Gets the name of the conditional operator for the ValueCondition
  91156. * @param operator the conditional operator
  91157. * @returns the name
  91158. */
  91159. static GetOperatorName(operator: number): string;
  91160. }
  91161. /**
  91162. * Defines a predicate condition as an extension of Condition
  91163. */
  91164. export class PredicateCondition extends Condition {
  91165. /** defines the predicate function used to validate the condition */
  91166. predicate: () => boolean;
  91167. /**
  91168. * Internal only - manager for action
  91169. * @hidden
  91170. */
  91171. _actionManager: ActionManager;
  91172. /**
  91173. * Creates a new PredicateCondition
  91174. * @param actionManager manager for the action the condition applies to
  91175. * @param predicate defines the predicate function used to validate the condition
  91176. */
  91177. constructor(actionManager: ActionManager,
  91178. /** defines the predicate function used to validate the condition */
  91179. predicate: () => boolean);
  91180. /**
  91181. * @returns the validity of the predicate condition
  91182. */
  91183. isValid(): boolean;
  91184. }
  91185. /**
  91186. * Defines a state condition as an extension of Condition
  91187. */
  91188. export class StateCondition extends Condition {
  91189. /** Value to compare with target state */
  91190. value: string;
  91191. /**
  91192. * Internal only - manager for action
  91193. * @hidden
  91194. */
  91195. _actionManager: ActionManager;
  91196. /**
  91197. * Internal only
  91198. * @hidden
  91199. */
  91200. private _target;
  91201. /**
  91202. * Creates a new StateCondition
  91203. * @param actionManager manager for the action the condition applies to
  91204. * @param target of the condition
  91205. * @param value to compare with target state
  91206. */
  91207. constructor(actionManager: ActionManager, target: any,
  91208. /** Value to compare with target state */
  91209. value: string);
  91210. /**
  91211. * Gets a boolean indicating if the current condition is met
  91212. * @returns the validity of the state
  91213. */
  91214. isValid(): boolean;
  91215. /**
  91216. * Serialize the StateCondition into a JSON compatible object
  91217. * @returns serialization object
  91218. */
  91219. serialize(): any;
  91220. }
  91221. }
  91222. declare module BABYLON {
  91223. /**
  91224. * This defines an action responsible to toggle a boolean once triggered.
  91225. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91226. */
  91227. export class SwitchBooleanAction extends Action {
  91228. /**
  91229. * The path to the boolean property in the target object
  91230. */
  91231. propertyPath: string;
  91232. private _target;
  91233. private _effectiveTarget;
  91234. private _property;
  91235. /**
  91236. * Instantiate the action
  91237. * @param triggerOptions defines the trigger options
  91238. * @param target defines the object containing the boolean
  91239. * @param propertyPath defines the path to the boolean property in the target object
  91240. * @param condition defines the trigger related conditions
  91241. */
  91242. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  91243. /** @hidden */
  91244. _prepare(): void;
  91245. /**
  91246. * Execute the action toggle the boolean value.
  91247. */
  91248. execute(): void;
  91249. /**
  91250. * Serializes the actions and its related information.
  91251. * @param parent defines the object to serialize in
  91252. * @returns the serialized object
  91253. */
  91254. serialize(parent: any): any;
  91255. }
  91256. /**
  91257. * This defines an action responsible to set a the state field of the target
  91258. * to a desired value once triggered.
  91259. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91260. */
  91261. export class SetStateAction extends Action {
  91262. /**
  91263. * The value to store in the state field.
  91264. */
  91265. value: string;
  91266. private _target;
  91267. /**
  91268. * Instantiate the action
  91269. * @param triggerOptions defines the trigger options
  91270. * @param target defines the object containing the state property
  91271. * @param value defines the value to store in the state field
  91272. * @param condition defines the trigger related conditions
  91273. */
  91274. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  91275. /**
  91276. * Execute the action and store the value on the target state property.
  91277. */
  91278. execute(): void;
  91279. /**
  91280. * Serializes the actions and its related information.
  91281. * @param parent defines the object to serialize in
  91282. * @returns the serialized object
  91283. */
  91284. serialize(parent: any): any;
  91285. }
  91286. /**
  91287. * This defines an action responsible to set a property of the target
  91288. * to a desired value once triggered.
  91289. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91290. */
  91291. export class SetValueAction extends Action {
  91292. /**
  91293. * The path of the property to set in the target.
  91294. */
  91295. propertyPath: string;
  91296. /**
  91297. * The value to set in the property
  91298. */
  91299. value: any;
  91300. private _target;
  91301. private _effectiveTarget;
  91302. private _property;
  91303. /**
  91304. * Instantiate the action
  91305. * @param triggerOptions defines the trigger options
  91306. * @param target defines the object containing the property
  91307. * @param propertyPath defines the path of the property to set in the target
  91308. * @param value defines the value to set in the property
  91309. * @param condition defines the trigger related conditions
  91310. */
  91311. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91312. /** @hidden */
  91313. _prepare(): void;
  91314. /**
  91315. * Execute the action and set the targetted property to the desired value.
  91316. */
  91317. execute(): void;
  91318. /**
  91319. * Serializes the actions and its related information.
  91320. * @param parent defines the object to serialize in
  91321. * @returns the serialized object
  91322. */
  91323. serialize(parent: any): any;
  91324. }
  91325. /**
  91326. * This defines an action responsible to increment the target value
  91327. * to a desired value once triggered.
  91328. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91329. */
  91330. export class IncrementValueAction extends Action {
  91331. /**
  91332. * The path of the property to increment in the target.
  91333. */
  91334. propertyPath: string;
  91335. /**
  91336. * The value we should increment the property by.
  91337. */
  91338. value: any;
  91339. private _target;
  91340. private _effectiveTarget;
  91341. private _property;
  91342. /**
  91343. * Instantiate the action
  91344. * @param triggerOptions defines the trigger options
  91345. * @param target defines the object containing the property
  91346. * @param propertyPath defines the path of the property to increment in the target
  91347. * @param value defines the value value we should increment the property by
  91348. * @param condition defines the trigger related conditions
  91349. */
  91350. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91351. /** @hidden */
  91352. _prepare(): void;
  91353. /**
  91354. * Execute the action and increment the target of the value amount.
  91355. */
  91356. execute(): void;
  91357. /**
  91358. * Serializes the actions and its related information.
  91359. * @param parent defines the object to serialize in
  91360. * @returns the serialized object
  91361. */
  91362. serialize(parent: any): any;
  91363. }
  91364. /**
  91365. * This defines an action responsible to start an animation once triggered.
  91366. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91367. */
  91368. export class PlayAnimationAction extends Action {
  91369. /**
  91370. * Where the animation should start (animation frame)
  91371. */
  91372. from: number;
  91373. /**
  91374. * Where the animation should stop (animation frame)
  91375. */
  91376. to: number;
  91377. /**
  91378. * Define if the animation should loop or stop after the first play.
  91379. */
  91380. loop?: boolean;
  91381. private _target;
  91382. /**
  91383. * Instantiate the action
  91384. * @param triggerOptions defines the trigger options
  91385. * @param target defines the target animation or animation name
  91386. * @param from defines from where the animation should start (animation frame)
  91387. * @param end defines where the animation should stop (animation frame)
  91388. * @param loop defines if the animation should loop or stop after the first play
  91389. * @param condition defines the trigger related conditions
  91390. */
  91391. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  91392. /** @hidden */
  91393. _prepare(): void;
  91394. /**
  91395. * Execute the action and play the animation.
  91396. */
  91397. execute(): void;
  91398. /**
  91399. * Serializes the actions and its related information.
  91400. * @param parent defines the object to serialize in
  91401. * @returns the serialized object
  91402. */
  91403. serialize(parent: any): any;
  91404. }
  91405. /**
  91406. * This defines an action responsible to stop an animation once triggered.
  91407. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91408. */
  91409. export class StopAnimationAction extends Action {
  91410. private _target;
  91411. /**
  91412. * Instantiate the action
  91413. * @param triggerOptions defines the trigger options
  91414. * @param target defines the target animation or animation name
  91415. * @param condition defines the trigger related conditions
  91416. */
  91417. constructor(triggerOptions: any, target: any, condition?: Condition);
  91418. /** @hidden */
  91419. _prepare(): void;
  91420. /**
  91421. * Execute the action and stop the animation.
  91422. */
  91423. execute(): void;
  91424. /**
  91425. * Serializes the actions and its related information.
  91426. * @param parent defines the object to serialize in
  91427. * @returns the serialized object
  91428. */
  91429. serialize(parent: any): any;
  91430. }
  91431. /**
  91432. * This defines an action responsible that does nothing once triggered.
  91433. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91434. */
  91435. export class DoNothingAction extends Action {
  91436. /**
  91437. * Instantiate the action
  91438. * @param triggerOptions defines the trigger options
  91439. * @param condition defines the trigger related conditions
  91440. */
  91441. constructor(triggerOptions?: any, condition?: Condition);
  91442. /**
  91443. * Execute the action and do nothing.
  91444. */
  91445. execute(): void;
  91446. /**
  91447. * Serializes the actions and its related information.
  91448. * @param parent defines the object to serialize in
  91449. * @returns the serialized object
  91450. */
  91451. serialize(parent: any): any;
  91452. }
  91453. /**
  91454. * This defines an action responsible to trigger several actions once triggered.
  91455. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91456. */
  91457. export class CombineAction extends Action {
  91458. /**
  91459. * The list of aggregated animations to run.
  91460. */
  91461. children: Action[];
  91462. /**
  91463. * Instantiate the action
  91464. * @param triggerOptions defines the trigger options
  91465. * @param children defines the list of aggregated animations to run
  91466. * @param condition defines the trigger related conditions
  91467. */
  91468. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  91469. /** @hidden */
  91470. _prepare(): void;
  91471. /**
  91472. * Execute the action and executes all the aggregated actions.
  91473. */
  91474. execute(evt: ActionEvent): void;
  91475. /**
  91476. * Serializes the actions and its related information.
  91477. * @param parent defines the object to serialize in
  91478. * @returns the serialized object
  91479. */
  91480. serialize(parent: any): any;
  91481. }
  91482. /**
  91483. * This defines an action responsible to run code (external event) once triggered.
  91484. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91485. */
  91486. export class ExecuteCodeAction extends Action {
  91487. /**
  91488. * The callback function to run.
  91489. */
  91490. func: (evt: ActionEvent) => void;
  91491. /**
  91492. * Instantiate the action
  91493. * @param triggerOptions defines the trigger options
  91494. * @param func defines the callback function to run
  91495. * @param condition defines the trigger related conditions
  91496. */
  91497. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  91498. /**
  91499. * Execute the action and run the attached code.
  91500. */
  91501. execute(evt: ActionEvent): void;
  91502. }
  91503. /**
  91504. * This defines an action responsible to set the parent property of the target once triggered.
  91505. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91506. */
  91507. export class SetParentAction extends Action {
  91508. private _parent;
  91509. private _target;
  91510. /**
  91511. * Instantiate the action
  91512. * @param triggerOptions defines the trigger options
  91513. * @param target defines the target containing the parent property
  91514. * @param parent defines from where the animation should start (animation frame)
  91515. * @param condition defines the trigger related conditions
  91516. */
  91517. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  91518. /** @hidden */
  91519. _prepare(): void;
  91520. /**
  91521. * Execute the action and set the parent property.
  91522. */
  91523. execute(): void;
  91524. /**
  91525. * Serializes the actions and its related information.
  91526. * @param parent defines the object to serialize in
  91527. * @returns the serialized object
  91528. */
  91529. serialize(parent: any): any;
  91530. }
  91531. }
  91532. declare module BABYLON {
  91533. /**
  91534. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  91535. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  91536. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91537. */
  91538. export class ActionManager extends AbstractActionManager {
  91539. /**
  91540. * Nothing
  91541. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91542. */
  91543. static readonly NothingTrigger: number;
  91544. /**
  91545. * On pick
  91546. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91547. */
  91548. static readonly OnPickTrigger: number;
  91549. /**
  91550. * On left pick
  91551. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91552. */
  91553. static readonly OnLeftPickTrigger: number;
  91554. /**
  91555. * On right pick
  91556. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91557. */
  91558. static readonly OnRightPickTrigger: number;
  91559. /**
  91560. * On center pick
  91561. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91562. */
  91563. static readonly OnCenterPickTrigger: number;
  91564. /**
  91565. * On pick down
  91566. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91567. */
  91568. static readonly OnPickDownTrigger: number;
  91569. /**
  91570. * On double pick
  91571. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91572. */
  91573. static readonly OnDoublePickTrigger: number;
  91574. /**
  91575. * On pick up
  91576. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91577. */
  91578. static readonly OnPickUpTrigger: number;
  91579. /**
  91580. * On pick out.
  91581. * This trigger will only be raised if you also declared a OnPickDown
  91582. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91583. */
  91584. static readonly OnPickOutTrigger: number;
  91585. /**
  91586. * On long press
  91587. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91588. */
  91589. static readonly OnLongPressTrigger: number;
  91590. /**
  91591. * On pointer over
  91592. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91593. */
  91594. static readonly OnPointerOverTrigger: number;
  91595. /**
  91596. * On pointer out
  91597. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91598. */
  91599. static readonly OnPointerOutTrigger: number;
  91600. /**
  91601. * On every frame
  91602. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91603. */
  91604. static readonly OnEveryFrameTrigger: number;
  91605. /**
  91606. * On intersection enter
  91607. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91608. */
  91609. static readonly OnIntersectionEnterTrigger: number;
  91610. /**
  91611. * On intersection exit
  91612. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91613. */
  91614. static readonly OnIntersectionExitTrigger: number;
  91615. /**
  91616. * On key down
  91617. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91618. */
  91619. static readonly OnKeyDownTrigger: number;
  91620. /**
  91621. * On key up
  91622. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91623. */
  91624. static readonly OnKeyUpTrigger: number;
  91625. private _scene;
  91626. /**
  91627. * Creates a new action manager
  91628. * @param scene defines the hosting scene
  91629. */
  91630. constructor(scene: Scene);
  91631. /**
  91632. * Releases all associated resources
  91633. */
  91634. dispose(): void;
  91635. /**
  91636. * Gets hosting scene
  91637. * @returns the hosting scene
  91638. */
  91639. getScene(): Scene;
  91640. /**
  91641. * Does this action manager handles actions of any of the given triggers
  91642. * @param triggers defines the triggers to be tested
  91643. * @return a boolean indicating whether one (or more) of the triggers is handled
  91644. */
  91645. hasSpecificTriggers(triggers: number[]): boolean;
  91646. /**
  91647. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91648. * speed.
  91649. * @param triggerA defines the trigger to be tested
  91650. * @param triggerB defines the trigger to be tested
  91651. * @return a boolean indicating whether one (or more) of the triggers is handled
  91652. */
  91653. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91654. /**
  91655. * Does this action manager handles actions of a given trigger
  91656. * @param trigger defines the trigger to be tested
  91657. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91658. * @return whether the trigger is handled
  91659. */
  91660. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91661. /**
  91662. * Does this action manager has pointer triggers
  91663. */
  91664. get hasPointerTriggers(): boolean;
  91665. /**
  91666. * Does this action manager has pick triggers
  91667. */
  91668. get hasPickTriggers(): boolean;
  91669. /**
  91670. * Registers an action to this action manager
  91671. * @param action defines the action to be registered
  91672. * @return the action amended (prepared) after registration
  91673. */
  91674. registerAction(action: IAction): Nullable<IAction>;
  91675. /**
  91676. * Unregisters an action to this action manager
  91677. * @param action defines the action to be unregistered
  91678. * @return a boolean indicating whether the action has been unregistered
  91679. */
  91680. unregisterAction(action: IAction): Boolean;
  91681. /**
  91682. * Process a specific trigger
  91683. * @param trigger defines the trigger to process
  91684. * @param evt defines the event details to be processed
  91685. */
  91686. processTrigger(trigger: number, evt?: IActionEvent): void;
  91687. /** @hidden */
  91688. _getEffectiveTarget(target: any, propertyPath: string): any;
  91689. /** @hidden */
  91690. _getProperty(propertyPath: string): string;
  91691. /**
  91692. * Serialize this manager to a JSON object
  91693. * @param name defines the property name to store this manager
  91694. * @returns a JSON representation of this manager
  91695. */
  91696. serialize(name: string): any;
  91697. /**
  91698. * Creates a new ActionManager from a JSON data
  91699. * @param parsedActions defines the JSON data to read from
  91700. * @param object defines the hosting mesh
  91701. * @param scene defines the hosting scene
  91702. */
  91703. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91704. /**
  91705. * Get a trigger name by index
  91706. * @param trigger defines the trigger index
  91707. * @returns a trigger name
  91708. */
  91709. static GetTriggerName(trigger: number): string;
  91710. }
  91711. }
  91712. declare module BABYLON {
  91713. /**
  91714. * Class representing a ray with position and direction
  91715. */
  91716. export class Ray {
  91717. /** origin point */
  91718. origin: Vector3;
  91719. /** direction */
  91720. direction: Vector3;
  91721. /** length of the ray */
  91722. length: number;
  91723. private static readonly _TmpVector3;
  91724. private _tmpRay;
  91725. /**
  91726. * Creates a new ray
  91727. * @param origin origin point
  91728. * @param direction direction
  91729. * @param length length of the ray
  91730. */
  91731. constructor(
  91732. /** origin point */
  91733. origin: Vector3,
  91734. /** direction */
  91735. direction: Vector3,
  91736. /** length of the ray */
  91737. length?: number);
  91738. /**
  91739. * Checks if the ray intersects a box
  91740. * This does not account for the ray lenght by design to improve perfs.
  91741. * @param minimum bound of the box
  91742. * @param maximum bound of the box
  91743. * @param intersectionTreshold extra extend to be added to the box in all direction
  91744. * @returns if the box was hit
  91745. */
  91746. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  91747. /**
  91748. * Checks if the ray intersects a box
  91749. * This does not account for the ray lenght by design to improve perfs.
  91750. * @param box the bounding box to check
  91751. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  91752. * @returns if the box was hit
  91753. */
  91754. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  91755. /**
  91756. * If the ray hits a sphere
  91757. * @param sphere the bounding sphere to check
  91758. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  91759. * @returns true if it hits the sphere
  91760. */
  91761. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  91762. /**
  91763. * If the ray hits a triange
  91764. * @param vertex0 triangle vertex
  91765. * @param vertex1 triangle vertex
  91766. * @param vertex2 triangle vertex
  91767. * @returns intersection information if hit
  91768. */
  91769. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  91770. /**
  91771. * Checks if ray intersects a plane
  91772. * @param plane the plane to check
  91773. * @returns the distance away it was hit
  91774. */
  91775. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  91776. /**
  91777. * Calculate the intercept of a ray on a given axis
  91778. * @param axis to check 'x' | 'y' | 'z'
  91779. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  91780. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  91781. */
  91782. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  91783. /**
  91784. * Checks if ray intersects a mesh
  91785. * @param mesh the mesh to check
  91786. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91787. * @returns picking info of the intersecton
  91788. */
  91789. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  91790. /**
  91791. * Checks if ray intersects a mesh
  91792. * @param meshes the meshes to check
  91793. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91794. * @param results array to store result in
  91795. * @returns Array of picking infos
  91796. */
  91797. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  91798. private _comparePickingInfo;
  91799. private static smallnum;
  91800. private static rayl;
  91801. /**
  91802. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  91803. * @param sega the first point of the segment to test the intersection against
  91804. * @param segb the second point of the segment to test the intersection against
  91805. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  91806. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  91807. */
  91808. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  91809. /**
  91810. * Update the ray from viewport position
  91811. * @param x position
  91812. * @param y y position
  91813. * @param viewportWidth viewport width
  91814. * @param viewportHeight viewport height
  91815. * @param world world matrix
  91816. * @param view view matrix
  91817. * @param projection projection matrix
  91818. * @returns this ray updated
  91819. */
  91820. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91821. /**
  91822. * Creates a ray with origin and direction of 0,0,0
  91823. * @returns the new ray
  91824. */
  91825. static Zero(): Ray;
  91826. /**
  91827. * Creates a new ray from screen space and viewport
  91828. * @param x position
  91829. * @param y y position
  91830. * @param viewportWidth viewport width
  91831. * @param viewportHeight viewport height
  91832. * @param world world matrix
  91833. * @param view view matrix
  91834. * @param projection projection matrix
  91835. * @returns new ray
  91836. */
  91837. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91838. /**
  91839. * 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
  91840. * transformed to the given world matrix.
  91841. * @param origin The origin point
  91842. * @param end The end point
  91843. * @param world a matrix to transform the ray to. Default is the identity matrix.
  91844. * @returns the new ray
  91845. */
  91846. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  91847. /**
  91848. * Transforms a ray by a matrix
  91849. * @param ray ray to transform
  91850. * @param matrix matrix to apply
  91851. * @returns the resulting new ray
  91852. */
  91853. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  91854. /**
  91855. * Transforms a ray by a matrix
  91856. * @param ray ray to transform
  91857. * @param matrix matrix to apply
  91858. * @param result ray to store result in
  91859. */
  91860. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  91861. /**
  91862. * Unproject a ray from screen space to object space
  91863. * @param sourceX defines the screen space x coordinate to use
  91864. * @param sourceY defines the screen space y coordinate to use
  91865. * @param viewportWidth defines the current width of the viewport
  91866. * @param viewportHeight defines the current height of the viewport
  91867. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  91868. * @param view defines the view matrix to use
  91869. * @param projection defines the projection matrix to use
  91870. */
  91871. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  91872. }
  91873. /**
  91874. * Type used to define predicate used to select faces when a mesh intersection is detected
  91875. */
  91876. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  91877. interface Scene {
  91878. /** @hidden */
  91879. _tempPickingRay: Nullable<Ray>;
  91880. /** @hidden */
  91881. _cachedRayForTransform: Ray;
  91882. /** @hidden */
  91883. _pickWithRayInverseMatrix: Matrix;
  91884. /** @hidden */
  91885. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91886. /** @hidden */
  91887. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91888. /** @hidden */
  91889. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  91890. }
  91891. }
  91892. declare module BABYLON {
  91893. /**
  91894. * Groups all the scene component constants in one place to ease maintenance.
  91895. * @hidden
  91896. */
  91897. export class SceneComponentConstants {
  91898. static readonly NAME_EFFECTLAYER: string;
  91899. static readonly NAME_LAYER: string;
  91900. static readonly NAME_LENSFLARESYSTEM: string;
  91901. static readonly NAME_BOUNDINGBOXRENDERER: string;
  91902. static readonly NAME_PARTICLESYSTEM: string;
  91903. static readonly NAME_GAMEPAD: string;
  91904. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  91905. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  91906. static readonly NAME_PREPASSRENDERER: string;
  91907. static readonly NAME_DEPTHRENDERER: string;
  91908. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  91909. static readonly NAME_SPRITE: string;
  91910. static readonly NAME_SUBSURFACE: string;
  91911. static readonly NAME_OUTLINERENDERER: string;
  91912. static readonly NAME_PROCEDURALTEXTURE: string;
  91913. static readonly NAME_SHADOWGENERATOR: string;
  91914. static readonly NAME_OCTREE: string;
  91915. static readonly NAME_PHYSICSENGINE: string;
  91916. static readonly NAME_AUDIO: string;
  91917. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  91918. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91919. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  91920. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91921. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  91922. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  91923. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  91924. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  91925. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  91926. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  91927. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  91928. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  91929. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  91930. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  91931. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  91932. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  91933. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  91934. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  91935. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  91936. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  91937. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  91938. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  91939. static readonly STEP_AFTERRENDER_AUDIO: number;
  91940. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  91941. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  91942. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  91943. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  91944. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  91945. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  91946. static readonly STEP_POINTERMOVE_SPRITE: number;
  91947. static readonly STEP_POINTERDOWN_SPRITE: number;
  91948. static readonly STEP_POINTERUP_SPRITE: number;
  91949. }
  91950. /**
  91951. * This represents a scene component.
  91952. *
  91953. * This is used to decouple the dependency the scene is having on the different workloads like
  91954. * layers, post processes...
  91955. */
  91956. export interface ISceneComponent {
  91957. /**
  91958. * The name of the component. Each component must have a unique name.
  91959. */
  91960. name: string;
  91961. /**
  91962. * The scene the component belongs to.
  91963. */
  91964. scene: Scene;
  91965. /**
  91966. * Register the component to one instance of a scene.
  91967. */
  91968. register(): void;
  91969. /**
  91970. * Rebuilds the elements related to this component in case of
  91971. * context lost for instance.
  91972. */
  91973. rebuild(): void;
  91974. /**
  91975. * Disposes the component and the associated ressources.
  91976. */
  91977. dispose(): void;
  91978. }
  91979. /**
  91980. * This represents a SERIALIZABLE scene component.
  91981. *
  91982. * This extends Scene Component to add Serialization methods on top.
  91983. */
  91984. export interface ISceneSerializableComponent extends ISceneComponent {
  91985. /**
  91986. * Adds all the elements from the container to the scene
  91987. * @param container the container holding the elements
  91988. */
  91989. addFromContainer(container: AbstractScene): void;
  91990. /**
  91991. * Removes all the elements in the container from the scene
  91992. * @param container contains the elements to remove
  91993. * @param dispose if the removed element should be disposed (default: false)
  91994. */
  91995. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  91996. /**
  91997. * Serializes the component data to the specified json object
  91998. * @param serializationObject The object to serialize to
  91999. */
  92000. serialize(serializationObject: any): void;
  92001. }
  92002. /**
  92003. * Strong typing of a Mesh related stage step action
  92004. */
  92005. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  92006. /**
  92007. * Strong typing of a Evaluate Sub Mesh related stage step action
  92008. */
  92009. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  92010. /**
  92011. * Strong typing of a pre active Mesh related stage step action
  92012. */
  92013. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  92014. /**
  92015. * Strong typing of a Camera related stage step action
  92016. */
  92017. export type CameraStageAction = (camera: Camera) => void;
  92018. /**
  92019. * Strong typing of a Camera Frame buffer related stage step action
  92020. */
  92021. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  92022. /**
  92023. * Strong typing of a Render Target related stage step action
  92024. */
  92025. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  92026. /**
  92027. * Strong typing of a RenderingGroup related stage step action
  92028. */
  92029. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  92030. /**
  92031. * Strong typing of a Mesh Render related stage step action
  92032. */
  92033. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  92034. /**
  92035. * Strong typing of a simple stage step action
  92036. */
  92037. export type SimpleStageAction = () => void;
  92038. /**
  92039. * Strong typing of a render target action.
  92040. */
  92041. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  92042. /**
  92043. * Strong typing of a pointer move action.
  92044. */
  92045. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  92046. /**
  92047. * Strong typing of a pointer up/down action.
  92048. */
  92049. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  92050. /**
  92051. * Representation of a stage in the scene (Basically a list of ordered steps)
  92052. * @hidden
  92053. */
  92054. export class Stage<T extends Function> extends Array<{
  92055. index: number;
  92056. component: ISceneComponent;
  92057. action: T;
  92058. }> {
  92059. /**
  92060. * Hide ctor from the rest of the world.
  92061. * @param items The items to add.
  92062. */
  92063. private constructor();
  92064. /**
  92065. * Creates a new Stage.
  92066. * @returns A new instance of a Stage
  92067. */
  92068. static Create<T extends Function>(): Stage<T>;
  92069. /**
  92070. * Registers a step in an ordered way in the targeted stage.
  92071. * @param index Defines the position to register the step in
  92072. * @param component Defines the component attached to the step
  92073. * @param action Defines the action to launch during the step
  92074. */
  92075. registerStep(index: number, component: ISceneComponent, action: T): void;
  92076. /**
  92077. * Clears all the steps from the stage.
  92078. */
  92079. clear(): void;
  92080. }
  92081. }
  92082. declare module BABYLON {
  92083. interface Scene {
  92084. /** @hidden */
  92085. _pointerOverSprite: Nullable<Sprite>;
  92086. /** @hidden */
  92087. _pickedDownSprite: Nullable<Sprite>;
  92088. /** @hidden */
  92089. _tempSpritePickingRay: Nullable<Ray>;
  92090. /**
  92091. * All of the sprite managers added to this scene
  92092. * @see https://doc.babylonjs.com/babylon101/sprites
  92093. */
  92094. spriteManagers: Array<ISpriteManager>;
  92095. /**
  92096. * An event triggered when sprites rendering is about to start
  92097. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  92098. */
  92099. onBeforeSpritesRenderingObservable: Observable<Scene>;
  92100. /**
  92101. * An event triggered when sprites rendering is done
  92102. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  92103. */
  92104. onAfterSpritesRenderingObservable: Observable<Scene>;
  92105. /** @hidden */
  92106. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92107. /** Launch a ray to try to pick a sprite in the scene
  92108. * @param x position on screen
  92109. * @param y position on screen
  92110. * @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
  92111. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92112. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92113. * @returns a PickingInfo
  92114. */
  92115. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92116. /** Use the given ray to pick a sprite in the scene
  92117. * @param ray The ray (in world space) to use to pick meshes
  92118. * @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
  92119. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92120. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  92121. * @returns a PickingInfo
  92122. */
  92123. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92124. /** @hidden */
  92125. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92126. /** Launch a ray to try to pick sprites in the scene
  92127. * @param x position on screen
  92128. * @param y position on screen
  92129. * @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
  92130. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92131. * @returns a PickingInfo array
  92132. */
  92133. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92134. /** Use the given ray to pick sprites in the scene
  92135. * @param ray The ray (in world space) to use to pick meshes
  92136. * @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
  92137. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  92138. * @returns a PickingInfo array
  92139. */
  92140. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92141. /**
  92142. * Force the sprite under the pointer
  92143. * @param sprite defines the sprite to use
  92144. */
  92145. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  92146. /**
  92147. * Gets the sprite under the pointer
  92148. * @returns a Sprite or null if no sprite is under the pointer
  92149. */
  92150. getPointerOverSprite(): Nullable<Sprite>;
  92151. }
  92152. /**
  92153. * Defines the sprite scene component responsible to manage sprites
  92154. * in a given scene.
  92155. */
  92156. export class SpriteSceneComponent implements ISceneComponent {
  92157. /**
  92158. * The component name helpfull to identify the component in the list of scene components.
  92159. */
  92160. readonly name: string;
  92161. /**
  92162. * The scene the component belongs to.
  92163. */
  92164. scene: Scene;
  92165. /** @hidden */
  92166. private _spritePredicate;
  92167. /**
  92168. * Creates a new instance of the component for the given scene
  92169. * @param scene Defines the scene to register the component in
  92170. */
  92171. constructor(scene: Scene);
  92172. /**
  92173. * Registers the component in a given scene
  92174. */
  92175. register(): void;
  92176. /**
  92177. * Rebuilds the elements related to this component in case of
  92178. * context lost for instance.
  92179. */
  92180. rebuild(): void;
  92181. /**
  92182. * Disposes the component and the associated ressources.
  92183. */
  92184. dispose(): void;
  92185. private _pickSpriteButKeepRay;
  92186. private _pointerMove;
  92187. private _pointerDown;
  92188. private _pointerUp;
  92189. }
  92190. }
  92191. declare module BABYLON {
  92192. /**
  92193. * Class used to provide helper for timing
  92194. */
  92195. export class TimingTools {
  92196. /**
  92197. * Polyfill for setImmediate
  92198. * @param action defines the action to execute after the current execution block
  92199. */
  92200. static SetImmediate(action: () => void): void;
  92201. }
  92202. }
  92203. declare module BABYLON {
  92204. /**
  92205. * Class used to enable instatition of objects by class name
  92206. */
  92207. export class InstantiationTools {
  92208. /**
  92209. * Use this object to register external classes like custom textures or material
  92210. * to allow the laoders to instantiate them
  92211. */
  92212. static RegisteredExternalClasses: {
  92213. [key: string]: Object;
  92214. };
  92215. /**
  92216. * Tries to instantiate a new object from a given class name
  92217. * @param className defines the class name to instantiate
  92218. * @returns the new object or null if the system was not able to do the instantiation
  92219. */
  92220. static Instantiate(className: string): any;
  92221. }
  92222. }
  92223. declare module BABYLON {
  92224. /**
  92225. * Class used to host copy specific utilities
  92226. */
  92227. export class CopyTools {
  92228. /**
  92229. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  92230. * @param texture defines the texture to read pixels from
  92231. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  92232. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  92233. * @returns The base64 encoded string or null
  92234. */
  92235. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  92236. }
  92237. }
  92238. declare module BABYLON {
  92239. /**
  92240. * Define options used to create a depth texture
  92241. */
  92242. export class DepthTextureCreationOptions {
  92243. /** Specifies whether or not a stencil should be allocated in the texture */
  92244. generateStencil?: boolean;
  92245. /** Specifies whether or not bilinear filtering is enable on the texture */
  92246. bilinearFiltering?: boolean;
  92247. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  92248. comparisonFunction?: number;
  92249. /** Specifies if the created texture is a cube texture */
  92250. isCube?: boolean;
  92251. }
  92252. }
  92253. declare module BABYLON {
  92254. interface ThinEngine {
  92255. /**
  92256. * Creates a depth stencil cube texture.
  92257. * This is only available in WebGL 2.
  92258. * @param size The size of face edge in the cube texture.
  92259. * @param options The options defining the cube texture.
  92260. * @returns The cube texture
  92261. */
  92262. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  92263. /**
  92264. * Creates a cube texture
  92265. * @param rootUrl defines the url where the files to load is located
  92266. * @param scene defines the current scene
  92267. * @param files defines the list of files to load (1 per face)
  92268. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  92269. * @param onLoad defines an optional callback raised when the texture is loaded
  92270. * @param onError defines an optional callback raised if there is an issue to load the texture
  92271. * @param format defines the format of the data
  92272. * @param forcedExtension defines the extension to use to pick the right loader
  92273. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  92274. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  92275. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  92276. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  92277. * @param loaderOptions options to be passed to the loader
  92278. * @returns the cube texture as an InternalTexture
  92279. */
  92280. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any): InternalTexture;
  92281. /**
  92282. * Creates a cube texture
  92283. * @param rootUrl defines the url where the files to load is located
  92284. * @param scene defines the current scene
  92285. * @param files defines the list of files to load (1 per face)
  92286. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  92287. * @param onLoad defines an optional callback raised when the texture is loaded
  92288. * @param onError defines an optional callback raised if there is an issue to load the texture
  92289. * @param format defines the format of the data
  92290. * @param forcedExtension defines the extension to use to pick the right loader
  92291. * @returns the cube texture as an InternalTexture
  92292. */
  92293. 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;
  92294. /**
  92295. * Creates a cube texture
  92296. * @param rootUrl defines the url where the files to load is located
  92297. * @param scene defines the current scene
  92298. * @param files defines the list of files to load (1 per face)
  92299. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  92300. * @param onLoad defines an optional callback raised when the texture is loaded
  92301. * @param onError defines an optional callback raised if there is an issue to load the texture
  92302. * @param format defines the format of the data
  92303. * @param forcedExtension defines the extension to use to pick the right loader
  92304. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  92305. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  92306. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  92307. * @returns the cube texture as an InternalTexture
  92308. */
  92309. 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;
  92310. /** @hidden */
  92311. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  92312. /** @hidden */
  92313. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  92314. /** @hidden */
  92315. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  92316. /** @hidden */
  92317. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  92318. /**
  92319. * @hidden
  92320. */
  92321. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  92322. }
  92323. }
  92324. declare module BABYLON {
  92325. /**
  92326. * Class for creating a cube texture
  92327. */
  92328. export class CubeTexture extends BaseTexture {
  92329. private _delayedOnLoad;
  92330. /**
  92331. * Observable triggered once the texture has been loaded.
  92332. */
  92333. onLoadObservable: Observable<CubeTexture>;
  92334. /**
  92335. * The url of the texture
  92336. */
  92337. url: string;
  92338. /**
  92339. * Gets or sets the center of the bounding box associated with the cube texture.
  92340. * It must define where the camera used to render the texture was set
  92341. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  92342. */
  92343. boundingBoxPosition: Vector3;
  92344. private _boundingBoxSize;
  92345. /**
  92346. * Gets or sets the size of the bounding box associated with the cube texture
  92347. * When defined, the cubemap will switch to local mode
  92348. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  92349. * @example https://www.babylonjs-playground.com/#RNASML
  92350. */
  92351. set boundingBoxSize(value: Vector3);
  92352. /**
  92353. * Returns the bounding box size
  92354. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  92355. */
  92356. get boundingBoxSize(): Vector3;
  92357. protected _rotationY: number;
  92358. /**
  92359. * Sets texture matrix rotation angle around Y axis in radians.
  92360. */
  92361. set rotationY(value: number);
  92362. /**
  92363. * Gets texture matrix rotation angle around Y axis radians.
  92364. */
  92365. get rotationY(): number;
  92366. /**
  92367. * Are mip maps generated for this texture or not.
  92368. */
  92369. get noMipmap(): boolean;
  92370. private _noMipmap;
  92371. private _files;
  92372. protected _forcedExtension: Nullable<string>;
  92373. private _extensions;
  92374. private _textureMatrix;
  92375. private _format;
  92376. private _createPolynomials;
  92377. private _loaderOptions;
  92378. /**
  92379. * Creates a cube texture from an array of image urls
  92380. * @param files defines an array of image urls
  92381. * @param scene defines the hosting scene
  92382. * @param noMipmap specifies if mip maps are not used
  92383. * @returns a cube texture
  92384. */
  92385. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  92386. /**
  92387. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  92388. * @param url defines the url of the prefiltered texture
  92389. * @param scene defines the scene the texture is attached to
  92390. * @param forcedExtension defines the extension of the file if different from the url
  92391. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  92392. * @return the prefiltered texture
  92393. */
  92394. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  92395. /**
  92396. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  92397. * as prefiltered data.
  92398. * @param rootUrl defines the url of the texture or the root name of the six images
  92399. * @param null defines the scene or engine the texture is attached to
  92400. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  92401. * @param noMipmap defines if mipmaps should be created or not
  92402. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  92403. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  92404. * @param onError defines a callback triggered in case of error during load
  92405. * @param format defines the internal format to use for the texture once loaded
  92406. * @param prefiltered defines whether or not the texture is created from prefiltered data
  92407. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  92408. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  92409. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  92410. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  92411. * @param loaderOptions options to be passed to the loader
  92412. * @return the cube texture
  92413. */
  92414. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, loaderOptions?: any);
  92415. /**
  92416. * Get the current class name of the texture useful for serialization or dynamic coding.
  92417. * @returns "CubeTexture"
  92418. */
  92419. getClassName(): string;
  92420. /**
  92421. * Update the url (and optional buffer) of this texture if url was null during construction.
  92422. * @param url the url of the texture
  92423. * @param forcedExtension defines the extension to use
  92424. * @param onLoad callback called when the texture is loaded (defaults to null)
  92425. * @param prefiltered Defines whether the updated texture is prefiltered or not
  92426. */
  92427. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  92428. /**
  92429. * Delays loading of the cube texture
  92430. * @param forcedExtension defines the extension to use
  92431. */
  92432. delayLoad(forcedExtension?: string): void;
  92433. /**
  92434. * Returns the reflection texture matrix
  92435. * @returns the reflection texture matrix
  92436. */
  92437. getReflectionTextureMatrix(): Matrix;
  92438. /**
  92439. * Sets the reflection texture matrix
  92440. * @param value Reflection texture matrix
  92441. */
  92442. setReflectionTextureMatrix(value: Matrix): void;
  92443. /**
  92444. * Parses text to create a cube texture
  92445. * @param parsedTexture define the serialized text to read from
  92446. * @param scene defines the hosting scene
  92447. * @param rootUrl defines the root url of the cube texture
  92448. * @returns a cube texture
  92449. */
  92450. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  92451. /**
  92452. * Makes a clone, or deep copy, of the cube texture
  92453. * @returns a new cube texture
  92454. */
  92455. clone(): CubeTexture;
  92456. }
  92457. }
  92458. declare module BABYLON {
  92459. /**
  92460. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  92461. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  92462. * 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;
  92463. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  92464. */
  92465. export class ColorCurves {
  92466. private _dirty;
  92467. private _tempColor;
  92468. private _globalCurve;
  92469. private _highlightsCurve;
  92470. private _midtonesCurve;
  92471. private _shadowsCurve;
  92472. private _positiveCurve;
  92473. private _negativeCurve;
  92474. private _globalHue;
  92475. private _globalDensity;
  92476. private _globalSaturation;
  92477. private _globalExposure;
  92478. /**
  92479. * Gets the global Hue value.
  92480. * 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).
  92481. */
  92482. get globalHue(): number;
  92483. /**
  92484. * Sets the global Hue value.
  92485. * 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).
  92486. */
  92487. set globalHue(value: number);
  92488. /**
  92489. * Gets the global Density value.
  92490. * 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.
  92491. * Values less than zero provide a filter of opposite hue.
  92492. */
  92493. get globalDensity(): number;
  92494. /**
  92495. * Sets the global Density value.
  92496. * 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.
  92497. * Values less than zero provide a filter of opposite hue.
  92498. */
  92499. set globalDensity(value: number);
  92500. /**
  92501. * Gets the global Saturation value.
  92502. * 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.
  92503. */
  92504. get globalSaturation(): number;
  92505. /**
  92506. * Sets the global Saturation value.
  92507. * 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.
  92508. */
  92509. set globalSaturation(value: number);
  92510. /**
  92511. * Gets the global Exposure value.
  92512. * 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.
  92513. */
  92514. get globalExposure(): number;
  92515. /**
  92516. * Sets the global Exposure value.
  92517. * 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.
  92518. */
  92519. set globalExposure(value: number);
  92520. private _highlightsHue;
  92521. private _highlightsDensity;
  92522. private _highlightsSaturation;
  92523. private _highlightsExposure;
  92524. /**
  92525. * Gets the highlights Hue value.
  92526. * 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).
  92527. */
  92528. get highlightsHue(): number;
  92529. /**
  92530. * Sets the highlights Hue value.
  92531. * 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).
  92532. */
  92533. set highlightsHue(value: number);
  92534. /**
  92535. * Gets the highlights Density value.
  92536. * 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.
  92537. * Values less than zero provide a filter of opposite hue.
  92538. */
  92539. get highlightsDensity(): number;
  92540. /**
  92541. * Sets the highlights Density value.
  92542. * 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.
  92543. * Values less than zero provide a filter of opposite hue.
  92544. */
  92545. set highlightsDensity(value: number);
  92546. /**
  92547. * Gets the highlights Saturation value.
  92548. * 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.
  92549. */
  92550. get highlightsSaturation(): number;
  92551. /**
  92552. * Sets the highlights Saturation value.
  92553. * 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.
  92554. */
  92555. set highlightsSaturation(value: number);
  92556. /**
  92557. * Gets the highlights Exposure value.
  92558. * 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.
  92559. */
  92560. get highlightsExposure(): number;
  92561. /**
  92562. * Sets the highlights Exposure value.
  92563. * 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.
  92564. */
  92565. set highlightsExposure(value: number);
  92566. private _midtonesHue;
  92567. private _midtonesDensity;
  92568. private _midtonesSaturation;
  92569. private _midtonesExposure;
  92570. /**
  92571. * Gets the midtones Hue value.
  92572. * 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).
  92573. */
  92574. get midtonesHue(): number;
  92575. /**
  92576. * Sets the midtones Hue value.
  92577. * 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).
  92578. */
  92579. set midtonesHue(value: number);
  92580. /**
  92581. * Gets the midtones Density value.
  92582. * 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.
  92583. * Values less than zero provide a filter of opposite hue.
  92584. */
  92585. get midtonesDensity(): number;
  92586. /**
  92587. * Sets the midtones Density value.
  92588. * 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.
  92589. * Values less than zero provide a filter of opposite hue.
  92590. */
  92591. set midtonesDensity(value: number);
  92592. /**
  92593. * Gets the midtones Saturation value.
  92594. * 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.
  92595. */
  92596. get midtonesSaturation(): number;
  92597. /**
  92598. * Sets the midtones Saturation value.
  92599. * 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.
  92600. */
  92601. set midtonesSaturation(value: number);
  92602. /**
  92603. * Gets the midtones Exposure value.
  92604. * 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.
  92605. */
  92606. get midtonesExposure(): number;
  92607. /**
  92608. * Sets the midtones Exposure value.
  92609. * 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.
  92610. */
  92611. set midtonesExposure(value: number);
  92612. private _shadowsHue;
  92613. private _shadowsDensity;
  92614. private _shadowsSaturation;
  92615. private _shadowsExposure;
  92616. /**
  92617. * Gets the shadows Hue value.
  92618. * 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).
  92619. */
  92620. get shadowsHue(): number;
  92621. /**
  92622. * Sets the shadows Hue value.
  92623. * 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).
  92624. */
  92625. set shadowsHue(value: number);
  92626. /**
  92627. * Gets the shadows Density value.
  92628. * 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.
  92629. * Values less than zero provide a filter of opposite hue.
  92630. */
  92631. get shadowsDensity(): number;
  92632. /**
  92633. * Sets the shadows Density value.
  92634. * 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.
  92635. * Values less than zero provide a filter of opposite hue.
  92636. */
  92637. set shadowsDensity(value: number);
  92638. /**
  92639. * Gets the shadows Saturation value.
  92640. * 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.
  92641. */
  92642. get shadowsSaturation(): number;
  92643. /**
  92644. * Sets the shadows Saturation value.
  92645. * 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.
  92646. */
  92647. set shadowsSaturation(value: number);
  92648. /**
  92649. * Gets the shadows Exposure value.
  92650. * 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.
  92651. */
  92652. get shadowsExposure(): number;
  92653. /**
  92654. * Sets the shadows Exposure value.
  92655. * 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.
  92656. */
  92657. set shadowsExposure(value: number);
  92658. /**
  92659. * Returns the class name
  92660. * @returns The class name
  92661. */
  92662. getClassName(): string;
  92663. /**
  92664. * Binds the color curves to the shader.
  92665. * @param colorCurves The color curve to bind
  92666. * @param effect The effect to bind to
  92667. * @param positiveUniform The positive uniform shader parameter
  92668. * @param neutralUniform The neutral uniform shader parameter
  92669. * @param negativeUniform The negative uniform shader parameter
  92670. */
  92671. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  92672. /**
  92673. * Prepare the list of uniforms associated with the ColorCurves effects.
  92674. * @param uniformsList The list of uniforms used in the effect
  92675. */
  92676. static PrepareUniforms(uniformsList: string[]): void;
  92677. /**
  92678. * Returns color grading data based on a hue, density, saturation and exposure value.
  92679. * @param filterHue The hue of the color filter.
  92680. * @param filterDensity The density of the color filter.
  92681. * @param saturation The saturation.
  92682. * @param exposure The exposure.
  92683. * @param result The result data container.
  92684. */
  92685. private getColorGradingDataToRef;
  92686. /**
  92687. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  92688. * @param value The input slider value in range [-100,100].
  92689. * @returns Adjusted value.
  92690. */
  92691. private static applyColorGradingSliderNonlinear;
  92692. /**
  92693. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  92694. * @param hue The hue (H) input.
  92695. * @param saturation The saturation (S) input.
  92696. * @param brightness The brightness (B) input.
  92697. * @result An RGBA color represented as Vector4.
  92698. */
  92699. private static fromHSBToRef;
  92700. /**
  92701. * Returns a value clamped between min and max
  92702. * @param value The value to clamp
  92703. * @param min The minimum of value
  92704. * @param max The maximum of value
  92705. * @returns The clamped value.
  92706. */
  92707. private static clamp;
  92708. /**
  92709. * Clones the current color curve instance.
  92710. * @return The cloned curves
  92711. */
  92712. clone(): ColorCurves;
  92713. /**
  92714. * Serializes the current color curve instance to a json representation.
  92715. * @return a JSON representation
  92716. */
  92717. serialize(): any;
  92718. /**
  92719. * Parses the color curve from a json representation.
  92720. * @param source the JSON source to parse
  92721. * @return The parsed curves
  92722. */
  92723. static Parse(source: any): ColorCurves;
  92724. }
  92725. }
  92726. declare module BABYLON {
  92727. /**
  92728. * Interface to follow in your material defines to integrate easily the
  92729. * Image proccessing functions.
  92730. * @hidden
  92731. */
  92732. export interface IImageProcessingConfigurationDefines {
  92733. IMAGEPROCESSING: boolean;
  92734. VIGNETTE: boolean;
  92735. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92736. VIGNETTEBLENDMODEOPAQUE: boolean;
  92737. TONEMAPPING: boolean;
  92738. TONEMAPPING_ACES: boolean;
  92739. CONTRAST: boolean;
  92740. EXPOSURE: boolean;
  92741. COLORCURVES: boolean;
  92742. COLORGRADING: boolean;
  92743. COLORGRADING3D: boolean;
  92744. SAMPLER3DGREENDEPTH: boolean;
  92745. SAMPLER3DBGRMAP: boolean;
  92746. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92747. }
  92748. /**
  92749. * @hidden
  92750. */
  92751. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  92752. IMAGEPROCESSING: boolean;
  92753. VIGNETTE: boolean;
  92754. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92755. VIGNETTEBLENDMODEOPAQUE: boolean;
  92756. TONEMAPPING: boolean;
  92757. TONEMAPPING_ACES: boolean;
  92758. CONTRAST: boolean;
  92759. COLORCURVES: boolean;
  92760. COLORGRADING: boolean;
  92761. COLORGRADING3D: boolean;
  92762. SAMPLER3DGREENDEPTH: boolean;
  92763. SAMPLER3DBGRMAP: boolean;
  92764. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92765. EXPOSURE: boolean;
  92766. constructor();
  92767. }
  92768. /**
  92769. * This groups together the common properties used for image processing either in direct forward pass
  92770. * or through post processing effect depending on the use of the image processing pipeline in your scene
  92771. * or not.
  92772. */
  92773. export class ImageProcessingConfiguration {
  92774. /**
  92775. * Default tone mapping applied in BabylonJS.
  92776. */
  92777. static readonly TONEMAPPING_STANDARD: number;
  92778. /**
  92779. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  92780. * to other engines rendering to increase portability.
  92781. */
  92782. static readonly TONEMAPPING_ACES: number;
  92783. /**
  92784. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  92785. */
  92786. colorCurves: Nullable<ColorCurves>;
  92787. private _colorCurvesEnabled;
  92788. /**
  92789. * Gets wether the color curves effect is enabled.
  92790. */
  92791. get colorCurvesEnabled(): boolean;
  92792. /**
  92793. * Sets wether the color curves effect is enabled.
  92794. */
  92795. set colorCurvesEnabled(value: boolean);
  92796. private _colorGradingTexture;
  92797. /**
  92798. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92799. */
  92800. get colorGradingTexture(): Nullable<BaseTexture>;
  92801. /**
  92802. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92803. */
  92804. set colorGradingTexture(value: Nullable<BaseTexture>);
  92805. private _colorGradingEnabled;
  92806. /**
  92807. * Gets wether the color grading effect is enabled.
  92808. */
  92809. get colorGradingEnabled(): boolean;
  92810. /**
  92811. * Sets wether the color grading effect is enabled.
  92812. */
  92813. set colorGradingEnabled(value: boolean);
  92814. private _colorGradingWithGreenDepth;
  92815. /**
  92816. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  92817. */
  92818. get colorGradingWithGreenDepth(): boolean;
  92819. /**
  92820. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  92821. */
  92822. set colorGradingWithGreenDepth(value: boolean);
  92823. private _colorGradingBGR;
  92824. /**
  92825. * Gets wether the color grading texture contains BGR values.
  92826. */
  92827. get colorGradingBGR(): boolean;
  92828. /**
  92829. * Sets wether the color grading texture contains BGR values.
  92830. */
  92831. set colorGradingBGR(value: boolean);
  92832. /** @hidden */
  92833. _exposure: number;
  92834. /**
  92835. * Gets the Exposure used in the effect.
  92836. */
  92837. get exposure(): number;
  92838. /**
  92839. * Sets the Exposure used in the effect.
  92840. */
  92841. set exposure(value: number);
  92842. private _toneMappingEnabled;
  92843. /**
  92844. * Gets wether the tone mapping effect is enabled.
  92845. */
  92846. get toneMappingEnabled(): boolean;
  92847. /**
  92848. * Sets wether the tone mapping effect is enabled.
  92849. */
  92850. set toneMappingEnabled(value: boolean);
  92851. private _toneMappingType;
  92852. /**
  92853. * Gets the type of tone mapping effect.
  92854. */
  92855. get toneMappingType(): number;
  92856. /**
  92857. * Sets the type of tone mapping effect used in BabylonJS.
  92858. */
  92859. set toneMappingType(value: number);
  92860. protected _contrast: number;
  92861. /**
  92862. * Gets the contrast used in the effect.
  92863. */
  92864. get contrast(): number;
  92865. /**
  92866. * Sets the contrast used in the effect.
  92867. */
  92868. set contrast(value: number);
  92869. /**
  92870. * Vignette stretch size.
  92871. */
  92872. vignetteStretch: number;
  92873. /**
  92874. * Vignette centre X Offset.
  92875. */
  92876. vignetteCentreX: number;
  92877. /**
  92878. * Vignette centre Y Offset.
  92879. */
  92880. vignetteCentreY: number;
  92881. /**
  92882. * Vignette weight or intensity of the vignette effect.
  92883. */
  92884. vignetteWeight: number;
  92885. /**
  92886. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  92887. * if vignetteEnabled is set to true.
  92888. */
  92889. vignetteColor: Color4;
  92890. /**
  92891. * Camera field of view used by the Vignette effect.
  92892. */
  92893. vignetteCameraFov: number;
  92894. private _vignetteBlendMode;
  92895. /**
  92896. * Gets the vignette blend mode allowing different kind of effect.
  92897. */
  92898. get vignetteBlendMode(): number;
  92899. /**
  92900. * Sets the vignette blend mode allowing different kind of effect.
  92901. */
  92902. set vignetteBlendMode(value: number);
  92903. private _vignetteEnabled;
  92904. /**
  92905. * Gets wether the vignette effect is enabled.
  92906. */
  92907. get vignetteEnabled(): boolean;
  92908. /**
  92909. * Sets wether the vignette effect is enabled.
  92910. */
  92911. set vignetteEnabled(value: boolean);
  92912. private _applyByPostProcess;
  92913. /**
  92914. * Gets wether the image processing is applied through a post process or not.
  92915. */
  92916. get applyByPostProcess(): boolean;
  92917. /**
  92918. * Sets wether the image processing is applied through a post process or not.
  92919. */
  92920. set applyByPostProcess(value: boolean);
  92921. private _isEnabled;
  92922. /**
  92923. * Gets wether the image processing is enabled or not.
  92924. */
  92925. get isEnabled(): boolean;
  92926. /**
  92927. * Sets wether the image processing is enabled or not.
  92928. */
  92929. set isEnabled(value: boolean);
  92930. /**
  92931. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  92932. */
  92933. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  92934. /**
  92935. * Method called each time the image processing information changes requires to recompile the effect.
  92936. */
  92937. protected _updateParameters(): void;
  92938. /**
  92939. * Gets the current class name.
  92940. * @return "ImageProcessingConfiguration"
  92941. */
  92942. getClassName(): string;
  92943. /**
  92944. * Prepare the list of uniforms associated with the Image Processing effects.
  92945. * @param uniforms The list of uniforms used in the effect
  92946. * @param defines the list of defines currently in use
  92947. */
  92948. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  92949. /**
  92950. * Prepare the list of samplers associated with the Image Processing effects.
  92951. * @param samplersList The list of uniforms used in the effect
  92952. * @param defines the list of defines currently in use
  92953. */
  92954. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  92955. /**
  92956. * Prepare the list of defines associated to the shader.
  92957. * @param defines the list of defines to complete
  92958. * @param forPostProcess Define if we are currently in post process mode or not
  92959. */
  92960. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  92961. /**
  92962. * Returns true if all the image processing information are ready.
  92963. * @returns True if ready, otherwise, false
  92964. */
  92965. isReady(): boolean;
  92966. /**
  92967. * Binds the image processing to the shader.
  92968. * @param effect The effect to bind to
  92969. * @param overrideAspectRatio Override the aspect ratio of the effect
  92970. */
  92971. bind(effect: Effect, overrideAspectRatio?: number): void;
  92972. /**
  92973. * Clones the current image processing instance.
  92974. * @return The cloned image processing
  92975. */
  92976. clone(): ImageProcessingConfiguration;
  92977. /**
  92978. * Serializes the current image processing instance to a json representation.
  92979. * @return a JSON representation
  92980. */
  92981. serialize(): any;
  92982. /**
  92983. * Parses the image processing from a json representation.
  92984. * @param source the JSON source to parse
  92985. * @return The parsed image processing
  92986. */
  92987. static Parse(source: any): ImageProcessingConfiguration;
  92988. private static _VIGNETTEMODE_MULTIPLY;
  92989. private static _VIGNETTEMODE_OPAQUE;
  92990. /**
  92991. * Used to apply the vignette as a mix with the pixel color.
  92992. */
  92993. static get VIGNETTEMODE_MULTIPLY(): number;
  92994. /**
  92995. * Used to apply the vignette as a replacement of the pixel color.
  92996. */
  92997. static get VIGNETTEMODE_OPAQUE(): number;
  92998. }
  92999. }
  93000. declare module BABYLON {
  93001. /** @hidden */
  93002. export var postprocessVertexShader: {
  93003. name: string;
  93004. shader: string;
  93005. };
  93006. }
  93007. declare module BABYLON {
  93008. /**
  93009. * Type used to define a render target texture size (either with a number or with a rect width and height)
  93010. */
  93011. export type RenderTargetTextureSize = number | {
  93012. width: number;
  93013. height: number;
  93014. layers?: number;
  93015. };
  93016. interface ThinEngine {
  93017. /**
  93018. * Creates a new render target texture
  93019. * @param size defines the size of the texture
  93020. * @param options defines the options used to create the texture
  93021. * @returns a new render target texture stored in an InternalTexture
  93022. */
  93023. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  93024. /**
  93025. * Creates a depth stencil texture.
  93026. * This is only available in WebGL 2 or with the depth texture extension available.
  93027. * @param size The size of face edge in the texture.
  93028. * @param options The options defining the texture.
  93029. * @returns The texture
  93030. */
  93031. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  93032. /** @hidden */
  93033. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  93034. }
  93035. }
  93036. declare module BABYLON {
  93037. /**
  93038. * Defines the kind of connection point for node based material
  93039. */
  93040. export enum NodeMaterialBlockConnectionPointTypes {
  93041. /** Float */
  93042. Float = 1,
  93043. /** Int */
  93044. Int = 2,
  93045. /** Vector2 */
  93046. Vector2 = 4,
  93047. /** Vector3 */
  93048. Vector3 = 8,
  93049. /** Vector4 */
  93050. Vector4 = 16,
  93051. /** Color3 */
  93052. Color3 = 32,
  93053. /** Color4 */
  93054. Color4 = 64,
  93055. /** Matrix */
  93056. Matrix = 128,
  93057. /** Custom object */
  93058. Object = 256,
  93059. /** Detect type based on connection */
  93060. AutoDetect = 1024,
  93061. /** Output type that will be defined by input type */
  93062. BasedOnInput = 2048
  93063. }
  93064. }
  93065. declare module BABYLON {
  93066. /**
  93067. * Enum used to define the target of a block
  93068. */
  93069. export enum NodeMaterialBlockTargets {
  93070. /** Vertex shader */
  93071. Vertex = 1,
  93072. /** Fragment shader */
  93073. Fragment = 2,
  93074. /** Neutral */
  93075. Neutral = 4,
  93076. /** Vertex and Fragment */
  93077. VertexAndFragment = 3
  93078. }
  93079. }
  93080. declare module BABYLON {
  93081. /**
  93082. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  93083. */
  93084. export enum NodeMaterialBlockConnectionPointMode {
  93085. /** Value is an uniform */
  93086. Uniform = 0,
  93087. /** Value is a mesh attribute */
  93088. Attribute = 1,
  93089. /** Value is a varying between vertex and fragment shaders */
  93090. Varying = 2,
  93091. /** Mode is undefined */
  93092. Undefined = 3
  93093. }
  93094. }
  93095. declare module BABYLON {
  93096. /**
  93097. * Enum used to define system values e.g. values automatically provided by the system
  93098. */
  93099. export enum NodeMaterialSystemValues {
  93100. /** World */
  93101. World = 1,
  93102. /** View */
  93103. View = 2,
  93104. /** Projection */
  93105. Projection = 3,
  93106. /** ViewProjection */
  93107. ViewProjection = 4,
  93108. /** WorldView */
  93109. WorldView = 5,
  93110. /** WorldViewProjection */
  93111. WorldViewProjection = 6,
  93112. /** CameraPosition */
  93113. CameraPosition = 7,
  93114. /** Fog Color */
  93115. FogColor = 8,
  93116. /** Delta time */
  93117. DeltaTime = 9
  93118. }
  93119. }
  93120. declare module BABYLON {
  93121. /**
  93122. * Represents a camera frustum
  93123. */
  93124. export class Frustum {
  93125. /**
  93126. * Gets the planes representing the frustum
  93127. * @param transform matrix to be applied to the returned planes
  93128. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  93129. */
  93130. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  93131. /**
  93132. * Gets the near frustum plane transformed by the transform matrix
  93133. * @param transform transformation matrix to be applied to the resulting frustum plane
  93134. * @param frustumPlane the resuling frustum plane
  93135. */
  93136. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93137. /**
  93138. * Gets the far frustum plane transformed by the transform matrix
  93139. * @param transform transformation matrix to be applied to the resulting frustum plane
  93140. * @param frustumPlane the resuling frustum plane
  93141. */
  93142. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93143. /**
  93144. * Gets the left frustum plane transformed by the transform matrix
  93145. * @param transform transformation matrix to be applied to the resulting frustum plane
  93146. * @param frustumPlane the resuling frustum plane
  93147. */
  93148. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93149. /**
  93150. * Gets the right frustum plane transformed by the transform matrix
  93151. * @param transform transformation matrix to be applied to the resulting frustum plane
  93152. * @param frustumPlane the resuling frustum plane
  93153. */
  93154. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93155. /**
  93156. * Gets the top frustum plane transformed by the transform matrix
  93157. * @param transform transformation matrix to be applied to the resulting frustum plane
  93158. * @param frustumPlane the resuling frustum plane
  93159. */
  93160. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93161. /**
  93162. * Gets the bottom frustum plane transformed by the transform matrix
  93163. * @param transform transformation matrix to be applied to the resulting frustum plane
  93164. * @param frustumPlane the resuling frustum plane
  93165. */
  93166. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93167. /**
  93168. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  93169. * @param transform transformation matrix to be applied to the resulting frustum planes
  93170. * @param frustumPlanes the resuling frustum planes
  93171. */
  93172. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  93173. }
  93174. }
  93175. declare module BABYLON {
  93176. /**
  93177. * Contains position and normal vectors for a vertex
  93178. */
  93179. export class PositionNormalVertex {
  93180. /** the position of the vertex (defaut: 0,0,0) */
  93181. position: Vector3;
  93182. /** the normal of the vertex (defaut: 0,1,0) */
  93183. normal: Vector3;
  93184. /**
  93185. * Creates a PositionNormalVertex
  93186. * @param position the position of the vertex (defaut: 0,0,0)
  93187. * @param normal the normal of the vertex (defaut: 0,1,0)
  93188. */
  93189. constructor(
  93190. /** the position of the vertex (defaut: 0,0,0) */
  93191. position?: Vector3,
  93192. /** the normal of the vertex (defaut: 0,1,0) */
  93193. normal?: Vector3);
  93194. /**
  93195. * Clones the PositionNormalVertex
  93196. * @returns the cloned PositionNormalVertex
  93197. */
  93198. clone(): PositionNormalVertex;
  93199. }
  93200. /**
  93201. * Contains position, normal and uv vectors for a vertex
  93202. */
  93203. export class PositionNormalTextureVertex {
  93204. /** the position of the vertex (defaut: 0,0,0) */
  93205. position: Vector3;
  93206. /** the normal of the vertex (defaut: 0,1,0) */
  93207. normal: Vector3;
  93208. /** the uv of the vertex (default: 0,0) */
  93209. uv: Vector2;
  93210. /**
  93211. * Creates a PositionNormalTextureVertex
  93212. * @param position the position of the vertex (defaut: 0,0,0)
  93213. * @param normal the normal of the vertex (defaut: 0,1,0)
  93214. * @param uv the uv of the vertex (default: 0,0)
  93215. */
  93216. constructor(
  93217. /** the position of the vertex (defaut: 0,0,0) */
  93218. position?: Vector3,
  93219. /** the normal of the vertex (defaut: 0,1,0) */
  93220. normal?: Vector3,
  93221. /** the uv of the vertex (default: 0,0) */
  93222. uv?: Vector2);
  93223. /**
  93224. * Clones the PositionNormalTextureVertex
  93225. * @returns the cloned PositionNormalTextureVertex
  93226. */
  93227. clone(): PositionNormalTextureVertex;
  93228. }
  93229. }
  93230. declare module BABYLON {
  93231. /**
  93232. * Enum defining the type of animations supported by InputBlock
  93233. */
  93234. export enum AnimatedInputBlockTypes {
  93235. /** No animation */
  93236. None = 0,
  93237. /** Time based animation. Will only work for floats */
  93238. Time = 1
  93239. }
  93240. }
  93241. declare module BABYLON {
  93242. /**
  93243. * Block used to expose an input value
  93244. */
  93245. export class InputBlock extends NodeMaterialBlock {
  93246. private _mode;
  93247. private _associatedVariableName;
  93248. private _storedValue;
  93249. private _valueCallback;
  93250. private _type;
  93251. private _animationType;
  93252. /** Gets or set a value used to limit the range of float values */
  93253. min: number;
  93254. /** Gets or set a value used to limit the range of float values */
  93255. max: number;
  93256. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  93257. isBoolean: boolean;
  93258. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  93259. matrixMode: number;
  93260. /** @hidden */
  93261. _systemValue: Nullable<NodeMaterialSystemValues>;
  93262. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  93263. isConstant: boolean;
  93264. /** Gets or sets the group to use to display this block in the Inspector */
  93265. groupInInspector: string;
  93266. /** Gets an observable raised when the value is changed */
  93267. onValueChangedObservable: Observable<InputBlock>;
  93268. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  93269. convertToGammaSpace: boolean;
  93270. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  93271. convertToLinearSpace: boolean;
  93272. /**
  93273. * Gets or sets the connection point type (default is float)
  93274. */
  93275. get type(): NodeMaterialBlockConnectionPointTypes;
  93276. /**
  93277. * Creates a new InputBlock
  93278. * @param name defines the block name
  93279. * @param target defines the target of that block (Vertex by default)
  93280. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  93281. */
  93282. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  93283. /**
  93284. * Validates if a name is a reserve word.
  93285. * @param newName the new name to be given to the node.
  93286. * @returns false if the name is a reserve word, else true.
  93287. */
  93288. validateBlockName(newName: string): boolean;
  93289. /**
  93290. * Gets the output component
  93291. */
  93292. get output(): NodeMaterialConnectionPoint;
  93293. /**
  93294. * Set the source of this connection point to a vertex attribute
  93295. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  93296. * @returns the current connection point
  93297. */
  93298. setAsAttribute(attributeName?: string): InputBlock;
  93299. /**
  93300. * Set the source of this connection point to a system value
  93301. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  93302. * @returns the current connection point
  93303. */
  93304. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  93305. /**
  93306. * Gets or sets the value of that point.
  93307. * Please note that this value will be ignored if valueCallback is defined
  93308. */
  93309. get value(): any;
  93310. set value(value: any);
  93311. /**
  93312. * Gets or sets a callback used to get the value of that point.
  93313. * Please note that setting this value will force the connection point to ignore the value property
  93314. */
  93315. get valueCallback(): () => any;
  93316. set valueCallback(value: () => any);
  93317. /**
  93318. * Gets or sets the associated variable name in the shader
  93319. */
  93320. get associatedVariableName(): string;
  93321. set associatedVariableName(value: string);
  93322. /** Gets or sets the type of animation applied to the input */
  93323. get animationType(): AnimatedInputBlockTypes;
  93324. set animationType(value: AnimatedInputBlockTypes);
  93325. /**
  93326. * Gets a boolean indicating that this connection point not defined yet
  93327. */
  93328. get isUndefined(): boolean;
  93329. /**
  93330. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  93331. * In this case the connection point name must be the name of the uniform to use.
  93332. * Can only be set on inputs
  93333. */
  93334. get isUniform(): boolean;
  93335. set isUniform(value: boolean);
  93336. /**
  93337. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  93338. * In this case the connection point name must be the name of the attribute to use
  93339. * Can only be set on inputs
  93340. */
  93341. get isAttribute(): boolean;
  93342. set isAttribute(value: boolean);
  93343. /**
  93344. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  93345. * Can only be set on exit points
  93346. */
  93347. get isVarying(): boolean;
  93348. set isVarying(value: boolean);
  93349. /**
  93350. * Gets a boolean indicating that the current connection point is a system value
  93351. */
  93352. get isSystemValue(): boolean;
  93353. /**
  93354. * Gets or sets the current well known value or null if not defined as a system value
  93355. */
  93356. get systemValue(): Nullable<NodeMaterialSystemValues>;
  93357. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  93358. /**
  93359. * Gets the current class name
  93360. * @returns the class name
  93361. */
  93362. getClassName(): string;
  93363. /**
  93364. * Animate the input if animationType !== None
  93365. * @param scene defines the rendering scene
  93366. */
  93367. animate(scene: Scene): void;
  93368. private _emitDefine;
  93369. initialize(state: NodeMaterialBuildState): void;
  93370. /**
  93371. * Set the input block to its default value (based on its type)
  93372. */
  93373. setDefaultValue(): void;
  93374. private _emitConstant;
  93375. /** @hidden */
  93376. get _noContextSwitch(): boolean;
  93377. private _emit;
  93378. /** @hidden */
  93379. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  93380. /** @hidden */
  93381. _transmit(effect: Effect, scene: Scene): void;
  93382. protected _buildBlock(state: NodeMaterialBuildState): void;
  93383. protected _dumpPropertiesCode(): string;
  93384. dispose(): void;
  93385. serialize(): any;
  93386. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  93387. }
  93388. }
  93389. declare module BABYLON {
  93390. /**
  93391. * Enum used to define the compatibility state between two connection points
  93392. */
  93393. export enum NodeMaterialConnectionPointCompatibilityStates {
  93394. /** Points are compatibles */
  93395. Compatible = 0,
  93396. /** Points are incompatible because of their types */
  93397. TypeIncompatible = 1,
  93398. /** Points are incompatible because of their targets (vertex vs fragment) */
  93399. TargetIncompatible = 2
  93400. }
  93401. /**
  93402. * Defines the direction of a connection point
  93403. */
  93404. export enum NodeMaterialConnectionPointDirection {
  93405. /** Input */
  93406. Input = 0,
  93407. /** Output */
  93408. Output = 1
  93409. }
  93410. /**
  93411. * Defines a connection point for a block
  93412. */
  93413. export class NodeMaterialConnectionPoint {
  93414. /**
  93415. * Checks if two types are equivalent
  93416. * @param type1 type 1 to check
  93417. * @param type2 type 2 to check
  93418. * @returns true if both types are equivalent, else false
  93419. */
  93420. static AreEquivalentTypes(type1: number, type2: number): boolean;
  93421. /** @hidden */
  93422. _ownerBlock: NodeMaterialBlock;
  93423. /** @hidden */
  93424. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  93425. private _endpoints;
  93426. private _associatedVariableName;
  93427. private _direction;
  93428. /** @hidden */
  93429. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  93430. /** @hidden */
  93431. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  93432. /** @hidden */
  93433. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  93434. private _type;
  93435. /** @hidden */
  93436. _enforceAssociatedVariableName: boolean;
  93437. /** Gets the direction of the point */
  93438. get direction(): NodeMaterialConnectionPointDirection;
  93439. /** Indicates that this connection point needs dual validation before being connected to another point */
  93440. needDualDirectionValidation: boolean;
  93441. /**
  93442. * Gets or sets the additional types supported by this connection point
  93443. */
  93444. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  93445. /**
  93446. * Gets or sets the additional types excluded by this connection point
  93447. */
  93448. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  93449. /**
  93450. * Observable triggered when this point is connected
  93451. */
  93452. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  93453. /**
  93454. * Gets or sets the associated variable name in the shader
  93455. */
  93456. get associatedVariableName(): string;
  93457. set associatedVariableName(value: string);
  93458. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  93459. get innerType(): NodeMaterialBlockConnectionPointTypes;
  93460. /**
  93461. * Gets or sets the connection point type (default is float)
  93462. */
  93463. get type(): NodeMaterialBlockConnectionPointTypes;
  93464. set type(value: NodeMaterialBlockConnectionPointTypes);
  93465. /**
  93466. * Gets or sets the connection point name
  93467. */
  93468. name: string;
  93469. /**
  93470. * Gets or sets the connection point name
  93471. */
  93472. displayName: string;
  93473. /**
  93474. * Gets or sets a boolean indicating that this connection point can be omitted
  93475. */
  93476. isOptional: boolean;
  93477. /**
  93478. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  93479. */
  93480. isExposedOnFrame: boolean;
  93481. /**
  93482. * Gets or sets number indicating the position that the port is exposed to on a frame
  93483. */
  93484. exposedPortPosition: number;
  93485. /**
  93486. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  93487. */
  93488. define: string;
  93489. /** @hidden */
  93490. _prioritizeVertex: boolean;
  93491. private _target;
  93492. /** Gets or sets the target of that connection point */
  93493. get target(): NodeMaterialBlockTargets;
  93494. set target(value: NodeMaterialBlockTargets);
  93495. /**
  93496. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  93497. */
  93498. get isConnected(): boolean;
  93499. /**
  93500. * Gets a boolean indicating that the current point is connected to an input block
  93501. */
  93502. get isConnectedToInputBlock(): boolean;
  93503. /**
  93504. * Gets a the connected input block (if any)
  93505. */
  93506. get connectInputBlock(): Nullable<InputBlock>;
  93507. /** Get the other side of the connection (if any) */
  93508. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  93509. /** Get the block that owns this connection point */
  93510. get ownerBlock(): NodeMaterialBlock;
  93511. /** Get the block connected on the other side of this connection (if any) */
  93512. get sourceBlock(): Nullable<NodeMaterialBlock>;
  93513. /** Get the block connected on the endpoints of this connection (if any) */
  93514. get connectedBlocks(): Array<NodeMaterialBlock>;
  93515. /** Gets the list of connected endpoints */
  93516. get endpoints(): NodeMaterialConnectionPoint[];
  93517. /** Gets a boolean indicating if that output point is connected to at least one input */
  93518. get hasEndpoints(): boolean;
  93519. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  93520. get isConnectedInVertexShader(): boolean;
  93521. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  93522. get isConnectedInFragmentShader(): boolean;
  93523. /**
  93524. * Creates a block suitable to be used as an input for this input point.
  93525. * If null is returned, a block based on the point type will be created.
  93526. * @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
  93527. */
  93528. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  93529. /**
  93530. * Creates a new connection point
  93531. * @param name defines the connection point name
  93532. * @param ownerBlock defines the block hosting this connection point
  93533. * @param direction defines the direction of the connection point
  93534. */
  93535. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  93536. /**
  93537. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  93538. * @returns the class name
  93539. */
  93540. getClassName(): string;
  93541. /**
  93542. * Gets a boolean indicating if the current point can be connected to another point
  93543. * @param connectionPoint defines the other connection point
  93544. * @returns a boolean
  93545. */
  93546. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  93547. /**
  93548. * Gets a number indicating if the current point can be connected to another point
  93549. * @param connectionPoint defines the other connection point
  93550. * @returns a number defining the compatibility state
  93551. */
  93552. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  93553. /**
  93554. * Connect this point to another connection point
  93555. * @param connectionPoint defines the other connection point
  93556. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  93557. * @returns the current connection point
  93558. */
  93559. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  93560. /**
  93561. * Disconnect this point from one of his endpoint
  93562. * @param endpoint defines the other connection point
  93563. * @returns the current connection point
  93564. */
  93565. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  93566. /**
  93567. * Serializes this point in a JSON representation
  93568. * @param isInput defines if the connection point is an input (default is true)
  93569. * @returns the serialized point object
  93570. */
  93571. serialize(isInput?: boolean): any;
  93572. /**
  93573. * Release resources
  93574. */
  93575. dispose(): void;
  93576. }
  93577. }
  93578. declare module BABYLON {
  93579. /**
  93580. * Enum used to define the material modes
  93581. */
  93582. export enum NodeMaterialModes {
  93583. /** Regular material */
  93584. Material = 0,
  93585. /** For post process */
  93586. PostProcess = 1,
  93587. /** For particle system */
  93588. Particle = 2,
  93589. /** For procedural texture */
  93590. ProceduralTexture = 3
  93591. }
  93592. }
  93593. declare module BABYLON {
  93594. /** @hidden */
  93595. export var helperFunctions: {
  93596. name: string;
  93597. shader: string;
  93598. };
  93599. }
  93600. declare module BABYLON {
  93601. /**
  93602. * Block used to read a texture from a sampler
  93603. */
  93604. export class TextureBlock extends NodeMaterialBlock {
  93605. private _defineName;
  93606. private _linearDefineName;
  93607. private _gammaDefineName;
  93608. private _tempTextureRead;
  93609. private _samplerName;
  93610. private _transformedUVName;
  93611. private _textureTransformName;
  93612. private _textureInfoName;
  93613. private _mainUVName;
  93614. private _mainUVDefineName;
  93615. private _fragmentOnly;
  93616. /**
  93617. * Gets or sets the texture associated with the node
  93618. */
  93619. texture: Nullable<Texture>;
  93620. /**
  93621. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  93622. */
  93623. convertToGammaSpace: boolean;
  93624. /**
  93625. * Gets or sets a boolean indicating if content needs to be converted to linear space
  93626. */
  93627. convertToLinearSpace: boolean;
  93628. /**
  93629. * Create a new TextureBlock
  93630. * @param name defines the block name
  93631. */
  93632. constructor(name: string, fragmentOnly?: boolean);
  93633. /**
  93634. * Gets the current class name
  93635. * @returns the class name
  93636. */
  93637. getClassName(): string;
  93638. /**
  93639. * Gets the uv input component
  93640. */
  93641. get uv(): NodeMaterialConnectionPoint;
  93642. /**
  93643. * Gets the rgba output component
  93644. */
  93645. get rgba(): NodeMaterialConnectionPoint;
  93646. /**
  93647. * Gets the rgb output component
  93648. */
  93649. get rgb(): NodeMaterialConnectionPoint;
  93650. /**
  93651. * Gets the r output component
  93652. */
  93653. get r(): NodeMaterialConnectionPoint;
  93654. /**
  93655. * Gets the g output component
  93656. */
  93657. get g(): NodeMaterialConnectionPoint;
  93658. /**
  93659. * Gets the b output component
  93660. */
  93661. get b(): NodeMaterialConnectionPoint;
  93662. /**
  93663. * Gets the a output component
  93664. */
  93665. get a(): NodeMaterialConnectionPoint;
  93666. get target(): NodeMaterialBlockTargets;
  93667. autoConfigure(material: NodeMaterial): void;
  93668. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  93669. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  93670. isReady(): boolean;
  93671. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  93672. private get _isMixed();
  93673. private _injectVertexCode;
  93674. private _writeTextureRead;
  93675. private _writeOutput;
  93676. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  93677. protected _dumpPropertiesCode(): string;
  93678. serialize(): any;
  93679. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  93680. }
  93681. }
  93682. declare module BABYLON {
  93683. /** @hidden */
  93684. export var reflectionFunction: {
  93685. name: string;
  93686. shader: string;
  93687. };
  93688. }
  93689. declare module BABYLON {
  93690. /**
  93691. * Base block used to read a reflection texture from a sampler
  93692. */
  93693. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  93694. /** @hidden */
  93695. _define3DName: string;
  93696. /** @hidden */
  93697. _defineCubicName: string;
  93698. /** @hidden */
  93699. _defineExplicitName: string;
  93700. /** @hidden */
  93701. _defineProjectionName: string;
  93702. /** @hidden */
  93703. _defineLocalCubicName: string;
  93704. /** @hidden */
  93705. _defineSphericalName: string;
  93706. /** @hidden */
  93707. _definePlanarName: string;
  93708. /** @hidden */
  93709. _defineEquirectangularName: string;
  93710. /** @hidden */
  93711. _defineMirroredEquirectangularFixedName: string;
  93712. /** @hidden */
  93713. _defineEquirectangularFixedName: string;
  93714. /** @hidden */
  93715. _defineSkyboxName: string;
  93716. /** @hidden */
  93717. _defineOppositeZ: string;
  93718. /** @hidden */
  93719. _cubeSamplerName: string;
  93720. /** @hidden */
  93721. _2DSamplerName: string;
  93722. protected _positionUVWName: string;
  93723. protected _directionWName: string;
  93724. protected _reflectionVectorName: string;
  93725. /** @hidden */
  93726. _reflectionCoordsName: string;
  93727. /** @hidden */
  93728. _reflectionMatrixName: string;
  93729. protected _reflectionColorName: string;
  93730. /**
  93731. * Gets or sets the texture associated with the node
  93732. */
  93733. texture: Nullable<BaseTexture>;
  93734. /**
  93735. * Create a new ReflectionTextureBaseBlock
  93736. * @param name defines the block name
  93737. */
  93738. constructor(name: string);
  93739. /**
  93740. * Gets the current class name
  93741. * @returns the class name
  93742. */
  93743. getClassName(): string;
  93744. /**
  93745. * Gets the world position input component
  93746. */
  93747. abstract get position(): NodeMaterialConnectionPoint;
  93748. /**
  93749. * Gets the world position input component
  93750. */
  93751. abstract get worldPosition(): NodeMaterialConnectionPoint;
  93752. /**
  93753. * Gets the world normal input component
  93754. */
  93755. abstract get worldNormal(): NodeMaterialConnectionPoint;
  93756. /**
  93757. * Gets the world input component
  93758. */
  93759. abstract get world(): NodeMaterialConnectionPoint;
  93760. /**
  93761. * Gets the camera (or eye) position component
  93762. */
  93763. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  93764. /**
  93765. * Gets the view input component
  93766. */
  93767. abstract get view(): NodeMaterialConnectionPoint;
  93768. protected _getTexture(): Nullable<BaseTexture>;
  93769. autoConfigure(material: NodeMaterial): void;
  93770. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  93771. isReady(): boolean;
  93772. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  93773. /**
  93774. * Gets the code to inject in the vertex shader
  93775. * @param state current state of the node material building
  93776. * @returns the shader code
  93777. */
  93778. handleVertexSide(state: NodeMaterialBuildState): string;
  93779. /**
  93780. * Handles the inits for the fragment code path
  93781. * @param state node material build state
  93782. */
  93783. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  93784. /**
  93785. * Generates the reflection coords code for the fragment code path
  93786. * @param worldNormalVarName name of the world normal variable
  93787. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  93788. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  93789. * @returns the shader code
  93790. */
  93791. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  93792. /**
  93793. * Generates the reflection color code for the fragment code path
  93794. * @param lodVarName name of the lod variable
  93795. * @param swizzleLookupTexture swizzle to use for the final color variable
  93796. * @returns the shader code
  93797. */
  93798. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  93799. /**
  93800. * Generates the code corresponding to the connected output points
  93801. * @param state node material build state
  93802. * @param varName name of the variable to output
  93803. * @returns the shader code
  93804. */
  93805. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  93806. protected _buildBlock(state: NodeMaterialBuildState): this;
  93807. protected _dumpPropertiesCode(): string;
  93808. serialize(): any;
  93809. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  93810. }
  93811. }
  93812. declare module BABYLON {
  93813. /**
  93814. * Defines a connection point to be used for points with a custom object type
  93815. */
  93816. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  93817. private _blockType;
  93818. private _blockName;
  93819. private _nameForCheking?;
  93820. /**
  93821. * Creates a new connection point
  93822. * @param name defines the connection point name
  93823. * @param ownerBlock defines the block hosting this connection point
  93824. * @param direction defines the direction of the connection point
  93825. */
  93826. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  93827. /**
  93828. * Gets a number indicating if the current point can be connected to another point
  93829. * @param connectionPoint defines the other connection point
  93830. * @returns a number defining the compatibility state
  93831. */
  93832. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  93833. /**
  93834. * Creates a block suitable to be used as an input for this input point.
  93835. * If null is returned, a block based on the point type will be created.
  93836. * @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
  93837. */
  93838. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  93839. }
  93840. }
  93841. declare module BABYLON {
  93842. /**
  93843. * Enum defining the type of properties that can be edited in the property pages in the NME
  93844. */
  93845. export enum PropertyTypeForEdition {
  93846. /** property is a boolean */
  93847. Boolean = 0,
  93848. /** property is a float */
  93849. Float = 1,
  93850. /** property is a Vector2 */
  93851. Vector2 = 2,
  93852. /** property is a list of values */
  93853. List = 3
  93854. }
  93855. /**
  93856. * Interface that defines an option in a variable of type list
  93857. */
  93858. export interface IEditablePropertyListOption {
  93859. /** label of the option */
  93860. "label": string;
  93861. /** value of the option */
  93862. "value": number;
  93863. }
  93864. /**
  93865. * Interface that defines the options available for an editable property
  93866. */
  93867. export interface IEditablePropertyOption {
  93868. /** min value */
  93869. "min"?: number;
  93870. /** max value */
  93871. "max"?: number;
  93872. /** notifiers: indicates which actions to take when the property is changed */
  93873. "notifiers"?: {
  93874. /** the material should be rebuilt */
  93875. "rebuild"?: boolean;
  93876. /** the preview should be updated */
  93877. "update"?: boolean;
  93878. };
  93879. /** list of the options for a variable of type list */
  93880. "options"?: IEditablePropertyListOption[];
  93881. }
  93882. /**
  93883. * Interface that describes an editable property
  93884. */
  93885. export interface IPropertyDescriptionForEdition {
  93886. /** name of the property */
  93887. "propertyName": string;
  93888. /** display name of the property */
  93889. "displayName": string;
  93890. /** type of the property */
  93891. "type": PropertyTypeForEdition;
  93892. /** group of the property - all properties with the same group value will be displayed in a specific section */
  93893. "groupName": string;
  93894. /** options for the property */
  93895. "options": IEditablePropertyOption;
  93896. }
  93897. /**
  93898. * Decorator that flags a property in a node material block as being editable
  93899. */
  93900. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  93901. }
  93902. declare module BABYLON {
  93903. /**
  93904. * Block used to implement the refraction part of the sub surface module of the PBR material
  93905. */
  93906. export class RefractionBlock extends NodeMaterialBlock {
  93907. /** @hidden */
  93908. _define3DName: string;
  93909. /** @hidden */
  93910. _refractionMatrixName: string;
  93911. /** @hidden */
  93912. _defineLODRefractionAlpha: string;
  93913. /** @hidden */
  93914. _defineLinearSpecularRefraction: string;
  93915. /** @hidden */
  93916. _defineOppositeZ: string;
  93917. /** @hidden */
  93918. _cubeSamplerName: string;
  93919. /** @hidden */
  93920. _2DSamplerName: string;
  93921. /** @hidden */
  93922. _vRefractionMicrosurfaceInfosName: string;
  93923. /** @hidden */
  93924. _vRefractionInfosName: string;
  93925. private _scene;
  93926. /**
  93927. * The properties below are set by the main PBR block prior to calling methods of this class.
  93928. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  93929. * It's less burden on the user side in the editor part.
  93930. */
  93931. /** @hidden */
  93932. viewConnectionPoint: NodeMaterialConnectionPoint;
  93933. /** @hidden */
  93934. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  93935. /**
  93936. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  93937. * Materials half opaque for instance using refraction could benefit from this control.
  93938. */
  93939. linkRefractionWithTransparency: boolean;
  93940. /**
  93941. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  93942. */
  93943. invertRefractionY: boolean;
  93944. /**
  93945. * Gets or sets the texture associated with the node
  93946. */
  93947. texture: Nullable<BaseTexture>;
  93948. /**
  93949. * Create a new RefractionBlock
  93950. * @param name defines the block name
  93951. */
  93952. constructor(name: string);
  93953. /**
  93954. * Gets the current class name
  93955. * @returns the class name
  93956. */
  93957. getClassName(): string;
  93958. /**
  93959. * Gets the intensity input component
  93960. */
  93961. get intensity(): NodeMaterialConnectionPoint;
  93962. /**
  93963. * Gets the tint at distance input component
  93964. */
  93965. get tintAtDistance(): NodeMaterialConnectionPoint;
  93966. /**
  93967. * Gets the view input component
  93968. */
  93969. get view(): NodeMaterialConnectionPoint;
  93970. /**
  93971. * Gets the refraction object output component
  93972. */
  93973. get refraction(): NodeMaterialConnectionPoint;
  93974. /**
  93975. * Returns true if the block has a texture
  93976. */
  93977. get hasTexture(): boolean;
  93978. protected _getTexture(): Nullable<BaseTexture>;
  93979. autoConfigure(material: NodeMaterial): void;
  93980. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  93981. isReady(): boolean;
  93982. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  93983. /**
  93984. * Gets the main code of the block (fragment side)
  93985. * @param state current state of the node material building
  93986. * @returns the shader code
  93987. */
  93988. getCode(state: NodeMaterialBuildState): string;
  93989. protected _buildBlock(state: NodeMaterialBuildState): this;
  93990. protected _dumpPropertiesCode(): string;
  93991. serialize(): any;
  93992. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  93993. }
  93994. }
  93995. declare module BABYLON {
  93996. /**
  93997. * Base block used as input for post process
  93998. */
  93999. export class CurrentScreenBlock extends NodeMaterialBlock {
  94000. private _samplerName;
  94001. private _linearDefineName;
  94002. private _gammaDefineName;
  94003. private _mainUVName;
  94004. private _tempTextureRead;
  94005. /**
  94006. * Gets or sets the texture associated with the node
  94007. */
  94008. texture: Nullable<BaseTexture>;
  94009. /**
  94010. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  94011. */
  94012. convertToGammaSpace: boolean;
  94013. /**
  94014. * Gets or sets a boolean indicating if content needs to be converted to linear space
  94015. */
  94016. convertToLinearSpace: boolean;
  94017. /**
  94018. * Create a new CurrentScreenBlock
  94019. * @param name defines the block name
  94020. */
  94021. constructor(name: string);
  94022. /**
  94023. * Gets the current class name
  94024. * @returns the class name
  94025. */
  94026. getClassName(): string;
  94027. /**
  94028. * Gets the uv input component
  94029. */
  94030. get uv(): NodeMaterialConnectionPoint;
  94031. /**
  94032. * Gets the rgba output component
  94033. */
  94034. get rgba(): NodeMaterialConnectionPoint;
  94035. /**
  94036. * Gets the rgb output component
  94037. */
  94038. get rgb(): NodeMaterialConnectionPoint;
  94039. /**
  94040. * Gets the r output component
  94041. */
  94042. get r(): NodeMaterialConnectionPoint;
  94043. /**
  94044. * Gets the g output component
  94045. */
  94046. get g(): NodeMaterialConnectionPoint;
  94047. /**
  94048. * Gets the b output component
  94049. */
  94050. get b(): NodeMaterialConnectionPoint;
  94051. /**
  94052. * Gets the a output component
  94053. */
  94054. get a(): NodeMaterialConnectionPoint;
  94055. /**
  94056. * Initialize the block and prepare the context for build
  94057. * @param state defines the state that will be used for the build
  94058. */
  94059. initialize(state: NodeMaterialBuildState): void;
  94060. get target(): NodeMaterialBlockTargets;
  94061. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  94062. isReady(): boolean;
  94063. private _injectVertexCode;
  94064. private _writeTextureRead;
  94065. private _writeOutput;
  94066. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  94067. serialize(): any;
  94068. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94069. }
  94070. }
  94071. declare module BABYLON {
  94072. /**
  94073. * Base block used for the particle texture
  94074. */
  94075. export class ParticleTextureBlock extends NodeMaterialBlock {
  94076. private _samplerName;
  94077. private _linearDefineName;
  94078. private _gammaDefineName;
  94079. private _tempTextureRead;
  94080. /**
  94081. * Gets or sets the texture associated with the node
  94082. */
  94083. texture: Nullable<BaseTexture>;
  94084. /**
  94085. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  94086. */
  94087. convertToGammaSpace: boolean;
  94088. /**
  94089. * Gets or sets a boolean indicating if content needs to be converted to linear space
  94090. */
  94091. convertToLinearSpace: boolean;
  94092. /**
  94093. * Create a new ParticleTextureBlock
  94094. * @param name defines the block name
  94095. */
  94096. constructor(name: string);
  94097. /**
  94098. * Gets the current class name
  94099. * @returns the class name
  94100. */
  94101. getClassName(): string;
  94102. /**
  94103. * Gets the uv input component
  94104. */
  94105. get uv(): NodeMaterialConnectionPoint;
  94106. /**
  94107. * Gets the rgba output component
  94108. */
  94109. get rgba(): NodeMaterialConnectionPoint;
  94110. /**
  94111. * Gets the rgb output component
  94112. */
  94113. get rgb(): NodeMaterialConnectionPoint;
  94114. /**
  94115. * Gets the r output component
  94116. */
  94117. get r(): NodeMaterialConnectionPoint;
  94118. /**
  94119. * Gets the g output component
  94120. */
  94121. get g(): NodeMaterialConnectionPoint;
  94122. /**
  94123. * Gets the b output component
  94124. */
  94125. get b(): NodeMaterialConnectionPoint;
  94126. /**
  94127. * Gets the a output component
  94128. */
  94129. get a(): NodeMaterialConnectionPoint;
  94130. /**
  94131. * Initialize the block and prepare the context for build
  94132. * @param state defines the state that will be used for the build
  94133. */
  94134. initialize(state: NodeMaterialBuildState): void;
  94135. autoConfigure(material: NodeMaterial): void;
  94136. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  94137. isReady(): boolean;
  94138. private _writeOutput;
  94139. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  94140. serialize(): any;
  94141. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94142. }
  94143. }
  94144. declare module BABYLON {
  94145. /**
  94146. * Class used to store shared data between 2 NodeMaterialBuildState
  94147. */
  94148. export class NodeMaterialBuildStateSharedData {
  94149. /**
  94150. * Gets the list of emitted varyings
  94151. */
  94152. temps: string[];
  94153. /**
  94154. * Gets the list of emitted varyings
  94155. */
  94156. varyings: string[];
  94157. /**
  94158. * Gets the varying declaration string
  94159. */
  94160. varyingDeclaration: string;
  94161. /**
  94162. * Input blocks
  94163. */
  94164. inputBlocks: InputBlock[];
  94165. /**
  94166. * Input blocks
  94167. */
  94168. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  94169. /**
  94170. * Bindable blocks (Blocks that need to set data to the effect)
  94171. */
  94172. bindableBlocks: NodeMaterialBlock[];
  94173. /**
  94174. * List of blocks that can provide a compilation fallback
  94175. */
  94176. blocksWithFallbacks: NodeMaterialBlock[];
  94177. /**
  94178. * List of blocks that can provide a define update
  94179. */
  94180. blocksWithDefines: NodeMaterialBlock[];
  94181. /**
  94182. * List of blocks that can provide a repeatable content
  94183. */
  94184. repeatableContentBlocks: NodeMaterialBlock[];
  94185. /**
  94186. * List of blocks that can provide a dynamic list of uniforms
  94187. */
  94188. dynamicUniformBlocks: NodeMaterialBlock[];
  94189. /**
  94190. * List of blocks that can block the isReady function for the material
  94191. */
  94192. blockingBlocks: NodeMaterialBlock[];
  94193. /**
  94194. * Gets the list of animated inputs
  94195. */
  94196. animatedInputs: InputBlock[];
  94197. /**
  94198. * Build Id used to avoid multiple recompilations
  94199. */
  94200. buildId: number;
  94201. /** List of emitted variables */
  94202. variableNames: {
  94203. [key: string]: number;
  94204. };
  94205. /** List of emitted defines */
  94206. defineNames: {
  94207. [key: string]: number;
  94208. };
  94209. /** Should emit comments? */
  94210. emitComments: boolean;
  94211. /** Emit build activity */
  94212. verbose: boolean;
  94213. /** Gets or sets the hosting scene */
  94214. scene: Scene;
  94215. /**
  94216. * Gets the compilation hints emitted at compilation time
  94217. */
  94218. hints: {
  94219. needWorldViewMatrix: boolean;
  94220. needWorldViewProjectionMatrix: boolean;
  94221. needAlphaBlending: boolean;
  94222. needAlphaTesting: boolean;
  94223. };
  94224. /**
  94225. * List of compilation checks
  94226. */
  94227. checks: {
  94228. emitVertex: boolean;
  94229. emitFragment: boolean;
  94230. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  94231. };
  94232. /**
  94233. * Is vertex program allowed to be empty?
  94234. */
  94235. allowEmptyVertexProgram: boolean;
  94236. /** Creates a new shared data */
  94237. constructor();
  94238. /**
  94239. * Emits console errors and exceptions if there is a failing check
  94240. */
  94241. emitErrors(): void;
  94242. }
  94243. }
  94244. declare module BABYLON {
  94245. /**
  94246. * Class used to store node based material build state
  94247. */
  94248. export class NodeMaterialBuildState {
  94249. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  94250. supportUniformBuffers: boolean;
  94251. /**
  94252. * Gets the list of emitted attributes
  94253. */
  94254. attributes: string[];
  94255. /**
  94256. * Gets the list of emitted uniforms
  94257. */
  94258. uniforms: string[];
  94259. /**
  94260. * Gets the list of emitted constants
  94261. */
  94262. constants: string[];
  94263. /**
  94264. * Gets the list of emitted samplers
  94265. */
  94266. samplers: string[];
  94267. /**
  94268. * Gets the list of emitted functions
  94269. */
  94270. functions: {
  94271. [key: string]: string;
  94272. };
  94273. /**
  94274. * Gets the list of emitted extensions
  94275. */
  94276. extensions: {
  94277. [key: string]: string;
  94278. };
  94279. /**
  94280. * Gets the target of the compilation state
  94281. */
  94282. target: NodeMaterialBlockTargets;
  94283. /**
  94284. * Gets the list of emitted counters
  94285. */
  94286. counters: {
  94287. [key: string]: number;
  94288. };
  94289. /**
  94290. * Shared data between multiple NodeMaterialBuildState instances
  94291. */
  94292. sharedData: NodeMaterialBuildStateSharedData;
  94293. /** @hidden */
  94294. _vertexState: NodeMaterialBuildState;
  94295. /** @hidden */
  94296. _attributeDeclaration: string;
  94297. /** @hidden */
  94298. _uniformDeclaration: string;
  94299. /** @hidden */
  94300. _constantDeclaration: string;
  94301. /** @hidden */
  94302. _samplerDeclaration: string;
  94303. /** @hidden */
  94304. _varyingTransfer: string;
  94305. /** @hidden */
  94306. _injectAtEnd: string;
  94307. private _repeatableContentAnchorIndex;
  94308. /** @hidden */
  94309. _builtCompilationString: string;
  94310. /**
  94311. * Gets the emitted compilation strings
  94312. */
  94313. compilationString: string;
  94314. /**
  94315. * Finalize the compilation strings
  94316. * @param state defines the current compilation state
  94317. */
  94318. finalize(state: NodeMaterialBuildState): void;
  94319. /** @hidden */
  94320. get _repeatableContentAnchor(): string;
  94321. /** @hidden */
  94322. _getFreeVariableName(prefix: string): string;
  94323. /** @hidden */
  94324. _getFreeDefineName(prefix: string): string;
  94325. /** @hidden */
  94326. _excludeVariableName(name: string): void;
  94327. /** @hidden */
  94328. _emit2DSampler(name: string): void;
  94329. /** @hidden */
  94330. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  94331. /** @hidden */
  94332. _emitExtension(name: string, extension: string, define?: string): void;
  94333. /** @hidden */
  94334. _emitFunction(name: string, code: string, comments: string): void;
  94335. /** @hidden */
  94336. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  94337. replaceStrings?: {
  94338. search: RegExp;
  94339. replace: string;
  94340. }[];
  94341. repeatKey?: string;
  94342. }): string;
  94343. /** @hidden */
  94344. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  94345. repeatKey?: string;
  94346. removeAttributes?: boolean;
  94347. removeUniforms?: boolean;
  94348. removeVaryings?: boolean;
  94349. removeIfDef?: boolean;
  94350. replaceStrings?: {
  94351. search: RegExp;
  94352. replace: string;
  94353. }[];
  94354. }, storeKey?: string): void;
  94355. /** @hidden */
  94356. _registerTempVariable(name: string): boolean;
  94357. /** @hidden */
  94358. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  94359. /** @hidden */
  94360. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  94361. /** @hidden */
  94362. _emitFloat(value: number): string;
  94363. }
  94364. }
  94365. declare module BABYLON {
  94366. /**
  94367. * Helper class used to generate session unique ID
  94368. */
  94369. export class UniqueIdGenerator {
  94370. private static _UniqueIdCounter;
  94371. /**
  94372. * Gets an unique (relatively to the current scene) Id
  94373. */
  94374. static get UniqueId(): number;
  94375. }
  94376. }
  94377. declare module BABYLON {
  94378. /**
  94379. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  94380. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  94381. */
  94382. export class EffectFallbacks implements IEffectFallbacks {
  94383. private _defines;
  94384. private _currentRank;
  94385. private _maxRank;
  94386. private _mesh;
  94387. /**
  94388. * Removes the fallback from the bound mesh.
  94389. */
  94390. unBindMesh(): void;
  94391. /**
  94392. * Adds a fallback on the specified property.
  94393. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94394. * @param define The name of the define in the shader
  94395. */
  94396. addFallback(rank: number, define: string): void;
  94397. /**
  94398. * Sets the mesh to use CPU skinning when needing to fallback.
  94399. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94400. * @param mesh The mesh to use the fallbacks.
  94401. */
  94402. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  94403. /**
  94404. * Checks to see if more fallbacks are still availible.
  94405. */
  94406. get hasMoreFallbacks(): boolean;
  94407. /**
  94408. * Removes the defines that should be removed when falling back.
  94409. * @param currentDefines defines the current define statements for the shader.
  94410. * @param effect defines the current effect we try to compile
  94411. * @returns The resulting defines with defines of the current rank removed.
  94412. */
  94413. reduce(currentDefines: string, effect: Effect): string;
  94414. }
  94415. }
  94416. declare module BABYLON {
  94417. /**
  94418. * Defines a block that can be used inside a node based material
  94419. */
  94420. export class NodeMaterialBlock {
  94421. private _buildId;
  94422. private _buildTarget;
  94423. private _target;
  94424. private _isFinalMerger;
  94425. private _isInput;
  94426. private _name;
  94427. protected _isUnique: boolean;
  94428. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  94429. inputsAreExclusive: boolean;
  94430. /** @hidden */
  94431. _codeVariableName: string;
  94432. /** @hidden */
  94433. _inputs: NodeMaterialConnectionPoint[];
  94434. /** @hidden */
  94435. _outputs: NodeMaterialConnectionPoint[];
  94436. /** @hidden */
  94437. _preparationId: number;
  94438. /**
  94439. * Gets the name of the block
  94440. */
  94441. get name(): string;
  94442. /**
  94443. * Sets the name of the block. Will check if the name is valid.
  94444. */
  94445. set name(newName: string);
  94446. /**
  94447. * Gets or sets the unique id of the node
  94448. */
  94449. uniqueId: number;
  94450. /**
  94451. * Gets or sets the comments associated with this block
  94452. */
  94453. comments: string;
  94454. /**
  94455. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  94456. */
  94457. get isUnique(): boolean;
  94458. /**
  94459. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  94460. */
  94461. get isFinalMerger(): boolean;
  94462. /**
  94463. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  94464. */
  94465. get isInput(): boolean;
  94466. /**
  94467. * Gets or sets the build Id
  94468. */
  94469. get buildId(): number;
  94470. set buildId(value: number);
  94471. /**
  94472. * Gets or sets the target of the block
  94473. */
  94474. get target(): NodeMaterialBlockTargets;
  94475. set target(value: NodeMaterialBlockTargets);
  94476. /**
  94477. * Gets the list of input points
  94478. */
  94479. get inputs(): NodeMaterialConnectionPoint[];
  94480. /** Gets the list of output points */
  94481. get outputs(): NodeMaterialConnectionPoint[];
  94482. /**
  94483. * Find an input by its name
  94484. * @param name defines the name of the input to look for
  94485. * @returns the input or null if not found
  94486. */
  94487. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  94488. /**
  94489. * Find an output by its name
  94490. * @param name defines the name of the outputto look for
  94491. * @returns the output or null if not found
  94492. */
  94493. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  94494. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  94495. visibleInInspector: boolean;
  94496. /**
  94497. * Creates a new NodeMaterialBlock
  94498. * @param name defines the block name
  94499. * @param target defines the target of that block (Vertex by default)
  94500. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  94501. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  94502. */
  94503. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  94504. /**
  94505. * Initialize the block and prepare the context for build
  94506. * @param state defines the state that will be used for the build
  94507. */
  94508. initialize(state: NodeMaterialBuildState): void;
  94509. /**
  94510. * Bind data to effect. Will only be called for blocks with isBindable === true
  94511. * @param effect defines the effect to bind data to
  94512. * @param nodeMaterial defines the hosting NodeMaterial
  94513. * @param mesh defines the mesh that will be rendered
  94514. * @param subMesh defines the submesh that will be rendered
  94515. */
  94516. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  94517. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  94518. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  94519. protected _writeFloat(value: number): string;
  94520. /**
  94521. * Gets the current class name e.g. "NodeMaterialBlock"
  94522. * @returns the class name
  94523. */
  94524. getClassName(): string;
  94525. /**
  94526. * Register a new input. Must be called inside a block constructor
  94527. * @param name defines the connection point name
  94528. * @param type defines the connection point type
  94529. * @param isOptional defines a boolean indicating that this input can be omitted
  94530. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  94531. * @param point an already created connection point. If not provided, create a new one
  94532. * @returns the current block
  94533. */
  94534. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  94535. /**
  94536. * Register a new output. Must be called inside a block constructor
  94537. * @param name defines the connection point name
  94538. * @param type defines the connection point type
  94539. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  94540. * @param point an already created connection point. If not provided, create a new one
  94541. * @returns the current block
  94542. */
  94543. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  94544. /**
  94545. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  94546. * @param forOutput defines an optional connection point to check compatibility with
  94547. * @returns the first available input or null
  94548. */
  94549. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  94550. /**
  94551. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  94552. * @param forBlock defines an optional block to check compatibility with
  94553. * @returns the first available input or null
  94554. */
  94555. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  94556. /**
  94557. * Gets the sibling of the given output
  94558. * @param current defines the current output
  94559. * @returns the next output in the list or null
  94560. */
  94561. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  94562. /**
  94563. * Connect current block with another block
  94564. * @param other defines the block to connect with
  94565. * @param options define the various options to help pick the right connections
  94566. * @returns the current block
  94567. */
  94568. connectTo(other: NodeMaterialBlock, options?: {
  94569. input?: string;
  94570. output?: string;
  94571. outputSwizzle?: string;
  94572. }): this | undefined;
  94573. protected _buildBlock(state: NodeMaterialBuildState): void;
  94574. /**
  94575. * Add uniforms, samplers and uniform buffers at compilation time
  94576. * @param state defines the state to update
  94577. * @param nodeMaterial defines the node material requesting the update
  94578. * @param defines defines the material defines to update
  94579. * @param uniformBuffers defines the list of uniform buffer names
  94580. */
  94581. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  94582. /**
  94583. * Add potential fallbacks if shader compilation fails
  94584. * @param mesh defines the mesh to be rendered
  94585. * @param fallbacks defines the current prioritized list of fallbacks
  94586. */
  94587. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  94588. /**
  94589. * Initialize defines for shader compilation
  94590. * @param mesh defines the mesh to be rendered
  94591. * @param nodeMaterial defines the node material requesting the update
  94592. * @param defines defines the material defines to update
  94593. * @param useInstances specifies that instances should be used
  94594. */
  94595. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  94596. /**
  94597. * Update defines for shader compilation
  94598. * @param mesh defines the mesh to be rendered
  94599. * @param nodeMaterial defines the node material requesting the update
  94600. * @param defines defines the material defines to update
  94601. * @param useInstances specifies that instances should be used
  94602. * @param subMesh defines which submesh to render
  94603. */
  94604. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  94605. /**
  94606. * Lets the block try to connect some inputs automatically
  94607. * @param material defines the hosting NodeMaterial
  94608. */
  94609. autoConfigure(material: NodeMaterial): void;
  94610. /**
  94611. * Function called when a block is declared as repeatable content generator
  94612. * @param vertexShaderState defines the current compilation state for the vertex shader
  94613. * @param fragmentShaderState defines the current compilation state for the fragment shader
  94614. * @param mesh defines the mesh to be rendered
  94615. * @param defines defines the material defines to update
  94616. */
  94617. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  94618. /**
  94619. * Checks if the block is ready
  94620. * @param mesh defines the mesh to be rendered
  94621. * @param nodeMaterial defines the node material requesting the update
  94622. * @param defines defines the material defines to update
  94623. * @param useInstances specifies that instances should be used
  94624. * @returns true if the block is ready
  94625. */
  94626. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  94627. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  94628. private _processBuild;
  94629. /**
  94630. * Validates the new name for the block node.
  94631. * @param newName the new name to be given to the node.
  94632. * @returns false if the name is a reserve word, else true.
  94633. */
  94634. validateBlockName(newName: string): boolean;
  94635. /**
  94636. * Compile the current node and generate the shader code
  94637. * @param state defines the current compilation state (uniforms, samplers, current string)
  94638. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  94639. * @returns true if already built
  94640. */
  94641. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  94642. protected _inputRename(name: string): string;
  94643. protected _outputRename(name: string): string;
  94644. protected _dumpPropertiesCode(): string;
  94645. /** @hidden */
  94646. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  94647. /** @hidden */
  94648. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  94649. /**
  94650. * Clone the current block to a new identical block
  94651. * @param scene defines the hosting scene
  94652. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94653. * @returns a copy of the current block
  94654. */
  94655. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  94656. /**
  94657. * Serializes this block in a JSON representation
  94658. * @returns the serialized block object
  94659. */
  94660. serialize(): any;
  94661. /** @hidden */
  94662. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94663. private _deserializePortDisplayNamesAndExposedOnFrame;
  94664. /**
  94665. * Release resources
  94666. */
  94667. dispose(): void;
  94668. }
  94669. }
  94670. declare module BABYLON {
  94671. /**
  94672. * Base class of materials working in push mode in babylon JS
  94673. * @hidden
  94674. */
  94675. export class PushMaterial extends Material {
  94676. protected _activeEffect: Effect;
  94677. protected _normalMatrix: Matrix;
  94678. constructor(name: string, scene: Scene);
  94679. getEffect(): Effect;
  94680. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94681. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  94682. /**
  94683. * Binds the given world matrix to the active effect
  94684. *
  94685. * @param world the matrix to bind
  94686. */
  94687. bindOnlyWorldMatrix(world: Matrix): void;
  94688. /**
  94689. * Binds the given normal matrix to the active effect
  94690. *
  94691. * @param normalMatrix the matrix to bind
  94692. */
  94693. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94694. bind(world: Matrix, mesh?: Mesh): void;
  94695. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94696. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94697. }
  94698. }
  94699. declare module BABYLON {
  94700. /**
  94701. * Root class for all node material optimizers
  94702. */
  94703. export class NodeMaterialOptimizer {
  94704. /**
  94705. * Function used to optimize a NodeMaterial graph
  94706. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  94707. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  94708. */
  94709. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  94710. }
  94711. }
  94712. declare module BABYLON {
  94713. /**
  94714. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  94715. */
  94716. export class TransformBlock extends NodeMaterialBlock {
  94717. /**
  94718. * Defines the value to use to complement W value to transform it to a Vector4
  94719. */
  94720. complementW: number;
  94721. /**
  94722. * Defines the value to use to complement z value to transform it to a Vector4
  94723. */
  94724. complementZ: number;
  94725. /**
  94726. * Creates a new TransformBlock
  94727. * @param name defines the block name
  94728. */
  94729. constructor(name: string);
  94730. /**
  94731. * Gets the current class name
  94732. * @returns the class name
  94733. */
  94734. getClassName(): string;
  94735. /**
  94736. * Gets the vector input
  94737. */
  94738. get vector(): NodeMaterialConnectionPoint;
  94739. /**
  94740. * Gets the output component
  94741. */
  94742. get output(): NodeMaterialConnectionPoint;
  94743. /**
  94744. * Gets the xyz output component
  94745. */
  94746. get xyz(): NodeMaterialConnectionPoint;
  94747. /**
  94748. * Gets the matrix transform input
  94749. */
  94750. get transform(): NodeMaterialConnectionPoint;
  94751. protected _buildBlock(state: NodeMaterialBuildState): this;
  94752. /**
  94753. * Update defines for shader compilation
  94754. * @param mesh defines the mesh to be rendered
  94755. * @param nodeMaterial defines the node material requesting the update
  94756. * @param defines defines the material defines to update
  94757. * @param useInstances specifies that instances should be used
  94758. * @param subMesh defines which submesh to render
  94759. */
  94760. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  94761. serialize(): any;
  94762. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94763. protected _dumpPropertiesCode(): string;
  94764. }
  94765. }
  94766. declare module BABYLON {
  94767. /**
  94768. * Block used to output the vertex position
  94769. */
  94770. export class VertexOutputBlock extends NodeMaterialBlock {
  94771. /**
  94772. * Creates a new VertexOutputBlock
  94773. * @param name defines the block name
  94774. */
  94775. constructor(name: string);
  94776. /**
  94777. * Gets the current class name
  94778. * @returns the class name
  94779. */
  94780. getClassName(): string;
  94781. /**
  94782. * Gets the vector input component
  94783. */
  94784. get vector(): NodeMaterialConnectionPoint;
  94785. protected _buildBlock(state: NodeMaterialBuildState): this;
  94786. }
  94787. }
  94788. declare module BABYLON {
  94789. /**
  94790. * Block used to output the final color
  94791. */
  94792. export class FragmentOutputBlock extends NodeMaterialBlock {
  94793. /**
  94794. * Create a new FragmentOutputBlock
  94795. * @param name defines the block name
  94796. */
  94797. constructor(name: string);
  94798. /**
  94799. * Gets the current class name
  94800. * @returns the class name
  94801. */
  94802. getClassName(): string;
  94803. /**
  94804. * Gets the rgba input component
  94805. */
  94806. get rgba(): NodeMaterialConnectionPoint;
  94807. /**
  94808. * Gets the rgb input component
  94809. */
  94810. get rgb(): NodeMaterialConnectionPoint;
  94811. /**
  94812. * Gets the a input component
  94813. */
  94814. get a(): NodeMaterialConnectionPoint;
  94815. protected _buildBlock(state: NodeMaterialBuildState): this;
  94816. }
  94817. }
  94818. declare module BABYLON {
  94819. /**
  94820. * Block used for the particle ramp gradient section
  94821. */
  94822. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  94823. /**
  94824. * Create a new ParticleRampGradientBlock
  94825. * @param name defines the block name
  94826. */
  94827. constructor(name: string);
  94828. /**
  94829. * Gets the current class name
  94830. * @returns the class name
  94831. */
  94832. getClassName(): string;
  94833. /**
  94834. * Gets the color input component
  94835. */
  94836. get color(): NodeMaterialConnectionPoint;
  94837. /**
  94838. * Gets the rampColor output component
  94839. */
  94840. get rampColor(): NodeMaterialConnectionPoint;
  94841. /**
  94842. * Initialize the block and prepare the context for build
  94843. * @param state defines the state that will be used for the build
  94844. */
  94845. initialize(state: NodeMaterialBuildState): void;
  94846. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  94847. }
  94848. }
  94849. declare module BABYLON {
  94850. /**
  94851. * Block used for the particle blend multiply section
  94852. */
  94853. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  94854. /**
  94855. * Create a new ParticleBlendMultiplyBlock
  94856. * @param name defines the block name
  94857. */
  94858. constructor(name: string);
  94859. /**
  94860. * Gets the current class name
  94861. * @returns the class name
  94862. */
  94863. getClassName(): string;
  94864. /**
  94865. * Gets the color input component
  94866. */
  94867. get color(): NodeMaterialConnectionPoint;
  94868. /**
  94869. * Gets the alphaTexture input component
  94870. */
  94871. get alphaTexture(): NodeMaterialConnectionPoint;
  94872. /**
  94873. * Gets the alphaColor input component
  94874. */
  94875. get alphaColor(): NodeMaterialConnectionPoint;
  94876. /**
  94877. * Gets the blendColor output component
  94878. */
  94879. get blendColor(): NodeMaterialConnectionPoint;
  94880. /**
  94881. * Initialize the block and prepare the context for build
  94882. * @param state defines the state that will be used for the build
  94883. */
  94884. initialize(state: NodeMaterialBuildState): void;
  94885. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  94886. }
  94887. }
  94888. declare module BABYLON {
  94889. /**
  94890. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  94891. */
  94892. export class VectorMergerBlock extends NodeMaterialBlock {
  94893. /**
  94894. * Create a new VectorMergerBlock
  94895. * @param name defines the block name
  94896. */
  94897. constructor(name: string);
  94898. /**
  94899. * Gets the current class name
  94900. * @returns the class name
  94901. */
  94902. getClassName(): string;
  94903. /**
  94904. * Gets the xyz component (input)
  94905. */
  94906. get xyzIn(): NodeMaterialConnectionPoint;
  94907. /**
  94908. * Gets the xy component (input)
  94909. */
  94910. get xyIn(): NodeMaterialConnectionPoint;
  94911. /**
  94912. * Gets the x component (input)
  94913. */
  94914. get x(): NodeMaterialConnectionPoint;
  94915. /**
  94916. * Gets the y component (input)
  94917. */
  94918. get y(): NodeMaterialConnectionPoint;
  94919. /**
  94920. * Gets the z component (input)
  94921. */
  94922. get z(): NodeMaterialConnectionPoint;
  94923. /**
  94924. * Gets the w component (input)
  94925. */
  94926. get w(): NodeMaterialConnectionPoint;
  94927. /**
  94928. * Gets the xyzw component (output)
  94929. */
  94930. get xyzw(): NodeMaterialConnectionPoint;
  94931. /**
  94932. * Gets the xyz component (output)
  94933. */
  94934. get xyzOut(): NodeMaterialConnectionPoint;
  94935. /**
  94936. * Gets the xy component (output)
  94937. */
  94938. get xyOut(): NodeMaterialConnectionPoint;
  94939. /**
  94940. * Gets the xy component (output)
  94941. * @deprecated Please use xyOut instead.
  94942. */
  94943. get xy(): NodeMaterialConnectionPoint;
  94944. /**
  94945. * Gets the xyz component (output)
  94946. * @deprecated Please use xyzOut instead.
  94947. */
  94948. get xyz(): NodeMaterialConnectionPoint;
  94949. protected _buildBlock(state: NodeMaterialBuildState): this;
  94950. }
  94951. }
  94952. declare module BABYLON {
  94953. /**
  94954. * Block used to remap a float from a range to a new one
  94955. */
  94956. export class RemapBlock extends NodeMaterialBlock {
  94957. /**
  94958. * Gets or sets the source range
  94959. */
  94960. sourceRange: Vector2;
  94961. /**
  94962. * Gets or sets the target range
  94963. */
  94964. targetRange: Vector2;
  94965. /**
  94966. * Creates a new RemapBlock
  94967. * @param name defines the block name
  94968. */
  94969. constructor(name: string);
  94970. /**
  94971. * Gets the current class name
  94972. * @returns the class name
  94973. */
  94974. getClassName(): string;
  94975. /**
  94976. * Gets the input component
  94977. */
  94978. get input(): NodeMaterialConnectionPoint;
  94979. /**
  94980. * Gets the source min input component
  94981. */
  94982. get sourceMin(): NodeMaterialConnectionPoint;
  94983. /**
  94984. * Gets the source max input component
  94985. */
  94986. get sourceMax(): NodeMaterialConnectionPoint;
  94987. /**
  94988. * Gets the target min input component
  94989. */
  94990. get targetMin(): NodeMaterialConnectionPoint;
  94991. /**
  94992. * Gets the target max input component
  94993. */
  94994. get targetMax(): NodeMaterialConnectionPoint;
  94995. /**
  94996. * Gets the output component
  94997. */
  94998. get output(): NodeMaterialConnectionPoint;
  94999. protected _buildBlock(state: NodeMaterialBuildState): this;
  95000. protected _dumpPropertiesCode(): string;
  95001. serialize(): any;
  95002. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  95003. }
  95004. }
  95005. declare module BABYLON {
  95006. /**
  95007. * Block used to multiply 2 values
  95008. */
  95009. export class MultiplyBlock extends NodeMaterialBlock {
  95010. /**
  95011. * Creates a new MultiplyBlock
  95012. * @param name defines the block name
  95013. */
  95014. constructor(name: string);
  95015. /**
  95016. * Gets the current class name
  95017. * @returns the class name
  95018. */
  95019. getClassName(): string;
  95020. /**
  95021. * Gets the left operand input component
  95022. */
  95023. get left(): NodeMaterialConnectionPoint;
  95024. /**
  95025. * Gets the right operand input component
  95026. */
  95027. get right(): NodeMaterialConnectionPoint;
  95028. /**
  95029. * Gets the output component
  95030. */
  95031. get output(): NodeMaterialConnectionPoint;
  95032. protected _buildBlock(state: NodeMaterialBuildState): this;
  95033. }
  95034. }
  95035. declare module BABYLON {
  95036. /** Interface used by value gradients (color, factor, ...) */
  95037. export interface IValueGradient {
  95038. /**
  95039. * Gets or sets the gradient value (between 0 and 1)
  95040. */
  95041. gradient: number;
  95042. }
  95043. /** Class used to store color4 gradient */
  95044. export class ColorGradient implements IValueGradient {
  95045. /**
  95046. * Gets or sets the gradient value (between 0 and 1)
  95047. */
  95048. gradient: number;
  95049. /**
  95050. * Gets or sets first associated color
  95051. */
  95052. color1: Color4;
  95053. /**
  95054. * Gets or sets second associated color
  95055. */
  95056. color2?: Color4 | undefined;
  95057. /**
  95058. * Creates a new color4 gradient
  95059. * @param gradient gets or sets the gradient value (between 0 and 1)
  95060. * @param color1 gets or sets first associated color
  95061. * @param color2 gets or sets first second color
  95062. */
  95063. constructor(
  95064. /**
  95065. * Gets or sets the gradient value (between 0 and 1)
  95066. */
  95067. gradient: number,
  95068. /**
  95069. * Gets or sets first associated color
  95070. */
  95071. color1: Color4,
  95072. /**
  95073. * Gets or sets second associated color
  95074. */
  95075. color2?: Color4 | undefined);
  95076. /**
  95077. * Will get a color picked randomly between color1 and color2.
  95078. * If color2 is undefined then color1 will be used
  95079. * @param result defines the target Color4 to store the result in
  95080. */
  95081. getColorToRef(result: Color4): void;
  95082. }
  95083. /** Class used to store color 3 gradient */
  95084. export class Color3Gradient implements IValueGradient {
  95085. /**
  95086. * Gets or sets the gradient value (between 0 and 1)
  95087. */
  95088. gradient: number;
  95089. /**
  95090. * Gets or sets the associated color
  95091. */
  95092. color: Color3;
  95093. /**
  95094. * Creates a new color3 gradient
  95095. * @param gradient gets or sets the gradient value (between 0 and 1)
  95096. * @param color gets or sets associated color
  95097. */
  95098. constructor(
  95099. /**
  95100. * Gets or sets the gradient value (between 0 and 1)
  95101. */
  95102. gradient: number,
  95103. /**
  95104. * Gets or sets the associated color
  95105. */
  95106. color: Color3);
  95107. }
  95108. /** Class used to store factor gradient */
  95109. export class FactorGradient implements IValueGradient {
  95110. /**
  95111. * Gets or sets the gradient value (between 0 and 1)
  95112. */
  95113. gradient: number;
  95114. /**
  95115. * Gets or sets first associated factor
  95116. */
  95117. factor1: number;
  95118. /**
  95119. * Gets or sets second associated factor
  95120. */
  95121. factor2?: number | undefined;
  95122. /**
  95123. * Creates a new factor gradient
  95124. * @param gradient gets or sets the gradient value (between 0 and 1)
  95125. * @param factor1 gets or sets first associated factor
  95126. * @param factor2 gets or sets second associated factor
  95127. */
  95128. constructor(
  95129. /**
  95130. * Gets or sets the gradient value (between 0 and 1)
  95131. */
  95132. gradient: number,
  95133. /**
  95134. * Gets or sets first associated factor
  95135. */
  95136. factor1: number,
  95137. /**
  95138. * Gets or sets second associated factor
  95139. */
  95140. factor2?: number | undefined);
  95141. /**
  95142. * Will get a number picked randomly between factor1 and factor2.
  95143. * If factor2 is undefined then factor1 will be used
  95144. * @returns the picked number
  95145. */
  95146. getFactor(): number;
  95147. }
  95148. /**
  95149. * Helper used to simplify some generic gradient tasks
  95150. */
  95151. export class GradientHelper {
  95152. /**
  95153. * Gets the current gradient from an array of IValueGradient
  95154. * @param ratio defines the current ratio to get
  95155. * @param gradients defines the array of IValueGradient
  95156. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  95157. */
  95158. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  95159. }
  95160. }
  95161. declare module BABYLON {
  95162. interface ThinEngine {
  95163. /**
  95164. * Creates a raw texture
  95165. * @param data defines the data to store in the texture
  95166. * @param width defines the width of the texture
  95167. * @param height defines the height of the texture
  95168. * @param format defines the format of the data
  95169. * @param generateMipMaps defines if the engine should generate the mip levels
  95170. * @param invertY defines if data must be stored with Y axis inverted
  95171. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  95172. * @param compression defines the compression used (null by default)
  95173. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95174. * @returns the raw texture inside an InternalTexture
  95175. */
  95176. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  95177. /**
  95178. * Update a raw texture
  95179. * @param texture defines the texture to update
  95180. * @param data defines the data to store in the texture
  95181. * @param format defines the format of the data
  95182. * @param invertY defines if data must be stored with Y axis inverted
  95183. */
  95184. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  95185. /**
  95186. * Update a raw texture
  95187. * @param texture defines the texture to update
  95188. * @param data defines the data to store in the texture
  95189. * @param format defines the format of the data
  95190. * @param invertY defines if data must be stored with Y axis inverted
  95191. * @param compression defines the compression used (null by default)
  95192. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95193. */
  95194. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  95195. /**
  95196. * Creates a new raw cube texture
  95197. * @param data defines the array of data to use to create each face
  95198. * @param size defines the size of the textures
  95199. * @param format defines the format of the data
  95200. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  95201. * @param generateMipMaps defines if the engine should generate the mip levels
  95202. * @param invertY defines if data must be stored with Y axis inverted
  95203. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95204. * @param compression defines the compression used (null by default)
  95205. * @returns the cube texture as an InternalTexture
  95206. */
  95207. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  95208. /**
  95209. * Update a raw cube texture
  95210. * @param texture defines the texture to udpdate
  95211. * @param data defines the data to store
  95212. * @param format defines the data format
  95213. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95214. * @param invertY defines if data must be stored with Y axis inverted
  95215. */
  95216. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  95217. /**
  95218. * Update a raw cube texture
  95219. * @param texture defines the texture to udpdate
  95220. * @param data defines the data to store
  95221. * @param format defines the data format
  95222. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95223. * @param invertY defines if data must be stored with Y axis inverted
  95224. * @param compression defines the compression used (null by default)
  95225. */
  95226. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  95227. /**
  95228. * Update a raw cube texture
  95229. * @param texture defines the texture to udpdate
  95230. * @param data defines the data to store
  95231. * @param format defines the data format
  95232. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95233. * @param invertY defines if data must be stored with Y axis inverted
  95234. * @param compression defines the compression used (null by default)
  95235. * @param level defines which level of the texture to update
  95236. */
  95237. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  95238. /**
  95239. * Creates a new raw cube texture from a specified url
  95240. * @param url defines the url where the data is located
  95241. * @param scene defines the current scene
  95242. * @param size defines the size of the textures
  95243. * @param format defines the format of the data
  95244. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  95245. * @param noMipmap defines if the engine should avoid generating the mip levels
  95246. * @param callback defines a callback used to extract texture data from loaded data
  95247. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  95248. * @param onLoad defines a callback called when texture is loaded
  95249. * @param onError defines a callback called if there is an error
  95250. * @returns the cube texture as an InternalTexture
  95251. */
  95252. 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;
  95253. /**
  95254. * Creates a new raw cube texture from a specified url
  95255. * @param url defines the url where the data is located
  95256. * @param scene defines the current scene
  95257. * @param size defines the size of the textures
  95258. * @param format defines the format of the data
  95259. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  95260. * @param noMipmap defines if the engine should avoid generating the mip levels
  95261. * @param callback defines a callback used to extract texture data from loaded data
  95262. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  95263. * @param onLoad defines a callback called when texture is loaded
  95264. * @param onError defines a callback called if there is an error
  95265. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95266. * @param invertY defines if data must be stored with Y axis inverted
  95267. * @returns the cube texture as an InternalTexture
  95268. */
  95269. 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;
  95270. /**
  95271. * Creates a new raw 3D texture
  95272. * @param data defines the data used to create the texture
  95273. * @param width defines the width of the texture
  95274. * @param height defines the height of the texture
  95275. * @param depth defines the depth of the texture
  95276. * @param format defines the format of the texture
  95277. * @param generateMipMaps defines if the engine must generate mip levels
  95278. * @param invertY defines if data must be stored with Y axis inverted
  95279. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95280. * @param compression defines the compressed used (can be null)
  95281. * @param textureType defines the compressed used (can be null)
  95282. * @returns a new raw 3D texture (stored in an InternalTexture)
  95283. */
  95284. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  95285. /**
  95286. * Update a raw 3D texture
  95287. * @param texture defines the texture to update
  95288. * @param data defines the data to store
  95289. * @param format defines the data format
  95290. * @param invertY defines if data must be stored with Y axis inverted
  95291. */
  95292. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  95293. /**
  95294. * Update a raw 3D texture
  95295. * @param texture defines the texture to update
  95296. * @param data defines the data to store
  95297. * @param format defines the data format
  95298. * @param invertY defines if data must be stored with Y axis inverted
  95299. * @param compression defines the used compression (can be null)
  95300. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  95301. */
  95302. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  95303. /**
  95304. * Creates a new raw 2D array texture
  95305. * @param data defines the data used to create the texture
  95306. * @param width defines the width of the texture
  95307. * @param height defines the height of the texture
  95308. * @param depth defines the number of layers of the texture
  95309. * @param format defines the format of the texture
  95310. * @param generateMipMaps defines if the engine must generate mip levels
  95311. * @param invertY defines if data must be stored with Y axis inverted
  95312. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95313. * @param compression defines the compressed used (can be null)
  95314. * @param textureType defines the compressed used (can be null)
  95315. * @returns a new raw 2D array texture (stored in an InternalTexture)
  95316. */
  95317. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  95318. /**
  95319. * Update a raw 2D array texture
  95320. * @param texture defines the texture to update
  95321. * @param data defines the data to store
  95322. * @param format defines the data format
  95323. * @param invertY defines if data must be stored with Y axis inverted
  95324. */
  95325. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  95326. /**
  95327. * Update a raw 2D array texture
  95328. * @param texture defines the texture to update
  95329. * @param data defines the data to store
  95330. * @param format defines the data format
  95331. * @param invertY defines if data must be stored with Y axis inverted
  95332. * @param compression defines the used compression (can be null)
  95333. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  95334. */
  95335. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  95336. }
  95337. }
  95338. declare module BABYLON {
  95339. /**
  95340. * Raw texture can help creating a texture directly from an array of data.
  95341. * This can be super useful if you either get the data from an uncompressed source or
  95342. * if you wish to create your texture pixel by pixel.
  95343. */
  95344. export class RawTexture extends Texture {
  95345. /**
  95346. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  95347. */
  95348. format: number;
  95349. /**
  95350. * Instantiates a new RawTexture.
  95351. * Raw texture can help creating a texture directly from an array of data.
  95352. * This can be super useful if you either get the data from an uncompressed source or
  95353. * if you wish to create your texture pixel by pixel.
  95354. * @param data define the array of data to use to create the texture
  95355. * @param width define the width of the texture
  95356. * @param height define the height of the texture
  95357. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  95358. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95359. * @param generateMipMaps define whether mip maps should be generated or not
  95360. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95361. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95362. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95363. */
  95364. constructor(data: ArrayBufferView, width: number, height: number,
  95365. /**
  95366. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  95367. */
  95368. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  95369. /**
  95370. * Updates the texture underlying data.
  95371. * @param data Define the new data of the texture
  95372. */
  95373. update(data: ArrayBufferView): void;
  95374. /**
  95375. * Creates a luminance texture from some data.
  95376. * @param data Define the texture data
  95377. * @param width Define the width of the texture
  95378. * @param height Define the height of the texture
  95379. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95380. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95381. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95382. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95383. * @returns the luminance texture
  95384. */
  95385. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  95386. /**
  95387. * Creates a luminance alpha texture from some data.
  95388. * @param data Define the texture data
  95389. * @param width Define the width of the texture
  95390. * @param height Define the height of the texture
  95391. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95392. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95393. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95394. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95395. * @returns the luminance alpha texture
  95396. */
  95397. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  95398. /**
  95399. * Creates an alpha texture from some data.
  95400. * @param data Define the texture data
  95401. * @param width Define the width of the texture
  95402. * @param height Define the height of the texture
  95403. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95404. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95405. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95406. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95407. * @returns the alpha texture
  95408. */
  95409. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  95410. /**
  95411. * Creates a RGB texture from some data.
  95412. * @param data Define the texture data
  95413. * @param width Define the width of the texture
  95414. * @param height Define the height of the texture
  95415. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95416. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95417. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95418. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95419. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95420. * @returns the RGB alpha texture
  95421. */
  95422. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  95423. /**
  95424. * Creates a RGBA texture from some data.
  95425. * @param data Define the texture data
  95426. * @param width Define the width of the texture
  95427. * @param height Define the height of the texture
  95428. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95429. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95430. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95431. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95432. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95433. * @returns the RGBA texture
  95434. */
  95435. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  95436. /**
  95437. * Creates a R texture from some data.
  95438. * @param data Define the texture data
  95439. * @param width Define the width of the texture
  95440. * @param height Define the height of the texture
  95441. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95442. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95443. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95444. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95445. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95446. * @returns the R texture
  95447. */
  95448. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  95449. }
  95450. }
  95451. declare module BABYLON {
  95452. interface ThinEngine {
  95453. /**
  95454. * Update a dynamic index buffer
  95455. * @param indexBuffer defines the target index buffer
  95456. * @param indices defines the data to update
  95457. * @param offset defines the offset in the target index buffer where update should start
  95458. */
  95459. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  95460. /**
  95461. * Updates a dynamic vertex buffer.
  95462. * @param vertexBuffer the vertex buffer to update
  95463. * @param data the data used to update the vertex buffer
  95464. * @param byteOffset the byte offset of the data
  95465. * @param byteLength the byte length of the data
  95466. */
  95467. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  95468. }
  95469. }
  95470. declare module BABYLON {
  95471. interface AbstractScene {
  95472. /**
  95473. * The list of procedural textures added to the scene
  95474. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  95475. */
  95476. proceduralTextures: Array<ProceduralTexture>;
  95477. }
  95478. /**
  95479. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  95480. * in a given scene.
  95481. */
  95482. export class ProceduralTextureSceneComponent implements ISceneComponent {
  95483. /**
  95484. * The component name helpfull to identify the component in the list of scene components.
  95485. */
  95486. readonly name: string;
  95487. /**
  95488. * The scene the component belongs to.
  95489. */
  95490. scene: Scene;
  95491. /**
  95492. * Creates a new instance of the component for the given scene
  95493. * @param scene Defines the scene to register the component in
  95494. */
  95495. constructor(scene: Scene);
  95496. /**
  95497. * Registers the component in a given scene
  95498. */
  95499. register(): void;
  95500. /**
  95501. * Rebuilds the elements related to this component in case of
  95502. * context lost for instance.
  95503. */
  95504. rebuild(): void;
  95505. /**
  95506. * Disposes the component and the associated ressources.
  95507. */
  95508. dispose(): void;
  95509. private _beforeClear;
  95510. }
  95511. }
  95512. declare module BABYLON {
  95513. interface ThinEngine {
  95514. /**
  95515. * Creates a new render target cube texture
  95516. * @param size defines the size of the texture
  95517. * @param options defines the options used to create the texture
  95518. * @returns a new render target cube texture stored in an InternalTexture
  95519. */
  95520. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  95521. }
  95522. }
  95523. declare module BABYLON {
  95524. /** @hidden */
  95525. export var proceduralVertexShader: {
  95526. name: string;
  95527. shader: string;
  95528. };
  95529. }
  95530. declare module BABYLON {
  95531. /**
  95532. * 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.
  95533. * This is the base class of any Procedural texture and contains most of the shareable code.
  95534. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  95535. */
  95536. export class ProceduralTexture extends Texture {
  95537. /**
  95538. * Define if the texture is enabled or not (disabled texture will not render)
  95539. */
  95540. isEnabled: boolean;
  95541. /**
  95542. * Define if the texture must be cleared before rendering (default is true)
  95543. */
  95544. autoClear: boolean;
  95545. /**
  95546. * Callback called when the texture is generated
  95547. */
  95548. onGenerated: () => void;
  95549. /**
  95550. * Event raised when the texture is generated
  95551. */
  95552. onGeneratedObservable: Observable<ProceduralTexture>;
  95553. /**
  95554. * Event raised before the texture is generated
  95555. */
  95556. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  95557. /**
  95558. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  95559. */
  95560. nodeMaterialSource: Nullable<NodeMaterial>;
  95561. /** @hidden */
  95562. _generateMipMaps: boolean;
  95563. /** @hidden **/
  95564. _effect: Effect;
  95565. /** @hidden */
  95566. _textures: {
  95567. [key: string]: Texture;
  95568. };
  95569. /** @hidden */
  95570. protected _fallbackTexture: Nullable<Texture>;
  95571. private _size;
  95572. private _currentRefreshId;
  95573. private _frameId;
  95574. private _refreshRate;
  95575. private _vertexBuffers;
  95576. private _indexBuffer;
  95577. private _uniforms;
  95578. private _samplers;
  95579. private _fragment;
  95580. private _floats;
  95581. private _ints;
  95582. private _floatsArrays;
  95583. private _colors3;
  95584. private _colors4;
  95585. private _vectors2;
  95586. private _vectors3;
  95587. private _matrices;
  95588. private _fallbackTextureUsed;
  95589. private _fullEngine;
  95590. private _cachedDefines;
  95591. private _contentUpdateId;
  95592. private _contentData;
  95593. /**
  95594. * Instantiates a new procedural texture.
  95595. * 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.
  95596. * This is the base class of any Procedural texture and contains most of the shareable code.
  95597. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  95598. * @param name Define the name of the texture
  95599. * @param size Define the size of the texture to create
  95600. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  95601. * @param scene Define the scene the texture belongs to
  95602. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  95603. * @param generateMipMaps Define if the texture should creates mip maps or not
  95604. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  95605. * @param textureType The FBO internal texture type
  95606. */
  95607. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  95608. /**
  95609. * The effect that is created when initializing the post process.
  95610. * @returns The created effect corresponding the the postprocess.
  95611. */
  95612. getEffect(): Effect;
  95613. /**
  95614. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  95615. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  95616. */
  95617. getContent(): Nullable<ArrayBufferView>;
  95618. private _createIndexBuffer;
  95619. /** @hidden */
  95620. _rebuild(): void;
  95621. /**
  95622. * Resets the texture in order to recreate its associated resources.
  95623. * This can be called in case of context loss
  95624. */
  95625. reset(): void;
  95626. protected _getDefines(): string;
  95627. /**
  95628. * Is the texture ready to be used ? (rendered at least once)
  95629. * @returns true if ready, otherwise, false.
  95630. */
  95631. isReady(): boolean;
  95632. /**
  95633. * Resets the refresh counter of the texture and start bak from scratch.
  95634. * Could be useful to regenerate the texture if it is setup to render only once.
  95635. */
  95636. resetRefreshCounter(): void;
  95637. /**
  95638. * Set the fragment shader to use in order to render the texture.
  95639. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  95640. */
  95641. setFragment(fragment: any): void;
  95642. /**
  95643. * Define the refresh rate of the texture or the rendering frequency.
  95644. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  95645. */
  95646. get refreshRate(): number;
  95647. set refreshRate(value: number);
  95648. /** @hidden */
  95649. _shouldRender(): boolean;
  95650. /**
  95651. * Get the size the texture is rendering at.
  95652. * @returns the size (on cube texture it is always squared)
  95653. */
  95654. getRenderSize(): RenderTargetTextureSize;
  95655. /**
  95656. * Resize the texture to new value.
  95657. * @param size Define the new size the texture should have
  95658. * @param generateMipMaps Define whether the new texture should create mip maps
  95659. */
  95660. resize(size: number, generateMipMaps: boolean): void;
  95661. private _checkUniform;
  95662. /**
  95663. * Set a texture in the shader program used to render.
  95664. * @param name Define the name of the uniform samplers as defined in the shader
  95665. * @param texture Define the texture to bind to this sampler
  95666. * @return the texture itself allowing "fluent" like uniform updates
  95667. */
  95668. setTexture(name: string, texture: Texture): ProceduralTexture;
  95669. /**
  95670. * Set a float in the shader.
  95671. * @param name Define the name of the uniform as defined in the shader
  95672. * @param value Define the value to give to the uniform
  95673. * @return the texture itself allowing "fluent" like uniform updates
  95674. */
  95675. setFloat(name: string, value: number): ProceduralTexture;
  95676. /**
  95677. * Set a int in the shader.
  95678. * @param name Define the name of the uniform as defined in the shader
  95679. * @param value Define the value to give to the uniform
  95680. * @return the texture itself allowing "fluent" like uniform updates
  95681. */
  95682. setInt(name: string, value: number): ProceduralTexture;
  95683. /**
  95684. * Set an array of floats in the shader.
  95685. * @param name Define the name of the uniform as defined in the shader
  95686. * @param value Define the value to give to the uniform
  95687. * @return the texture itself allowing "fluent" like uniform updates
  95688. */
  95689. setFloats(name: string, value: number[]): ProceduralTexture;
  95690. /**
  95691. * Set a vec3 in the shader from a Color3.
  95692. * @param name Define the name of the uniform as defined in the shader
  95693. * @param value Define the value to give to the uniform
  95694. * @return the texture itself allowing "fluent" like uniform updates
  95695. */
  95696. setColor3(name: string, value: Color3): ProceduralTexture;
  95697. /**
  95698. * Set a vec4 in the shader from a Color4.
  95699. * @param name Define the name of the uniform as defined in the shader
  95700. * @param value Define the value to give to the uniform
  95701. * @return the texture itself allowing "fluent" like uniform updates
  95702. */
  95703. setColor4(name: string, value: Color4): ProceduralTexture;
  95704. /**
  95705. * Set a vec2 in the shader from a Vector2.
  95706. * @param name Define the name of the uniform as defined in the shader
  95707. * @param value Define the value to give to the uniform
  95708. * @return the texture itself allowing "fluent" like uniform updates
  95709. */
  95710. setVector2(name: string, value: Vector2): ProceduralTexture;
  95711. /**
  95712. * Set a vec3 in the shader from a Vector3.
  95713. * @param name Define the name of the uniform as defined in the shader
  95714. * @param value Define the value to give to the uniform
  95715. * @return the texture itself allowing "fluent" like uniform updates
  95716. */
  95717. setVector3(name: string, value: Vector3): ProceduralTexture;
  95718. /**
  95719. * Set a mat4 in the shader from a MAtrix.
  95720. * @param name Define the name of the uniform as defined in the shader
  95721. * @param value Define the value to give to the uniform
  95722. * @return the texture itself allowing "fluent" like uniform updates
  95723. */
  95724. setMatrix(name: string, value: Matrix): ProceduralTexture;
  95725. /**
  95726. * Render the texture to its associated render target.
  95727. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  95728. */
  95729. render(useCameraPostProcess?: boolean): void;
  95730. /**
  95731. * Clone the texture.
  95732. * @returns the cloned texture
  95733. */
  95734. clone(): ProceduralTexture;
  95735. /**
  95736. * Dispose the texture and release its asoociated resources.
  95737. */
  95738. dispose(): void;
  95739. }
  95740. }
  95741. declare module BABYLON {
  95742. /**
  95743. * This represents the base class for particle system in Babylon.
  95744. * 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.
  95745. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  95746. * @example https://doc.babylonjs.com/babylon101/particles
  95747. */
  95748. export class BaseParticleSystem {
  95749. /**
  95750. * Source color is added to the destination color without alpha affecting the result
  95751. */
  95752. static BLENDMODE_ONEONE: number;
  95753. /**
  95754. * Blend current color and particle color using particle’s alpha
  95755. */
  95756. static BLENDMODE_STANDARD: number;
  95757. /**
  95758. * Add current color and particle color multiplied by particle’s alpha
  95759. */
  95760. static BLENDMODE_ADD: number;
  95761. /**
  95762. * Multiply current color with particle color
  95763. */
  95764. static BLENDMODE_MULTIPLY: number;
  95765. /**
  95766. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  95767. */
  95768. static BLENDMODE_MULTIPLYADD: number;
  95769. /**
  95770. * List of animations used by the particle system.
  95771. */
  95772. animations: Animation[];
  95773. /**
  95774. * Gets or sets the unique id of the particle system
  95775. */
  95776. uniqueId: number;
  95777. /**
  95778. * The id of the Particle system.
  95779. */
  95780. id: string;
  95781. /**
  95782. * The friendly name of the Particle system.
  95783. */
  95784. name: string;
  95785. /**
  95786. * Snippet ID if the particle system was created from the snippet server
  95787. */
  95788. snippetId: string;
  95789. /**
  95790. * The rendering group used by the Particle system to chose when to render.
  95791. */
  95792. renderingGroupId: number;
  95793. /**
  95794. * The emitter represents the Mesh or position we are attaching the particle system to.
  95795. */
  95796. emitter: Nullable<AbstractMesh | Vector3>;
  95797. /**
  95798. * The maximum number of particles to emit per frame
  95799. */
  95800. emitRate: number;
  95801. /**
  95802. * If you want to launch only a few particles at once, that can be done, as well.
  95803. */
  95804. manualEmitCount: number;
  95805. /**
  95806. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  95807. */
  95808. updateSpeed: number;
  95809. /**
  95810. * The amount of time the particle system is running (depends of the overall update speed).
  95811. */
  95812. targetStopDuration: number;
  95813. /**
  95814. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  95815. */
  95816. disposeOnStop: boolean;
  95817. /**
  95818. * Minimum power of emitting particles.
  95819. */
  95820. minEmitPower: number;
  95821. /**
  95822. * Maximum power of emitting particles.
  95823. */
  95824. maxEmitPower: number;
  95825. /**
  95826. * Minimum life time of emitting particles.
  95827. */
  95828. minLifeTime: number;
  95829. /**
  95830. * Maximum life time of emitting particles.
  95831. */
  95832. maxLifeTime: number;
  95833. /**
  95834. * Minimum Size of emitting particles.
  95835. */
  95836. minSize: number;
  95837. /**
  95838. * Maximum Size of emitting particles.
  95839. */
  95840. maxSize: number;
  95841. /**
  95842. * Minimum scale of emitting particles on X axis.
  95843. */
  95844. minScaleX: number;
  95845. /**
  95846. * Maximum scale of emitting particles on X axis.
  95847. */
  95848. maxScaleX: number;
  95849. /**
  95850. * Minimum scale of emitting particles on Y axis.
  95851. */
  95852. minScaleY: number;
  95853. /**
  95854. * Maximum scale of emitting particles on Y axis.
  95855. */
  95856. maxScaleY: number;
  95857. /**
  95858. * Gets or sets the minimal initial rotation in radians.
  95859. */
  95860. minInitialRotation: number;
  95861. /**
  95862. * Gets or sets the maximal initial rotation in radians.
  95863. */
  95864. maxInitialRotation: number;
  95865. /**
  95866. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  95867. */
  95868. minAngularSpeed: number;
  95869. /**
  95870. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  95871. */
  95872. maxAngularSpeed: number;
  95873. /**
  95874. * The texture used to render each particle. (this can be a spritesheet)
  95875. */
  95876. particleTexture: Nullable<BaseTexture>;
  95877. /**
  95878. * The layer mask we are rendering the particles through.
  95879. */
  95880. layerMask: number;
  95881. /**
  95882. * This can help using your own shader to render the particle system.
  95883. * The according effect will be created
  95884. */
  95885. customShader: any;
  95886. /**
  95887. * By default particle system starts as soon as they are created. This prevents the
  95888. * automatic start to happen and let you decide when to start emitting particles.
  95889. */
  95890. preventAutoStart: boolean;
  95891. private _noiseTexture;
  95892. /**
  95893. * Gets or sets a texture used to add random noise to particle positions
  95894. */
  95895. get noiseTexture(): Nullable<ProceduralTexture>;
  95896. set noiseTexture(value: Nullable<ProceduralTexture>);
  95897. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  95898. noiseStrength: Vector3;
  95899. /**
  95900. * Callback triggered when the particle animation is ending.
  95901. */
  95902. onAnimationEnd: Nullable<() => void>;
  95903. /**
  95904. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  95905. */
  95906. blendMode: number;
  95907. /**
  95908. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  95909. * to override the particles.
  95910. */
  95911. forceDepthWrite: boolean;
  95912. /** 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 */
  95913. preWarmCycles: number;
  95914. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  95915. preWarmStepOffset: number;
  95916. /**
  95917. * 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)
  95918. */
  95919. spriteCellChangeSpeed: number;
  95920. /**
  95921. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  95922. */
  95923. startSpriteCellID: number;
  95924. /**
  95925. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  95926. */
  95927. endSpriteCellID: number;
  95928. /**
  95929. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  95930. */
  95931. spriteCellWidth: number;
  95932. /**
  95933. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  95934. */
  95935. spriteCellHeight: number;
  95936. /**
  95937. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  95938. */
  95939. spriteRandomStartCell: boolean;
  95940. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  95941. translationPivot: Vector2;
  95942. /** @hidden */
  95943. protected _isAnimationSheetEnabled: boolean;
  95944. /**
  95945. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  95946. */
  95947. beginAnimationOnStart: boolean;
  95948. /**
  95949. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  95950. */
  95951. beginAnimationFrom: number;
  95952. /**
  95953. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  95954. */
  95955. beginAnimationTo: number;
  95956. /**
  95957. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  95958. */
  95959. beginAnimationLoop: boolean;
  95960. /**
  95961. * Gets or sets a world offset applied to all particles
  95962. */
  95963. worldOffset: Vector3;
  95964. /**
  95965. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  95966. */
  95967. get isAnimationSheetEnabled(): boolean;
  95968. set isAnimationSheetEnabled(value: boolean);
  95969. /**
  95970. * Get hosting scene
  95971. * @returns the scene
  95972. */
  95973. getScene(): Nullable<Scene>;
  95974. /**
  95975. * You can use gravity if you want to give an orientation to your particles.
  95976. */
  95977. gravity: Vector3;
  95978. protected _colorGradients: Nullable<Array<ColorGradient>>;
  95979. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  95980. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  95981. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  95982. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  95983. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  95984. protected _dragGradients: Nullable<Array<FactorGradient>>;
  95985. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  95986. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  95987. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  95988. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  95989. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  95990. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  95991. /**
  95992. * Defines the delay in milliseconds before starting the system (0 by default)
  95993. */
  95994. startDelay: number;
  95995. /**
  95996. * Gets the current list of drag gradients.
  95997. * You must use addDragGradient and removeDragGradient to udpate this list
  95998. * @returns the list of drag gradients
  95999. */
  96000. getDragGradients(): Nullable<Array<FactorGradient>>;
  96001. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  96002. limitVelocityDamping: number;
  96003. /**
  96004. * Gets the current list of limit velocity gradients.
  96005. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  96006. * @returns the list of limit velocity gradients
  96007. */
  96008. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  96009. /**
  96010. * Gets the current list of color gradients.
  96011. * You must use addColorGradient and removeColorGradient to udpate this list
  96012. * @returns the list of color gradients
  96013. */
  96014. getColorGradients(): Nullable<Array<ColorGradient>>;
  96015. /**
  96016. * Gets the current list of size gradients.
  96017. * You must use addSizeGradient and removeSizeGradient to udpate this list
  96018. * @returns the list of size gradients
  96019. */
  96020. getSizeGradients(): Nullable<Array<FactorGradient>>;
  96021. /**
  96022. * Gets the current list of color remap gradients.
  96023. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  96024. * @returns the list of color remap gradients
  96025. */
  96026. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  96027. /**
  96028. * Gets the current list of alpha remap gradients.
  96029. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  96030. * @returns the list of alpha remap gradients
  96031. */
  96032. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  96033. /**
  96034. * Gets the current list of life time gradients.
  96035. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  96036. * @returns the list of life time gradients
  96037. */
  96038. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  96039. /**
  96040. * Gets the current list of angular speed gradients.
  96041. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  96042. * @returns the list of angular speed gradients
  96043. */
  96044. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  96045. /**
  96046. * Gets the current list of velocity gradients.
  96047. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  96048. * @returns the list of velocity gradients
  96049. */
  96050. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  96051. /**
  96052. * Gets the current list of start size gradients.
  96053. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  96054. * @returns the list of start size gradients
  96055. */
  96056. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  96057. /**
  96058. * Gets the current list of emit rate gradients.
  96059. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  96060. * @returns the list of emit rate gradients
  96061. */
  96062. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  96063. /**
  96064. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  96065. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96066. */
  96067. get direction1(): Vector3;
  96068. set direction1(value: Vector3);
  96069. /**
  96070. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  96071. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96072. */
  96073. get direction2(): Vector3;
  96074. set direction2(value: Vector3);
  96075. /**
  96076. * 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.
  96077. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96078. */
  96079. get minEmitBox(): Vector3;
  96080. set minEmitBox(value: Vector3);
  96081. /**
  96082. * 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.
  96083. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96084. */
  96085. get maxEmitBox(): Vector3;
  96086. set maxEmitBox(value: Vector3);
  96087. /**
  96088. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  96089. */
  96090. color1: Color4;
  96091. /**
  96092. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  96093. */
  96094. color2: Color4;
  96095. /**
  96096. * Color the particle will have at the end of its lifetime
  96097. */
  96098. colorDead: Color4;
  96099. /**
  96100. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  96101. */
  96102. textureMask: Color4;
  96103. /**
  96104. * The particle emitter type defines the emitter used by the particle system.
  96105. * It can be for example box, sphere, or cone...
  96106. */
  96107. particleEmitterType: IParticleEmitterType;
  96108. /** @hidden */
  96109. _isSubEmitter: boolean;
  96110. /**
  96111. * Gets or sets the billboard mode to use when isBillboardBased = true.
  96112. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  96113. */
  96114. billboardMode: number;
  96115. protected _isBillboardBased: boolean;
  96116. /**
  96117. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  96118. */
  96119. get isBillboardBased(): boolean;
  96120. set isBillboardBased(value: boolean);
  96121. /**
  96122. * The scene the particle system belongs to.
  96123. */
  96124. protected _scene: Nullable<Scene>;
  96125. /**
  96126. * The engine the particle system belongs to.
  96127. */
  96128. protected _engine: ThinEngine;
  96129. /**
  96130. * Local cache of defines for image processing.
  96131. */
  96132. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  96133. /**
  96134. * Default configuration related to image processing available in the standard Material.
  96135. */
  96136. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  96137. /**
  96138. * Gets the image processing configuration used either in this material.
  96139. */
  96140. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  96141. /**
  96142. * Sets the Default image processing configuration used either in the this material.
  96143. *
  96144. * If sets to null, the scene one is in use.
  96145. */
  96146. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  96147. /**
  96148. * Attaches a new image processing configuration to the Standard Material.
  96149. * @param configuration
  96150. */
  96151. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  96152. /** @hidden */
  96153. protected _reset(): void;
  96154. /** @hidden */
  96155. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  96156. /**
  96157. * Instantiates a particle system.
  96158. * 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.
  96159. * @param name The name of the particle system
  96160. */
  96161. constructor(name: string);
  96162. /**
  96163. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  96164. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  96165. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  96166. * @returns the emitter
  96167. */
  96168. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  96169. /**
  96170. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  96171. * @param radius The radius of the hemisphere to emit from
  96172. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  96173. * @returns the emitter
  96174. */
  96175. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  96176. /**
  96177. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  96178. * @param radius The radius of the sphere to emit from
  96179. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  96180. * @returns the emitter
  96181. */
  96182. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  96183. /**
  96184. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  96185. * @param radius The radius of the sphere to emit from
  96186. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  96187. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  96188. * @returns the emitter
  96189. */
  96190. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  96191. /**
  96192. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  96193. * @param radius The radius of the emission cylinder
  96194. * @param height The height of the emission cylinder
  96195. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  96196. * @param directionRandomizer How much to randomize the particle direction [0-1]
  96197. * @returns the emitter
  96198. */
  96199. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  96200. /**
  96201. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  96202. * @param radius The radius of the cylinder to emit from
  96203. * @param height The height of the emission cylinder
  96204. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  96205. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  96206. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  96207. * @returns the emitter
  96208. */
  96209. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  96210. /**
  96211. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  96212. * @param radius The radius of the cone to emit from
  96213. * @param angle The base angle of the cone
  96214. * @returns the emitter
  96215. */
  96216. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  96217. /**
  96218. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  96219. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  96220. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  96221. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  96222. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  96223. * @returns the emitter
  96224. */
  96225. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  96226. }
  96227. }
  96228. declare module BABYLON {
  96229. /**
  96230. * Type of sub emitter
  96231. */
  96232. export enum SubEmitterType {
  96233. /**
  96234. * Attached to the particle over it's lifetime
  96235. */
  96236. ATTACHED = 0,
  96237. /**
  96238. * Created when the particle dies
  96239. */
  96240. END = 1
  96241. }
  96242. /**
  96243. * Sub emitter class used to emit particles from an existing particle
  96244. */
  96245. export class SubEmitter {
  96246. /**
  96247. * the particle system to be used by the sub emitter
  96248. */
  96249. particleSystem: ParticleSystem;
  96250. /**
  96251. * Type of the submitter (Default: END)
  96252. */
  96253. type: SubEmitterType;
  96254. /**
  96255. * 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)
  96256. * Note: This only is supported when using an emitter of type Mesh
  96257. */
  96258. inheritDirection: boolean;
  96259. /**
  96260. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  96261. */
  96262. inheritedVelocityAmount: number;
  96263. /**
  96264. * Creates a sub emitter
  96265. * @param particleSystem the particle system to be used by the sub emitter
  96266. */
  96267. constructor(
  96268. /**
  96269. * the particle system to be used by the sub emitter
  96270. */
  96271. particleSystem: ParticleSystem);
  96272. /**
  96273. * Clones the sub emitter
  96274. * @returns the cloned sub emitter
  96275. */
  96276. clone(): SubEmitter;
  96277. /**
  96278. * Serialize current object to a JSON object
  96279. * @returns the serialized object
  96280. */
  96281. serialize(): any;
  96282. /** @hidden */
  96283. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  96284. /**
  96285. * Creates a new SubEmitter from a serialized JSON version
  96286. * @param serializationObject defines the JSON object to read from
  96287. * @param sceneOrEngine defines the hosting scene or the hosting engine
  96288. * @param rootUrl defines the rootUrl for data loading
  96289. * @returns a new SubEmitter
  96290. */
  96291. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  96292. /** Release associated resources */
  96293. dispose(): void;
  96294. }
  96295. }
  96296. declare module BABYLON {
  96297. /** @hidden */
  96298. export var clipPlaneFragmentDeclaration: {
  96299. name: string;
  96300. shader: string;
  96301. };
  96302. }
  96303. declare module BABYLON {
  96304. /** @hidden */
  96305. export var imageProcessingDeclaration: {
  96306. name: string;
  96307. shader: string;
  96308. };
  96309. }
  96310. declare module BABYLON {
  96311. /** @hidden */
  96312. export var imageProcessingFunctions: {
  96313. name: string;
  96314. shader: string;
  96315. };
  96316. }
  96317. declare module BABYLON {
  96318. /** @hidden */
  96319. export var clipPlaneFragment: {
  96320. name: string;
  96321. shader: string;
  96322. };
  96323. }
  96324. declare module BABYLON {
  96325. /** @hidden */
  96326. export var particlesPixelShader: {
  96327. name: string;
  96328. shader: string;
  96329. };
  96330. }
  96331. declare module BABYLON {
  96332. /** @hidden */
  96333. export var clipPlaneVertexDeclaration: {
  96334. name: string;
  96335. shader: string;
  96336. };
  96337. }
  96338. declare module BABYLON {
  96339. /** @hidden */
  96340. export var clipPlaneVertex: {
  96341. name: string;
  96342. shader: string;
  96343. };
  96344. }
  96345. declare module BABYLON {
  96346. /** @hidden */
  96347. export var particlesVertexShader: {
  96348. name: string;
  96349. shader: string;
  96350. };
  96351. }
  96352. declare module BABYLON {
  96353. /**
  96354. * Interface used to define entities containing multiple clip planes
  96355. */
  96356. export interface IClipPlanesHolder {
  96357. /**
  96358. * Gets or sets the active clipplane 1
  96359. */
  96360. clipPlane: Nullable<Plane>;
  96361. /**
  96362. * Gets or sets the active clipplane 2
  96363. */
  96364. clipPlane2: Nullable<Plane>;
  96365. /**
  96366. * Gets or sets the active clipplane 3
  96367. */
  96368. clipPlane3: Nullable<Plane>;
  96369. /**
  96370. * Gets or sets the active clipplane 4
  96371. */
  96372. clipPlane4: Nullable<Plane>;
  96373. /**
  96374. * Gets or sets the active clipplane 5
  96375. */
  96376. clipPlane5: Nullable<Plane>;
  96377. /**
  96378. * Gets or sets the active clipplane 6
  96379. */
  96380. clipPlane6: Nullable<Plane>;
  96381. }
  96382. }
  96383. declare module BABYLON {
  96384. /**
  96385. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  96386. *
  96387. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  96388. *
  96389. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  96390. */
  96391. export class ThinMaterialHelper {
  96392. /**
  96393. * Binds the clip plane information from the holder to the effect.
  96394. * @param effect The effect we are binding the data to
  96395. * @param holder The entity containing the clip plane information
  96396. */
  96397. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  96398. }
  96399. }
  96400. declare module BABYLON {
  96401. interface ThinEngine {
  96402. /**
  96403. * Sets alpha constants used by some alpha blending modes
  96404. * @param r defines the red component
  96405. * @param g defines the green component
  96406. * @param b defines the blue component
  96407. * @param a defines the alpha component
  96408. */
  96409. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  96410. /**
  96411. * Sets the current alpha mode
  96412. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  96413. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  96414. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96415. */
  96416. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  96417. /**
  96418. * Gets the current alpha mode
  96419. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96420. * @returns the current alpha mode
  96421. */
  96422. getAlphaMode(): number;
  96423. /**
  96424. * Sets the current alpha equation
  96425. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  96426. */
  96427. setAlphaEquation(equation: number): void;
  96428. /**
  96429. * Gets the current alpha equation.
  96430. * @returns the current alpha equation
  96431. */
  96432. getAlphaEquation(): number;
  96433. }
  96434. }
  96435. declare module BABYLON {
  96436. /**
  96437. * This represents a particle system in Babylon.
  96438. * 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.
  96439. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  96440. * @example https://doc.babylonjs.com/babylon101/particles
  96441. */
  96442. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  96443. /**
  96444. * Billboard mode will only apply to Y axis
  96445. */
  96446. static readonly BILLBOARDMODE_Y: number;
  96447. /**
  96448. * Billboard mode will apply to all axes
  96449. */
  96450. static readonly BILLBOARDMODE_ALL: number;
  96451. /**
  96452. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  96453. */
  96454. static readonly BILLBOARDMODE_STRETCHED: number;
  96455. /**
  96456. * This function can be defined to provide custom update for active particles.
  96457. * This function will be called instead of regular update (age, position, color, etc.).
  96458. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  96459. */
  96460. updateFunction: (particles: Particle[]) => void;
  96461. private _emitterWorldMatrix;
  96462. /**
  96463. * This function can be defined to specify initial direction for every new particle.
  96464. * It by default use the emitterType defined function
  96465. */
  96466. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  96467. /**
  96468. * This function can be defined to specify initial position for every new particle.
  96469. * It by default use the emitterType defined function
  96470. */
  96471. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  96472. /**
  96473. * @hidden
  96474. */
  96475. _inheritedVelocityOffset: Vector3;
  96476. /**
  96477. * An event triggered when the system is disposed
  96478. */
  96479. onDisposeObservable: Observable<IParticleSystem>;
  96480. /**
  96481. * An event triggered when the system is stopped
  96482. */
  96483. onStoppedObservable: Observable<IParticleSystem>;
  96484. private _onDisposeObserver;
  96485. /**
  96486. * Sets a callback that will be triggered when the system is disposed
  96487. */
  96488. set onDispose(callback: () => void);
  96489. private _particles;
  96490. private _epsilon;
  96491. private _capacity;
  96492. private _stockParticles;
  96493. private _newPartsExcess;
  96494. private _vertexData;
  96495. private _vertexBuffer;
  96496. private _vertexBuffers;
  96497. private _spriteBuffer;
  96498. private _indexBuffer;
  96499. private _effect;
  96500. private _customEffect;
  96501. private _cachedDefines;
  96502. private _scaledColorStep;
  96503. private _colorDiff;
  96504. private _scaledDirection;
  96505. private _scaledGravity;
  96506. private _currentRenderId;
  96507. private _alive;
  96508. private _useInstancing;
  96509. private _vertexArrayObject;
  96510. private _started;
  96511. private _stopped;
  96512. private _actualFrame;
  96513. private _scaledUpdateSpeed;
  96514. private _vertexBufferSize;
  96515. /** @hidden */
  96516. _currentEmitRateGradient: Nullable<FactorGradient>;
  96517. /** @hidden */
  96518. _currentEmitRate1: number;
  96519. /** @hidden */
  96520. _currentEmitRate2: number;
  96521. /** @hidden */
  96522. _currentStartSizeGradient: Nullable<FactorGradient>;
  96523. /** @hidden */
  96524. _currentStartSize1: number;
  96525. /** @hidden */
  96526. _currentStartSize2: number;
  96527. private readonly _rawTextureWidth;
  96528. private _rampGradientsTexture;
  96529. private _useRampGradients;
  96530. /** Gets or sets a matrix to use to compute projection */
  96531. defaultProjectionMatrix: Matrix;
  96532. /** Gets or sets a matrix to use to compute view */
  96533. defaultViewMatrix: Matrix;
  96534. /** Gets or sets a boolean indicating that ramp gradients must be used
  96535. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  96536. */
  96537. get useRampGradients(): boolean;
  96538. set useRampGradients(value: boolean);
  96539. /**
  96540. * 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.
  96541. * 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: [])
  96542. */
  96543. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  96544. private _subEmitters;
  96545. /**
  96546. * @hidden
  96547. * If the particle systems emitter should be disposed when the particle system is disposed
  96548. */
  96549. _disposeEmitterOnDispose: boolean;
  96550. /**
  96551. * The current active Sub-systems, this property is used by the root particle system only.
  96552. */
  96553. activeSubSystems: Array<ParticleSystem>;
  96554. /**
  96555. * Specifies if the particles are updated in emitter local space or world space
  96556. */
  96557. isLocal: boolean;
  96558. private _rootParticleSystem;
  96559. /**
  96560. * Gets the current list of active particles
  96561. */
  96562. get particles(): Particle[];
  96563. /**
  96564. * Gets the number of particles active at the same time.
  96565. * @returns The number of active particles.
  96566. */
  96567. getActiveCount(): number;
  96568. /**
  96569. * Returns the string "ParticleSystem"
  96570. * @returns a string containing the class name
  96571. */
  96572. getClassName(): string;
  96573. /**
  96574. * Gets a boolean indicating that the system is stopping
  96575. * @returns true if the system is currently stopping
  96576. */
  96577. isStopping(): boolean;
  96578. /**
  96579. * Gets the custom effect used to render the particles
  96580. * @param blendMode Blend mode for which the effect should be retrieved
  96581. * @returns The effect
  96582. */
  96583. getCustomEffect(blendMode?: number): Nullable<Effect>;
  96584. /**
  96585. * Sets the custom effect used to render the particles
  96586. * @param effect The effect to set
  96587. * @param blendMode Blend mode for which the effect should be set
  96588. */
  96589. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  96590. /** @hidden */
  96591. private _onBeforeDrawParticlesObservable;
  96592. /**
  96593. * Observable that will be called just before the particles are drawn
  96594. */
  96595. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  96596. /**
  96597. * Gets the name of the particle vertex shader
  96598. */
  96599. get vertexShaderName(): string;
  96600. /**
  96601. * Instantiates a particle system.
  96602. * 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.
  96603. * @param name The name of the particle system
  96604. * @param capacity The max number of particles alive at the same time
  96605. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  96606. * @param customEffect a custom effect used to change the way particles are rendered by default
  96607. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  96608. * @param epsilon Offset used to render the particles
  96609. */
  96610. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  96611. private _addFactorGradient;
  96612. private _removeFactorGradient;
  96613. /**
  96614. * Adds a new life time gradient
  96615. * @param gradient defines the gradient to use (between 0 and 1)
  96616. * @param factor defines the life time factor to affect to the specified gradient
  96617. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96618. * @returns the current particle system
  96619. */
  96620. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96621. /**
  96622. * Remove a specific life time gradient
  96623. * @param gradient defines the gradient to remove
  96624. * @returns the current particle system
  96625. */
  96626. removeLifeTimeGradient(gradient: number): IParticleSystem;
  96627. /**
  96628. * Adds a new size gradient
  96629. * @param gradient defines the gradient to use (between 0 and 1)
  96630. * @param factor defines the size factor to affect to the specified gradient
  96631. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96632. * @returns the current particle system
  96633. */
  96634. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96635. /**
  96636. * Remove a specific size gradient
  96637. * @param gradient defines the gradient to remove
  96638. * @returns the current particle system
  96639. */
  96640. removeSizeGradient(gradient: number): IParticleSystem;
  96641. /**
  96642. * Adds a new color remap gradient
  96643. * @param gradient defines the gradient to use (between 0 and 1)
  96644. * @param min defines the color remap minimal range
  96645. * @param max defines the color remap maximal range
  96646. * @returns the current particle system
  96647. */
  96648. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  96649. /**
  96650. * Remove a specific color remap gradient
  96651. * @param gradient defines the gradient to remove
  96652. * @returns the current particle system
  96653. */
  96654. removeColorRemapGradient(gradient: number): IParticleSystem;
  96655. /**
  96656. * Adds a new alpha remap gradient
  96657. * @param gradient defines the gradient to use (between 0 and 1)
  96658. * @param min defines the alpha remap minimal range
  96659. * @param max defines the alpha remap maximal range
  96660. * @returns the current particle system
  96661. */
  96662. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  96663. /**
  96664. * Remove a specific alpha remap gradient
  96665. * @param gradient defines the gradient to remove
  96666. * @returns the current particle system
  96667. */
  96668. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  96669. /**
  96670. * Adds a new angular speed gradient
  96671. * @param gradient defines the gradient to use (between 0 and 1)
  96672. * @param factor defines the angular speed to affect to the specified gradient
  96673. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96674. * @returns the current particle system
  96675. */
  96676. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96677. /**
  96678. * Remove a specific angular speed gradient
  96679. * @param gradient defines the gradient to remove
  96680. * @returns the current particle system
  96681. */
  96682. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  96683. /**
  96684. * Adds a new velocity gradient
  96685. * @param gradient defines the gradient to use (between 0 and 1)
  96686. * @param factor defines the velocity to affect to the specified gradient
  96687. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96688. * @returns the current particle system
  96689. */
  96690. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96691. /**
  96692. * Remove a specific velocity gradient
  96693. * @param gradient defines the gradient to remove
  96694. * @returns the current particle system
  96695. */
  96696. removeVelocityGradient(gradient: number): IParticleSystem;
  96697. /**
  96698. * Adds a new limit velocity gradient
  96699. * @param gradient defines the gradient to use (between 0 and 1)
  96700. * @param factor defines the limit velocity value to affect to the specified gradient
  96701. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96702. * @returns the current particle system
  96703. */
  96704. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96705. /**
  96706. * Remove a specific limit velocity gradient
  96707. * @param gradient defines the gradient to remove
  96708. * @returns the current particle system
  96709. */
  96710. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  96711. /**
  96712. * Adds a new drag gradient
  96713. * @param gradient defines the gradient to use (between 0 and 1)
  96714. * @param factor defines the drag value to affect to the specified gradient
  96715. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96716. * @returns the current particle system
  96717. */
  96718. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96719. /**
  96720. * Remove a specific drag gradient
  96721. * @param gradient defines the gradient to remove
  96722. * @returns the current particle system
  96723. */
  96724. removeDragGradient(gradient: number): IParticleSystem;
  96725. /**
  96726. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  96727. * @param gradient defines the gradient to use (between 0 and 1)
  96728. * @param factor defines the emit rate value to affect to the specified gradient
  96729. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96730. * @returns the current particle system
  96731. */
  96732. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96733. /**
  96734. * Remove a specific emit rate gradient
  96735. * @param gradient defines the gradient to remove
  96736. * @returns the current particle system
  96737. */
  96738. removeEmitRateGradient(gradient: number): IParticleSystem;
  96739. /**
  96740. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  96741. * @param gradient defines the gradient to use (between 0 and 1)
  96742. * @param factor defines the start size value to affect to the specified gradient
  96743. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96744. * @returns the current particle system
  96745. */
  96746. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96747. /**
  96748. * Remove a specific start size gradient
  96749. * @param gradient defines the gradient to remove
  96750. * @returns the current particle system
  96751. */
  96752. removeStartSizeGradient(gradient: number): IParticleSystem;
  96753. private _createRampGradientTexture;
  96754. /**
  96755. * Gets the current list of ramp gradients.
  96756. * You must use addRampGradient and removeRampGradient to udpate this list
  96757. * @returns the list of ramp gradients
  96758. */
  96759. getRampGradients(): Nullable<Array<Color3Gradient>>;
  96760. /** Force the system to rebuild all gradients that need to be resync */
  96761. forceRefreshGradients(): void;
  96762. private _syncRampGradientTexture;
  96763. /**
  96764. * Adds a new ramp gradient used to remap particle colors
  96765. * @param gradient defines the gradient to use (between 0 and 1)
  96766. * @param color defines the color to affect to the specified gradient
  96767. * @returns the current particle system
  96768. */
  96769. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  96770. /**
  96771. * Remove a specific ramp gradient
  96772. * @param gradient defines the gradient to remove
  96773. * @returns the current particle system
  96774. */
  96775. removeRampGradient(gradient: number): ParticleSystem;
  96776. /**
  96777. * Adds a new color gradient
  96778. * @param gradient defines the gradient to use (between 0 and 1)
  96779. * @param color1 defines the color to affect to the specified gradient
  96780. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  96781. * @returns this particle system
  96782. */
  96783. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  96784. /**
  96785. * Remove a specific color gradient
  96786. * @param gradient defines the gradient to remove
  96787. * @returns this particle system
  96788. */
  96789. removeColorGradient(gradient: number): IParticleSystem;
  96790. private _fetchR;
  96791. protected _reset(): void;
  96792. private _resetEffect;
  96793. private _createVertexBuffers;
  96794. private _createIndexBuffer;
  96795. /**
  96796. * Gets the maximum number of particles active at the same time.
  96797. * @returns The max number of active particles.
  96798. */
  96799. getCapacity(): number;
  96800. /**
  96801. * Gets whether there are still active particles in the system.
  96802. * @returns True if it is alive, otherwise false.
  96803. */
  96804. isAlive(): boolean;
  96805. /**
  96806. * Gets if the system has been started. (Note: this will still be true after stop is called)
  96807. * @returns True if it has been started, otherwise false.
  96808. */
  96809. isStarted(): boolean;
  96810. private _prepareSubEmitterInternalArray;
  96811. /**
  96812. * Starts the particle system and begins to emit
  96813. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  96814. */
  96815. start(delay?: number): void;
  96816. /**
  96817. * Stops the particle system.
  96818. * @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.
  96819. */
  96820. stop(stopSubEmitters?: boolean): void;
  96821. /**
  96822. * Remove all active particles
  96823. */
  96824. reset(): void;
  96825. /**
  96826. * @hidden (for internal use only)
  96827. */
  96828. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  96829. /**
  96830. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  96831. * Its lifetime will start back at 0.
  96832. */
  96833. recycleParticle: (particle: Particle) => void;
  96834. private _stopSubEmitters;
  96835. private _createParticle;
  96836. private _removeFromRoot;
  96837. private _emitFromParticle;
  96838. private _update;
  96839. /** @hidden */
  96840. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  96841. /** @hidden */
  96842. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  96843. /**
  96844. * Fill the defines array according to the current settings of the particle system
  96845. * @param defines Array to be updated
  96846. * @param blendMode blend mode to take into account when updating the array
  96847. */
  96848. fillDefines(defines: Array<string>, blendMode: number): void;
  96849. /**
  96850. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  96851. * @param uniforms Uniforms array to fill
  96852. * @param attributes Attributes array to fill
  96853. * @param samplers Samplers array to fill
  96854. */
  96855. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  96856. /** @hidden */
  96857. private _getEffect;
  96858. /**
  96859. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  96860. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  96861. */
  96862. animate(preWarmOnly?: boolean): void;
  96863. private _appendParticleVertices;
  96864. /**
  96865. * Rebuilds the particle system.
  96866. */
  96867. rebuild(): void;
  96868. /**
  96869. * Is this system ready to be used/rendered
  96870. * @return true if the system is ready
  96871. */
  96872. isReady(): boolean;
  96873. private _render;
  96874. /**
  96875. * Renders the particle system in its current state.
  96876. * @returns the current number of particles
  96877. */
  96878. render(): number;
  96879. /**
  96880. * Disposes the particle system and free the associated resources
  96881. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  96882. */
  96883. dispose(disposeTexture?: boolean): void;
  96884. /**
  96885. * Clones the particle system.
  96886. * @param name The name of the cloned object
  96887. * @param newEmitter The new emitter to use
  96888. * @returns the cloned particle system
  96889. */
  96890. clone(name: string, newEmitter: any): ParticleSystem;
  96891. /**
  96892. * Serializes the particle system to a JSON object
  96893. * @param serializeTexture defines if the texture must be serialized as well
  96894. * @returns the JSON object
  96895. */
  96896. serialize(serializeTexture?: boolean): any;
  96897. /** @hidden */
  96898. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  96899. /** @hidden */
  96900. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  96901. /**
  96902. * Parses a JSON object to create a particle system.
  96903. * @param parsedParticleSystem The JSON object to parse
  96904. * @param sceneOrEngine The scene or the engine to create the particle system in
  96905. * @param rootUrl The root url to use to load external dependencies like texture
  96906. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  96907. * @returns the Parsed particle system
  96908. */
  96909. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  96910. }
  96911. }
  96912. declare module BABYLON {
  96913. /**
  96914. * A particle represents one of the element emitted by a particle system.
  96915. * This is mainly define by its coordinates, direction, velocity and age.
  96916. */
  96917. export class Particle {
  96918. /**
  96919. * The particle system the particle belongs to.
  96920. */
  96921. particleSystem: ParticleSystem;
  96922. private static _Count;
  96923. /**
  96924. * Unique ID of the particle
  96925. */
  96926. id: number;
  96927. /**
  96928. * The world position of the particle in the scene.
  96929. */
  96930. position: Vector3;
  96931. /**
  96932. * The world direction of the particle in the scene.
  96933. */
  96934. direction: Vector3;
  96935. /**
  96936. * The color of the particle.
  96937. */
  96938. color: Color4;
  96939. /**
  96940. * The color change of the particle per step.
  96941. */
  96942. colorStep: Color4;
  96943. /**
  96944. * Defines how long will the life of the particle be.
  96945. */
  96946. lifeTime: number;
  96947. /**
  96948. * The current age of the particle.
  96949. */
  96950. age: number;
  96951. /**
  96952. * The current size of the particle.
  96953. */
  96954. size: number;
  96955. /**
  96956. * The current scale of the particle.
  96957. */
  96958. scale: Vector2;
  96959. /**
  96960. * The current angle of the particle.
  96961. */
  96962. angle: number;
  96963. /**
  96964. * Defines how fast is the angle changing.
  96965. */
  96966. angularSpeed: number;
  96967. /**
  96968. * Defines the cell index used by the particle to be rendered from a sprite.
  96969. */
  96970. cellIndex: number;
  96971. /**
  96972. * The information required to support color remapping
  96973. */
  96974. remapData: Vector4;
  96975. /** @hidden */
  96976. _randomCellOffset?: number;
  96977. /** @hidden */
  96978. _initialDirection: Nullable<Vector3>;
  96979. /** @hidden */
  96980. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  96981. /** @hidden */
  96982. _initialStartSpriteCellID: number;
  96983. /** @hidden */
  96984. _initialEndSpriteCellID: number;
  96985. /** @hidden */
  96986. _currentColorGradient: Nullable<ColorGradient>;
  96987. /** @hidden */
  96988. _currentColor1: Color4;
  96989. /** @hidden */
  96990. _currentColor2: Color4;
  96991. /** @hidden */
  96992. _currentSizeGradient: Nullable<FactorGradient>;
  96993. /** @hidden */
  96994. _currentSize1: number;
  96995. /** @hidden */
  96996. _currentSize2: number;
  96997. /** @hidden */
  96998. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  96999. /** @hidden */
  97000. _currentAngularSpeed1: number;
  97001. /** @hidden */
  97002. _currentAngularSpeed2: number;
  97003. /** @hidden */
  97004. _currentVelocityGradient: Nullable<FactorGradient>;
  97005. /** @hidden */
  97006. _currentVelocity1: number;
  97007. /** @hidden */
  97008. _currentVelocity2: number;
  97009. /** @hidden */
  97010. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  97011. /** @hidden */
  97012. _currentLimitVelocity1: number;
  97013. /** @hidden */
  97014. _currentLimitVelocity2: number;
  97015. /** @hidden */
  97016. _currentDragGradient: Nullable<FactorGradient>;
  97017. /** @hidden */
  97018. _currentDrag1: number;
  97019. /** @hidden */
  97020. _currentDrag2: number;
  97021. /** @hidden */
  97022. _randomNoiseCoordinates1: Vector3;
  97023. /** @hidden */
  97024. _randomNoiseCoordinates2: Vector3;
  97025. /** @hidden */
  97026. _localPosition?: Vector3;
  97027. /**
  97028. * Creates a new instance Particle
  97029. * @param particleSystem the particle system the particle belongs to
  97030. */
  97031. constructor(
  97032. /**
  97033. * The particle system the particle belongs to.
  97034. */
  97035. particleSystem: ParticleSystem);
  97036. private updateCellInfoFromSystem;
  97037. /**
  97038. * Defines how the sprite cell index is updated for the particle
  97039. */
  97040. updateCellIndex(): void;
  97041. /** @hidden */
  97042. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  97043. /** @hidden */
  97044. _inheritParticleInfoToSubEmitters(): void;
  97045. /** @hidden */
  97046. _reset(): void;
  97047. /**
  97048. * Copy the properties of particle to another one.
  97049. * @param other the particle to copy the information to.
  97050. */
  97051. copyTo(other: Particle): void;
  97052. }
  97053. }
  97054. declare module BABYLON {
  97055. /**
  97056. * Particle emitter represents a volume emitting particles.
  97057. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  97058. */
  97059. export interface IParticleEmitterType {
  97060. /**
  97061. * Called by the particle System when the direction is computed for the created particle.
  97062. * @param worldMatrix is the world matrix of the particle system
  97063. * @param directionToUpdate is the direction vector to update with the result
  97064. * @param particle is the particle we are computed the direction for
  97065. * @param isLocal defines if the direction should be set in local space
  97066. */
  97067. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97068. /**
  97069. * Called by the particle System when the position is computed for the created particle.
  97070. * @param worldMatrix is the world matrix of the particle system
  97071. * @param positionToUpdate is the position vector to update with the result
  97072. * @param particle is the particle we are computed the position for
  97073. * @param isLocal defines if the position should be set in local space
  97074. */
  97075. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97076. /**
  97077. * Clones the current emitter and returns a copy of it
  97078. * @returns the new emitter
  97079. */
  97080. clone(): IParticleEmitterType;
  97081. /**
  97082. * Called by the GPUParticleSystem to setup the update shader
  97083. * @param effect defines the update shader
  97084. */
  97085. applyToShader(effect: Effect): void;
  97086. /**
  97087. * Returns a string to use to update the GPU particles update shader
  97088. * @returns the effect defines string
  97089. */
  97090. getEffectDefines(): string;
  97091. /**
  97092. * Returns a string representing the class name
  97093. * @returns a string containing the class name
  97094. */
  97095. getClassName(): string;
  97096. /**
  97097. * Serializes the particle system to a JSON object.
  97098. * @returns the JSON object
  97099. */
  97100. serialize(): any;
  97101. /**
  97102. * Parse properties from a JSON object
  97103. * @param serializationObject defines the JSON object
  97104. * @param scene defines the hosting scene
  97105. */
  97106. parse(serializationObject: any, scene: Nullable<Scene>): void;
  97107. }
  97108. }
  97109. declare module BABYLON {
  97110. /**
  97111. * Particle emitter emitting particles from the inside of a box.
  97112. * It emits the particles randomly between 2 given directions.
  97113. */
  97114. export class BoxParticleEmitter implements IParticleEmitterType {
  97115. /**
  97116. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97117. */
  97118. direction1: Vector3;
  97119. /**
  97120. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97121. */
  97122. direction2: Vector3;
  97123. /**
  97124. * 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.
  97125. */
  97126. minEmitBox: Vector3;
  97127. /**
  97128. * 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.
  97129. */
  97130. maxEmitBox: Vector3;
  97131. /**
  97132. * Creates a new instance BoxParticleEmitter
  97133. */
  97134. constructor();
  97135. /**
  97136. * Called by the particle System when the direction is computed for the created particle.
  97137. * @param worldMatrix is the world matrix of the particle system
  97138. * @param directionToUpdate is the direction vector to update with the result
  97139. * @param particle is the particle we are computed the direction for
  97140. * @param isLocal defines if the direction should be set in local space
  97141. */
  97142. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97143. /**
  97144. * Called by the particle System when the position is computed for the created particle.
  97145. * @param worldMatrix is the world matrix of the particle system
  97146. * @param positionToUpdate is the position vector to update with the result
  97147. * @param particle is the particle we are computed the position for
  97148. * @param isLocal defines if the position should be set in local space
  97149. */
  97150. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97151. /**
  97152. * Clones the current emitter and returns a copy of it
  97153. * @returns the new emitter
  97154. */
  97155. clone(): BoxParticleEmitter;
  97156. /**
  97157. * Called by the GPUParticleSystem to setup the update shader
  97158. * @param effect defines the update shader
  97159. */
  97160. applyToShader(effect: Effect): void;
  97161. /**
  97162. * Returns a string to use to update the GPU particles update shader
  97163. * @returns a string containng the defines string
  97164. */
  97165. getEffectDefines(): string;
  97166. /**
  97167. * Returns the string "BoxParticleEmitter"
  97168. * @returns a string containing the class name
  97169. */
  97170. getClassName(): string;
  97171. /**
  97172. * Serializes the particle system to a JSON object.
  97173. * @returns the JSON object
  97174. */
  97175. serialize(): any;
  97176. /**
  97177. * Parse properties from a JSON object
  97178. * @param serializationObject defines the JSON object
  97179. */
  97180. parse(serializationObject: any): void;
  97181. }
  97182. }
  97183. declare module BABYLON {
  97184. /**
  97185. * Particle emitter emitting particles from the inside of a cone.
  97186. * It emits the particles alongside the cone volume from the base to the particle.
  97187. * The emission direction might be randomized.
  97188. */
  97189. export class ConeParticleEmitter implements IParticleEmitterType {
  97190. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  97191. directionRandomizer: number;
  97192. private _radius;
  97193. private _angle;
  97194. private _height;
  97195. /**
  97196. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  97197. */
  97198. radiusRange: number;
  97199. /**
  97200. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  97201. */
  97202. heightRange: number;
  97203. /**
  97204. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  97205. */
  97206. emitFromSpawnPointOnly: boolean;
  97207. /**
  97208. * Gets or sets the radius of the emission cone
  97209. */
  97210. get radius(): number;
  97211. set radius(value: number);
  97212. /**
  97213. * Gets or sets the angle of the emission cone
  97214. */
  97215. get angle(): number;
  97216. set angle(value: number);
  97217. private _buildHeight;
  97218. /**
  97219. * Creates a new instance ConeParticleEmitter
  97220. * @param radius the radius of the emission cone (1 by default)
  97221. * @param angle the cone base angle (PI by default)
  97222. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  97223. */
  97224. constructor(radius?: number, angle?: number,
  97225. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  97226. directionRandomizer?: number);
  97227. /**
  97228. * Called by the particle System when the direction is computed for the created particle.
  97229. * @param worldMatrix is the world matrix of the particle system
  97230. * @param directionToUpdate is the direction vector to update with the result
  97231. * @param particle is the particle we are computed the direction for
  97232. * @param isLocal defines if the direction should be set in local space
  97233. */
  97234. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97235. /**
  97236. * Called by the particle System when the position is computed for the created particle.
  97237. * @param worldMatrix is the world matrix of the particle system
  97238. * @param positionToUpdate is the position vector to update with the result
  97239. * @param particle is the particle we are computed the position for
  97240. * @param isLocal defines if the position should be set in local space
  97241. */
  97242. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97243. /**
  97244. * Clones the current emitter and returns a copy of it
  97245. * @returns the new emitter
  97246. */
  97247. clone(): ConeParticleEmitter;
  97248. /**
  97249. * Called by the GPUParticleSystem to setup the update shader
  97250. * @param effect defines the update shader
  97251. */
  97252. applyToShader(effect: Effect): void;
  97253. /**
  97254. * Returns a string to use to update the GPU particles update shader
  97255. * @returns a string containng the defines string
  97256. */
  97257. getEffectDefines(): string;
  97258. /**
  97259. * Returns the string "ConeParticleEmitter"
  97260. * @returns a string containing the class name
  97261. */
  97262. getClassName(): string;
  97263. /**
  97264. * Serializes the particle system to a JSON object.
  97265. * @returns the JSON object
  97266. */
  97267. serialize(): any;
  97268. /**
  97269. * Parse properties from a JSON object
  97270. * @param serializationObject defines the JSON object
  97271. */
  97272. parse(serializationObject: any): void;
  97273. }
  97274. }
  97275. declare module BABYLON {
  97276. /**
  97277. * Particle emitter emitting particles from the inside of a cylinder.
  97278. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  97279. */
  97280. export class CylinderParticleEmitter implements IParticleEmitterType {
  97281. /**
  97282. * The radius of the emission cylinder.
  97283. */
  97284. radius: number;
  97285. /**
  97286. * The height of the emission cylinder.
  97287. */
  97288. height: number;
  97289. /**
  97290. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97291. */
  97292. radiusRange: number;
  97293. /**
  97294. * How much to randomize the particle direction [0-1].
  97295. */
  97296. directionRandomizer: number;
  97297. /**
  97298. * Creates a new instance CylinderParticleEmitter
  97299. * @param radius the radius of the emission cylinder (1 by default)
  97300. * @param height the height of the emission cylinder (1 by default)
  97301. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97302. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  97303. */
  97304. constructor(
  97305. /**
  97306. * The radius of the emission cylinder.
  97307. */
  97308. radius?: number,
  97309. /**
  97310. * The height of the emission cylinder.
  97311. */
  97312. height?: number,
  97313. /**
  97314. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97315. */
  97316. radiusRange?: number,
  97317. /**
  97318. * How much to randomize the particle direction [0-1].
  97319. */
  97320. directionRandomizer?: number);
  97321. /**
  97322. * Called by the particle System when the direction is computed for the created particle.
  97323. * @param worldMatrix is the world matrix of the particle system
  97324. * @param directionToUpdate is the direction vector to update with the result
  97325. * @param particle is the particle we are computed the direction for
  97326. * @param isLocal defines if the direction should be set in local space
  97327. */
  97328. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97329. /**
  97330. * Called by the particle System when the position is computed for the created particle.
  97331. * @param worldMatrix is the world matrix of the particle system
  97332. * @param positionToUpdate is the position vector to update with the result
  97333. * @param particle is the particle we are computed the position for
  97334. * @param isLocal defines if the position should be set in local space
  97335. */
  97336. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97337. /**
  97338. * Clones the current emitter and returns a copy of it
  97339. * @returns the new emitter
  97340. */
  97341. clone(): CylinderParticleEmitter;
  97342. /**
  97343. * Called by the GPUParticleSystem to setup the update shader
  97344. * @param effect defines the update shader
  97345. */
  97346. applyToShader(effect: Effect): void;
  97347. /**
  97348. * Returns a string to use to update the GPU particles update shader
  97349. * @returns a string containng the defines string
  97350. */
  97351. getEffectDefines(): string;
  97352. /**
  97353. * Returns the string "CylinderParticleEmitter"
  97354. * @returns a string containing the class name
  97355. */
  97356. getClassName(): string;
  97357. /**
  97358. * Serializes the particle system to a JSON object.
  97359. * @returns the JSON object
  97360. */
  97361. serialize(): any;
  97362. /**
  97363. * Parse properties from a JSON object
  97364. * @param serializationObject defines the JSON object
  97365. */
  97366. parse(serializationObject: any): void;
  97367. }
  97368. /**
  97369. * Particle emitter emitting particles from the inside of a cylinder.
  97370. * It emits the particles randomly between two vectors.
  97371. */
  97372. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  97373. /**
  97374. * The min limit of the emission direction.
  97375. */
  97376. direction1: Vector3;
  97377. /**
  97378. * The max limit of the emission direction.
  97379. */
  97380. direction2: Vector3;
  97381. /**
  97382. * Creates a new instance CylinderDirectedParticleEmitter
  97383. * @param radius the radius of the emission cylinder (1 by default)
  97384. * @param height the height of the emission cylinder (1 by default)
  97385. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97386. * @param direction1 the min limit of the emission direction (up vector by default)
  97387. * @param direction2 the max limit of the emission direction (up vector by default)
  97388. */
  97389. constructor(radius?: number, height?: number, radiusRange?: number,
  97390. /**
  97391. * The min limit of the emission direction.
  97392. */
  97393. direction1?: Vector3,
  97394. /**
  97395. * The max limit of the emission direction.
  97396. */
  97397. direction2?: Vector3);
  97398. /**
  97399. * Called by the particle System when the direction is computed for the created particle.
  97400. * @param worldMatrix is the world matrix of the particle system
  97401. * @param directionToUpdate is the direction vector to update with the result
  97402. * @param particle is the particle we are computed the direction for
  97403. */
  97404. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  97405. /**
  97406. * Clones the current emitter and returns a copy of it
  97407. * @returns the new emitter
  97408. */
  97409. clone(): CylinderDirectedParticleEmitter;
  97410. /**
  97411. * Called by the GPUParticleSystem to setup the update shader
  97412. * @param effect defines the update shader
  97413. */
  97414. applyToShader(effect: Effect): void;
  97415. /**
  97416. * Returns a string to use to update the GPU particles update shader
  97417. * @returns a string containng the defines string
  97418. */
  97419. getEffectDefines(): string;
  97420. /**
  97421. * Returns the string "CylinderDirectedParticleEmitter"
  97422. * @returns a string containing the class name
  97423. */
  97424. getClassName(): string;
  97425. /**
  97426. * Serializes the particle system to a JSON object.
  97427. * @returns the JSON object
  97428. */
  97429. serialize(): any;
  97430. /**
  97431. * Parse properties from a JSON object
  97432. * @param serializationObject defines the JSON object
  97433. */
  97434. parse(serializationObject: any): void;
  97435. }
  97436. }
  97437. declare module BABYLON {
  97438. /**
  97439. * Particle emitter emitting particles from the inside of a hemisphere.
  97440. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  97441. */
  97442. export class HemisphericParticleEmitter implements IParticleEmitterType {
  97443. /**
  97444. * The radius of the emission hemisphere.
  97445. */
  97446. radius: number;
  97447. /**
  97448. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97449. */
  97450. radiusRange: number;
  97451. /**
  97452. * How much to randomize the particle direction [0-1].
  97453. */
  97454. directionRandomizer: number;
  97455. /**
  97456. * Creates a new instance HemisphericParticleEmitter
  97457. * @param radius the radius of the emission hemisphere (1 by default)
  97458. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97459. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  97460. */
  97461. constructor(
  97462. /**
  97463. * The radius of the emission hemisphere.
  97464. */
  97465. radius?: number,
  97466. /**
  97467. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97468. */
  97469. radiusRange?: number,
  97470. /**
  97471. * How much to randomize the particle direction [0-1].
  97472. */
  97473. directionRandomizer?: number);
  97474. /**
  97475. * Called by the particle System when the direction is computed for the created particle.
  97476. * @param worldMatrix is the world matrix of the particle system
  97477. * @param directionToUpdate is the direction vector to update with the result
  97478. * @param particle is the particle we are computed the direction for
  97479. * @param isLocal defines if the direction should be set in local space
  97480. */
  97481. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97482. /**
  97483. * Called by the particle System when the position is computed for the created particle.
  97484. * @param worldMatrix is the world matrix of the particle system
  97485. * @param positionToUpdate is the position vector to update with the result
  97486. * @param particle is the particle we are computed the position for
  97487. * @param isLocal defines if the position should be set in local space
  97488. */
  97489. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97490. /**
  97491. * Clones the current emitter and returns a copy of it
  97492. * @returns the new emitter
  97493. */
  97494. clone(): HemisphericParticleEmitter;
  97495. /**
  97496. * Called by the GPUParticleSystem to setup the update shader
  97497. * @param effect defines the update shader
  97498. */
  97499. applyToShader(effect: Effect): void;
  97500. /**
  97501. * Returns a string to use to update the GPU particles update shader
  97502. * @returns a string containng the defines string
  97503. */
  97504. getEffectDefines(): string;
  97505. /**
  97506. * Returns the string "HemisphericParticleEmitter"
  97507. * @returns a string containing the class name
  97508. */
  97509. getClassName(): string;
  97510. /**
  97511. * Serializes the particle system to a JSON object.
  97512. * @returns the JSON object
  97513. */
  97514. serialize(): any;
  97515. /**
  97516. * Parse properties from a JSON object
  97517. * @param serializationObject defines the JSON object
  97518. */
  97519. parse(serializationObject: any): void;
  97520. }
  97521. }
  97522. declare module BABYLON {
  97523. /**
  97524. * Particle emitter emitting particles from a point.
  97525. * It emits the particles randomly between 2 given directions.
  97526. */
  97527. export class PointParticleEmitter implements IParticleEmitterType {
  97528. /**
  97529. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97530. */
  97531. direction1: Vector3;
  97532. /**
  97533. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97534. */
  97535. direction2: Vector3;
  97536. /**
  97537. * Creates a new instance PointParticleEmitter
  97538. */
  97539. constructor();
  97540. /**
  97541. * Called by the particle System when the direction is computed for the created particle.
  97542. * @param worldMatrix is the world matrix of the particle system
  97543. * @param directionToUpdate is the direction vector to update with the result
  97544. * @param particle is the particle we are computed the direction for
  97545. * @param isLocal defines if the direction should be set in local space
  97546. */
  97547. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97548. /**
  97549. * Called by the particle System when the position is computed for the created particle.
  97550. * @param worldMatrix is the world matrix of the particle system
  97551. * @param positionToUpdate is the position vector to update with the result
  97552. * @param particle is the particle we are computed the position for
  97553. * @param isLocal defines if the position should be set in local space
  97554. */
  97555. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97556. /**
  97557. * Clones the current emitter and returns a copy of it
  97558. * @returns the new emitter
  97559. */
  97560. clone(): PointParticleEmitter;
  97561. /**
  97562. * Called by the GPUParticleSystem to setup the update shader
  97563. * @param effect defines the update shader
  97564. */
  97565. applyToShader(effect: Effect): void;
  97566. /**
  97567. * Returns a string to use to update the GPU particles update shader
  97568. * @returns a string containng the defines string
  97569. */
  97570. getEffectDefines(): string;
  97571. /**
  97572. * Returns the string "PointParticleEmitter"
  97573. * @returns a string containing the class name
  97574. */
  97575. getClassName(): string;
  97576. /**
  97577. * Serializes the particle system to a JSON object.
  97578. * @returns the JSON object
  97579. */
  97580. serialize(): any;
  97581. /**
  97582. * Parse properties from a JSON object
  97583. * @param serializationObject defines the JSON object
  97584. */
  97585. parse(serializationObject: any): void;
  97586. }
  97587. }
  97588. declare module BABYLON {
  97589. /**
  97590. * Particle emitter emitting particles from the inside of a sphere.
  97591. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  97592. */
  97593. export class SphereParticleEmitter implements IParticleEmitterType {
  97594. /**
  97595. * The radius of the emission sphere.
  97596. */
  97597. radius: number;
  97598. /**
  97599. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97600. */
  97601. radiusRange: number;
  97602. /**
  97603. * How much to randomize the particle direction [0-1].
  97604. */
  97605. directionRandomizer: number;
  97606. /**
  97607. * Creates a new instance SphereParticleEmitter
  97608. * @param radius the radius of the emission sphere (1 by default)
  97609. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97610. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  97611. */
  97612. constructor(
  97613. /**
  97614. * The radius of the emission sphere.
  97615. */
  97616. radius?: number,
  97617. /**
  97618. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97619. */
  97620. radiusRange?: number,
  97621. /**
  97622. * How much to randomize the particle direction [0-1].
  97623. */
  97624. directionRandomizer?: number);
  97625. /**
  97626. * Called by the particle System when the direction is computed for the created particle.
  97627. * @param worldMatrix is the world matrix of the particle system
  97628. * @param directionToUpdate is the direction vector to update with the result
  97629. * @param particle is the particle we are computed the direction for
  97630. * @param isLocal defines if the direction should be set in local space
  97631. */
  97632. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97633. /**
  97634. * Called by the particle System when the position is computed for the created particle.
  97635. * @param worldMatrix is the world matrix of the particle system
  97636. * @param positionToUpdate is the position vector to update with the result
  97637. * @param particle is the particle we are computed the position for
  97638. * @param isLocal defines if the position should be set in local space
  97639. */
  97640. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97641. /**
  97642. * Clones the current emitter and returns a copy of it
  97643. * @returns the new emitter
  97644. */
  97645. clone(): SphereParticleEmitter;
  97646. /**
  97647. * Called by the GPUParticleSystem to setup the update shader
  97648. * @param effect defines the update shader
  97649. */
  97650. applyToShader(effect: Effect): void;
  97651. /**
  97652. * Returns a string to use to update the GPU particles update shader
  97653. * @returns a string containng the defines string
  97654. */
  97655. getEffectDefines(): string;
  97656. /**
  97657. * Returns the string "SphereParticleEmitter"
  97658. * @returns a string containing the class name
  97659. */
  97660. getClassName(): string;
  97661. /**
  97662. * Serializes the particle system to a JSON object.
  97663. * @returns the JSON object
  97664. */
  97665. serialize(): any;
  97666. /**
  97667. * Parse properties from a JSON object
  97668. * @param serializationObject defines the JSON object
  97669. */
  97670. parse(serializationObject: any): void;
  97671. }
  97672. /**
  97673. * Particle emitter emitting particles from the inside of a sphere.
  97674. * It emits the particles randomly between two vectors.
  97675. */
  97676. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  97677. /**
  97678. * The min limit of the emission direction.
  97679. */
  97680. direction1: Vector3;
  97681. /**
  97682. * The max limit of the emission direction.
  97683. */
  97684. direction2: Vector3;
  97685. /**
  97686. * Creates a new instance SphereDirectedParticleEmitter
  97687. * @param radius the radius of the emission sphere (1 by default)
  97688. * @param direction1 the min limit of the emission direction (up vector by default)
  97689. * @param direction2 the max limit of the emission direction (up vector by default)
  97690. */
  97691. constructor(radius?: number,
  97692. /**
  97693. * The min limit of the emission direction.
  97694. */
  97695. direction1?: Vector3,
  97696. /**
  97697. * The max limit of the emission direction.
  97698. */
  97699. direction2?: Vector3);
  97700. /**
  97701. * Called by the particle System when the direction is computed for the created particle.
  97702. * @param worldMatrix is the world matrix of the particle system
  97703. * @param directionToUpdate is the direction vector to update with the result
  97704. * @param particle is the particle we are computed the direction for
  97705. */
  97706. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  97707. /**
  97708. * Clones the current emitter and returns a copy of it
  97709. * @returns the new emitter
  97710. */
  97711. clone(): SphereDirectedParticleEmitter;
  97712. /**
  97713. * Called by the GPUParticleSystem to setup the update shader
  97714. * @param effect defines the update shader
  97715. */
  97716. applyToShader(effect: Effect): void;
  97717. /**
  97718. * Returns a string to use to update the GPU particles update shader
  97719. * @returns a string containng the defines string
  97720. */
  97721. getEffectDefines(): string;
  97722. /**
  97723. * Returns the string "SphereDirectedParticleEmitter"
  97724. * @returns a string containing the class name
  97725. */
  97726. getClassName(): string;
  97727. /**
  97728. * Serializes the particle system to a JSON object.
  97729. * @returns the JSON object
  97730. */
  97731. serialize(): any;
  97732. /**
  97733. * Parse properties from a JSON object
  97734. * @param serializationObject defines the JSON object
  97735. */
  97736. parse(serializationObject: any): void;
  97737. }
  97738. }
  97739. declare module BABYLON {
  97740. /**
  97741. * Particle emitter emitting particles from a custom list of positions.
  97742. */
  97743. export class CustomParticleEmitter implements IParticleEmitterType {
  97744. /**
  97745. * Gets or sets the position generator that will create the inital position of each particle.
  97746. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  97747. */
  97748. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  97749. /**
  97750. * Gets or sets the destination generator that will create the final destination of each particle.
  97751. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  97752. */
  97753. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  97754. /**
  97755. * Creates a new instance CustomParticleEmitter
  97756. */
  97757. constructor();
  97758. /**
  97759. * Called by the particle System when the direction is computed for the created particle.
  97760. * @param worldMatrix is the world matrix of the particle system
  97761. * @param directionToUpdate is the direction vector to update with the result
  97762. * @param particle is the particle we are computed the direction for
  97763. * @param isLocal defines if the direction should be set in local space
  97764. */
  97765. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97766. /**
  97767. * Called by the particle System when the position is computed for the created particle.
  97768. * @param worldMatrix is the world matrix of the particle system
  97769. * @param positionToUpdate is the position vector to update with the result
  97770. * @param particle is the particle we are computed the position for
  97771. * @param isLocal defines if the position should be set in local space
  97772. */
  97773. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97774. /**
  97775. * Clones the current emitter and returns a copy of it
  97776. * @returns the new emitter
  97777. */
  97778. clone(): CustomParticleEmitter;
  97779. /**
  97780. * Called by the GPUParticleSystem to setup the update shader
  97781. * @param effect defines the update shader
  97782. */
  97783. applyToShader(effect: Effect): void;
  97784. /**
  97785. * Returns a string to use to update the GPU particles update shader
  97786. * @returns a string containng the defines string
  97787. */
  97788. getEffectDefines(): string;
  97789. /**
  97790. * Returns the string "PointParticleEmitter"
  97791. * @returns a string containing the class name
  97792. */
  97793. getClassName(): string;
  97794. /**
  97795. * Serializes the particle system to a JSON object.
  97796. * @returns the JSON object
  97797. */
  97798. serialize(): any;
  97799. /**
  97800. * Parse properties from a JSON object
  97801. * @param serializationObject defines the JSON object
  97802. */
  97803. parse(serializationObject: any): void;
  97804. }
  97805. }
  97806. declare module BABYLON {
  97807. /**
  97808. * Particle emitter emitting particles from the inside of a box.
  97809. * It emits the particles randomly between 2 given directions.
  97810. */
  97811. export class MeshParticleEmitter implements IParticleEmitterType {
  97812. private _indices;
  97813. private _positions;
  97814. private _normals;
  97815. private _storedNormal;
  97816. private _mesh;
  97817. /**
  97818. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97819. */
  97820. direction1: Vector3;
  97821. /**
  97822. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97823. */
  97824. direction2: Vector3;
  97825. /**
  97826. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  97827. */
  97828. useMeshNormalsForDirection: boolean;
  97829. /** Defines the mesh to use as source */
  97830. get mesh(): Nullable<AbstractMesh>;
  97831. set mesh(value: Nullable<AbstractMesh>);
  97832. /**
  97833. * Creates a new instance MeshParticleEmitter
  97834. * @param mesh defines the mesh to use as source
  97835. */
  97836. constructor(mesh?: Nullable<AbstractMesh>);
  97837. /**
  97838. * Called by the particle System when the direction is computed for the created particle.
  97839. * @param worldMatrix is the world matrix of the particle system
  97840. * @param directionToUpdate is the direction vector to update with the result
  97841. * @param particle is the particle we are computed the direction for
  97842. * @param isLocal defines if the direction should be set in local space
  97843. */
  97844. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97845. /**
  97846. * Called by the particle System when the position is computed for the created particle.
  97847. * @param worldMatrix is the world matrix of the particle system
  97848. * @param positionToUpdate is the position vector to update with the result
  97849. * @param particle is the particle we are computed the position for
  97850. * @param isLocal defines if the position should be set in local space
  97851. */
  97852. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97853. /**
  97854. * Clones the current emitter and returns a copy of it
  97855. * @returns the new emitter
  97856. */
  97857. clone(): MeshParticleEmitter;
  97858. /**
  97859. * Called by the GPUParticleSystem to setup the update shader
  97860. * @param effect defines the update shader
  97861. */
  97862. applyToShader(effect: Effect): void;
  97863. /**
  97864. * Returns a string to use to update the GPU particles update shader
  97865. * @returns a string containng the defines string
  97866. */
  97867. getEffectDefines(): string;
  97868. /**
  97869. * Returns the string "BoxParticleEmitter"
  97870. * @returns a string containing the class name
  97871. */
  97872. getClassName(): string;
  97873. /**
  97874. * Serializes the particle system to a JSON object.
  97875. * @returns the JSON object
  97876. */
  97877. serialize(): any;
  97878. /**
  97879. * Parse properties from a JSON object
  97880. * @param serializationObject defines the JSON object
  97881. * @param scene defines the hosting scene
  97882. */
  97883. parse(serializationObject: any, scene: Nullable<Scene>): void;
  97884. }
  97885. }
  97886. declare module BABYLON {
  97887. /**
  97888. * Interface representing a particle system in Babylon.js.
  97889. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  97890. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  97891. */
  97892. export interface IParticleSystem {
  97893. /**
  97894. * List of animations used by the particle system.
  97895. */
  97896. animations: Animation[];
  97897. /**
  97898. * The id of the Particle system.
  97899. */
  97900. id: string;
  97901. /**
  97902. * The name of the Particle system.
  97903. */
  97904. name: string;
  97905. /**
  97906. * The emitter represents the Mesh or position we are attaching the particle system to.
  97907. */
  97908. emitter: Nullable<AbstractMesh | Vector3>;
  97909. /**
  97910. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  97911. */
  97912. isBillboardBased: boolean;
  97913. /**
  97914. * The rendering group used by the Particle system to chose when to render.
  97915. */
  97916. renderingGroupId: number;
  97917. /**
  97918. * The layer mask we are rendering the particles through.
  97919. */
  97920. layerMask: number;
  97921. /**
  97922. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  97923. */
  97924. updateSpeed: number;
  97925. /**
  97926. * The amount of time the particle system is running (depends of the overall update speed).
  97927. */
  97928. targetStopDuration: number;
  97929. /**
  97930. * The texture used to render each particle. (this can be a spritesheet)
  97931. */
  97932. particleTexture: Nullable<BaseTexture>;
  97933. /**
  97934. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  97935. */
  97936. blendMode: number;
  97937. /**
  97938. * Minimum life time of emitting particles.
  97939. */
  97940. minLifeTime: number;
  97941. /**
  97942. * Maximum life time of emitting particles.
  97943. */
  97944. maxLifeTime: number;
  97945. /**
  97946. * Minimum Size of emitting particles.
  97947. */
  97948. minSize: number;
  97949. /**
  97950. * Maximum Size of emitting particles.
  97951. */
  97952. maxSize: number;
  97953. /**
  97954. * Minimum scale of emitting particles on X axis.
  97955. */
  97956. minScaleX: number;
  97957. /**
  97958. * Maximum scale of emitting particles on X axis.
  97959. */
  97960. maxScaleX: number;
  97961. /**
  97962. * Minimum scale of emitting particles on Y axis.
  97963. */
  97964. minScaleY: number;
  97965. /**
  97966. * Maximum scale of emitting particles on Y axis.
  97967. */
  97968. maxScaleY: number;
  97969. /**
  97970. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  97971. */
  97972. color1: Color4;
  97973. /**
  97974. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  97975. */
  97976. color2: Color4;
  97977. /**
  97978. * Color the particle will have at the end of its lifetime.
  97979. */
  97980. colorDead: Color4;
  97981. /**
  97982. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  97983. */
  97984. emitRate: number;
  97985. /**
  97986. * You can use gravity if you want to give an orientation to your particles.
  97987. */
  97988. gravity: Vector3;
  97989. /**
  97990. * Minimum power of emitting particles.
  97991. */
  97992. minEmitPower: number;
  97993. /**
  97994. * Maximum power of emitting particles.
  97995. */
  97996. maxEmitPower: number;
  97997. /**
  97998. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  97999. */
  98000. minAngularSpeed: number;
  98001. /**
  98002. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  98003. */
  98004. maxAngularSpeed: number;
  98005. /**
  98006. * Gets or sets the minimal initial rotation in radians.
  98007. */
  98008. minInitialRotation: number;
  98009. /**
  98010. * Gets or sets the maximal initial rotation in radians.
  98011. */
  98012. maxInitialRotation: number;
  98013. /**
  98014. * The particle emitter type defines the emitter used by the particle system.
  98015. * It can be for example box, sphere, or cone...
  98016. */
  98017. particleEmitterType: Nullable<IParticleEmitterType>;
  98018. /**
  98019. * Defines the delay in milliseconds before starting the system (0 by default)
  98020. */
  98021. startDelay: number;
  98022. /**
  98023. * 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
  98024. */
  98025. preWarmCycles: number;
  98026. /**
  98027. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  98028. */
  98029. preWarmStepOffset: number;
  98030. /**
  98031. * 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)
  98032. */
  98033. spriteCellChangeSpeed: number;
  98034. /**
  98035. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  98036. */
  98037. startSpriteCellID: number;
  98038. /**
  98039. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  98040. */
  98041. endSpriteCellID: number;
  98042. /**
  98043. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  98044. */
  98045. spriteCellWidth: number;
  98046. /**
  98047. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  98048. */
  98049. spriteCellHeight: number;
  98050. /**
  98051. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  98052. */
  98053. spriteRandomStartCell: boolean;
  98054. /**
  98055. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  98056. */
  98057. isAnimationSheetEnabled: boolean;
  98058. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  98059. translationPivot: Vector2;
  98060. /**
  98061. * Gets or sets a texture used to add random noise to particle positions
  98062. */
  98063. noiseTexture: Nullable<BaseTexture>;
  98064. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  98065. noiseStrength: Vector3;
  98066. /**
  98067. * Gets or sets the billboard mode to use when isBillboardBased = true.
  98068. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  98069. */
  98070. billboardMode: number;
  98071. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  98072. limitVelocityDamping: number;
  98073. /**
  98074. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  98075. */
  98076. beginAnimationOnStart: boolean;
  98077. /**
  98078. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  98079. */
  98080. beginAnimationFrom: number;
  98081. /**
  98082. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  98083. */
  98084. beginAnimationTo: number;
  98085. /**
  98086. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  98087. */
  98088. beginAnimationLoop: boolean;
  98089. /**
  98090. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  98091. */
  98092. disposeOnStop: boolean;
  98093. /**
  98094. * Specifies if the particles are updated in emitter local space or world space
  98095. */
  98096. isLocal: boolean;
  98097. /** Snippet ID if the particle system was created from the snippet server */
  98098. snippetId: string;
  98099. /** Gets or sets a matrix to use to compute projection */
  98100. defaultProjectionMatrix: Matrix;
  98101. /**
  98102. * Gets the maximum number of particles active at the same time.
  98103. * @returns The max number of active particles.
  98104. */
  98105. getCapacity(): number;
  98106. /**
  98107. * Gets the number of particles active at the same time.
  98108. * @returns The number of active particles.
  98109. */
  98110. getActiveCount(): number;
  98111. /**
  98112. * Gets if the system has been started. (Note: this will still be true after stop is called)
  98113. * @returns True if it has been started, otherwise false.
  98114. */
  98115. isStarted(): boolean;
  98116. /**
  98117. * Animates the particle system for this frame.
  98118. */
  98119. animate(): void;
  98120. /**
  98121. * Renders the particle system in its current state.
  98122. * @returns the current number of particles
  98123. */
  98124. render(): number;
  98125. /**
  98126. * Dispose the particle system and frees its associated resources.
  98127. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  98128. */
  98129. dispose(disposeTexture?: boolean): void;
  98130. /**
  98131. * An event triggered when the system is disposed
  98132. */
  98133. onDisposeObservable: Observable<IParticleSystem>;
  98134. /**
  98135. * An event triggered when the system is stopped
  98136. */
  98137. onStoppedObservable: Observable<IParticleSystem>;
  98138. /**
  98139. * Clones the particle system.
  98140. * @param name The name of the cloned object
  98141. * @param newEmitter The new emitter to use
  98142. * @returns the cloned particle system
  98143. */
  98144. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  98145. /**
  98146. * Serializes the particle system to a JSON object
  98147. * @param serializeTexture defines if the texture must be serialized as well
  98148. * @returns the JSON object
  98149. */
  98150. serialize(serializeTexture: boolean): any;
  98151. /**
  98152. * Rebuild the particle system
  98153. */
  98154. rebuild(): void;
  98155. /** Force the system to rebuild all gradients that need to be resync */
  98156. forceRefreshGradients(): void;
  98157. /**
  98158. * Starts the particle system and begins to emit
  98159. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  98160. */
  98161. start(delay?: number): void;
  98162. /**
  98163. * Stops the particle system.
  98164. */
  98165. stop(): void;
  98166. /**
  98167. * Remove all active particles
  98168. */
  98169. reset(): void;
  98170. /**
  98171. * Gets a boolean indicating that the system is stopping
  98172. * @returns true if the system is currently stopping
  98173. */
  98174. isStopping(): boolean;
  98175. /**
  98176. * Is this system ready to be used/rendered
  98177. * @return true if the system is ready
  98178. */
  98179. isReady(): boolean;
  98180. /**
  98181. * Returns the string "ParticleSystem"
  98182. * @returns a string containing the class name
  98183. */
  98184. getClassName(): string;
  98185. /**
  98186. * Gets the custom effect used to render the particles
  98187. * @param blendMode Blend mode for which the effect should be retrieved
  98188. * @returns The effect
  98189. */
  98190. getCustomEffect(blendMode: number): Nullable<Effect>;
  98191. /**
  98192. * Sets the custom effect used to render the particles
  98193. * @param effect The effect to set
  98194. * @param blendMode Blend mode for which the effect should be set
  98195. */
  98196. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  98197. /**
  98198. * Fill the defines array according to the current settings of the particle system
  98199. * @param defines Array to be updated
  98200. * @param blendMode blend mode to take into account when updating the array
  98201. */
  98202. fillDefines(defines: Array<string>, blendMode: number): void;
  98203. /**
  98204. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  98205. * @param uniforms Uniforms array to fill
  98206. * @param attributes Attributes array to fill
  98207. * @param samplers Samplers array to fill
  98208. */
  98209. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  98210. /**
  98211. * Observable that will be called just before the particles are drawn
  98212. */
  98213. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  98214. /**
  98215. * Gets the name of the particle vertex shader
  98216. */
  98217. vertexShaderName: string;
  98218. /**
  98219. * Adds a new color gradient
  98220. * @param gradient defines the gradient to use (between 0 and 1)
  98221. * @param color1 defines the color to affect to the specified gradient
  98222. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  98223. * @returns the current particle system
  98224. */
  98225. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  98226. /**
  98227. * Remove a specific color gradient
  98228. * @param gradient defines the gradient to remove
  98229. * @returns the current particle system
  98230. */
  98231. removeColorGradient(gradient: number): IParticleSystem;
  98232. /**
  98233. * Adds a new size gradient
  98234. * @param gradient defines the gradient to use (between 0 and 1)
  98235. * @param factor defines the size factor to affect to the specified gradient
  98236. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98237. * @returns the current particle system
  98238. */
  98239. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98240. /**
  98241. * Remove a specific size gradient
  98242. * @param gradient defines the gradient to remove
  98243. * @returns the current particle system
  98244. */
  98245. removeSizeGradient(gradient: number): IParticleSystem;
  98246. /**
  98247. * Gets the current list of color gradients.
  98248. * You must use addColorGradient and removeColorGradient to udpate this list
  98249. * @returns the list of color gradients
  98250. */
  98251. getColorGradients(): Nullable<Array<ColorGradient>>;
  98252. /**
  98253. * Gets the current list of size gradients.
  98254. * You must use addSizeGradient and removeSizeGradient to udpate this list
  98255. * @returns the list of size gradients
  98256. */
  98257. getSizeGradients(): Nullable<Array<FactorGradient>>;
  98258. /**
  98259. * Gets the current list of angular speed gradients.
  98260. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  98261. * @returns the list of angular speed gradients
  98262. */
  98263. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  98264. /**
  98265. * Adds a new angular speed gradient
  98266. * @param gradient defines the gradient to use (between 0 and 1)
  98267. * @param factor defines the angular speed to affect to the specified gradient
  98268. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98269. * @returns the current particle system
  98270. */
  98271. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98272. /**
  98273. * Remove a specific angular speed gradient
  98274. * @param gradient defines the gradient to remove
  98275. * @returns the current particle system
  98276. */
  98277. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  98278. /**
  98279. * Gets the current list of velocity gradients.
  98280. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  98281. * @returns the list of velocity gradients
  98282. */
  98283. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  98284. /**
  98285. * Adds a new velocity gradient
  98286. * @param gradient defines the gradient to use (between 0 and 1)
  98287. * @param factor defines the velocity to affect to the specified gradient
  98288. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98289. * @returns the current particle system
  98290. */
  98291. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98292. /**
  98293. * Remove a specific velocity gradient
  98294. * @param gradient defines the gradient to remove
  98295. * @returns the current particle system
  98296. */
  98297. removeVelocityGradient(gradient: number): IParticleSystem;
  98298. /**
  98299. * Gets the current list of limit velocity gradients.
  98300. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  98301. * @returns the list of limit velocity gradients
  98302. */
  98303. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  98304. /**
  98305. * Adds a new limit velocity gradient
  98306. * @param gradient defines the gradient to use (between 0 and 1)
  98307. * @param factor defines the limit velocity to affect to the specified gradient
  98308. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98309. * @returns the current particle system
  98310. */
  98311. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98312. /**
  98313. * Remove a specific limit velocity gradient
  98314. * @param gradient defines the gradient to remove
  98315. * @returns the current particle system
  98316. */
  98317. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  98318. /**
  98319. * Adds a new drag gradient
  98320. * @param gradient defines the gradient to use (between 0 and 1)
  98321. * @param factor defines the drag to affect to the specified gradient
  98322. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98323. * @returns the current particle system
  98324. */
  98325. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98326. /**
  98327. * Remove a specific drag gradient
  98328. * @param gradient defines the gradient to remove
  98329. * @returns the current particle system
  98330. */
  98331. removeDragGradient(gradient: number): IParticleSystem;
  98332. /**
  98333. * Gets the current list of drag gradients.
  98334. * You must use addDragGradient and removeDragGradient to udpate this list
  98335. * @returns the list of drag gradients
  98336. */
  98337. getDragGradients(): Nullable<Array<FactorGradient>>;
  98338. /**
  98339. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  98340. * @param gradient defines the gradient to use (between 0 and 1)
  98341. * @param factor defines the emit rate to affect to the specified gradient
  98342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98343. * @returns the current particle system
  98344. */
  98345. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98346. /**
  98347. * Remove a specific emit rate gradient
  98348. * @param gradient defines the gradient to remove
  98349. * @returns the current particle system
  98350. */
  98351. removeEmitRateGradient(gradient: number): IParticleSystem;
  98352. /**
  98353. * Gets the current list of emit rate gradients.
  98354. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  98355. * @returns the list of emit rate gradients
  98356. */
  98357. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  98358. /**
  98359. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  98360. * @param gradient defines the gradient to use (between 0 and 1)
  98361. * @param factor defines the start size to affect to the specified gradient
  98362. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98363. * @returns the current particle system
  98364. */
  98365. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98366. /**
  98367. * Remove a specific start size gradient
  98368. * @param gradient defines the gradient to remove
  98369. * @returns the current particle system
  98370. */
  98371. removeStartSizeGradient(gradient: number): IParticleSystem;
  98372. /**
  98373. * Gets the current list of start size gradients.
  98374. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  98375. * @returns the list of start size gradients
  98376. */
  98377. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  98378. /**
  98379. * Adds a new life time gradient
  98380. * @param gradient defines the gradient to use (between 0 and 1)
  98381. * @param factor defines the life time factor to affect to the specified gradient
  98382. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98383. * @returns the current particle system
  98384. */
  98385. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98386. /**
  98387. * Remove a specific life time gradient
  98388. * @param gradient defines the gradient to remove
  98389. * @returns the current particle system
  98390. */
  98391. removeLifeTimeGradient(gradient: number): IParticleSystem;
  98392. /**
  98393. * Gets the current list of life time gradients.
  98394. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  98395. * @returns the list of life time gradients
  98396. */
  98397. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  98398. /**
  98399. * Gets the current list of color gradients.
  98400. * You must use addColorGradient and removeColorGradient to udpate this list
  98401. * @returns the list of color gradients
  98402. */
  98403. getColorGradients(): Nullable<Array<ColorGradient>>;
  98404. /**
  98405. * Adds a new ramp gradient used to remap particle colors
  98406. * @param gradient defines the gradient to use (between 0 and 1)
  98407. * @param color defines the color to affect to the specified gradient
  98408. * @returns the current particle system
  98409. */
  98410. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  98411. /**
  98412. * Gets the current list of ramp gradients.
  98413. * You must use addRampGradient and removeRampGradient to udpate this list
  98414. * @returns the list of ramp gradients
  98415. */
  98416. getRampGradients(): Nullable<Array<Color3Gradient>>;
  98417. /** Gets or sets a boolean indicating that ramp gradients must be used
  98418. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  98419. */
  98420. useRampGradients: boolean;
  98421. /**
  98422. * Adds a new color remap gradient
  98423. * @param gradient defines the gradient to use (between 0 and 1)
  98424. * @param min defines the color remap minimal range
  98425. * @param max defines the color remap maximal range
  98426. * @returns the current particle system
  98427. */
  98428. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  98429. /**
  98430. * Gets the current list of color remap gradients.
  98431. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  98432. * @returns the list of color remap gradients
  98433. */
  98434. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  98435. /**
  98436. * Adds a new alpha remap gradient
  98437. * @param gradient defines the gradient to use (between 0 and 1)
  98438. * @param min defines the alpha remap minimal range
  98439. * @param max defines the alpha remap maximal range
  98440. * @returns the current particle system
  98441. */
  98442. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  98443. /**
  98444. * Gets the current list of alpha remap gradients.
  98445. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  98446. * @returns the list of alpha remap gradients
  98447. */
  98448. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  98449. /**
  98450. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  98451. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  98452. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  98453. * @returns the emitter
  98454. */
  98455. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  98456. /**
  98457. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  98458. * @param radius The radius of the hemisphere to emit from
  98459. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  98460. * @returns the emitter
  98461. */
  98462. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  98463. /**
  98464. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  98465. * @param radius The radius of the sphere to emit from
  98466. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  98467. * @returns the emitter
  98468. */
  98469. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  98470. /**
  98471. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  98472. * @param radius The radius of the sphere to emit from
  98473. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  98474. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  98475. * @returns the emitter
  98476. */
  98477. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  98478. /**
  98479. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  98480. * @param radius The radius of the emission cylinder
  98481. * @param height The height of the emission cylinder
  98482. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  98483. * @param directionRandomizer How much to randomize the particle direction [0-1]
  98484. * @returns the emitter
  98485. */
  98486. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  98487. /**
  98488. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  98489. * @param radius The radius of the cylinder to emit from
  98490. * @param height The height of the emission cylinder
  98491. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  98492. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  98493. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  98494. * @returns the emitter
  98495. */
  98496. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  98497. /**
  98498. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  98499. * @param radius The radius of the cone to emit from
  98500. * @param angle The base angle of the cone
  98501. * @returns the emitter
  98502. */
  98503. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  98504. /**
  98505. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  98506. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  98507. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  98508. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  98509. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  98510. * @returns the emitter
  98511. */
  98512. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  98513. /**
  98514. * Get hosting scene
  98515. * @returns the scene
  98516. */
  98517. getScene(): Nullable<Scene>;
  98518. }
  98519. }
  98520. declare module BABYLON {
  98521. /**
  98522. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  98523. */
  98524. export class ColorSplitterBlock extends NodeMaterialBlock {
  98525. /**
  98526. * Create a new ColorSplitterBlock
  98527. * @param name defines the block name
  98528. */
  98529. constructor(name: string);
  98530. /**
  98531. * Gets the current class name
  98532. * @returns the class name
  98533. */
  98534. getClassName(): string;
  98535. /**
  98536. * Gets the rgba component (input)
  98537. */
  98538. get rgba(): NodeMaterialConnectionPoint;
  98539. /**
  98540. * Gets the rgb component (input)
  98541. */
  98542. get rgbIn(): NodeMaterialConnectionPoint;
  98543. /**
  98544. * Gets the rgb component (output)
  98545. */
  98546. get rgbOut(): NodeMaterialConnectionPoint;
  98547. /**
  98548. * Gets the r component (output)
  98549. */
  98550. get r(): NodeMaterialConnectionPoint;
  98551. /**
  98552. * Gets the g component (output)
  98553. */
  98554. get g(): NodeMaterialConnectionPoint;
  98555. /**
  98556. * Gets the b component (output)
  98557. */
  98558. get b(): NodeMaterialConnectionPoint;
  98559. /**
  98560. * Gets the a component (output)
  98561. */
  98562. get a(): NodeMaterialConnectionPoint;
  98563. protected _inputRename(name: string): string;
  98564. protected _outputRename(name: string): string;
  98565. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98566. }
  98567. }
  98568. declare module BABYLON {
  98569. /**
  98570. * Operations supported by the Trigonometry block
  98571. */
  98572. export enum TrigonometryBlockOperations {
  98573. /** Cos */
  98574. Cos = 0,
  98575. /** Sin */
  98576. Sin = 1,
  98577. /** Abs */
  98578. Abs = 2,
  98579. /** Exp */
  98580. Exp = 3,
  98581. /** Exp2 */
  98582. Exp2 = 4,
  98583. /** Round */
  98584. Round = 5,
  98585. /** Floor */
  98586. Floor = 6,
  98587. /** Ceiling */
  98588. Ceiling = 7,
  98589. /** Square root */
  98590. Sqrt = 8,
  98591. /** Log */
  98592. Log = 9,
  98593. /** Tangent */
  98594. Tan = 10,
  98595. /** Arc tangent */
  98596. ArcTan = 11,
  98597. /** Arc cosinus */
  98598. ArcCos = 12,
  98599. /** Arc sinus */
  98600. ArcSin = 13,
  98601. /** Fraction */
  98602. Fract = 14,
  98603. /** Sign */
  98604. Sign = 15,
  98605. /** To radians (from degrees) */
  98606. Radians = 16,
  98607. /** To degrees (from radians) */
  98608. Degrees = 17
  98609. }
  98610. /**
  98611. * Block used to apply trigonometry operation to floats
  98612. */
  98613. export class TrigonometryBlock extends NodeMaterialBlock {
  98614. /**
  98615. * Gets or sets the operation applied by the block
  98616. */
  98617. operation: TrigonometryBlockOperations;
  98618. /**
  98619. * Creates a new TrigonometryBlock
  98620. * @param name defines the block name
  98621. */
  98622. constructor(name: string);
  98623. /**
  98624. * Gets the current class name
  98625. * @returns the class name
  98626. */
  98627. getClassName(): string;
  98628. /**
  98629. * Gets the input component
  98630. */
  98631. get input(): NodeMaterialConnectionPoint;
  98632. /**
  98633. * Gets the output component
  98634. */
  98635. get output(): NodeMaterialConnectionPoint;
  98636. protected _buildBlock(state: NodeMaterialBuildState): this;
  98637. serialize(): any;
  98638. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98639. protected _dumpPropertiesCode(): string;
  98640. }
  98641. }
  98642. declare module BABYLON {
  98643. /**
  98644. * Interface used to configure the node material editor
  98645. */
  98646. export interface INodeMaterialEditorOptions {
  98647. /** Define the URl to load node editor script */
  98648. editorURL?: string;
  98649. }
  98650. /** @hidden */
  98651. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98652. NORMAL: boolean;
  98653. TANGENT: boolean;
  98654. UV1: boolean;
  98655. /** BONES */
  98656. NUM_BONE_INFLUENCERS: number;
  98657. BonesPerMesh: number;
  98658. BONETEXTURE: boolean;
  98659. /** MORPH TARGETS */
  98660. MORPHTARGETS: boolean;
  98661. MORPHTARGETS_NORMAL: boolean;
  98662. MORPHTARGETS_TANGENT: boolean;
  98663. MORPHTARGETS_UV: boolean;
  98664. NUM_MORPH_INFLUENCERS: number;
  98665. /** IMAGE PROCESSING */
  98666. IMAGEPROCESSING: boolean;
  98667. VIGNETTE: boolean;
  98668. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98669. VIGNETTEBLENDMODEOPAQUE: boolean;
  98670. TONEMAPPING: boolean;
  98671. TONEMAPPING_ACES: boolean;
  98672. CONTRAST: boolean;
  98673. EXPOSURE: boolean;
  98674. COLORCURVES: boolean;
  98675. COLORGRADING: boolean;
  98676. COLORGRADING3D: boolean;
  98677. SAMPLER3DGREENDEPTH: boolean;
  98678. SAMPLER3DBGRMAP: boolean;
  98679. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98680. /** MISC. */
  98681. BUMPDIRECTUV: number;
  98682. constructor();
  98683. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  98684. }
  98685. /**
  98686. * Class used to configure NodeMaterial
  98687. */
  98688. export interface INodeMaterialOptions {
  98689. /**
  98690. * Defines if blocks should emit comments
  98691. */
  98692. emitComments: boolean;
  98693. }
  98694. /**
  98695. * Class used to create a node based material built by assembling shader blocks
  98696. */
  98697. export class NodeMaterial extends PushMaterial {
  98698. private static _BuildIdGenerator;
  98699. private _options;
  98700. private _vertexCompilationState;
  98701. private _fragmentCompilationState;
  98702. private _sharedData;
  98703. private _buildId;
  98704. private _buildWasSuccessful;
  98705. private _cachedWorldViewMatrix;
  98706. private _cachedWorldViewProjectionMatrix;
  98707. private _optimizers;
  98708. private _animationFrame;
  98709. /** Define the Url to load node editor script */
  98710. static EditorURL: string;
  98711. /** Define the Url to load snippets */
  98712. static SnippetUrl: string;
  98713. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  98714. static IgnoreTexturesAtLoadTime: boolean;
  98715. private BJSNODEMATERIALEDITOR;
  98716. /** Get the inspector from bundle or global */
  98717. private _getGlobalNodeMaterialEditor;
  98718. /**
  98719. * Snippet ID if the material was created from the snippet server
  98720. */
  98721. snippetId: string;
  98722. /**
  98723. * Gets or sets data used by visual editor
  98724. * @see https://nme.babylonjs.com
  98725. */
  98726. editorData: any;
  98727. /**
  98728. * 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)
  98729. */
  98730. ignoreAlpha: boolean;
  98731. /**
  98732. * Defines the maximum number of lights that can be used in the material
  98733. */
  98734. maxSimultaneousLights: number;
  98735. /**
  98736. * Observable raised when the material is built
  98737. */
  98738. onBuildObservable: Observable<NodeMaterial>;
  98739. /**
  98740. * Gets or sets the root nodes of the material vertex shader
  98741. */
  98742. _vertexOutputNodes: NodeMaterialBlock[];
  98743. /**
  98744. * Gets or sets the root nodes of the material fragment (pixel) shader
  98745. */
  98746. _fragmentOutputNodes: NodeMaterialBlock[];
  98747. /** Gets or sets options to control the node material overall behavior */
  98748. get options(): INodeMaterialOptions;
  98749. set options(options: INodeMaterialOptions);
  98750. /**
  98751. * Default configuration related to image processing available in the standard Material.
  98752. */
  98753. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98754. /**
  98755. * Gets the image processing configuration used either in this material.
  98756. */
  98757. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  98758. /**
  98759. * Sets the Default image processing configuration used either in the this material.
  98760. *
  98761. * If sets to null, the scene one is in use.
  98762. */
  98763. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  98764. /**
  98765. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  98766. */
  98767. attachedBlocks: NodeMaterialBlock[];
  98768. /**
  98769. * Specifies the mode of the node material
  98770. * @hidden
  98771. */
  98772. _mode: NodeMaterialModes;
  98773. /**
  98774. * Gets the mode property
  98775. */
  98776. get mode(): NodeMaterialModes;
  98777. /**
  98778. * A free comment about the material
  98779. */
  98780. comment: string;
  98781. /**
  98782. * Create a new node based material
  98783. * @param name defines the material name
  98784. * @param scene defines the hosting scene
  98785. * @param options defines creation option
  98786. */
  98787. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  98788. /**
  98789. * Gets the current class name of the material e.g. "NodeMaterial"
  98790. * @returns the class name
  98791. */
  98792. getClassName(): string;
  98793. /**
  98794. * Keep track of the image processing observer to allow dispose and replace.
  98795. */
  98796. private _imageProcessingObserver;
  98797. /**
  98798. * Attaches a new image processing configuration to the Standard Material.
  98799. * @param configuration
  98800. */
  98801. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98802. /**
  98803. * Get a block by its name
  98804. * @param name defines the name of the block to retrieve
  98805. * @returns the required block or null if not found
  98806. */
  98807. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  98808. /**
  98809. * Get a block by its name
  98810. * @param predicate defines the predicate used to find the good candidate
  98811. * @returns the required block or null if not found
  98812. */
  98813. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  98814. /**
  98815. * Get an input block by its name
  98816. * @param predicate defines the predicate used to find the good candidate
  98817. * @returns the required input block or null if not found
  98818. */
  98819. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  98820. /**
  98821. * Gets the list of input blocks attached to this material
  98822. * @returns an array of InputBlocks
  98823. */
  98824. getInputBlocks(): InputBlock[];
  98825. /**
  98826. * Adds a new optimizer to the list of optimizers
  98827. * @param optimizer defines the optimizers to add
  98828. * @returns the current material
  98829. */
  98830. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  98831. /**
  98832. * Remove an optimizer from the list of optimizers
  98833. * @param optimizer defines the optimizers to remove
  98834. * @returns the current material
  98835. */
  98836. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  98837. /**
  98838. * Add a new block to the list of output nodes
  98839. * @param node defines the node to add
  98840. * @returns the current material
  98841. */
  98842. addOutputNode(node: NodeMaterialBlock): this;
  98843. /**
  98844. * Remove a block from the list of root nodes
  98845. * @param node defines the node to remove
  98846. * @returns the current material
  98847. */
  98848. removeOutputNode(node: NodeMaterialBlock): this;
  98849. private _addVertexOutputNode;
  98850. private _removeVertexOutputNode;
  98851. private _addFragmentOutputNode;
  98852. private _removeFragmentOutputNode;
  98853. /**
  98854. * Specifies if the material will require alpha blending
  98855. * @returns a boolean specifying if alpha blending is needed
  98856. */
  98857. needAlphaBlending(): boolean;
  98858. /**
  98859. * Specifies if this material should be rendered in alpha test mode
  98860. * @returns a boolean specifying if an alpha test is needed.
  98861. */
  98862. needAlphaTesting(): boolean;
  98863. private _initializeBlock;
  98864. private _resetDualBlocks;
  98865. /**
  98866. * Remove a block from the current node material
  98867. * @param block defines the block to remove
  98868. */
  98869. removeBlock(block: NodeMaterialBlock): void;
  98870. /**
  98871. * Build the material and generates the inner effect
  98872. * @param verbose defines if the build should log activity
  98873. */
  98874. build(verbose?: boolean): void;
  98875. /**
  98876. * Runs an otpimization phase to try to improve the shader code
  98877. */
  98878. optimize(): void;
  98879. private _prepareDefinesForAttributes;
  98880. /**
  98881. * Create a post process from the material
  98882. * @param camera The camera to apply the render pass to.
  98883. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  98884. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  98885. * @param engine The engine which the post process will be applied. (default: current engine)
  98886. * @param reusable If the post process can be reused on the same frame. (default: false)
  98887. * @param textureType Type of textures used when performing the post process. (default: 0)
  98888. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  98889. * @returns the post process created
  98890. */
  98891. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  98892. /**
  98893. * Create the post process effect from the material
  98894. * @param postProcess The post process to create the effect for
  98895. */
  98896. createEffectForPostProcess(postProcess: PostProcess): void;
  98897. private _createEffectForPostProcess;
  98898. /**
  98899. * Create a new procedural texture based on this node material
  98900. * @param size defines the size of the texture
  98901. * @param scene defines the hosting scene
  98902. * @returns the new procedural texture attached to this node material
  98903. */
  98904. createProceduralTexture(size: number | {
  98905. width: number;
  98906. height: number;
  98907. layers?: number;
  98908. }, scene: Scene): Nullable<ProceduralTexture>;
  98909. private _createEffectForParticles;
  98910. private _checkInternals;
  98911. /**
  98912. * Create the effect to be used as the custom effect for a particle system
  98913. * @param particleSystem Particle system to create the effect for
  98914. * @param onCompiled defines a function to call when the effect creation is successful
  98915. * @param onError defines a function to call when the effect creation has failed
  98916. */
  98917. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  98918. private _processDefines;
  98919. /**
  98920. * Get if the submesh is ready to be used and all its information available.
  98921. * Child classes can use it to update shaders
  98922. * @param mesh defines the mesh to check
  98923. * @param subMesh defines which submesh to check
  98924. * @param useInstances specifies that instances should be used
  98925. * @returns a boolean indicating that the submesh is ready or not
  98926. */
  98927. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98928. /**
  98929. * Get a string representing the shaders built by the current node graph
  98930. */
  98931. get compiledShaders(): string;
  98932. /**
  98933. * Binds the world matrix to the material
  98934. * @param world defines the world transformation matrix
  98935. */
  98936. bindOnlyWorldMatrix(world: Matrix): void;
  98937. /**
  98938. * Binds the submesh to this material by preparing the effect and shader to draw
  98939. * @param world defines the world transformation matrix
  98940. * @param mesh defines the mesh containing the submesh
  98941. * @param subMesh defines the submesh to bind the material to
  98942. */
  98943. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98944. /**
  98945. * Gets the active textures from the material
  98946. * @returns an array of textures
  98947. */
  98948. getActiveTextures(): BaseTexture[];
  98949. /**
  98950. * Gets the list of texture blocks
  98951. * @returns an array of texture blocks
  98952. */
  98953. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  98954. /**
  98955. * Specifies if the material uses a texture
  98956. * @param texture defines the texture to check against the material
  98957. * @returns a boolean specifying if the material uses the texture
  98958. */
  98959. hasTexture(texture: BaseTexture): boolean;
  98960. /**
  98961. * Disposes the material
  98962. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98963. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98964. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  98965. */
  98966. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  98967. /** Creates the node editor window. */
  98968. private _createNodeEditor;
  98969. /**
  98970. * Launch the node material editor
  98971. * @param config Define the configuration of the editor
  98972. * @return a promise fulfilled when the node editor is visible
  98973. */
  98974. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  98975. /**
  98976. * Clear the current material
  98977. */
  98978. clear(): void;
  98979. /**
  98980. * Clear the current material and set it to a default state
  98981. */
  98982. setToDefault(): void;
  98983. /**
  98984. * Clear the current material and set it to a default state for post process
  98985. */
  98986. setToDefaultPostProcess(): void;
  98987. /**
  98988. * Clear the current material and set it to a default state for procedural texture
  98989. */
  98990. setToDefaultProceduralTexture(): void;
  98991. /**
  98992. * Clear the current material and set it to a default state for particle
  98993. */
  98994. setToDefaultParticle(): void;
  98995. /**
  98996. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  98997. * @param url defines the url to load from
  98998. * @returns a promise that will fullfil when the material is fully loaded
  98999. */
  99000. loadAsync(url: string): Promise<void>;
  99001. private _gatherBlocks;
  99002. /**
  99003. * Generate a string containing the code declaration required to create an equivalent of this material
  99004. * @returns a string
  99005. */
  99006. generateCode(): string;
  99007. /**
  99008. * Serializes this material in a JSON representation
  99009. * @returns the serialized material object
  99010. */
  99011. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  99012. private _restoreConnections;
  99013. /**
  99014. * Clear the current graph and load a new one from a serialization object
  99015. * @param source defines the JSON representation of the material
  99016. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99017. * @param merge defines whether or not the source must be merged or replace the current content
  99018. */
  99019. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  99020. /**
  99021. * Makes a duplicate of the current material.
  99022. * @param name - name to use for the new material.
  99023. */
  99024. clone(name: string): NodeMaterial;
  99025. /**
  99026. * Creates a node material from parsed material data
  99027. * @param source defines the JSON representation of the material
  99028. * @param scene defines the hosting scene
  99029. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99030. * @returns a new node material
  99031. */
  99032. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  99033. /**
  99034. * Creates a node material from a snippet saved in a remote file
  99035. * @param name defines the name of the material to create
  99036. * @param url defines the url to load from
  99037. * @param scene defines the hosting scene
  99038. * @returns a promise that will resolve to the new node material
  99039. */
  99040. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  99041. /**
  99042. * Creates a node material from a snippet saved by the node material editor
  99043. * @param snippetId defines the snippet to load
  99044. * @param scene defines the hosting scene
  99045. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99046. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  99047. * @returns a promise that will resolve to the new node material
  99048. */
  99049. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  99050. /**
  99051. * Creates a new node material set to default basic configuration
  99052. * @param name defines the name of the material
  99053. * @param scene defines the hosting scene
  99054. * @returns a new NodeMaterial
  99055. */
  99056. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  99057. }
  99058. }
  99059. declare module BABYLON {
  99060. interface ThinEngine {
  99061. /**
  99062. * Unbind a list of render target textures from the webGL context
  99063. * This is used only when drawBuffer extension or webGL2 are active
  99064. * @param textures defines the render target textures to unbind
  99065. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  99066. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  99067. */
  99068. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  99069. /**
  99070. * Create a multi render target texture
  99071. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  99072. * @param size defines the size of the texture
  99073. * @param options defines the creation options
  99074. * @returns the cube texture as an InternalTexture
  99075. */
  99076. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  99077. /**
  99078. * Update the sample count for a given multiple render target texture
  99079. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  99080. * @param textures defines the textures to update
  99081. * @param samples defines the sample count to set
  99082. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  99083. */
  99084. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  99085. /**
  99086. * Select a subsets of attachments to draw to.
  99087. * @param attachments gl attachments
  99088. */
  99089. bindAttachments(attachments: number[]): void;
  99090. /**
  99091. * Creates a layout object to draw/clear on specific textures in a MRT
  99092. * @param textureStatus textureStatus[i] indicates if the i-th is active
  99093. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  99094. */
  99095. buildTextureLayout(textureStatus: boolean[]): number[];
  99096. /**
  99097. * Restores the webgl state to only draw on the main color attachment
  99098. */
  99099. restoreSingleAttachment(): void;
  99100. }
  99101. }
  99102. declare module BABYLON {
  99103. /**
  99104. * Creation options of the multi render target texture.
  99105. */
  99106. export interface IMultiRenderTargetOptions {
  99107. /**
  99108. * Define if the texture needs to create mip maps after render.
  99109. */
  99110. generateMipMaps?: boolean;
  99111. /**
  99112. * Define the types of all the draw buffers we want to create
  99113. */
  99114. types?: number[];
  99115. /**
  99116. * Define the sampling modes of all the draw buffers we want to create
  99117. */
  99118. samplingModes?: number[];
  99119. /**
  99120. * Define if a depth buffer is required
  99121. */
  99122. generateDepthBuffer?: boolean;
  99123. /**
  99124. * Define if a stencil buffer is required
  99125. */
  99126. generateStencilBuffer?: boolean;
  99127. /**
  99128. * Define if a depth texture is required instead of a depth buffer
  99129. */
  99130. generateDepthTexture?: boolean;
  99131. /**
  99132. * Define the number of desired draw buffers
  99133. */
  99134. textureCount?: number;
  99135. /**
  99136. * Define if aspect ratio should be adapted to the texture or stay the scene one
  99137. */
  99138. doNotChangeAspectRatio?: boolean;
  99139. /**
  99140. * Define the default type of the buffers we are creating
  99141. */
  99142. defaultType?: number;
  99143. }
  99144. /**
  99145. * A multi render target, like a render target provides the ability to render to a texture.
  99146. * Unlike the render target, it can render to several draw buffers in one draw.
  99147. * This is specially interesting in deferred rendering or for any effects requiring more than
  99148. * just one color from a single pass.
  99149. */
  99150. export class MultiRenderTarget extends RenderTargetTexture {
  99151. private _internalTextures;
  99152. private _textures;
  99153. private _multiRenderTargetOptions;
  99154. private _count;
  99155. /**
  99156. * Get if draw buffers are currently supported by the used hardware and browser.
  99157. */
  99158. get isSupported(): boolean;
  99159. /**
  99160. * Get the list of textures generated by the multi render target.
  99161. */
  99162. get textures(): Texture[];
  99163. /**
  99164. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  99165. */
  99166. get count(): number;
  99167. /**
  99168. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  99169. */
  99170. get depthTexture(): Texture;
  99171. /**
  99172. * Set the wrapping mode on U of all the textures we are rendering to.
  99173. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  99174. */
  99175. set wrapU(wrap: number);
  99176. /**
  99177. * Set the wrapping mode on V of all the textures we are rendering to.
  99178. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  99179. */
  99180. set wrapV(wrap: number);
  99181. /**
  99182. * Instantiate a new multi render target texture.
  99183. * A multi render target, like a render target provides the ability to render to a texture.
  99184. * Unlike the render target, it can render to several draw buffers in one draw.
  99185. * This is specially interesting in deferred rendering or for any effects requiring more than
  99186. * just one color from a single pass.
  99187. * @param name Define the name of the texture
  99188. * @param size Define the size of the buffers to render to
  99189. * @param count Define the number of target we are rendering into
  99190. * @param scene Define the scene the texture belongs to
  99191. * @param options Define the options used to create the multi render target
  99192. */
  99193. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  99194. private _initTypes;
  99195. /** @hidden */
  99196. _rebuild(forceFullRebuild?: boolean): void;
  99197. private _createInternalTextures;
  99198. private _createTextures;
  99199. /**
  99200. * Replaces a texture within the MRT.
  99201. * @param texture The new texture to insert in the MRT
  99202. * @param index The index of the texture to replace
  99203. */
  99204. replaceTexture(texture: Texture, index: number): void;
  99205. /**
  99206. * Define the number of samples used if MSAA is enabled.
  99207. */
  99208. get samples(): number;
  99209. set samples(value: number);
  99210. /**
  99211. * Resize all the textures in the multi render target.
  99212. * Be careful as it will recreate all the data in the new texture.
  99213. * @param size Define the new size
  99214. */
  99215. resize(size: any): void;
  99216. /**
  99217. * Changes the number of render targets in this MRT
  99218. * Be careful as it will recreate all the data in the new texture.
  99219. * @param count new texture count
  99220. * @param options Specifies texture types and sampling modes for new textures
  99221. */
  99222. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  99223. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  99224. /**
  99225. * Dispose the render targets and their associated resources
  99226. */
  99227. dispose(): void;
  99228. /**
  99229. * Release all the underlying texture used as draw buffers.
  99230. */
  99231. releaseInternalTextures(): void;
  99232. }
  99233. }
  99234. declare module BABYLON {
  99235. /** @hidden */
  99236. export var imageProcessingPixelShader: {
  99237. name: string;
  99238. shader: string;
  99239. };
  99240. }
  99241. declare module BABYLON {
  99242. /**
  99243. * ImageProcessingPostProcess
  99244. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  99245. */
  99246. export class ImageProcessingPostProcess extends PostProcess {
  99247. /**
  99248. * Default configuration related to image processing available in the PBR Material.
  99249. */
  99250. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99251. /**
  99252. * Gets the image processing configuration used either in this material.
  99253. */
  99254. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99255. /**
  99256. * Sets the Default image processing configuration used either in the this material.
  99257. *
  99258. * If sets to null, the scene one is in use.
  99259. */
  99260. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99261. /**
  99262. * Keep track of the image processing observer to allow dispose and replace.
  99263. */
  99264. private _imageProcessingObserver;
  99265. /**
  99266. * Attaches a new image processing configuration to the PBR Material.
  99267. * @param configuration
  99268. */
  99269. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  99270. /**
  99271. * If the post process is supported.
  99272. */
  99273. get isSupported(): boolean;
  99274. /**
  99275. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99276. */
  99277. get colorCurves(): Nullable<ColorCurves>;
  99278. /**
  99279. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99280. */
  99281. set colorCurves(value: Nullable<ColorCurves>);
  99282. /**
  99283. * Gets wether the color curves effect is enabled.
  99284. */
  99285. get colorCurvesEnabled(): boolean;
  99286. /**
  99287. * Sets wether the color curves effect is enabled.
  99288. */
  99289. set colorCurvesEnabled(value: boolean);
  99290. /**
  99291. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99292. */
  99293. get colorGradingTexture(): Nullable<BaseTexture>;
  99294. /**
  99295. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99296. */
  99297. set colorGradingTexture(value: Nullable<BaseTexture>);
  99298. /**
  99299. * Gets wether the color grading effect is enabled.
  99300. */
  99301. get colorGradingEnabled(): boolean;
  99302. /**
  99303. * Gets wether the color grading effect is enabled.
  99304. */
  99305. set colorGradingEnabled(value: boolean);
  99306. /**
  99307. * Gets exposure used in the effect.
  99308. */
  99309. get exposure(): number;
  99310. /**
  99311. * Sets exposure used in the effect.
  99312. */
  99313. set exposure(value: number);
  99314. /**
  99315. * Gets wether tonemapping is enabled or not.
  99316. */
  99317. get toneMappingEnabled(): boolean;
  99318. /**
  99319. * Sets wether tonemapping is enabled or not
  99320. */
  99321. set toneMappingEnabled(value: boolean);
  99322. /**
  99323. * Gets the type of tone mapping effect.
  99324. */
  99325. get toneMappingType(): number;
  99326. /**
  99327. * Sets the type of tone mapping effect.
  99328. */
  99329. set toneMappingType(value: number);
  99330. /**
  99331. * Gets contrast used in the effect.
  99332. */
  99333. get contrast(): number;
  99334. /**
  99335. * Sets contrast used in the effect.
  99336. */
  99337. set contrast(value: number);
  99338. /**
  99339. * Gets Vignette stretch size.
  99340. */
  99341. get vignetteStretch(): number;
  99342. /**
  99343. * Sets Vignette stretch size.
  99344. */
  99345. set vignetteStretch(value: number);
  99346. /**
  99347. * Gets Vignette centre X Offset.
  99348. */
  99349. get vignetteCentreX(): number;
  99350. /**
  99351. * Sets Vignette centre X Offset.
  99352. */
  99353. set vignetteCentreX(value: number);
  99354. /**
  99355. * Gets Vignette centre Y Offset.
  99356. */
  99357. get vignetteCentreY(): number;
  99358. /**
  99359. * Sets Vignette centre Y Offset.
  99360. */
  99361. set vignetteCentreY(value: number);
  99362. /**
  99363. * Gets Vignette weight or intensity of the vignette effect.
  99364. */
  99365. get vignetteWeight(): number;
  99366. /**
  99367. * Sets Vignette weight or intensity of the vignette effect.
  99368. */
  99369. set vignetteWeight(value: number);
  99370. /**
  99371. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99372. * if vignetteEnabled is set to true.
  99373. */
  99374. get vignetteColor(): Color4;
  99375. /**
  99376. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99377. * if vignetteEnabled is set to true.
  99378. */
  99379. set vignetteColor(value: Color4);
  99380. /**
  99381. * Gets Camera field of view used by the Vignette effect.
  99382. */
  99383. get vignetteCameraFov(): number;
  99384. /**
  99385. * Sets Camera field of view used by the Vignette effect.
  99386. */
  99387. set vignetteCameraFov(value: number);
  99388. /**
  99389. * Gets the vignette blend mode allowing different kind of effect.
  99390. */
  99391. get vignetteBlendMode(): number;
  99392. /**
  99393. * Sets the vignette blend mode allowing different kind of effect.
  99394. */
  99395. set vignetteBlendMode(value: number);
  99396. /**
  99397. * Gets wether the vignette effect is enabled.
  99398. */
  99399. get vignetteEnabled(): boolean;
  99400. /**
  99401. * Sets wether the vignette effect is enabled.
  99402. */
  99403. set vignetteEnabled(value: boolean);
  99404. private _fromLinearSpace;
  99405. /**
  99406. * Gets wether the input of the processing is in Gamma or Linear Space.
  99407. */
  99408. get fromLinearSpace(): boolean;
  99409. /**
  99410. * Sets wether the input of the processing is in Gamma or Linear Space.
  99411. */
  99412. set fromLinearSpace(value: boolean);
  99413. /**
  99414. * Defines cache preventing GC.
  99415. */
  99416. private _defines;
  99417. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  99418. /**
  99419. * "ImageProcessingPostProcess"
  99420. * @returns "ImageProcessingPostProcess"
  99421. */
  99422. getClassName(): string;
  99423. /**
  99424. * @hidden
  99425. */
  99426. _updateParameters(): void;
  99427. dispose(camera?: Camera): void;
  99428. }
  99429. }
  99430. declare module BABYLON {
  99431. /**
  99432. * Interface for defining prepass effects in the prepass post-process pipeline
  99433. */
  99434. export interface PrePassEffectConfiguration {
  99435. /**
  99436. * Name of the effect
  99437. */
  99438. name: string;
  99439. /**
  99440. * Post process to attach for this effect
  99441. */
  99442. postProcess?: PostProcess;
  99443. /**
  99444. * Textures required in the MRT
  99445. */
  99446. texturesRequired: number[];
  99447. /**
  99448. * Is the effect enabled
  99449. */
  99450. enabled: boolean;
  99451. /**
  99452. * Disposes the effect configuration
  99453. */
  99454. dispose?: () => void;
  99455. /**
  99456. * Creates the associated post process
  99457. */
  99458. createPostProcess?: () => PostProcess;
  99459. }
  99460. }
  99461. declare module BABYLON {
  99462. /**
  99463. * Options to be used when creating a FresnelParameters.
  99464. */
  99465. export type IFresnelParametersCreationOptions = {
  99466. /**
  99467. * Define the color used on edges (grazing angle)
  99468. */
  99469. leftColor?: Color3;
  99470. /**
  99471. * Define the color used on center
  99472. */
  99473. rightColor?: Color3;
  99474. /**
  99475. * Define bias applied to computed fresnel term
  99476. */
  99477. bias?: number;
  99478. /**
  99479. * Defined the power exponent applied to fresnel term
  99480. */
  99481. power?: number;
  99482. /**
  99483. * Define if the fresnel effect is enable or not.
  99484. */
  99485. isEnabled?: boolean;
  99486. };
  99487. /**
  99488. * Serialized format for FresnelParameters.
  99489. */
  99490. export type IFresnelParametersSerialized = {
  99491. /**
  99492. * Define the color used on edges (grazing angle) [as an array]
  99493. */
  99494. leftColor: number[];
  99495. /**
  99496. * Define the color used on center [as an array]
  99497. */
  99498. rightColor: number[];
  99499. /**
  99500. * Define bias applied to computed fresnel term
  99501. */
  99502. bias: number;
  99503. /**
  99504. * Defined the power exponent applied to fresnel term
  99505. */
  99506. power?: number;
  99507. /**
  99508. * Define if the fresnel effect is enable or not.
  99509. */
  99510. isEnabled: boolean;
  99511. };
  99512. /**
  99513. * This represents all the required information to add a fresnel effect on a material:
  99514. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99515. */
  99516. export class FresnelParameters {
  99517. private _isEnabled;
  99518. /**
  99519. * Define if the fresnel effect is enable or not.
  99520. */
  99521. get isEnabled(): boolean;
  99522. set isEnabled(value: boolean);
  99523. /**
  99524. * Define the color used on edges (grazing angle)
  99525. */
  99526. leftColor: Color3;
  99527. /**
  99528. * Define the color used on center
  99529. */
  99530. rightColor: Color3;
  99531. /**
  99532. * Define bias applied to computed fresnel term
  99533. */
  99534. bias: number;
  99535. /**
  99536. * Defined the power exponent applied to fresnel term
  99537. */
  99538. power: number;
  99539. /**
  99540. * Creates a new FresnelParameters object.
  99541. *
  99542. * @param options provide your own settings to optionally to override defaults
  99543. */
  99544. constructor(options?: IFresnelParametersCreationOptions);
  99545. /**
  99546. * Clones the current fresnel and its valuues
  99547. * @returns a clone fresnel configuration
  99548. */
  99549. clone(): FresnelParameters;
  99550. /**
  99551. * Determines equality between FresnelParameters objects
  99552. * @param otherFresnelParameters defines the second operand
  99553. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  99554. */
  99555. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  99556. /**
  99557. * Serializes the current fresnel parameters to a JSON representation.
  99558. * @return the JSON serialization
  99559. */
  99560. serialize(): IFresnelParametersSerialized;
  99561. /**
  99562. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99563. * @param parsedFresnelParameters Define the JSON representation
  99564. * @returns the parsed parameters
  99565. */
  99566. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  99567. }
  99568. }
  99569. declare module BABYLON {
  99570. /**
  99571. * This groups all the flags used to control the materials channel.
  99572. */
  99573. export class MaterialFlags {
  99574. private static _DiffuseTextureEnabled;
  99575. /**
  99576. * Are diffuse textures enabled in the application.
  99577. */
  99578. static get DiffuseTextureEnabled(): boolean;
  99579. static set DiffuseTextureEnabled(value: boolean);
  99580. private static _DetailTextureEnabled;
  99581. /**
  99582. * Are detail textures enabled in the application.
  99583. */
  99584. static get DetailTextureEnabled(): boolean;
  99585. static set DetailTextureEnabled(value: boolean);
  99586. private static _AmbientTextureEnabled;
  99587. /**
  99588. * Are ambient textures enabled in the application.
  99589. */
  99590. static get AmbientTextureEnabled(): boolean;
  99591. static set AmbientTextureEnabled(value: boolean);
  99592. private static _OpacityTextureEnabled;
  99593. /**
  99594. * Are opacity textures enabled in the application.
  99595. */
  99596. static get OpacityTextureEnabled(): boolean;
  99597. static set OpacityTextureEnabled(value: boolean);
  99598. private static _ReflectionTextureEnabled;
  99599. /**
  99600. * Are reflection textures enabled in the application.
  99601. */
  99602. static get ReflectionTextureEnabled(): boolean;
  99603. static set ReflectionTextureEnabled(value: boolean);
  99604. private static _EmissiveTextureEnabled;
  99605. /**
  99606. * Are emissive textures enabled in the application.
  99607. */
  99608. static get EmissiveTextureEnabled(): boolean;
  99609. static set EmissiveTextureEnabled(value: boolean);
  99610. private static _SpecularTextureEnabled;
  99611. /**
  99612. * Are specular textures enabled in the application.
  99613. */
  99614. static get SpecularTextureEnabled(): boolean;
  99615. static set SpecularTextureEnabled(value: boolean);
  99616. private static _BumpTextureEnabled;
  99617. /**
  99618. * Are bump textures enabled in the application.
  99619. */
  99620. static get BumpTextureEnabled(): boolean;
  99621. static set BumpTextureEnabled(value: boolean);
  99622. private static _LightmapTextureEnabled;
  99623. /**
  99624. * Are lightmap textures enabled in the application.
  99625. */
  99626. static get LightmapTextureEnabled(): boolean;
  99627. static set LightmapTextureEnabled(value: boolean);
  99628. private static _RefractionTextureEnabled;
  99629. /**
  99630. * Are refraction textures enabled in the application.
  99631. */
  99632. static get RefractionTextureEnabled(): boolean;
  99633. static set RefractionTextureEnabled(value: boolean);
  99634. private static _ColorGradingTextureEnabled;
  99635. /**
  99636. * Are color grading textures enabled in the application.
  99637. */
  99638. static get ColorGradingTextureEnabled(): boolean;
  99639. static set ColorGradingTextureEnabled(value: boolean);
  99640. private static _FresnelEnabled;
  99641. /**
  99642. * Are fresnels enabled in the application.
  99643. */
  99644. static get FresnelEnabled(): boolean;
  99645. static set FresnelEnabled(value: boolean);
  99646. private static _ClearCoatTextureEnabled;
  99647. /**
  99648. * Are clear coat textures enabled in the application.
  99649. */
  99650. static get ClearCoatTextureEnabled(): boolean;
  99651. static set ClearCoatTextureEnabled(value: boolean);
  99652. private static _ClearCoatBumpTextureEnabled;
  99653. /**
  99654. * Are clear coat bump textures enabled in the application.
  99655. */
  99656. static get ClearCoatBumpTextureEnabled(): boolean;
  99657. static set ClearCoatBumpTextureEnabled(value: boolean);
  99658. private static _ClearCoatTintTextureEnabled;
  99659. /**
  99660. * Are clear coat tint textures enabled in the application.
  99661. */
  99662. static get ClearCoatTintTextureEnabled(): boolean;
  99663. static set ClearCoatTintTextureEnabled(value: boolean);
  99664. private static _SheenTextureEnabled;
  99665. /**
  99666. * Are sheen textures enabled in the application.
  99667. */
  99668. static get SheenTextureEnabled(): boolean;
  99669. static set SheenTextureEnabled(value: boolean);
  99670. private static _AnisotropicTextureEnabled;
  99671. /**
  99672. * Are anisotropic textures enabled in the application.
  99673. */
  99674. static get AnisotropicTextureEnabled(): boolean;
  99675. static set AnisotropicTextureEnabled(value: boolean);
  99676. private static _ThicknessTextureEnabled;
  99677. /**
  99678. * Are thickness textures enabled in the application.
  99679. */
  99680. static get ThicknessTextureEnabled(): boolean;
  99681. static set ThicknessTextureEnabled(value: boolean);
  99682. }
  99683. }
  99684. declare module BABYLON {
  99685. /** @hidden */
  99686. export var defaultFragmentDeclaration: {
  99687. name: string;
  99688. shader: string;
  99689. };
  99690. }
  99691. declare module BABYLON {
  99692. /** @hidden */
  99693. export var defaultUboDeclaration: {
  99694. name: string;
  99695. shader: string;
  99696. };
  99697. }
  99698. declare module BABYLON {
  99699. /** @hidden */
  99700. export var prePassDeclaration: {
  99701. name: string;
  99702. shader: string;
  99703. };
  99704. }
  99705. declare module BABYLON {
  99706. /** @hidden */
  99707. export var lightFragmentDeclaration: {
  99708. name: string;
  99709. shader: string;
  99710. };
  99711. }
  99712. declare module BABYLON {
  99713. /** @hidden */
  99714. export var lightUboDeclaration: {
  99715. name: string;
  99716. shader: string;
  99717. };
  99718. }
  99719. declare module BABYLON {
  99720. /** @hidden */
  99721. export var lightsFragmentFunctions: {
  99722. name: string;
  99723. shader: string;
  99724. };
  99725. }
  99726. declare module BABYLON {
  99727. /** @hidden */
  99728. export var shadowsFragmentFunctions: {
  99729. name: string;
  99730. shader: string;
  99731. };
  99732. }
  99733. declare module BABYLON {
  99734. /** @hidden */
  99735. export var fresnelFunction: {
  99736. name: string;
  99737. shader: string;
  99738. };
  99739. }
  99740. declare module BABYLON {
  99741. /** @hidden */
  99742. export var bumpFragmentMainFunctions: {
  99743. name: string;
  99744. shader: string;
  99745. };
  99746. }
  99747. declare module BABYLON {
  99748. /** @hidden */
  99749. export var bumpFragmentFunctions: {
  99750. name: string;
  99751. shader: string;
  99752. };
  99753. }
  99754. declare module BABYLON {
  99755. /** @hidden */
  99756. export var logDepthDeclaration: {
  99757. name: string;
  99758. shader: string;
  99759. };
  99760. }
  99761. declare module BABYLON {
  99762. /** @hidden */
  99763. export var fogFragmentDeclaration: {
  99764. name: string;
  99765. shader: string;
  99766. };
  99767. }
  99768. declare module BABYLON {
  99769. /** @hidden */
  99770. export var bumpFragment: {
  99771. name: string;
  99772. shader: string;
  99773. };
  99774. }
  99775. declare module BABYLON {
  99776. /** @hidden */
  99777. export var depthPrePass: {
  99778. name: string;
  99779. shader: string;
  99780. };
  99781. }
  99782. declare module BABYLON {
  99783. /** @hidden */
  99784. export var lightFragment: {
  99785. name: string;
  99786. shader: string;
  99787. };
  99788. }
  99789. declare module BABYLON {
  99790. /** @hidden */
  99791. export var logDepthFragment: {
  99792. name: string;
  99793. shader: string;
  99794. };
  99795. }
  99796. declare module BABYLON {
  99797. /** @hidden */
  99798. export var fogFragment: {
  99799. name: string;
  99800. shader: string;
  99801. };
  99802. }
  99803. declare module BABYLON {
  99804. /** @hidden */
  99805. export var defaultPixelShader: {
  99806. name: string;
  99807. shader: string;
  99808. };
  99809. }
  99810. declare module BABYLON {
  99811. /** @hidden */
  99812. export var defaultVertexDeclaration: {
  99813. name: string;
  99814. shader: string;
  99815. };
  99816. }
  99817. declare module BABYLON {
  99818. /** @hidden */
  99819. export var bonesDeclaration: {
  99820. name: string;
  99821. shader: string;
  99822. };
  99823. }
  99824. declare module BABYLON {
  99825. /** @hidden */
  99826. export var instancesDeclaration: {
  99827. name: string;
  99828. shader: string;
  99829. };
  99830. }
  99831. declare module BABYLON {
  99832. /** @hidden */
  99833. export var prePassVertexDeclaration: {
  99834. name: string;
  99835. shader: string;
  99836. };
  99837. }
  99838. declare module BABYLON {
  99839. /** @hidden */
  99840. export var bumpVertexDeclaration: {
  99841. name: string;
  99842. shader: string;
  99843. };
  99844. }
  99845. declare module BABYLON {
  99846. /** @hidden */
  99847. export var fogVertexDeclaration: {
  99848. name: string;
  99849. shader: string;
  99850. };
  99851. }
  99852. declare module BABYLON {
  99853. /** @hidden */
  99854. export var morphTargetsVertexGlobalDeclaration: {
  99855. name: string;
  99856. shader: string;
  99857. };
  99858. }
  99859. declare module BABYLON {
  99860. /** @hidden */
  99861. export var morphTargetsVertexDeclaration: {
  99862. name: string;
  99863. shader: string;
  99864. };
  99865. }
  99866. declare module BABYLON {
  99867. /** @hidden */
  99868. export var morphTargetsVertex: {
  99869. name: string;
  99870. shader: string;
  99871. };
  99872. }
  99873. declare module BABYLON {
  99874. /** @hidden */
  99875. export var instancesVertex: {
  99876. name: string;
  99877. shader: string;
  99878. };
  99879. }
  99880. declare module BABYLON {
  99881. /** @hidden */
  99882. export var bonesVertex: {
  99883. name: string;
  99884. shader: string;
  99885. };
  99886. }
  99887. declare module BABYLON {
  99888. /** @hidden */
  99889. export var prePassVertex: {
  99890. name: string;
  99891. shader: string;
  99892. };
  99893. }
  99894. declare module BABYLON {
  99895. /** @hidden */
  99896. export var bumpVertex: {
  99897. name: string;
  99898. shader: string;
  99899. };
  99900. }
  99901. declare module BABYLON {
  99902. /** @hidden */
  99903. export var fogVertex: {
  99904. name: string;
  99905. shader: string;
  99906. };
  99907. }
  99908. declare module BABYLON {
  99909. /** @hidden */
  99910. export var shadowsVertex: {
  99911. name: string;
  99912. shader: string;
  99913. };
  99914. }
  99915. declare module BABYLON {
  99916. /** @hidden */
  99917. export var pointCloudVertex: {
  99918. name: string;
  99919. shader: string;
  99920. };
  99921. }
  99922. declare module BABYLON {
  99923. /** @hidden */
  99924. export var logDepthVertex: {
  99925. name: string;
  99926. shader: string;
  99927. };
  99928. }
  99929. declare module BABYLON {
  99930. /** @hidden */
  99931. export var defaultVertexShader: {
  99932. name: string;
  99933. shader: string;
  99934. };
  99935. }
  99936. declare module BABYLON {
  99937. /**
  99938. * @hidden
  99939. */
  99940. export interface IMaterialDetailMapDefines {
  99941. DETAIL: boolean;
  99942. DETAILDIRECTUV: number;
  99943. DETAIL_NORMALBLENDMETHOD: number;
  99944. /** @hidden */
  99945. _areTexturesDirty: boolean;
  99946. }
  99947. /**
  99948. * Define the code related to the detail map parameters of a material
  99949. *
  99950. * Inspired from:
  99951. * 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
  99952. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  99953. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  99954. */
  99955. export class DetailMapConfiguration {
  99956. private _texture;
  99957. /**
  99958. * The detail texture of the material.
  99959. */
  99960. texture: Nullable<BaseTexture>;
  99961. /**
  99962. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  99963. * Bigger values mean stronger blending
  99964. */
  99965. diffuseBlendLevel: number;
  99966. /**
  99967. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  99968. * Bigger values mean stronger blending. Only used with PBR materials
  99969. */
  99970. roughnessBlendLevel: number;
  99971. /**
  99972. * Defines how strong the bump effect from the detail map is
  99973. * Bigger values mean stronger effect
  99974. */
  99975. bumpLevel: number;
  99976. private _normalBlendMethod;
  99977. /**
  99978. * The method used to blend the bump and detail normals together
  99979. */
  99980. normalBlendMethod: number;
  99981. private _isEnabled;
  99982. /**
  99983. * Enable or disable the detail map on this material
  99984. */
  99985. isEnabled: boolean;
  99986. /** @hidden */
  99987. private _internalMarkAllSubMeshesAsTexturesDirty;
  99988. /** @hidden */
  99989. _markAllSubMeshesAsTexturesDirty(): void;
  99990. /**
  99991. * Instantiate a new detail map
  99992. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  99993. */
  99994. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  99995. /**
  99996. * Gets whether the submesh is ready to be used or not.
  99997. * @param defines the list of "defines" to update.
  99998. * @param scene defines the scene the material belongs to.
  99999. * @returns - boolean indicating that the submesh is ready or not.
  100000. */
  100001. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  100002. /**
  100003. * Update the defines for detail map usage
  100004. * @param defines the list of "defines" to update.
  100005. * @param scene defines the scene the material belongs to.
  100006. */
  100007. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  100008. /**
  100009. * Binds the material data.
  100010. * @param uniformBuffer defines the Uniform buffer to fill in.
  100011. * @param scene defines the scene the material belongs to.
  100012. * @param isFrozen defines whether the material is frozen or not.
  100013. */
  100014. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  100015. /**
  100016. * Checks to see if a texture is used in the material.
  100017. * @param texture - Base texture to use.
  100018. * @returns - Boolean specifying if a texture is used in the material.
  100019. */
  100020. hasTexture(texture: BaseTexture): boolean;
  100021. /**
  100022. * Returns an array of the actively used textures.
  100023. * @param activeTextures Array of BaseTextures
  100024. */
  100025. getActiveTextures(activeTextures: BaseTexture[]): void;
  100026. /**
  100027. * Returns the animatable textures.
  100028. * @param animatables Array of animatable textures.
  100029. */
  100030. getAnimatables(animatables: IAnimatable[]): void;
  100031. /**
  100032. * Disposes the resources of the material.
  100033. * @param forceDisposeTextures - Forces the disposal of all textures.
  100034. */
  100035. dispose(forceDisposeTextures?: boolean): void;
  100036. /**
  100037. * Get the current class name useful for serialization or dynamic coding.
  100038. * @returns "DetailMap"
  100039. */
  100040. getClassName(): string;
  100041. /**
  100042. * Add the required uniforms to the current list.
  100043. * @param uniforms defines the current uniform list.
  100044. */
  100045. static AddUniforms(uniforms: string[]): void;
  100046. /**
  100047. * Add the required samplers to the current list.
  100048. * @param samplers defines the current sampler list.
  100049. */
  100050. static AddSamplers(samplers: string[]): void;
  100051. /**
  100052. * Add the required uniforms to the current buffer.
  100053. * @param uniformBuffer defines the current uniform buffer.
  100054. */
  100055. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100056. /**
  100057. * Makes a duplicate of the current instance into another one.
  100058. * @param detailMap define the instance where to copy the info
  100059. */
  100060. copyTo(detailMap: DetailMapConfiguration): void;
  100061. /**
  100062. * Serializes this detail map instance
  100063. * @returns - An object with the serialized instance.
  100064. */
  100065. serialize(): any;
  100066. /**
  100067. * Parses a detail map setting from a serialized object.
  100068. * @param source - Serialized object.
  100069. * @param scene Defines the scene we are parsing for
  100070. * @param rootUrl Defines the rootUrl to load from
  100071. */
  100072. parse(source: any, scene: Scene, rootUrl: string): void;
  100073. }
  100074. }
  100075. declare module BABYLON {
  100076. /** @hidden */
  100077. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  100078. MAINUV1: boolean;
  100079. MAINUV2: boolean;
  100080. DIFFUSE: boolean;
  100081. DIFFUSEDIRECTUV: number;
  100082. DETAIL: boolean;
  100083. DETAILDIRECTUV: number;
  100084. DETAIL_NORMALBLENDMETHOD: number;
  100085. AMBIENT: boolean;
  100086. AMBIENTDIRECTUV: number;
  100087. OPACITY: boolean;
  100088. OPACITYDIRECTUV: number;
  100089. OPACITYRGB: boolean;
  100090. REFLECTION: boolean;
  100091. EMISSIVE: boolean;
  100092. EMISSIVEDIRECTUV: number;
  100093. SPECULAR: boolean;
  100094. SPECULARDIRECTUV: number;
  100095. BUMP: boolean;
  100096. BUMPDIRECTUV: number;
  100097. PARALLAX: boolean;
  100098. PARALLAXOCCLUSION: boolean;
  100099. SPECULAROVERALPHA: boolean;
  100100. CLIPPLANE: boolean;
  100101. CLIPPLANE2: boolean;
  100102. CLIPPLANE3: boolean;
  100103. CLIPPLANE4: boolean;
  100104. CLIPPLANE5: boolean;
  100105. CLIPPLANE6: boolean;
  100106. ALPHATEST: boolean;
  100107. DEPTHPREPASS: boolean;
  100108. ALPHAFROMDIFFUSE: boolean;
  100109. POINTSIZE: boolean;
  100110. FOG: boolean;
  100111. SPECULARTERM: boolean;
  100112. DIFFUSEFRESNEL: boolean;
  100113. OPACITYFRESNEL: boolean;
  100114. REFLECTIONFRESNEL: boolean;
  100115. REFRACTIONFRESNEL: boolean;
  100116. EMISSIVEFRESNEL: boolean;
  100117. FRESNEL: boolean;
  100118. NORMAL: boolean;
  100119. UV1: boolean;
  100120. UV2: boolean;
  100121. VERTEXCOLOR: boolean;
  100122. VERTEXALPHA: boolean;
  100123. NUM_BONE_INFLUENCERS: number;
  100124. BonesPerMesh: number;
  100125. BONETEXTURE: boolean;
  100126. BONES_VELOCITY_ENABLED: boolean;
  100127. INSTANCES: boolean;
  100128. THIN_INSTANCES: boolean;
  100129. GLOSSINESS: boolean;
  100130. ROUGHNESS: boolean;
  100131. EMISSIVEASILLUMINATION: boolean;
  100132. LINKEMISSIVEWITHDIFFUSE: boolean;
  100133. REFLECTIONFRESNELFROMSPECULAR: boolean;
  100134. LIGHTMAP: boolean;
  100135. LIGHTMAPDIRECTUV: number;
  100136. OBJECTSPACE_NORMALMAP: boolean;
  100137. USELIGHTMAPASSHADOWMAP: boolean;
  100138. REFLECTIONMAP_3D: boolean;
  100139. REFLECTIONMAP_SPHERICAL: boolean;
  100140. REFLECTIONMAP_PLANAR: boolean;
  100141. REFLECTIONMAP_CUBIC: boolean;
  100142. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  100143. REFLECTIONMAP_PROJECTION: boolean;
  100144. REFLECTIONMAP_SKYBOX: boolean;
  100145. REFLECTIONMAP_EXPLICIT: boolean;
  100146. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  100147. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  100148. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  100149. INVERTCUBICMAP: boolean;
  100150. LOGARITHMICDEPTH: boolean;
  100151. REFRACTION: boolean;
  100152. REFRACTIONMAP_3D: boolean;
  100153. REFLECTIONOVERALPHA: boolean;
  100154. TWOSIDEDLIGHTING: boolean;
  100155. SHADOWFLOAT: boolean;
  100156. MORPHTARGETS: boolean;
  100157. MORPHTARGETS_NORMAL: boolean;
  100158. MORPHTARGETS_TANGENT: boolean;
  100159. MORPHTARGETS_UV: boolean;
  100160. NUM_MORPH_INFLUENCERS: number;
  100161. NONUNIFORMSCALING: boolean;
  100162. PREMULTIPLYALPHA: boolean;
  100163. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  100164. ALPHABLEND: boolean;
  100165. PREPASS: boolean;
  100166. PREPASS_IRRADIANCE: boolean;
  100167. PREPASS_IRRADIANCE_INDEX: number;
  100168. PREPASS_ALBEDO: boolean;
  100169. PREPASS_ALBEDO_INDEX: number;
  100170. PREPASS_DEPTHNORMAL: boolean;
  100171. PREPASS_DEPTHNORMAL_INDEX: number;
  100172. PREPASS_POSITION: boolean;
  100173. PREPASS_POSITION_INDEX: number;
  100174. PREPASS_VELOCITY: boolean;
  100175. PREPASS_VELOCITY_INDEX: number;
  100176. PREPASS_REFLECTIVITY: boolean;
  100177. PREPASS_REFLECTIVITY_INDEX: number;
  100178. SCENE_MRT_COUNT: number;
  100179. RGBDLIGHTMAP: boolean;
  100180. RGBDREFLECTION: boolean;
  100181. RGBDREFRACTION: boolean;
  100182. IMAGEPROCESSING: boolean;
  100183. VIGNETTE: boolean;
  100184. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100185. VIGNETTEBLENDMODEOPAQUE: boolean;
  100186. TONEMAPPING: boolean;
  100187. TONEMAPPING_ACES: boolean;
  100188. CONTRAST: boolean;
  100189. COLORCURVES: boolean;
  100190. COLORGRADING: boolean;
  100191. COLORGRADING3D: boolean;
  100192. SAMPLER3DGREENDEPTH: boolean;
  100193. SAMPLER3DBGRMAP: boolean;
  100194. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100195. MULTIVIEW: boolean;
  100196. /**
  100197. * If the reflection texture on this material is in linear color space
  100198. * @hidden
  100199. */
  100200. IS_REFLECTION_LINEAR: boolean;
  100201. /**
  100202. * If the refraction texture on this material is in linear color space
  100203. * @hidden
  100204. */
  100205. IS_REFRACTION_LINEAR: boolean;
  100206. EXPOSURE: boolean;
  100207. constructor();
  100208. setReflectionMode(modeToEnable: string): void;
  100209. }
  100210. /**
  100211. * This is the default material used in Babylon. It is the best trade off between quality
  100212. * and performances.
  100213. * @see https://doc.babylonjs.com/babylon101/materials
  100214. */
  100215. export class StandardMaterial extends PushMaterial {
  100216. private _diffuseTexture;
  100217. /**
  100218. * The basic texture of the material as viewed under a light.
  100219. */
  100220. diffuseTexture: Nullable<BaseTexture>;
  100221. private _ambientTexture;
  100222. /**
  100223. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  100224. */
  100225. ambientTexture: Nullable<BaseTexture>;
  100226. private _opacityTexture;
  100227. /**
  100228. * Define the transparency of the material from a texture.
  100229. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  100230. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  100231. */
  100232. opacityTexture: Nullable<BaseTexture>;
  100233. private _reflectionTexture;
  100234. /**
  100235. * Define the texture used to display the reflection.
  100236. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100237. */
  100238. reflectionTexture: Nullable<BaseTexture>;
  100239. private _emissiveTexture;
  100240. /**
  100241. * Define texture of the material as if self lit.
  100242. * This will be mixed in the final result even in the absence of light.
  100243. */
  100244. emissiveTexture: Nullable<BaseTexture>;
  100245. private _specularTexture;
  100246. /**
  100247. * Define how the color and intensity of the highlight given by the light in the material.
  100248. */
  100249. specularTexture: Nullable<BaseTexture>;
  100250. private _bumpTexture;
  100251. /**
  100252. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  100253. * 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.
  100254. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  100255. */
  100256. bumpTexture: Nullable<BaseTexture>;
  100257. private _lightmapTexture;
  100258. /**
  100259. * Complex lighting can be computationally expensive to compute at runtime.
  100260. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  100261. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  100262. */
  100263. lightmapTexture: Nullable<BaseTexture>;
  100264. private _refractionTexture;
  100265. /**
  100266. * Define the texture used to display the refraction.
  100267. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100268. */
  100269. refractionTexture: Nullable<BaseTexture>;
  100270. /**
  100271. * The color of the material lit by the environmental background lighting.
  100272. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  100273. */
  100274. ambientColor: Color3;
  100275. /**
  100276. * The basic color of the material as viewed under a light.
  100277. */
  100278. diffuseColor: Color3;
  100279. /**
  100280. * Define how the color and intensity of the highlight given by the light in the material.
  100281. */
  100282. specularColor: Color3;
  100283. /**
  100284. * Define the color of the material as if self lit.
  100285. * This will be mixed in the final result even in the absence of light.
  100286. */
  100287. emissiveColor: Color3;
  100288. /**
  100289. * Defines how sharp are the highlights in the material.
  100290. * The bigger the value the sharper giving a more glossy feeling to the result.
  100291. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  100292. */
  100293. specularPower: number;
  100294. private _useAlphaFromDiffuseTexture;
  100295. /**
  100296. * Does the transparency come from the diffuse texture alpha channel.
  100297. */
  100298. useAlphaFromDiffuseTexture: boolean;
  100299. private _useEmissiveAsIllumination;
  100300. /**
  100301. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  100302. */
  100303. useEmissiveAsIllumination: boolean;
  100304. private _linkEmissiveWithDiffuse;
  100305. /**
  100306. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  100307. * the emissive level when the final color is close to one.
  100308. */
  100309. linkEmissiveWithDiffuse: boolean;
  100310. private _useSpecularOverAlpha;
  100311. /**
  100312. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  100313. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  100314. */
  100315. useSpecularOverAlpha: boolean;
  100316. private _useReflectionOverAlpha;
  100317. /**
  100318. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  100319. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  100320. */
  100321. useReflectionOverAlpha: boolean;
  100322. private _disableLighting;
  100323. /**
  100324. * Does lights from the scene impacts this material.
  100325. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  100326. */
  100327. disableLighting: boolean;
  100328. private _useObjectSpaceNormalMap;
  100329. /**
  100330. * Allows using an object space normal map (instead of tangent space).
  100331. */
  100332. useObjectSpaceNormalMap: boolean;
  100333. private _useParallax;
  100334. /**
  100335. * Is parallax enabled or not.
  100336. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  100337. */
  100338. useParallax: boolean;
  100339. private _useParallaxOcclusion;
  100340. /**
  100341. * Is parallax occlusion enabled or not.
  100342. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  100343. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  100344. */
  100345. useParallaxOcclusion: boolean;
  100346. /**
  100347. * 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.
  100348. */
  100349. parallaxScaleBias: number;
  100350. private _roughness;
  100351. /**
  100352. * Helps to define how blurry the reflections should appears in the material.
  100353. */
  100354. roughness: number;
  100355. /**
  100356. * In case of refraction, define the value of the index of refraction.
  100357. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100358. */
  100359. indexOfRefraction: number;
  100360. /**
  100361. * Invert the refraction texture alongside the y axis.
  100362. * It can be useful with procedural textures or probe for instance.
  100363. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100364. */
  100365. invertRefractionY: boolean;
  100366. /**
  100367. * Defines the alpha limits in alpha test mode.
  100368. */
  100369. alphaCutOff: number;
  100370. private _useLightmapAsShadowmap;
  100371. /**
  100372. * In case of light mapping, define whether the map contains light or shadow informations.
  100373. */
  100374. useLightmapAsShadowmap: boolean;
  100375. private _diffuseFresnelParameters;
  100376. /**
  100377. * Define the diffuse fresnel parameters of the material.
  100378. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100379. */
  100380. diffuseFresnelParameters: FresnelParameters;
  100381. private _opacityFresnelParameters;
  100382. /**
  100383. * Define the opacity fresnel parameters of the material.
  100384. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100385. */
  100386. opacityFresnelParameters: FresnelParameters;
  100387. private _reflectionFresnelParameters;
  100388. /**
  100389. * Define the reflection fresnel parameters of the material.
  100390. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100391. */
  100392. reflectionFresnelParameters: FresnelParameters;
  100393. private _refractionFresnelParameters;
  100394. /**
  100395. * Define the refraction fresnel parameters of the material.
  100396. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100397. */
  100398. refractionFresnelParameters: FresnelParameters;
  100399. private _emissiveFresnelParameters;
  100400. /**
  100401. * Define the emissive fresnel parameters of the material.
  100402. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100403. */
  100404. emissiveFresnelParameters: FresnelParameters;
  100405. private _useReflectionFresnelFromSpecular;
  100406. /**
  100407. * If true automatically deducts the fresnels values from the material specularity.
  100408. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100409. */
  100410. useReflectionFresnelFromSpecular: boolean;
  100411. private _useGlossinessFromSpecularMapAlpha;
  100412. /**
  100413. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  100414. */
  100415. useGlossinessFromSpecularMapAlpha: boolean;
  100416. private _maxSimultaneousLights;
  100417. /**
  100418. * Defines the maximum number of lights that can be used in the material
  100419. */
  100420. maxSimultaneousLights: number;
  100421. private _invertNormalMapX;
  100422. /**
  100423. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  100424. */
  100425. invertNormalMapX: boolean;
  100426. private _invertNormalMapY;
  100427. /**
  100428. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  100429. */
  100430. invertNormalMapY: boolean;
  100431. private _twoSidedLighting;
  100432. /**
  100433. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  100434. */
  100435. twoSidedLighting: boolean;
  100436. /**
  100437. * Default configuration related to image processing available in the standard Material.
  100438. */
  100439. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100440. /**
  100441. * Gets the image processing configuration used either in this material.
  100442. */
  100443. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  100444. /**
  100445. * Sets the Default image processing configuration used either in the this material.
  100446. *
  100447. * If sets to null, the scene one is in use.
  100448. */
  100449. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  100450. /**
  100451. * Keep track of the image processing observer to allow dispose and replace.
  100452. */
  100453. private _imageProcessingObserver;
  100454. /**
  100455. * Attaches a new image processing configuration to the Standard Material.
  100456. * @param configuration
  100457. */
  100458. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100459. /**
  100460. * Defines additionnal PrePass parameters for the material.
  100461. */
  100462. readonly prePassConfiguration: PrePassConfiguration;
  100463. /**
  100464. * Gets wether the color curves effect is enabled.
  100465. */
  100466. get cameraColorCurvesEnabled(): boolean;
  100467. /**
  100468. * Sets wether the color curves effect is enabled.
  100469. */
  100470. set cameraColorCurvesEnabled(value: boolean);
  100471. /**
  100472. * Gets wether the color grading effect is enabled.
  100473. */
  100474. get cameraColorGradingEnabled(): boolean;
  100475. /**
  100476. * Gets wether the color grading effect is enabled.
  100477. */
  100478. set cameraColorGradingEnabled(value: boolean);
  100479. /**
  100480. * Gets wether tonemapping is enabled or not.
  100481. */
  100482. get cameraToneMappingEnabled(): boolean;
  100483. /**
  100484. * Sets wether tonemapping is enabled or not
  100485. */
  100486. set cameraToneMappingEnabled(value: boolean);
  100487. /**
  100488. * The camera exposure used on this material.
  100489. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100490. * This corresponds to a photographic exposure.
  100491. */
  100492. get cameraExposure(): number;
  100493. /**
  100494. * The camera exposure used on this material.
  100495. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100496. * This corresponds to a photographic exposure.
  100497. */
  100498. set cameraExposure(value: number);
  100499. /**
  100500. * Gets The camera contrast used on this material.
  100501. */
  100502. get cameraContrast(): number;
  100503. /**
  100504. * Sets The camera contrast used on this material.
  100505. */
  100506. set cameraContrast(value: number);
  100507. /**
  100508. * Gets the Color Grading 2D Lookup Texture.
  100509. */
  100510. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  100511. /**
  100512. * Sets the Color Grading 2D Lookup Texture.
  100513. */
  100514. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  100515. /**
  100516. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100517. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100518. * 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;
  100519. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100520. */
  100521. get cameraColorCurves(): Nullable<ColorCurves>;
  100522. /**
  100523. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100524. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100525. * 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;
  100526. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100527. */
  100528. set cameraColorCurves(value: Nullable<ColorCurves>);
  100529. /**
  100530. * Can this material render to several textures at once
  100531. */
  100532. get canRenderToMRT(): boolean;
  100533. /**
  100534. * Defines the detail map parameters for the material.
  100535. */
  100536. readonly detailMap: DetailMapConfiguration;
  100537. protected _renderTargets: SmartArray<RenderTargetTexture>;
  100538. protected _worldViewProjectionMatrix: Matrix;
  100539. protected _globalAmbientColor: Color3;
  100540. protected _useLogarithmicDepth: boolean;
  100541. protected _rebuildInParallel: boolean;
  100542. /**
  100543. * Instantiates a new standard material.
  100544. * This is the default material used in Babylon. It is the best trade off between quality
  100545. * and performances.
  100546. * @see https://doc.babylonjs.com/babylon101/materials
  100547. * @param name Define the name of the material in the scene
  100548. * @param scene Define the scene the material belong to
  100549. */
  100550. constructor(name: string, scene: Scene);
  100551. /**
  100552. * Gets a boolean indicating that current material needs to register RTT
  100553. */
  100554. get hasRenderTargetTextures(): boolean;
  100555. /**
  100556. * Gets the current class name of the material e.g. "StandardMaterial"
  100557. * Mainly use in serialization.
  100558. * @returns the class name
  100559. */
  100560. getClassName(): string;
  100561. /**
  100562. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  100563. * You can try switching to logarithmic depth.
  100564. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  100565. */
  100566. get useLogarithmicDepth(): boolean;
  100567. set useLogarithmicDepth(value: boolean);
  100568. /**
  100569. * Specifies if the material will require alpha blending
  100570. * @returns a boolean specifying if alpha blending is needed
  100571. */
  100572. needAlphaBlending(): boolean;
  100573. /**
  100574. * Specifies if this material should be rendered in alpha test mode
  100575. * @returns a boolean specifying if an alpha test is needed.
  100576. */
  100577. needAlphaTesting(): boolean;
  100578. /**
  100579. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  100580. */
  100581. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  100582. /**
  100583. * Specifies whether or not there is a usable alpha channel for transparency.
  100584. */
  100585. protected _hasAlphaChannel(): boolean;
  100586. /**
  100587. * Get the texture used for alpha test purpose.
  100588. * @returns the diffuse texture in case of the standard material.
  100589. */
  100590. getAlphaTestTexture(): Nullable<BaseTexture>;
  100591. /**
  100592. * Get if the submesh is ready to be used and all its information available.
  100593. * Child classes can use it to update shaders
  100594. * @param mesh defines the mesh to check
  100595. * @param subMesh defines which submesh to check
  100596. * @param useInstances specifies that instances should be used
  100597. * @returns a boolean indicating that the submesh is ready or not
  100598. */
  100599. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100600. /**
  100601. * Builds the material UBO layouts.
  100602. * Used internally during the effect preparation.
  100603. */
  100604. buildUniformLayout(): void;
  100605. /**
  100606. * Unbinds the material from the mesh
  100607. */
  100608. unbind(): void;
  100609. /**
  100610. * Binds the submesh to this material by preparing the effect and shader to draw
  100611. * @param world defines the world transformation matrix
  100612. * @param mesh defines the mesh containing the submesh
  100613. * @param subMesh defines the submesh to bind the material to
  100614. */
  100615. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100616. /**
  100617. * Get the list of animatables in the material.
  100618. * @returns the list of animatables object used in the material
  100619. */
  100620. getAnimatables(): IAnimatable[];
  100621. /**
  100622. * Gets the active textures from the material
  100623. * @returns an array of textures
  100624. */
  100625. getActiveTextures(): BaseTexture[];
  100626. /**
  100627. * Specifies if the material uses a texture
  100628. * @param texture defines the texture to check against the material
  100629. * @returns a boolean specifying if the material uses the texture
  100630. */
  100631. hasTexture(texture: BaseTexture): boolean;
  100632. /**
  100633. * Disposes the material
  100634. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100635. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100636. */
  100637. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100638. /**
  100639. * Makes a duplicate of the material, and gives it a new name
  100640. * @param name defines the new name for the duplicated material
  100641. * @returns the cloned material
  100642. */
  100643. clone(name: string): StandardMaterial;
  100644. /**
  100645. * Serializes this material in a JSON representation
  100646. * @returns the serialized material object
  100647. */
  100648. serialize(): any;
  100649. /**
  100650. * Creates a standard material from parsed material data
  100651. * @param source defines the JSON representation of the material
  100652. * @param scene defines the hosting scene
  100653. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100654. * @returns a new standard material
  100655. */
  100656. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100657. /**
  100658. * Are diffuse textures enabled in the application.
  100659. */
  100660. static get DiffuseTextureEnabled(): boolean;
  100661. static set DiffuseTextureEnabled(value: boolean);
  100662. /**
  100663. * Are detail textures enabled in the application.
  100664. */
  100665. static get DetailTextureEnabled(): boolean;
  100666. static set DetailTextureEnabled(value: boolean);
  100667. /**
  100668. * Are ambient textures enabled in the application.
  100669. */
  100670. static get AmbientTextureEnabled(): boolean;
  100671. static set AmbientTextureEnabled(value: boolean);
  100672. /**
  100673. * Are opacity textures enabled in the application.
  100674. */
  100675. static get OpacityTextureEnabled(): boolean;
  100676. static set OpacityTextureEnabled(value: boolean);
  100677. /**
  100678. * Are reflection textures enabled in the application.
  100679. */
  100680. static get ReflectionTextureEnabled(): boolean;
  100681. static set ReflectionTextureEnabled(value: boolean);
  100682. /**
  100683. * Are emissive textures enabled in the application.
  100684. */
  100685. static get EmissiveTextureEnabled(): boolean;
  100686. static set EmissiveTextureEnabled(value: boolean);
  100687. /**
  100688. * Are specular textures enabled in the application.
  100689. */
  100690. static get SpecularTextureEnabled(): boolean;
  100691. static set SpecularTextureEnabled(value: boolean);
  100692. /**
  100693. * Are bump textures enabled in the application.
  100694. */
  100695. static get BumpTextureEnabled(): boolean;
  100696. static set BumpTextureEnabled(value: boolean);
  100697. /**
  100698. * Are lightmap textures enabled in the application.
  100699. */
  100700. static get LightmapTextureEnabled(): boolean;
  100701. static set LightmapTextureEnabled(value: boolean);
  100702. /**
  100703. * Are refraction textures enabled in the application.
  100704. */
  100705. static get RefractionTextureEnabled(): boolean;
  100706. static set RefractionTextureEnabled(value: boolean);
  100707. /**
  100708. * Are color grading textures enabled in the application.
  100709. */
  100710. static get ColorGradingTextureEnabled(): boolean;
  100711. static set ColorGradingTextureEnabled(value: boolean);
  100712. /**
  100713. * Are fresnels enabled in the application.
  100714. */
  100715. static get FresnelEnabled(): boolean;
  100716. static set FresnelEnabled(value: boolean);
  100717. }
  100718. }
  100719. declare module BABYLON {
  100720. /** @hidden */
  100721. export var rgbdDecodePixelShader: {
  100722. name: string;
  100723. shader: string;
  100724. };
  100725. }
  100726. declare module BABYLON {
  100727. /**
  100728. * Class used to host RGBD texture specific utilities
  100729. */
  100730. export class RGBDTextureTools {
  100731. /**
  100732. * Expand the RGBD Texture from RGBD to Half Float if possible.
  100733. * @param texture the texture to expand.
  100734. */
  100735. static ExpandRGBDTexture(texture: Texture): void;
  100736. }
  100737. }
  100738. declare module BABYLON {
  100739. /**
  100740. * Class used to host texture specific utilities
  100741. */
  100742. export class BRDFTextureTools {
  100743. /**
  100744. * Prevents texture cache collision
  100745. */
  100746. private static _instanceNumber;
  100747. /**
  100748. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  100749. * @param scene defines the hosting scene
  100750. * @returns the environment BRDF texture
  100751. */
  100752. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  100753. private static _environmentBRDFBase64Texture;
  100754. }
  100755. }
  100756. declare module BABYLON {
  100757. /**
  100758. * @hidden
  100759. */
  100760. export interface IMaterialClearCoatDefines {
  100761. CLEARCOAT: boolean;
  100762. CLEARCOAT_DEFAULTIOR: boolean;
  100763. CLEARCOAT_TEXTURE: boolean;
  100764. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  100765. CLEARCOAT_TEXTUREDIRECTUV: number;
  100766. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  100767. CLEARCOAT_BUMP: boolean;
  100768. CLEARCOAT_BUMPDIRECTUV: number;
  100769. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  100770. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  100771. CLEARCOAT_REMAP_F0: boolean;
  100772. CLEARCOAT_TINT: boolean;
  100773. CLEARCOAT_TINT_TEXTURE: boolean;
  100774. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  100775. /** @hidden */
  100776. _areTexturesDirty: boolean;
  100777. }
  100778. /**
  100779. * Define the code related to the clear coat parameters of the pbr material.
  100780. */
  100781. export class PBRClearCoatConfiguration {
  100782. /**
  100783. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100784. * The default fits with a polyurethane material.
  100785. * @hidden
  100786. */
  100787. static readonly _DefaultIndexOfRefraction: number;
  100788. private _isEnabled;
  100789. /**
  100790. * Defines if the clear coat is enabled in the material.
  100791. */
  100792. isEnabled: boolean;
  100793. /**
  100794. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  100795. */
  100796. intensity: number;
  100797. /**
  100798. * Defines the clear coat layer roughness.
  100799. */
  100800. roughness: number;
  100801. private _indexOfRefraction;
  100802. /**
  100803. * Defines the index of refraction of the clear coat.
  100804. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100805. * The default fits with a polyurethane material.
  100806. * Changing the default value is more performance intensive.
  100807. */
  100808. indexOfRefraction: number;
  100809. private _texture;
  100810. /**
  100811. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  100812. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  100813. * if textureRoughness is not empty, else no texture roughness is used
  100814. */
  100815. texture: Nullable<BaseTexture>;
  100816. private _useRoughnessFromMainTexture;
  100817. /**
  100818. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  100819. * If false, the green channel from textureRoughness is used for roughness
  100820. */
  100821. useRoughnessFromMainTexture: boolean;
  100822. private _textureRoughness;
  100823. /**
  100824. * Stores the clear coat roughness in a texture (green channel)
  100825. * Not used if useRoughnessFromMainTexture is true
  100826. */
  100827. textureRoughness: Nullable<BaseTexture>;
  100828. private _remapF0OnInterfaceChange;
  100829. /**
  100830. * Defines if the F0 value should be remapped to account for the interface change in the material.
  100831. */
  100832. remapF0OnInterfaceChange: boolean;
  100833. private _bumpTexture;
  100834. /**
  100835. * Define the clear coat specific bump texture.
  100836. */
  100837. bumpTexture: Nullable<BaseTexture>;
  100838. private _isTintEnabled;
  100839. /**
  100840. * Defines if the clear coat tint is enabled in the material.
  100841. */
  100842. isTintEnabled: boolean;
  100843. /**
  100844. * Defines the clear coat tint of the material.
  100845. * This is only use if tint is enabled
  100846. */
  100847. tintColor: Color3;
  100848. /**
  100849. * Defines the distance at which the tint color should be found in the
  100850. * clear coat media.
  100851. * This is only use if tint is enabled
  100852. */
  100853. tintColorAtDistance: number;
  100854. /**
  100855. * Defines the clear coat layer thickness.
  100856. * This is only use if tint is enabled
  100857. */
  100858. tintThickness: number;
  100859. private _tintTexture;
  100860. /**
  100861. * Stores the clear tint values in a texture.
  100862. * rgb is tint
  100863. * a is a thickness factor
  100864. */
  100865. tintTexture: Nullable<BaseTexture>;
  100866. /** @hidden */
  100867. private _internalMarkAllSubMeshesAsTexturesDirty;
  100868. /** @hidden */
  100869. _markAllSubMeshesAsTexturesDirty(): void;
  100870. /**
  100871. * Instantiate a new istance of clear coat configuration.
  100872. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100873. */
  100874. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100875. /**
  100876. * Gets wehter the submesh is ready to be used or not.
  100877. * @param defines the list of "defines" to update.
  100878. * @param scene defines the scene the material belongs to.
  100879. * @param engine defines the engine the material belongs to.
  100880. * @param disableBumpMap defines wether the material disables bump or not.
  100881. * @returns - boolean indicating that the submesh is ready or not.
  100882. */
  100883. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  100884. /**
  100885. * Checks to see if a texture is used in the material.
  100886. * @param defines the list of "defines" to update.
  100887. * @param scene defines the scene to the material belongs to.
  100888. */
  100889. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  100890. /**
  100891. * Binds the material data.
  100892. * @param uniformBuffer defines the Uniform buffer to fill in.
  100893. * @param scene defines the scene the material belongs to.
  100894. * @param engine defines the engine the material belongs to.
  100895. * @param disableBumpMap defines wether the material disables bump or not.
  100896. * @param isFrozen defines wether the material is frozen or not.
  100897. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100898. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100899. * @param subMesh the submesh to bind data for
  100900. */
  100901. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  100902. /**
  100903. * Checks to see if a texture is used in the material.
  100904. * @param texture - Base texture to use.
  100905. * @returns - Boolean specifying if a texture is used in the material.
  100906. */
  100907. hasTexture(texture: BaseTexture): boolean;
  100908. /**
  100909. * Returns an array of the actively used textures.
  100910. * @param activeTextures Array of BaseTextures
  100911. */
  100912. getActiveTextures(activeTextures: BaseTexture[]): void;
  100913. /**
  100914. * Returns the animatable textures.
  100915. * @param animatables Array of animatable textures.
  100916. */
  100917. getAnimatables(animatables: IAnimatable[]): void;
  100918. /**
  100919. * Disposes the resources of the material.
  100920. * @param forceDisposeTextures - Forces the disposal of all textures.
  100921. */
  100922. dispose(forceDisposeTextures?: boolean): void;
  100923. /**
  100924. * Get the current class name of the texture useful for serialization or dynamic coding.
  100925. * @returns "PBRClearCoatConfiguration"
  100926. */
  100927. getClassName(): string;
  100928. /**
  100929. * Add fallbacks to the effect fallbacks list.
  100930. * @param defines defines the Base texture to use.
  100931. * @param fallbacks defines the current fallback list.
  100932. * @param currentRank defines the current fallback rank.
  100933. * @returns the new fallback rank.
  100934. */
  100935. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100936. /**
  100937. * Add the required uniforms to the current list.
  100938. * @param uniforms defines the current uniform list.
  100939. */
  100940. static AddUniforms(uniforms: string[]): void;
  100941. /**
  100942. * Add the required samplers to the current list.
  100943. * @param samplers defines the current sampler list.
  100944. */
  100945. static AddSamplers(samplers: string[]): void;
  100946. /**
  100947. * Add the required uniforms to the current buffer.
  100948. * @param uniformBuffer defines the current uniform buffer.
  100949. */
  100950. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100951. /**
  100952. * Makes a duplicate of the current configuration into another one.
  100953. * @param clearCoatConfiguration define the config where to copy the info
  100954. */
  100955. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  100956. /**
  100957. * Serializes this clear coat configuration.
  100958. * @returns - An object with the serialized config.
  100959. */
  100960. serialize(): any;
  100961. /**
  100962. * Parses a anisotropy Configuration from a serialized object.
  100963. * @param source - Serialized object.
  100964. * @param scene Defines the scene we are parsing for
  100965. * @param rootUrl Defines the rootUrl to load from
  100966. */
  100967. parse(source: any, scene: Scene, rootUrl: string): void;
  100968. }
  100969. }
  100970. declare module BABYLON {
  100971. /**
  100972. * @hidden
  100973. */
  100974. export interface IMaterialAnisotropicDefines {
  100975. ANISOTROPIC: boolean;
  100976. ANISOTROPIC_TEXTURE: boolean;
  100977. ANISOTROPIC_TEXTUREDIRECTUV: number;
  100978. MAINUV1: boolean;
  100979. _areTexturesDirty: boolean;
  100980. _needUVs: boolean;
  100981. }
  100982. /**
  100983. * Define the code related to the anisotropic parameters of the pbr material.
  100984. */
  100985. export class PBRAnisotropicConfiguration {
  100986. private _isEnabled;
  100987. /**
  100988. * Defines if the anisotropy is enabled in the material.
  100989. */
  100990. isEnabled: boolean;
  100991. /**
  100992. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  100993. */
  100994. intensity: number;
  100995. /**
  100996. * Defines if the effect is along the tangents, bitangents or in between.
  100997. * By default, the effect is "strectching" the highlights along the tangents.
  100998. */
  100999. direction: Vector2;
  101000. private _texture;
  101001. /**
  101002. * Stores the anisotropy values in a texture.
  101003. * rg is direction (like normal from -1 to 1)
  101004. * b is a intensity
  101005. */
  101006. texture: Nullable<BaseTexture>;
  101007. /** @hidden */
  101008. private _internalMarkAllSubMeshesAsTexturesDirty;
  101009. /** @hidden */
  101010. _markAllSubMeshesAsTexturesDirty(): void;
  101011. /**
  101012. * Instantiate a new istance of anisotropy configuration.
  101013. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101014. */
  101015. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101016. /**
  101017. * Specifies that the submesh is ready to be used.
  101018. * @param defines the list of "defines" to update.
  101019. * @param scene defines the scene the material belongs to.
  101020. * @returns - boolean indicating that the submesh is ready or not.
  101021. */
  101022. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  101023. /**
  101024. * Checks to see if a texture is used in the material.
  101025. * @param defines the list of "defines" to update.
  101026. * @param mesh the mesh we are preparing the defines for.
  101027. * @param scene defines the scene the material belongs to.
  101028. */
  101029. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  101030. /**
  101031. * Binds the material data.
  101032. * @param uniformBuffer defines the Uniform buffer to fill in.
  101033. * @param scene defines the scene the material belongs to.
  101034. * @param isFrozen defines wether the material is frozen or not.
  101035. */
  101036. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  101037. /**
  101038. * Checks to see if a texture is used in the material.
  101039. * @param texture - Base texture to use.
  101040. * @returns - Boolean specifying if a texture is used in the material.
  101041. */
  101042. hasTexture(texture: BaseTexture): boolean;
  101043. /**
  101044. * Returns an array of the actively used textures.
  101045. * @param activeTextures Array of BaseTextures
  101046. */
  101047. getActiveTextures(activeTextures: BaseTexture[]): void;
  101048. /**
  101049. * Returns the animatable textures.
  101050. * @param animatables Array of animatable textures.
  101051. */
  101052. getAnimatables(animatables: IAnimatable[]): void;
  101053. /**
  101054. * Disposes the resources of the material.
  101055. * @param forceDisposeTextures - Forces the disposal of all textures.
  101056. */
  101057. dispose(forceDisposeTextures?: boolean): void;
  101058. /**
  101059. * Get the current class name of the texture useful for serialization or dynamic coding.
  101060. * @returns "PBRAnisotropicConfiguration"
  101061. */
  101062. getClassName(): string;
  101063. /**
  101064. * Add fallbacks to the effect fallbacks list.
  101065. * @param defines defines the Base texture to use.
  101066. * @param fallbacks defines the current fallback list.
  101067. * @param currentRank defines the current fallback rank.
  101068. * @returns the new fallback rank.
  101069. */
  101070. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101071. /**
  101072. * Add the required uniforms to the current list.
  101073. * @param uniforms defines the current uniform list.
  101074. */
  101075. static AddUniforms(uniforms: string[]): void;
  101076. /**
  101077. * Add the required uniforms to the current buffer.
  101078. * @param uniformBuffer defines the current uniform buffer.
  101079. */
  101080. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101081. /**
  101082. * Add the required samplers to the current list.
  101083. * @param samplers defines the current sampler list.
  101084. */
  101085. static AddSamplers(samplers: string[]): void;
  101086. /**
  101087. * Makes a duplicate of the current configuration into another one.
  101088. * @param anisotropicConfiguration define the config where to copy the info
  101089. */
  101090. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  101091. /**
  101092. * Serializes this anisotropy configuration.
  101093. * @returns - An object with the serialized config.
  101094. */
  101095. serialize(): any;
  101096. /**
  101097. * Parses a anisotropy Configuration from a serialized object.
  101098. * @param source - Serialized object.
  101099. * @param scene Defines the scene we are parsing for
  101100. * @param rootUrl Defines the rootUrl to load from
  101101. */
  101102. parse(source: any, scene: Scene, rootUrl: string): void;
  101103. }
  101104. }
  101105. declare module BABYLON {
  101106. /**
  101107. * @hidden
  101108. */
  101109. export interface IMaterialBRDFDefines {
  101110. BRDF_V_HEIGHT_CORRELATED: boolean;
  101111. MS_BRDF_ENERGY_CONSERVATION: boolean;
  101112. SPHERICAL_HARMONICS: boolean;
  101113. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  101114. /** @hidden */
  101115. _areMiscDirty: boolean;
  101116. }
  101117. /**
  101118. * Define the code related to the BRDF parameters of the pbr material.
  101119. */
  101120. export class PBRBRDFConfiguration {
  101121. /**
  101122. * Default value used for the energy conservation.
  101123. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  101124. */
  101125. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  101126. /**
  101127. * Default value used for the Smith Visibility Height Correlated mode.
  101128. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  101129. */
  101130. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  101131. /**
  101132. * Default value used for the IBL diffuse part.
  101133. * This can help switching back to the polynomials mode globally which is a tiny bit
  101134. * less GPU intensive at the drawback of a lower quality.
  101135. */
  101136. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  101137. /**
  101138. * Default value used for activating energy conservation for the specular workflow.
  101139. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  101140. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  101141. */
  101142. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  101143. private _useEnergyConservation;
  101144. /**
  101145. * Defines if the material uses energy conservation.
  101146. */
  101147. useEnergyConservation: boolean;
  101148. private _useSmithVisibilityHeightCorrelated;
  101149. /**
  101150. * LEGACY Mode set to false
  101151. * Defines if the material uses height smith correlated visibility term.
  101152. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  101153. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101154. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  101155. * Not relying on height correlated will also disable energy conservation.
  101156. */
  101157. useSmithVisibilityHeightCorrelated: boolean;
  101158. private _useSphericalHarmonics;
  101159. /**
  101160. * LEGACY Mode set to false
  101161. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  101162. * diffuse part of the IBL.
  101163. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  101164. * to the ground truth.
  101165. */
  101166. useSphericalHarmonics: boolean;
  101167. private _useSpecularGlossinessInputEnergyConservation;
  101168. /**
  101169. * Defines if the material uses energy conservation, when the specular workflow is active.
  101170. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  101171. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  101172. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  101173. */
  101174. useSpecularGlossinessInputEnergyConservation: boolean;
  101175. /** @hidden */
  101176. private _internalMarkAllSubMeshesAsMiscDirty;
  101177. /** @hidden */
  101178. _markAllSubMeshesAsMiscDirty(): void;
  101179. /**
  101180. * Instantiate a new istance of clear coat configuration.
  101181. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  101182. */
  101183. constructor(markAllSubMeshesAsMiscDirty: () => void);
  101184. /**
  101185. * Checks to see if a texture is used in the material.
  101186. * @param defines the list of "defines" to update.
  101187. */
  101188. prepareDefines(defines: IMaterialBRDFDefines): void;
  101189. /**
  101190. * Get the current class name of the texture useful for serialization or dynamic coding.
  101191. * @returns "PBRClearCoatConfiguration"
  101192. */
  101193. getClassName(): string;
  101194. /**
  101195. * Makes a duplicate of the current configuration into another one.
  101196. * @param brdfConfiguration define the config where to copy the info
  101197. */
  101198. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  101199. /**
  101200. * Serializes this BRDF configuration.
  101201. * @returns - An object with the serialized config.
  101202. */
  101203. serialize(): any;
  101204. /**
  101205. * Parses a anisotropy Configuration from a serialized object.
  101206. * @param source - Serialized object.
  101207. * @param scene Defines the scene we are parsing for
  101208. * @param rootUrl Defines the rootUrl to load from
  101209. */
  101210. parse(source: any, scene: Scene, rootUrl: string): void;
  101211. }
  101212. }
  101213. declare module BABYLON {
  101214. /**
  101215. * @hidden
  101216. */
  101217. export interface IMaterialSheenDefines {
  101218. SHEEN: boolean;
  101219. SHEEN_TEXTURE: boolean;
  101220. SHEEN_TEXTURE_ROUGHNESS: boolean;
  101221. SHEEN_TEXTUREDIRECTUV: number;
  101222. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  101223. SHEEN_LINKWITHALBEDO: boolean;
  101224. SHEEN_ROUGHNESS: boolean;
  101225. SHEEN_ALBEDOSCALING: boolean;
  101226. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  101227. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  101228. /** @hidden */
  101229. _areTexturesDirty: boolean;
  101230. }
  101231. /**
  101232. * Define the code related to the Sheen parameters of the pbr material.
  101233. */
  101234. export class PBRSheenConfiguration {
  101235. private _isEnabled;
  101236. /**
  101237. * Defines if the material uses sheen.
  101238. */
  101239. isEnabled: boolean;
  101240. private _linkSheenWithAlbedo;
  101241. /**
  101242. * Defines if the sheen is linked to the sheen color.
  101243. */
  101244. linkSheenWithAlbedo: boolean;
  101245. /**
  101246. * Defines the sheen intensity.
  101247. */
  101248. intensity: number;
  101249. /**
  101250. * Defines the sheen color.
  101251. */
  101252. color: Color3;
  101253. private _texture;
  101254. /**
  101255. * Stores the sheen tint values in a texture.
  101256. * rgb is tint
  101257. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  101258. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  101259. */
  101260. texture: Nullable<BaseTexture>;
  101261. private _useRoughnessFromMainTexture;
  101262. /**
  101263. * Indicates that the alpha channel of the texture property will be used for roughness.
  101264. * Has no effect if the roughness (and texture!) property is not defined
  101265. */
  101266. useRoughnessFromMainTexture: boolean;
  101267. private _roughness;
  101268. /**
  101269. * Defines the sheen roughness.
  101270. * It is not taken into account if linkSheenWithAlbedo is true.
  101271. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  101272. */
  101273. roughness: Nullable<number>;
  101274. private _textureRoughness;
  101275. /**
  101276. * Stores the sheen roughness in a texture.
  101277. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  101278. */
  101279. textureRoughness: Nullable<BaseTexture>;
  101280. private _albedoScaling;
  101281. /**
  101282. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  101283. * It allows the strength of the sheen effect to not depend on the base color of the material,
  101284. * making it easier to setup and tweak the effect
  101285. */
  101286. albedoScaling: boolean;
  101287. /** @hidden */
  101288. private _internalMarkAllSubMeshesAsTexturesDirty;
  101289. /** @hidden */
  101290. _markAllSubMeshesAsTexturesDirty(): void;
  101291. /**
  101292. * Instantiate a new istance of clear coat configuration.
  101293. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101294. */
  101295. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101296. /**
  101297. * Specifies that the submesh is ready to be used.
  101298. * @param defines the list of "defines" to update.
  101299. * @param scene defines the scene the material belongs to.
  101300. * @returns - boolean indicating that the submesh is ready or not.
  101301. */
  101302. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  101303. /**
  101304. * Checks to see if a texture is used in the material.
  101305. * @param defines the list of "defines" to update.
  101306. * @param scene defines the scene the material belongs to.
  101307. */
  101308. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  101309. /**
  101310. * Binds the material data.
  101311. * @param uniformBuffer defines the Uniform buffer to fill in.
  101312. * @param scene defines the scene the material belongs to.
  101313. * @param isFrozen defines wether the material is frozen or not.
  101314. * @param subMesh the submesh to bind data for
  101315. */
  101316. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  101317. /**
  101318. * Checks to see if a texture is used in the material.
  101319. * @param texture - Base texture to use.
  101320. * @returns - Boolean specifying if a texture is used in the material.
  101321. */
  101322. hasTexture(texture: BaseTexture): boolean;
  101323. /**
  101324. * Returns an array of the actively used textures.
  101325. * @param activeTextures Array of BaseTextures
  101326. */
  101327. getActiveTextures(activeTextures: BaseTexture[]): void;
  101328. /**
  101329. * Returns the animatable textures.
  101330. * @param animatables Array of animatable textures.
  101331. */
  101332. getAnimatables(animatables: IAnimatable[]): void;
  101333. /**
  101334. * Disposes the resources of the material.
  101335. * @param forceDisposeTextures - Forces the disposal of all textures.
  101336. */
  101337. dispose(forceDisposeTextures?: boolean): void;
  101338. /**
  101339. * Get the current class name of the texture useful for serialization or dynamic coding.
  101340. * @returns "PBRSheenConfiguration"
  101341. */
  101342. getClassName(): string;
  101343. /**
  101344. * Add fallbacks to the effect fallbacks list.
  101345. * @param defines defines the Base texture to use.
  101346. * @param fallbacks defines the current fallback list.
  101347. * @param currentRank defines the current fallback rank.
  101348. * @returns the new fallback rank.
  101349. */
  101350. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101351. /**
  101352. * Add the required uniforms to the current list.
  101353. * @param uniforms defines the current uniform list.
  101354. */
  101355. static AddUniforms(uniforms: string[]): void;
  101356. /**
  101357. * Add the required uniforms to the current buffer.
  101358. * @param uniformBuffer defines the current uniform buffer.
  101359. */
  101360. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101361. /**
  101362. * Add the required samplers to the current list.
  101363. * @param samplers defines the current sampler list.
  101364. */
  101365. static AddSamplers(samplers: string[]): void;
  101366. /**
  101367. * Makes a duplicate of the current configuration into another one.
  101368. * @param sheenConfiguration define the config where to copy the info
  101369. */
  101370. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  101371. /**
  101372. * Serializes this BRDF configuration.
  101373. * @returns - An object with the serialized config.
  101374. */
  101375. serialize(): any;
  101376. /**
  101377. * Parses a anisotropy Configuration from a serialized object.
  101378. * @param source - Serialized object.
  101379. * @param scene Defines the scene we are parsing for
  101380. * @param rootUrl Defines the rootUrl to load from
  101381. */
  101382. parse(source: any, scene: Scene, rootUrl: string): void;
  101383. }
  101384. }
  101385. declare module BABYLON {
  101386. /**
  101387. * @hidden
  101388. */
  101389. export interface IMaterialSubSurfaceDefines {
  101390. SUBSURFACE: boolean;
  101391. SS_REFRACTION: boolean;
  101392. SS_TRANSLUCENCY: boolean;
  101393. SS_SCATTERING: boolean;
  101394. SS_THICKNESSANDMASK_TEXTURE: boolean;
  101395. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  101396. SS_REFRACTIONMAP_3D: boolean;
  101397. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  101398. SS_LODINREFRACTIONALPHA: boolean;
  101399. SS_GAMMAREFRACTION: boolean;
  101400. SS_RGBDREFRACTION: boolean;
  101401. SS_LINEARSPECULARREFRACTION: boolean;
  101402. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  101403. SS_ALBEDOFORREFRACTIONTINT: boolean;
  101404. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  101405. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  101406. /** @hidden */
  101407. _areTexturesDirty: boolean;
  101408. }
  101409. /**
  101410. * Define the code related to the sub surface parameters of the pbr material.
  101411. */
  101412. export class PBRSubSurfaceConfiguration {
  101413. private _isRefractionEnabled;
  101414. /**
  101415. * Defines if the refraction is enabled in the material.
  101416. */
  101417. isRefractionEnabled: boolean;
  101418. private _isTranslucencyEnabled;
  101419. /**
  101420. * Defines if the translucency is enabled in the material.
  101421. */
  101422. isTranslucencyEnabled: boolean;
  101423. private _isScatteringEnabled;
  101424. /**
  101425. * Defines if the sub surface scattering is enabled in the material.
  101426. */
  101427. isScatteringEnabled: boolean;
  101428. private _scatteringDiffusionProfileIndex;
  101429. /**
  101430. * Diffusion profile for subsurface scattering.
  101431. * Useful for better scattering in the skins or foliages.
  101432. */
  101433. get scatteringDiffusionProfile(): Nullable<Color3>;
  101434. set scatteringDiffusionProfile(c: Nullable<Color3>);
  101435. /**
  101436. * Defines the refraction intensity of the material.
  101437. * The refraction when enabled replaces the Diffuse part of the material.
  101438. * The intensity helps transitionning between diffuse and refraction.
  101439. */
  101440. refractionIntensity: number;
  101441. /**
  101442. * Defines the translucency intensity of the material.
  101443. * When translucency has been enabled, this defines how much of the "translucency"
  101444. * is addded to the diffuse part of the material.
  101445. */
  101446. translucencyIntensity: number;
  101447. /**
  101448. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  101449. */
  101450. useAlbedoToTintRefraction: boolean;
  101451. private _thicknessTexture;
  101452. /**
  101453. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  101454. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  101455. * 0 would mean minimumThickness
  101456. * 1 would mean maximumThickness
  101457. * The other channels might be use as a mask to vary the different effects intensity.
  101458. */
  101459. thicknessTexture: Nullable<BaseTexture>;
  101460. private _refractionTexture;
  101461. /**
  101462. * Defines the texture to use for refraction.
  101463. */
  101464. refractionTexture: Nullable<BaseTexture>;
  101465. private _indexOfRefraction;
  101466. /**
  101467. * Index of refraction of the material base layer.
  101468. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  101469. *
  101470. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  101471. *
  101472. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  101473. */
  101474. indexOfRefraction: number;
  101475. private _volumeIndexOfRefraction;
  101476. /**
  101477. * Index of refraction of the material's volume.
  101478. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  101479. *
  101480. * This ONLY impacts refraction. If not provided or given a non-valid value,
  101481. * the volume will use the same IOR as the surface.
  101482. */
  101483. get volumeIndexOfRefraction(): number;
  101484. set volumeIndexOfRefraction(value: number);
  101485. private _invertRefractionY;
  101486. /**
  101487. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101488. */
  101489. invertRefractionY: boolean;
  101490. private _linkRefractionWithTransparency;
  101491. /**
  101492. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101493. * Materials half opaque for instance using refraction could benefit from this control.
  101494. */
  101495. linkRefractionWithTransparency: boolean;
  101496. /**
  101497. * Defines the minimum thickness stored in the thickness map.
  101498. * If no thickness map is defined, this value will be used to simulate thickness.
  101499. */
  101500. minimumThickness: number;
  101501. /**
  101502. * Defines the maximum thickness stored in the thickness map.
  101503. */
  101504. maximumThickness: number;
  101505. /**
  101506. * Defines the volume tint of the material.
  101507. * This is used for both translucency and scattering.
  101508. */
  101509. tintColor: Color3;
  101510. /**
  101511. * Defines the distance at which the tint color should be found in the media.
  101512. * This is used for refraction only.
  101513. */
  101514. tintColorAtDistance: number;
  101515. /**
  101516. * Defines how far each channel transmit through the media.
  101517. * It is defined as a color to simplify it selection.
  101518. */
  101519. diffusionDistance: Color3;
  101520. private _useMaskFromThicknessTexture;
  101521. /**
  101522. * Stores the intensity of the different subsurface effects in the thickness texture.
  101523. * * the green channel is the translucency intensity.
  101524. * * the blue channel is the scattering intensity.
  101525. * * the alpha channel is the refraction intensity.
  101526. */
  101527. useMaskFromThicknessTexture: boolean;
  101528. private _scene;
  101529. private _useMaskFromThicknessTextureGltf;
  101530. /**
  101531. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  101532. * matches the channel-packing that is used by glTF.
  101533. * * the red channel is the transmission/translucency intensity.
  101534. * * the green channel is the thickness.
  101535. */
  101536. useMaskFromThicknessTextureGltf: boolean;
  101537. /** @hidden */
  101538. private _internalMarkAllSubMeshesAsTexturesDirty;
  101539. private _internalMarkScenePrePassDirty;
  101540. /** @hidden */
  101541. _markAllSubMeshesAsTexturesDirty(): void;
  101542. /** @hidden */
  101543. _markScenePrePassDirty(): void;
  101544. /**
  101545. * Instantiate a new istance of sub surface configuration.
  101546. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101547. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  101548. * @param scene The scene
  101549. */
  101550. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  101551. /**
  101552. * Gets wehter the submesh is ready to be used or not.
  101553. * @param defines the list of "defines" to update.
  101554. * @param scene defines the scene the material belongs to.
  101555. * @returns - boolean indicating that the submesh is ready or not.
  101556. */
  101557. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  101558. /**
  101559. * Checks to see if a texture is used in the material.
  101560. * @param defines the list of "defines" to update.
  101561. * @param scene defines the scene to the material belongs to.
  101562. */
  101563. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  101564. /**
  101565. * Binds the material data.
  101566. * @param uniformBuffer defines the Uniform buffer to fill in.
  101567. * @param scene defines the scene the material belongs to.
  101568. * @param engine defines the engine the material belongs to.
  101569. * @param isFrozen defines whether the material is frozen or not.
  101570. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  101571. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  101572. */
  101573. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  101574. /**
  101575. * Unbinds the material from the mesh.
  101576. * @param activeEffect defines the effect that should be unbound from.
  101577. * @returns true if unbound, otherwise false
  101578. */
  101579. unbind(activeEffect: Effect): boolean;
  101580. /**
  101581. * Returns the texture used for refraction or null if none is used.
  101582. * @param scene defines the scene the material belongs to.
  101583. * @returns - Refraction texture if present. If no refraction texture and refraction
  101584. * is linked with transparency, returns environment texture. Otherwise, returns null.
  101585. */
  101586. private _getRefractionTexture;
  101587. /**
  101588. * Returns true if alpha blending should be disabled.
  101589. */
  101590. get disableAlphaBlending(): boolean;
  101591. /**
  101592. * Fills the list of render target textures.
  101593. * @param renderTargets the list of render targets to update
  101594. */
  101595. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  101596. /**
  101597. * Checks to see if a texture is used in the material.
  101598. * @param texture - Base texture to use.
  101599. * @returns - Boolean specifying if a texture is used in the material.
  101600. */
  101601. hasTexture(texture: BaseTexture): boolean;
  101602. /**
  101603. * Gets a boolean indicating that current material needs to register RTT
  101604. * @returns true if this uses a render target otherwise false.
  101605. */
  101606. hasRenderTargetTextures(): boolean;
  101607. /**
  101608. * Returns an array of the actively used textures.
  101609. * @param activeTextures Array of BaseTextures
  101610. */
  101611. getActiveTextures(activeTextures: BaseTexture[]): void;
  101612. /**
  101613. * Returns the animatable textures.
  101614. * @param animatables Array of animatable textures.
  101615. */
  101616. getAnimatables(animatables: IAnimatable[]): void;
  101617. /**
  101618. * Disposes the resources of the material.
  101619. * @param forceDisposeTextures - Forces the disposal of all textures.
  101620. */
  101621. dispose(forceDisposeTextures?: boolean): void;
  101622. /**
  101623. * Get the current class name of the texture useful for serialization or dynamic coding.
  101624. * @returns "PBRSubSurfaceConfiguration"
  101625. */
  101626. getClassName(): string;
  101627. /**
  101628. * Add fallbacks to the effect fallbacks list.
  101629. * @param defines defines the Base texture to use.
  101630. * @param fallbacks defines the current fallback list.
  101631. * @param currentRank defines the current fallback rank.
  101632. * @returns the new fallback rank.
  101633. */
  101634. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101635. /**
  101636. * Add the required uniforms to the current list.
  101637. * @param uniforms defines the current uniform list.
  101638. */
  101639. static AddUniforms(uniforms: string[]): void;
  101640. /**
  101641. * Add the required samplers to the current list.
  101642. * @param samplers defines the current sampler list.
  101643. */
  101644. static AddSamplers(samplers: string[]): void;
  101645. /**
  101646. * Add the required uniforms to the current buffer.
  101647. * @param uniformBuffer defines the current uniform buffer.
  101648. */
  101649. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101650. /**
  101651. * Makes a duplicate of the current configuration into another one.
  101652. * @param configuration define the config where to copy the info
  101653. */
  101654. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  101655. /**
  101656. * Serializes this Sub Surface configuration.
  101657. * @returns - An object with the serialized config.
  101658. */
  101659. serialize(): any;
  101660. /**
  101661. * Parses a anisotropy Configuration from a serialized object.
  101662. * @param source - Serialized object.
  101663. * @param scene Defines the scene we are parsing for
  101664. * @param rootUrl Defines the rootUrl to load from
  101665. */
  101666. parse(source: any, scene: Scene, rootUrl: string): void;
  101667. }
  101668. }
  101669. declare module BABYLON {
  101670. /**
  101671. * Class representing spherical harmonics coefficients to the 3rd degree
  101672. */
  101673. export class SphericalHarmonics {
  101674. /**
  101675. * Defines whether or not the harmonics have been prescaled for rendering.
  101676. */
  101677. preScaled: boolean;
  101678. /**
  101679. * The l0,0 coefficients of the spherical harmonics
  101680. */
  101681. l00: Vector3;
  101682. /**
  101683. * The l1,-1 coefficients of the spherical harmonics
  101684. */
  101685. l1_1: Vector3;
  101686. /**
  101687. * The l1,0 coefficients of the spherical harmonics
  101688. */
  101689. l10: Vector3;
  101690. /**
  101691. * The l1,1 coefficients of the spherical harmonics
  101692. */
  101693. l11: Vector3;
  101694. /**
  101695. * The l2,-2 coefficients of the spherical harmonics
  101696. */
  101697. l2_2: Vector3;
  101698. /**
  101699. * The l2,-1 coefficients of the spherical harmonics
  101700. */
  101701. l2_1: Vector3;
  101702. /**
  101703. * The l2,0 coefficients of the spherical harmonics
  101704. */
  101705. l20: Vector3;
  101706. /**
  101707. * The l2,1 coefficients of the spherical harmonics
  101708. */
  101709. l21: Vector3;
  101710. /**
  101711. * The l2,2 coefficients of the spherical harmonics
  101712. */
  101713. l22: Vector3;
  101714. /**
  101715. * Adds a light to the spherical harmonics
  101716. * @param direction the direction of the light
  101717. * @param color the color of the light
  101718. * @param deltaSolidAngle the delta solid angle of the light
  101719. */
  101720. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  101721. /**
  101722. * Scales the spherical harmonics by the given amount
  101723. * @param scale the amount to scale
  101724. */
  101725. scaleInPlace(scale: number): void;
  101726. /**
  101727. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  101728. *
  101729. * ```
  101730. * E_lm = A_l * L_lm
  101731. * ```
  101732. *
  101733. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  101734. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  101735. * the scaling factors are given in equation 9.
  101736. */
  101737. convertIncidentRadianceToIrradiance(): void;
  101738. /**
  101739. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  101740. *
  101741. * ```
  101742. * L = (1/pi) * E * rho
  101743. * ```
  101744. *
  101745. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  101746. */
  101747. convertIrradianceToLambertianRadiance(): void;
  101748. /**
  101749. * Integrates the reconstruction coefficients directly in to the SH preventing further
  101750. * required operations at run time.
  101751. *
  101752. * This is simply done by scaling back the SH with Ylm constants parameter.
  101753. * The trigonometric part being applied by the shader at run time.
  101754. */
  101755. preScaleForRendering(): void;
  101756. /**
  101757. * Constructs a spherical harmonics from an array.
  101758. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  101759. * @returns the spherical harmonics
  101760. */
  101761. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  101762. /**
  101763. * Gets the spherical harmonics from polynomial
  101764. * @param polynomial the spherical polynomial
  101765. * @returns the spherical harmonics
  101766. */
  101767. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  101768. }
  101769. /**
  101770. * Class representing spherical polynomial coefficients to the 3rd degree
  101771. */
  101772. export class SphericalPolynomial {
  101773. private _harmonics;
  101774. /**
  101775. * The spherical harmonics used to create the polynomials.
  101776. */
  101777. get preScaledHarmonics(): SphericalHarmonics;
  101778. /**
  101779. * The x coefficients of the spherical polynomial
  101780. */
  101781. x: Vector3;
  101782. /**
  101783. * The y coefficients of the spherical polynomial
  101784. */
  101785. y: Vector3;
  101786. /**
  101787. * The z coefficients of the spherical polynomial
  101788. */
  101789. z: Vector3;
  101790. /**
  101791. * The xx coefficients of the spherical polynomial
  101792. */
  101793. xx: Vector3;
  101794. /**
  101795. * The yy coefficients of the spherical polynomial
  101796. */
  101797. yy: Vector3;
  101798. /**
  101799. * The zz coefficients of the spherical polynomial
  101800. */
  101801. zz: Vector3;
  101802. /**
  101803. * The xy coefficients of the spherical polynomial
  101804. */
  101805. xy: Vector3;
  101806. /**
  101807. * The yz coefficients of the spherical polynomial
  101808. */
  101809. yz: Vector3;
  101810. /**
  101811. * The zx coefficients of the spherical polynomial
  101812. */
  101813. zx: Vector3;
  101814. /**
  101815. * Adds an ambient color to the spherical polynomial
  101816. * @param color the color to add
  101817. */
  101818. addAmbient(color: Color3): void;
  101819. /**
  101820. * Scales the spherical polynomial by the given amount
  101821. * @param scale the amount to scale
  101822. */
  101823. scaleInPlace(scale: number): void;
  101824. /**
  101825. * Gets the spherical polynomial from harmonics
  101826. * @param harmonics the spherical harmonics
  101827. * @returns the spherical polynomial
  101828. */
  101829. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  101830. /**
  101831. * Constructs a spherical polynomial from an array.
  101832. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  101833. * @returns the spherical polynomial
  101834. */
  101835. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  101836. }
  101837. }
  101838. declare module BABYLON {
  101839. /**
  101840. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  101841. */
  101842. export interface CubeMapInfo {
  101843. /**
  101844. * The pixel array for the front face.
  101845. * This is stored in format, left to right, up to down format.
  101846. */
  101847. front: Nullable<ArrayBufferView>;
  101848. /**
  101849. * The pixel array for the back face.
  101850. * This is stored in format, left to right, up to down format.
  101851. */
  101852. back: Nullable<ArrayBufferView>;
  101853. /**
  101854. * The pixel array for the left face.
  101855. * This is stored in format, left to right, up to down format.
  101856. */
  101857. left: Nullable<ArrayBufferView>;
  101858. /**
  101859. * The pixel array for the right face.
  101860. * This is stored in format, left to right, up to down format.
  101861. */
  101862. right: Nullable<ArrayBufferView>;
  101863. /**
  101864. * The pixel array for the up face.
  101865. * This is stored in format, left to right, up to down format.
  101866. */
  101867. up: Nullable<ArrayBufferView>;
  101868. /**
  101869. * The pixel array for the down face.
  101870. * This is stored in format, left to right, up to down format.
  101871. */
  101872. down: Nullable<ArrayBufferView>;
  101873. /**
  101874. * The size of the cubemap stored.
  101875. *
  101876. * Each faces will be size * size pixels.
  101877. */
  101878. size: number;
  101879. /**
  101880. * The format of the texture.
  101881. *
  101882. * RGBA, RGB.
  101883. */
  101884. format: number;
  101885. /**
  101886. * The type of the texture data.
  101887. *
  101888. * UNSIGNED_INT, FLOAT.
  101889. */
  101890. type: number;
  101891. /**
  101892. * Specifies whether the texture is in gamma space.
  101893. */
  101894. gammaSpace: boolean;
  101895. }
  101896. /**
  101897. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  101898. */
  101899. export class PanoramaToCubeMapTools {
  101900. private static FACE_LEFT;
  101901. private static FACE_RIGHT;
  101902. private static FACE_FRONT;
  101903. private static FACE_BACK;
  101904. private static FACE_DOWN;
  101905. private static FACE_UP;
  101906. /**
  101907. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  101908. *
  101909. * @param float32Array The source data.
  101910. * @param inputWidth The width of the input panorama.
  101911. * @param inputHeight The height of the input panorama.
  101912. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  101913. * @return The cubemap data
  101914. */
  101915. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  101916. private static CreateCubemapTexture;
  101917. private static CalcProjectionSpherical;
  101918. }
  101919. }
  101920. declare module BABYLON {
  101921. /**
  101922. * Helper class dealing with the extraction of spherical polynomial dataArray
  101923. * from a cube map.
  101924. */
  101925. export class CubeMapToSphericalPolynomialTools {
  101926. private static FileFaces;
  101927. /**
  101928. * Converts a texture to the according Spherical Polynomial data.
  101929. * This extracts the first 3 orders only as they are the only one used in the lighting.
  101930. *
  101931. * @param texture The texture to extract the information from.
  101932. * @return The Spherical Polynomial data.
  101933. */
  101934. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  101935. /**
  101936. * Converts a cubemap to the according Spherical Polynomial data.
  101937. * This extracts the first 3 orders only as they are the only one used in the lighting.
  101938. *
  101939. * @param cubeInfo The Cube map to extract the information from.
  101940. * @return The Spherical Polynomial data.
  101941. */
  101942. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  101943. }
  101944. }
  101945. declare module BABYLON {
  101946. interface BaseTexture {
  101947. /**
  101948. * Get the polynomial representation of the texture data.
  101949. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  101950. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  101951. */
  101952. sphericalPolynomial: Nullable<SphericalPolynomial>;
  101953. }
  101954. }
  101955. declare module BABYLON {
  101956. /** @hidden */
  101957. export var pbrFragmentDeclaration: {
  101958. name: string;
  101959. shader: string;
  101960. };
  101961. }
  101962. declare module BABYLON {
  101963. /** @hidden */
  101964. export var pbrUboDeclaration: {
  101965. name: string;
  101966. shader: string;
  101967. };
  101968. }
  101969. declare module BABYLON {
  101970. /** @hidden */
  101971. export var pbrFragmentExtraDeclaration: {
  101972. name: string;
  101973. shader: string;
  101974. };
  101975. }
  101976. declare module BABYLON {
  101977. /** @hidden */
  101978. export var pbrFragmentSamplersDeclaration: {
  101979. name: string;
  101980. shader: string;
  101981. };
  101982. }
  101983. declare module BABYLON {
  101984. /** @hidden */
  101985. export var subSurfaceScatteringFunctions: {
  101986. name: string;
  101987. shader: string;
  101988. };
  101989. }
  101990. declare module BABYLON {
  101991. /** @hidden */
  101992. export var importanceSampling: {
  101993. name: string;
  101994. shader: string;
  101995. };
  101996. }
  101997. declare module BABYLON {
  101998. /** @hidden */
  101999. export var pbrHelperFunctions: {
  102000. name: string;
  102001. shader: string;
  102002. };
  102003. }
  102004. declare module BABYLON {
  102005. /** @hidden */
  102006. export var harmonicsFunctions: {
  102007. name: string;
  102008. shader: string;
  102009. };
  102010. }
  102011. declare module BABYLON {
  102012. /** @hidden */
  102013. export var pbrDirectLightingSetupFunctions: {
  102014. name: string;
  102015. shader: string;
  102016. };
  102017. }
  102018. declare module BABYLON {
  102019. /** @hidden */
  102020. export var pbrDirectLightingFalloffFunctions: {
  102021. name: string;
  102022. shader: string;
  102023. };
  102024. }
  102025. declare module BABYLON {
  102026. /** @hidden */
  102027. export var pbrBRDFFunctions: {
  102028. name: string;
  102029. shader: string;
  102030. };
  102031. }
  102032. declare module BABYLON {
  102033. /** @hidden */
  102034. export var hdrFilteringFunctions: {
  102035. name: string;
  102036. shader: string;
  102037. };
  102038. }
  102039. declare module BABYLON {
  102040. /** @hidden */
  102041. export var pbrDirectLightingFunctions: {
  102042. name: string;
  102043. shader: string;
  102044. };
  102045. }
  102046. declare module BABYLON {
  102047. /** @hidden */
  102048. export var pbrIBLFunctions: {
  102049. name: string;
  102050. shader: string;
  102051. };
  102052. }
  102053. declare module BABYLON {
  102054. /** @hidden */
  102055. export var pbrBlockAlbedoOpacity: {
  102056. name: string;
  102057. shader: string;
  102058. };
  102059. }
  102060. declare module BABYLON {
  102061. /** @hidden */
  102062. export var pbrBlockReflectivity: {
  102063. name: string;
  102064. shader: string;
  102065. };
  102066. }
  102067. declare module BABYLON {
  102068. /** @hidden */
  102069. export var pbrBlockAmbientOcclusion: {
  102070. name: string;
  102071. shader: string;
  102072. };
  102073. }
  102074. declare module BABYLON {
  102075. /** @hidden */
  102076. export var pbrBlockAlphaFresnel: {
  102077. name: string;
  102078. shader: string;
  102079. };
  102080. }
  102081. declare module BABYLON {
  102082. /** @hidden */
  102083. export var pbrBlockAnisotropic: {
  102084. name: string;
  102085. shader: string;
  102086. };
  102087. }
  102088. declare module BABYLON {
  102089. /** @hidden */
  102090. export var pbrBlockReflection: {
  102091. name: string;
  102092. shader: string;
  102093. };
  102094. }
  102095. declare module BABYLON {
  102096. /** @hidden */
  102097. export var pbrBlockSheen: {
  102098. name: string;
  102099. shader: string;
  102100. };
  102101. }
  102102. declare module BABYLON {
  102103. /** @hidden */
  102104. export var pbrBlockClearcoat: {
  102105. name: string;
  102106. shader: string;
  102107. };
  102108. }
  102109. declare module BABYLON {
  102110. /** @hidden */
  102111. export var pbrBlockSubSurface: {
  102112. name: string;
  102113. shader: string;
  102114. };
  102115. }
  102116. declare module BABYLON {
  102117. /** @hidden */
  102118. export var pbrBlockNormalGeometric: {
  102119. name: string;
  102120. shader: string;
  102121. };
  102122. }
  102123. declare module BABYLON {
  102124. /** @hidden */
  102125. export var pbrBlockNormalFinal: {
  102126. name: string;
  102127. shader: string;
  102128. };
  102129. }
  102130. declare module BABYLON {
  102131. /** @hidden */
  102132. export var pbrBlockLightmapInit: {
  102133. name: string;
  102134. shader: string;
  102135. };
  102136. }
  102137. declare module BABYLON {
  102138. /** @hidden */
  102139. export var pbrBlockGeometryInfo: {
  102140. name: string;
  102141. shader: string;
  102142. };
  102143. }
  102144. declare module BABYLON {
  102145. /** @hidden */
  102146. export var pbrBlockReflectance0: {
  102147. name: string;
  102148. shader: string;
  102149. };
  102150. }
  102151. declare module BABYLON {
  102152. /** @hidden */
  102153. export var pbrBlockReflectance: {
  102154. name: string;
  102155. shader: string;
  102156. };
  102157. }
  102158. declare module BABYLON {
  102159. /** @hidden */
  102160. export var pbrBlockDirectLighting: {
  102161. name: string;
  102162. shader: string;
  102163. };
  102164. }
  102165. declare module BABYLON {
  102166. /** @hidden */
  102167. export var pbrBlockFinalLitComponents: {
  102168. name: string;
  102169. shader: string;
  102170. };
  102171. }
  102172. declare module BABYLON {
  102173. /** @hidden */
  102174. export var pbrBlockFinalUnlitComponents: {
  102175. name: string;
  102176. shader: string;
  102177. };
  102178. }
  102179. declare module BABYLON {
  102180. /** @hidden */
  102181. export var pbrBlockFinalColorComposition: {
  102182. name: string;
  102183. shader: string;
  102184. };
  102185. }
  102186. declare module BABYLON {
  102187. /** @hidden */
  102188. export var pbrBlockImageProcessing: {
  102189. name: string;
  102190. shader: string;
  102191. };
  102192. }
  102193. declare module BABYLON {
  102194. /** @hidden */
  102195. export var pbrDebug: {
  102196. name: string;
  102197. shader: string;
  102198. };
  102199. }
  102200. declare module BABYLON {
  102201. /** @hidden */
  102202. export var pbrPixelShader: {
  102203. name: string;
  102204. shader: string;
  102205. };
  102206. }
  102207. declare module BABYLON {
  102208. /** @hidden */
  102209. export var pbrVertexDeclaration: {
  102210. name: string;
  102211. shader: string;
  102212. };
  102213. }
  102214. declare module BABYLON {
  102215. /** @hidden */
  102216. export var pbrVertexShader: {
  102217. name: string;
  102218. shader: string;
  102219. };
  102220. }
  102221. declare module BABYLON {
  102222. /**
  102223. * Manages the defines for the PBR Material.
  102224. * @hidden
  102225. */
  102226. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  102227. PBR: boolean;
  102228. NUM_SAMPLES: string;
  102229. REALTIME_FILTERING: boolean;
  102230. MAINUV1: boolean;
  102231. MAINUV2: boolean;
  102232. UV1: boolean;
  102233. UV2: boolean;
  102234. ALBEDO: boolean;
  102235. GAMMAALBEDO: boolean;
  102236. ALBEDODIRECTUV: number;
  102237. VERTEXCOLOR: boolean;
  102238. DETAIL: boolean;
  102239. DETAILDIRECTUV: number;
  102240. DETAIL_NORMALBLENDMETHOD: number;
  102241. AMBIENT: boolean;
  102242. AMBIENTDIRECTUV: number;
  102243. AMBIENTINGRAYSCALE: boolean;
  102244. OPACITY: boolean;
  102245. VERTEXALPHA: boolean;
  102246. OPACITYDIRECTUV: number;
  102247. OPACITYRGB: boolean;
  102248. ALPHATEST: boolean;
  102249. DEPTHPREPASS: boolean;
  102250. ALPHABLEND: boolean;
  102251. ALPHAFROMALBEDO: boolean;
  102252. ALPHATESTVALUE: string;
  102253. SPECULAROVERALPHA: boolean;
  102254. RADIANCEOVERALPHA: boolean;
  102255. ALPHAFRESNEL: boolean;
  102256. LINEARALPHAFRESNEL: boolean;
  102257. PREMULTIPLYALPHA: boolean;
  102258. EMISSIVE: boolean;
  102259. EMISSIVEDIRECTUV: number;
  102260. REFLECTIVITY: boolean;
  102261. REFLECTIVITYDIRECTUV: number;
  102262. SPECULARTERM: boolean;
  102263. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  102264. MICROSURFACEAUTOMATIC: boolean;
  102265. LODBASEDMICROSFURACE: boolean;
  102266. MICROSURFACEMAP: boolean;
  102267. MICROSURFACEMAPDIRECTUV: number;
  102268. METALLICWORKFLOW: boolean;
  102269. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  102270. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  102271. METALLNESSSTOREINMETALMAPBLUE: boolean;
  102272. AOSTOREINMETALMAPRED: boolean;
  102273. METALLIC_REFLECTANCE: boolean;
  102274. METALLIC_REFLECTANCEDIRECTUV: number;
  102275. ENVIRONMENTBRDF: boolean;
  102276. ENVIRONMENTBRDF_RGBD: boolean;
  102277. NORMAL: boolean;
  102278. TANGENT: boolean;
  102279. BUMP: boolean;
  102280. BUMPDIRECTUV: number;
  102281. OBJECTSPACE_NORMALMAP: boolean;
  102282. PARALLAX: boolean;
  102283. PARALLAXOCCLUSION: boolean;
  102284. NORMALXYSCALE: boolean;
  102285. LIGHTMAP: boolean;
  102286. LIGHTMAPDIRECTUV: number;
  102287. USELIGHTMAPASSHADOWMAP: boolean;
  102288. GAMMALIGHTMAP: boolean;
  102289. RGBDLIGHTMAP: boolean;
  102290. REFLECTION: boolean;
  102291. REFLECTIONMAP_3D: boolean;
  102292. REFLECTIONMAP_SPHERICAL: boolean;
  102293. REFLECTIONMAP_PLANAR: boolean;
  102294. REFLECTIONMAP_CUBIC: boolean;
  102295. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  102296. REFLECTIONMAP_PROJECTION: boolean;
  102297. REFLECTIONMAP_SKYBOX: boolean;
  102298. REFLECTIONMAP_EXPLICIT: boolean;
  102299. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  102300. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  102301. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  102302. INVERTCUBICMAP: boolean;
  102303. USESPHERICALFROMREFLECTIONMAP: boolean;
  102304. USEIRRADIANCEMAP: boolean;
  102305. SPHERICAL_HARMONICS: boolean;
  102306. USESPHERICALINVERTEX: boolean;
  102307. REFLECTIONMAP_OPPOSITEZ: boolean;
  102308. LODINREFLECTIONALPHA: boolean;
  102309. GAMMAREFLECTION: boolean;
  102310. RGBDREFLECTION: boolean;
  102311. LINEARSPECULARREFLECTION: boolean;
  102312. RADIANCEOCCLUSION: boolean;
  102313. HORIZONOCCLUSION: boolean;
  102314. INSTANCES: boolean;
  102315. THIN_INSTANCES: boolean;
  102316. PREPASS: boolean;
  102317. PREPASS_IRRADIANCE: boolean;
  102318. PREPASS_IRRADIANCE_INDEX: number;
  102319. PREPASS_ALBEDO: boolean;
  102320. PREPASS_ALBEDO_INDEX: number;
  102321. PREPASS_DEPTHNORMAL: boolean;
  102322. PREPASS_DEPTHNORMAL_INDEX: number;
  102323. PREPASS_POSITION: boolean;
  102324. PREPASS_POSITION_INDEX: number;
  102325. PREPASS_VELOCITY: boolean;
  102326. PREPASS_VELOCITY_INDEX: number;
  102327. PREPASS_REFLECTIVITY: boolean;
  102328. PREPASS_REFLECTIVITY_INDEX: number;
  102329. SCENE_MRT_COUNT: number;
  102330. NUM_BONE_INFLUENCERS: number;
  102331. BonesPerMesh: number;
  102332. BONETEXTURE: boolean;
  102333. BONES_VELOCITY_ENABLED: boolean;
  102334. NONUNIFORMSCALING: boolean;
  102335. MORPHTARGETS: boolean;
  102336. MORPHTARGETS_NORMAL: boolean;
  102337. MORPHTARGETS_TANGENT: boolean;
  102338. MORPHTARGETS_UV: boolean;
  102339. NUM_MORPH_INFLUENCERS: number;
  102340. IMAGEPROCESSING: boolean;
  102341. VIGNETTE: boolean;
  102342. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102343. VIGNETTEBLENDMODEOPAQUE: boolean;
  102344. TONEMAPPING: boolean;
  102345. TONEMAPPING_ACES: boolean;
  102346. CONTRAST: boolean;
  102347. COLORCURVES: boolean;
  102348. COLORGRADING: boolean;
  102349. COLORGRADING3D: boolean;
  102350. SAMPLER3DGREENDEPTH: boolean;
  102351. SAMPLER3DBGRMAP: boolean;
  102352. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102353. EXPOSURE: boolean;
  102354. MULTIVIEW: boolean;
  102355. USEPHYSICALLIGHTFALLOFF: boolean;
  102356. USEGLTFLIGHTFALLOFF: boolean;
  102357. TWOSIDEDLIGHTING: boolean;
  102358. SHADOWFLOAT: boolean;
  102359. CLIPPLANE: boolean;
  102360. CLIPPLANE2: boolean;
  102361. CLIPPLANE3: boolean;
  102362. CLIPPLANE4: boolean;
  102363. CLIPPLANE5: boolean;
  102364. CLIPPLANE6: boolean;
  102365. POINTSIZE: boolean;
  102366. FOG: boolean;
  102367. LOGARITHMICDEPTH: boolean;
  102368. FORCENORMALFORWARD: boolean;
  102369. SPECULARAA: boolean;
  102370. CLEARCOAT: boolean;
  102371. CLEARCOAT_DEFAULTIOR: boolean;
  102372. CLEARCOAT_TEXTURE: boolean;
  102373. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  102374. CLEARCOAT_TEXTUREDIRECTUV: number;
  102375. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  102376. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  102377. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  102378. CLEARCOAT_BUMP: boolean;
  102379. CLEARCOAT_BUMPDIRECTUV: number;
  102380. CLEARCOAT_REMAP_F0: boolean;
  102381. CLEARCOAT_TINT: boolean;
  102382. CLEARCOAT_TINT_TEXTURE: boolean;
  102383. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  102384. ANISOTROPIC: boolean;
  102385. ANISOTROPIC_TEXTURE: boolean;
  102386. ANISOTROPIC_TEXTUREDIRECTUV: number;
  102387. BRDF_V_HEIGHT_CORRELATED: boolean;
  102388. MS_BRDF_ENERGY_CONSERVATION: boolean;
  102389. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  102390. SHEEN: boolean;
  102391. SHEEN_TEXTURE: boolean;
  102392. SHEEN_TEXTURE_ROUGHNESS: boolean;
  102393. SHEEN_TEXTUREDIRECTUV: number;
  102394. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  102395. SHEEN_LINKWITHALBEDO: boolean;
  102396. SHEEN_ROUGHNESS: boolean;
  102397. SHEEN_ALBEDOSCALING: boolean;
  102398. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  102399. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  102400. SUBSURFACE: boolean;
  102401. SS_REFRACTION: boolean;
  102402. SS_TRANSLUCENCY: boolean;
  102403. SS_SCATTERING: boolean;
  102404. SS_THICKNESSANDMASK_TEXTURE: boolean;
  102405. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  102406. SS_REFRACTIONMAP_3D: boolean;
  102407. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  102408. SS_LODINREFRACTIONALPHA: boolean;
  102409. SS_GAMMAREFRACTION: boolean;
  102410. SS_RGBDREFRACTION: boolean;
  102411. SS_LINEARSPECULARREFRACTION: boolean;
  102412. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  102413. SS_ALBEDOFORREFRACTIONTINT: boolean;
  102414. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  102415. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  102416. UNLIT: boolean;
  102417. DEBUGMODE: number;
  102418. /**
  102419. * Initializes the PBR Material defines.
  102420. */
  102421. constructor();
  102422. /**
  102423. * Resets the PBR Material defines.
  102424. */
  102425. reset(): void;
  102426. }
  102427. /**
  102428. * The Physically based material base class of BJS.
  102429. *
  102430. * This offers the main features of a standard PBR material.
  102431. * For more information, please refer to the documentation :
  102432. * https://doc.babylonjs.com/how_to/physically_based_rendering
  102433. */
  102434. export abstract class PBRBaseMaterial extends PushMaterial {
  102435. /**
  102436. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102437. */
  102438. static readonly PBRMATERIAL_OPAQUE: number;
  102439. /**
  102440. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102441. */
  102442. static readonly PBRMATERIAL_ALPHATEST: number;
  102443. /**
  102444. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102445. */
  102446. static readonly PBRMATERIAL_ALPHABLEND: number;
  102447. /**
  102448. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102449. * They are also discarded below the alpha cutoff threshold to improve performances.
  102450. */
  102451. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  102452. /**
  102453. * Defines the default value of how much AO map is occluding the analytical lights
  102454. * (point spot...).
  102455. */
  102456. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  102457. /**
  102458. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  102459. */
  102460. static readonly LIGHTFALLOFF_PHYSICAL: number;
  102461. /**
  102462. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  102463. * to enhance interoperability with other engines.
  102464. */
  102465. static readonly LIGHTFALLOFF_GLTF: number;
  102466. /**
  102467. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  102468. * to enhance interoperability with other materials.
  102469. */
  102470. static readonly LIGHTFALLOFF_STANDARD: number;
  102471. /**
  102472. * Intensity of the direct lights e.g. the four lights available in your scene.
  102473. * This impacts both the direct diffuse and specular highlights.
  102474. */
  102475. protected _directIntensity: number;
  102476. /**
  102477. * Intensity of the emissive part of the material.
  102478. * This helps controlling the emissive effect without modifying the emissive color.
  102479. */
  102480. protected _emissiveIntensity: number;
  102481. /**
  102482. * Intensity of the environment e.g. how much the environment will light the object
  102483. * either through harmonics for rough material or through the refelction for shiny ones.
  102484. */
  102485. protected _environmentIntensity: number;
  102486. /**
  102487. * This is a special control allowing the reduction of the specular highlights coming from the
  102488. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  102489. */
  102490. protected _specularIntensity: number;
  102491. /**
  102492. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  102493. */
  102494. private _lightingInfos;
  102495. /**
  102496. * Debug Control allowing disabling the bump map on this material.
  102497. */
  102498. protected _disableBumpMap: boolean;
  102499. /**
  102500. * AKA Diffuse Texture in standard nomenclature.
  102501. */
  102502. protected _albedoTexture: Nullable<BaseTexture>;
  102503. /**
  102504. * AKA Occlusion Texture in other nomenclature.
  102505. */
  102506. protected _ambientTexture: Nullable<BaseTexture>;
  102507. /**
  102508. * AKA Occlusion Texture Intensity in other nomenclature.
  102509. */
  102510. protected _ambientTextureStrength: number;
  102511. /**
  102512. * Defines how much the AO map is occluding the analytical lights (point spot...).
  102513. * 1 means it completely occludes it
  102514. * 0 mean it has no impact
  102515. */
  102516. protected _ambientTextureImpactOnAnalyticalLights: number;
  102517. /**
  102518. * Stores the alpha values in a texture.
  102519. */
  102520. protected _opacityTexture: Nullable<BaseTexture>;
  102521. /**
  102522. * Stores the reflection values in a texture.
  102523. */
  102524. protected _reflectionTexture: Nullable<BaseTexture>;
  102525. /**
  102526. * Stores the emissive values in a texture.
  102527. */
  102528. protected _emissiveTexture: Nullable<BaseTexture>;
  102529. /**
  102530. * AKA Specular texture in other nomenclature.
  102531. */
  102532. protected _reflectivityTexture: Nullable<BaseTexture>;
  102533. /**
  102534. * Used to switch from specular/glossiness to metallic/roughness workflow.
  102535. */
  102536. protected _metallicTexture: Nullable<BaseTexture>;
  102537. /**
  102538. * Specifies the metallic scalar of the metallic/roughness workflow.
  102539. * Can also be used to scale the metalness values of the metallic texture.
  102540. */
  102541. protected _metallic: Nullable<number>;
  102542. /**
  102543. * Specifies the roughness scalar of the metallic/roughness workflow.
  102544. * Can also be used to scale the roughness values of the metallic texture.
  102545. */
  102546. protected _roughness: Nullable<number>;
  102547. /**
  102548. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  102549. * By default the indexOfrefraction is used to compute F0;
  102550. *
  102551. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  102552. *
  102553. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  102554. * F90 = metallicReflectanceColor;
  102555. */
  102556. protected _metallicF0Factor: number;
  102557. /**
  102558. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  102559. * By default the F90 is always 1;
  102560. *
  102561. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  102562. *
  102563. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  102564. * F90 = metallicReflectanceColor;
  102565. */
  102566. protected _metallicReflectanceColor: Color3;
  102567. /**
  102568. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  102569. * This is multiply against the scalar values defined in the material.
  102570. */
  102571. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  102572. /**
  102573. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  102574. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  102575. */
  102576. protected _microSurfaceTexture: Nullable<BaseTexture>;
  102577. /**
  102578. * Stores surface normal data used to displace a mesh in a texture.
  102579. */
  102580. protected _bumpTexture: Nullable<BaseTexture>;
  102581. /**
  102582. * Stores the pre-calculated light information of a mesh in a texture.
  102583. */
  102584. protected _lightmapTexture: Nullable<BaseTexture>;
  102585. /**
  102586. * The color of a material in ambient lighting.
  102587. */
  102588. protected _ambientColor: Color3;
  102589. /**
  102590. * AKA Diffuse Color in other nomenclature.
  102591. */
  102592. protected _albedoColor: Color3;
  102593. /**
  102594. * AKA Specular Color in other nomenclature.
  102595. */
  102596. protected _reflectivityColor: Color3;
  102597. /**
  102598. * The color applied when light is reflected from a material.
  102599. */
  102600. protected _reflectionColor: Color3;
  102601. /**
  102602. * The color applied when light is emitted from a material.
  102603. */
  102604. protected _emissiveColor: Color3;
  102605. /**
  102606. * AKA Glossiness in other nomenclature.
  102607. */
  102608. protected _microSurface: number;
  102609. /**
  102610. * Specifies that the material will use the light map as a show map.
  102611. */
  102612. protected _useLightmapAsShadowmap: boolean;
  102613. /**
  102614. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  102615. * makes the reflect vector face the model (under horizon).
  102616. */
  102617. protected _useHorizonOcclusion: boolean;
  102618. /**
  102619. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  102620. * too much the area relying on ambient texture to define their ambient occlusion.
  102621. */
  102622. protected _useRadianceOcclusion: boolean;
  102623. /**
  102624. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  102625. */
  102626. protected _useAlphaFromAlbedoTexture: boolean;
  102627. /**
  102628. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  102629. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102630. */
  102631. protected _useSpecularOverAlpha: boolean;
  102632. /**
  102633. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  102634. */
  102635. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  102636. /**
  102637. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  102638. */
  102639. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  102640. /**
  102641. * Specifies if the metallic texture contains the roughness information in its green channel.
  102642. */
  102643. protected _useRoughnessFromMetallicTextureGreen: boolean;
  102644. /**
  102645. * Specifies if the metallic texture contains the metallness information in its blue channel.
  102646. */
  102647. protected _useMetallnessFromMetallicTextureBlue: boolean;
  102648. /**
  102649. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  102650. */
  102651. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  102652. /**
  102653. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  102654. */
  102655. protected _useAmbientInGrayScale: boolean;
  102656. /**
  102657. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  102658. * The material will try to infer what glossiness each pixel should be.
  102659. */
  102660. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  102661. /**
  102662. * Defines the falloff type used in this material.
  102663. * It by default is Physical.
  102664. */
  102665. protected _lightFalloff: number;
  102666. /**
  102667. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102668. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102669. */
  102670. protected _useRadianceOverAlpha: boolean;
  102671. /**
  102672. * Allows using an object space normal map (instead of tangent space).
  102673. */
  102674. protected _useObjectSpaceNormalMap: boolean;
  102675. /**
  102676. * Allows using the bump map in parallax mode.
  102677. */
  102678. protected _useParallax: boolean;
  102679. /**
  102680. * Allows using the bump map in parallax occlusion mode.
  102681. */
  102682. protected _useParallaxOcclusion: boolean;
  102683. /**
  102684. * Controls the scale bias of the parallax mode.
  102685. */
  102686. protected _parallaxScaleBias: number;
  102687. /**
  102688. * If sets to true, disables all the lights affecting the material.
  102689. */
  102690. protected _disableLighting: boolean;
  102691. /**
  102692. * Number of Simultaneous lights allowed on the material.
  102693. */
  102694. protected _maxSimultaneousLights: number;
  102695. /**
  102696. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  102697. */
  102698. protected _invertNormalMapX: boolean;
  102699. /**
  102700. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  102701. */
  102702. protected _invertNormalMapY: boolean;
  102703. /**
  102704. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102705. */
  102706. protected _twoSidedLighting: boolean;
  102707. /**
  102708. * Defines the alpha limits in alpha test mode.
  102709. */
  102710. protected _alphaCutOff: number;
  102711. /**
  102712. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102713. */
  102714. protected _forceAlphaTest: boolean;
  102715. /**
  102716. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102717. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  102718. */
  102719. protected _useAlphaFresnel: boolean;
  102720. /**
  102721. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102722. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  102723. */
  102724. protected _useLinearAlphaFresnel: boolean;
  102725. /**
  102726. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  102727. * from cos thetav and roughness:
  102728. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  102729. */
  102730. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  102731. /**
  102732. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  102733. */
  102734. protected _forceIrradianceInFragment: boolean;
  102735. private _realTimeFiltering;
  102736. /**
  102737. * Enables realtime filtering on the texture.
  102738. */
  102739. get realTimeFiltering(): boolean;
  102740. set realTimeFiltering(b: boolean);
  102741. private _realTimeFilteringQuality;
  102742. /**
  102743. * Quality switch for realtime filtering
  102744. */
  102745. get realTimeFilteringQuality(): number;
  102746. set realTimeFilteringQuality(n: number);
  102747. /**
  102748. * Can this material render to several textures at once
  102749. */
  102750. get canRenderToMRT(): boolean;
  102751. /**
  102752. * Force normal to face away from face.
  102753. */
  102754. protected _forceNormalForward: boolean;
  102755. /**
  102756. * Enables specular anti aliasing in the PBR shader.
  102757. * It will both interacts on the Geometry for analytical and IBL lighting.
  102758. * It also prefilter the roughness map based on the bump values.
  102759. */
  102760. protected _enableSpecularAntiAliasing: boolean;
  102761. /**
  102762. * Default configuration related to image processing available in the PBR Material.
  102763. */
  102764. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102765. /**
  102766. * Keep track of the image processing observer to allow dispose and replace.
  102767. */
  102768. private _imageProcessingObserver;
  102769. /**
  102770. * Attaches a new image processing configuration to the PBR Material.
  102771. * @param configuration
  102772. */
  102773. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102774. /**
  102775. * Stores the available render targets.
  102776. */
  102777. private _renderTargets;
  102778. /**
  102779. * Sets the global ambient color for the material used in lighting calculations.
  102780. */
  102781. private _globalAmbientColor;
  102782. /**
  102783. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  102784. */
  102785. private _useLogarithmicDepth;
  102786. /**
  102787. * If set to true, no lighting calculations will be applied.
  102788. */
  102789. private _unlit;
  102790. private _debugMode;
  102791. /**
  102792. * @hidden
  102793. * This is reserved for the inspector.
  102794. * Defines the material debug mode.
  102795. * It helps seeing only some components of the material while troubleshooting.
  102796. */
  102797. debugMode: number;
  102798. /**
  102799. * @hidden
  102800. * This is reserved for the inspector.
  102801. * Specify from where on screen the debug mode should start.
  102802. * The value goes from -1 (full screen) to 1 (not visible)
  102803. * It helps with side by side comparison against the final render
  102804. * This defaults to -1
  102805. */
  102806. private debugLimit;
  102807. /**
  102808. * @hidden
  102809. * This is reserved for the inspector.
  102810. * As the default viewing range might not be enough (if the ambient is really small for instance)
  102811. * You can use the factor to better multiply the final value.
  102812. */
  102813. private debugFactor;
  102814. /**
  102815. * Defines the clear coat layer parameters for the material.
  102816. */
  102817. readonly clearCoat: PBRClearCoatConfiguration;
  102818. /**
  102819. * Defines the anisotropic parameters for the material.
  102820. */
  102821. readonly anisotropy: PBRAnisotropicConfiguration;
  102822. /**
  102823. * Defines the BRDF parameters for the material.
  102824. */
  102825. readonly brdf: PBRBRDFConfiguration;
  102826. /**
  102827. * Defines the Sheen parameters for the material.
  102828. */
  102829. readonly sheen: PBRSheenConfiguration;
  102830. /**
  102831. * Defines the SubSurface parameters for the material.
  102832. */
  102833. readonly subSurface: PBRSubSurfaceConfiguration;
  102834. /**
  102835. * Defines additionnal PrePass parameters for the material.
  102836. */
  102837. readonly prePassConfiguration: PrePassConfiguration;
  102838. /**
  102839. * Defines the detail map parameters for the material.
  102840. */
  102841. readonly detailMap: DetailMapConfiguration;
  102842. protected _rebuildInParallel: boolean;
  102843. /**
  102844. * Instantiates a new PBRMaterial instance.
  102845. *
  102846. * @param name The material name
  102847. * @param scene The scene the material will be use in.
  102848. */
  102849. constructor(name: string, scene: Scene);
  102850. /**
  102851. * Gets a boolean indicating that current material needs to register RTT
  102852. */
  102853. get hasRenderTargetTextures(): boolean;
  102854. /**
  102855. * Gets the name of the material class.
  102856. */
  102857. getClassName(): string;
  102858. /**
  102859. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  102860. */
  102861. get useLogarithmicDepth(): boolean;
  102862. /**
  102863. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  102864. */
  102865. set useLogarithmicDepth(value: boolean);
  102866. /**
  102867. * Returns true if alpha blending should be disabled.
  102868. */
  102869. protected get _disableAlphaBlending(): boolean;
  102870. /**
  102871. * Specifies whether or not this material should be rendered in alpha blend mode.
  102872. */
  102873. needAlphaBlending(): boolean;
  102874. /**
  102875. * Specifies whether or not this material should be rendered in alpha test mode.
  102876. */
  102877. needAlphaTesting(): boolean;
  102878. /**
  102879. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  102880. */
  102881. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  102882. /**
  102883. * Specifies whether or not there is a usable alpha channel for transparency.
  102884. */
  102885. protected _hasAlphaChannel(): boolean;
  102886. /**
  102887. * Gets the texture used for the alpha test.
  102888. */
  102889. getAlphaTestTexture(): Nullable<BaseTexture>;
  102890. /**
  102891. * Specifies that the submesh is ready to be used.
  102892. * @param mesh - BJS mesh.
  102893. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  102894. * @param useInstances - Specifies that instances should be used.
  102895. * @returns - boolean indicating that the submesh is ready or not.
  102896. */
  102897. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102898. /**
  102899. * Specifies if the material uses metallic roughness workflow.
  102900. * @returns boolean specifiying if the material uses metallic roughness workflow.
  102901. */
  102902. isMetallicWorkflow(): boolean;
  102903. private _prepareEffect;
  102904. private _prepareDefines;
  102905. /**
  102906. * Force shader compilation
  102907. */
  102908. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  102909. /**
  102910. * Initializes the uniform buffer layout for the shader.
  102911. */
  102912. buildUniformLayout(): void;
  102913. /**
  102914. * Unbinds the material from the mesh
  102915. */
  102916. unbind(): void;
  102917. /**
  102918. * Binds the submesh data.
  102919. * @param world - The world matrix.
  102920. * @param mesh - The BJS mesh.
  102921. * @param subMesh - A submesh of the BJS mesh.
  102922. */
  102923. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102924. /**
  102925. * Returns the animatable textures.
  102926. * @returns - Array of animatable textures.
  102927. */
  102928. getAnimatables(): IAnimatable[];
  102929. /**
  102930. * Returns the texture used for reflections.
  102931. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  102932. */
  102933. private _getReflectionTexture;
  102934. /**
  102935. * Returns an array of the actively used textures.
  102936. * @returns - Array of BaseTextures
  102937. */
  102938. getActiveTextures(): BaseTexture[];
  102939. /**
  102940. * Checks to see if a texture is used in the material.
  102941. * @param texture - Base texture to use.
  102942. * @returns - Boolean specifying if a texture is used in the material.
  102943. */
  102944. hasTexture(texture: BaseTexture): boolean;
  102945. /**
  102946. * Sets the required values to the prepass renderer.
  102947. * @param prePassRenderer defines the prepass renderer to setup
  102948. */
  102949. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  102950. /**
  102951. * Disposes the resources of the material.
  102952. * @param forceDisposeEffect - Forces the disposal of effects.
  102953. * @param forceDisposeTextures - Forces the disposal of all textures.
  102954. */
  102955. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102956. }
  102957. }
  102958. declare module BABYLON {
  102959. /**
  102960. * The Physically based material of BJS.
  102961. *
  102962. * This offers the main features of a standard PBR material.
  102963. * For more information, please refer to the documentation :
  102964. * https://doc.babylonjs.com/how_to/physically_based_rendering
  102965. */
  102966. export class PBRMaterial extends PBRBaseMaterial {
  102967. /**
  102968. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102969. */
  102970. static readonly PBRMATERIAL_OPAQUE: number;
  102971. /**
  102972. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102973. */
  102974. static readonly PBRMATERIAL_ALPHATEST: number;
  102975. /**
  102976. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102977. */
  102978. static readonly PBRMATERIAL_ALPHABLEND: number;
  102979. /**
  102980. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102981. * They are also discarded below the alpha cutoff threshold to improve performances.
  102982. */
  102983. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  102984. /**
  102985. * Defines the default value of how much AO map is occluding the analytical lights
  102986. * (point spot...).
  102987. */
  102988. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  102989. /**
  102990. * Intensity of the direct lights e.g. the four lights available in your scene.
  102991. * This impacts both the direct diffuse and specular highlights.
  102992. */
  102993. directIntensity: number;
  102994. /**
  102995. * Intensity of the emissive part of the material.
  102996. * This helps controlling the emissive effect without modifying the emissive color.
  102997. */
  102998. emissiveIntensity: number;
  102999. /**
  103000. * Intensity of the environment e.g. how much the environment will light the object
  103001. * either through harmonics for rough material or through the refelction for shiny ones.
  103002. */
  103003. environmentIntensity: number;
  103004. /**
  103005. * This is a special control allowing the reduction of the specular highlights coming from the
  103006. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  103007. */
  103008. specularIntensity: number;
  103009. /**
  103010. * Debug Control allowing disabling the bump map on this material.
  103011. */
  103012. disableBumpMap: boolean;
  103013. /**
  103014. * AKA Diffuse Texture in standard nomenclature.
  103015. */
  103016. albedoTexture: BaseTexture;
  103017. /**
  103018. * AKA Occlusion Texture in other nomenclature.
  103019. */
  103020. ambientTexture: BaseTexture;
  103021. /**
  103022. * AKA Occlusion Texture Intensity in other nomenclature.
  103023. */
  103024. ambientTextureStrength: number;
  103025. /**
  103026. * Defines how much the AO map is occluding the analytical lights (point spot...).
  103027. * 1 means it completely occludes it
  103028. * 0 mean it has no impact
  103029. */
  103030. ambientTextureImpactOnAnalyticalLights: number;
  103031. /**
  103032. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  103033. */
  103034. opacityTexture: BaseTexture;
  103035. /**
  103036. * Stores the reflection values in a texture.
  103037. */
  103038. reflectionTexture: Nullable<BaseTexture>;
  103039. /**
  103040. * Stores the emissive values in a texture.
  103041. */
  103042. emissiveTexture: BaseTexture;
  103043. /**
  103044. * AKA Specular texture in other nomenclature.
  103045. */
  103046. reflectivityTexture: BaseTexture;
  103047. /**
  103048. * Used to switch from specular/glossiness to metallic/roughness workflow.
  103049. */
  103050. metallicTexture: BaseTexture;
  103051. /**
  103052. * Specifies the metallic scalar of the metallic/roughness workflow.
  103053. * Can also be used to scale the metalness values of the metallic texture.
  103054. */
  103055. metallic: Nullable<number>;
  103056. /**
  103057. * Specifies the roughness scalar of the metallic/roughness workflow.
  103058. * Can also be used to scale the roughness values of the metallic texture.
  103059. */
  103060. roughness: Nullable<number>;
  103061. /**
  103062. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  103063. * By default the indexOfrefraction is used to compute F0;
  103064. *
  103065. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  103066. *
  103067. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  103068. * F90 = metallicReflectanceColor;
  103069. */
  103070. metallicF0Factor: number;
  103071. /**
  103072. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  103073. * By default the F90 is always 1;
  103074. *
  103075. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  103076. *
  103077. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  103078. * F90 = metallicReflectanceColor;
  103079. */
  103080. metallicReflectanceColor: Color3;
  103081. /**
  103082. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  103083. * This is multiply against the scalar values defined in the material.
  103084. */
  103085. metallicReflectanceTexture: Nullable<BaseTexture>;
  103086. /**
  103087. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  103088. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  103089. */
  103090. microSurfaceTexture: BaseTexture;
  103091. /**
  103092. * Stores surface normal data used to displace a mesh in a texture.
  103093. */
  103094. bumpTexture: BaseTexture;
  103095. /**
  103096. * Stores the pre-calculated light information of a mesh in a texture.
  103097. */
  103098. lightmapTexture: BaseTexture;
  103099. /**
  103100. * Stores the refracted light information in a texture.
  103101. */
  103102. get refractionTexture(): Nullable<BaseTexture>;
  103103. set refractionTexture(value: Nullable<BaseTexture>);
  103104. /**
  103105. * The color of a material in ambient lighting.
  103106. */
  103107. ambientColor: Color3;
  103108. /**
  103109. * AKA Diffuse Color in other nomenclature.
  103110. */
  103111. albedoColor: Color3;
  103112. /**
  103113. * AKA Specular Color in other nomenclature.
  103114. */
  103115. reflectivityColor: Color3;
  103116. /**
  103117. * The color reflected from the material.
  103118. */
  103119. reflectionColor: Color3;
  103120. /**
  103121. * The color emitted from the material.
  103122. */
  103123. emissiveColor: Color3;
  103124. /**
  103125. * AKA Glossiness in other nomenclature.
  103126. */
  103127. microSurface: number;
  103128. /**
  103129. * Index of refraction of the material base layer.
  103130. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  103131. *
  103132. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  103133. *
  103134. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  103135. */
  103136. get indexOfRefraction(): number;
  103137. set indexOfRefraction(value: number);
  103138. /**
  103139. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  103140. */
  103141. get invertRefractionY(): boolean;
  103142. set invertRefractionY(value: boolean);
  103143. /**
  103144. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  103145. * Materials half opaque for instance using refraction could benefit from this control.
  103146. */
  103147. get linkRefractionWithTransparency(): boolean;
  103148. set linkRefractionWithTransparency(value: boolean);
  103149. /**
  103150. * If true, the light map contains occlusion information instead of lighting info.
  103151. */
  103152. useLightmapAsShadowmap: boolean;
  103153. /**
  103154. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  103155. */
  103156. useAlphaFromAlbedoTexture: boolean;
  103157. /**
  103158. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  103159. */
  103160. forceAlphaTest: boolean;
  103161. /**
  103162. * Defines the alpha limits in alpha test mode.
  103163. */
  103164. alphaCutOff: number;
  103165. /**
  103166. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  103167. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  103168. */
  103169. useSpecularOverAlpha: boolean;
  103170. /**
  103171. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  103172. */
  103173. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  103174. /**
  103175. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  103176. */
  103177. useRoughnessFromMetallicTextureAlpha: boolean;
  103178. /**
  103179. * Specifies if the metallic texture contains the roughness information in its green channel.
  103180. */
  103181. useRoughnessFromMetallicTextureGreen: boolean;
  103182. /**
  103183. * Specifies if the metallic texture contains the metallness information in its blue channel.
  103184. */
  103185. useMetallnessFromMetallicTextureBlue: boolean;
  103186. /**
  103187. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  103188. */
  103189. useAmbientOcclusionFromMetallicTextureRed: boolean;
  103190. /**
  103191. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  103192. */
  103193. useAmbientInGrayScale: boolean;
  103194. /**
  103195. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  103196. * The material will try to infer what glossiness each pixel should be.
  103197. */
  103198. useAutoMicroSurfaceFromReflectivityMap: boolean;
  103199. /**
  103200. * BJS is using an harcoded light falloff based on a manually sets up range.
  103201. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  103202. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  103203. */
  103204. get usePhysicalLightFalloff(): boolean;
  103205. /**
  103206. * BJS is using an harcoded light falloff based on a manually sets up range.
  103207. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  103208. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  103209. */
  103210. set usePhysicalLightFalloff(value: boolean);
  103211. /**
  103212. * In order to support the falloff compatibility with gltf, a special mode has been added
  103213. * to reproduce the gltf light falloff.
  103214. */
  103215. get useGLTFLightFalloff(): boolean;
  103216. /**
  103217. * In order to support the falloff compatibility with gltf, a special mode has been added
  103218. * to reproduce the gltf light falloff.
  103219. */
  103220. set useGLTFLightFalloff(value: boolean);
  103221. /**
  103222. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  103223. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  103224. */
  103225. useRadianceOverAlpha: boolean;
  103226. /**
  103227. * Allows using an object space normal map (instead of tangent space).
  103228. */
  103229. useObjectSpaceNormalMap: boolean;
  103230. /**
  103231. * Allows using the bump map in parallax mode.
  103232. */
  103233. useParallax: boolean;
  103234. /**
  103235. * Allows using the bump map in parallax occlusion mode.
  103236. */
  103237. useParallaxOcclusion: boolean;
  103238. /**
  103239. * Controls the scale bias of the parallax mode.
  103240. */
  103241. parallaxScaleBias: number;
  103242. /**
  103243. * If sets to true, disables all the lights affecting the material.
  103244. */
  103245. disableLighting: boolean;
  103246. /**
  103247. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  103248. */
  103249. forceIrradianceInFragment: boolean;
  103250. /**
  103251. * Number of Simultaneous lights allowed on the material.
  103252. */
  103253. maxSimultaneousLights: number;
  103254. /**
  103255. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  103256. */
  103257. invertNormalMapX: boolean;
  103258. /**
  103259. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  103260. */
  103261. invertNormalMapY: boolean;
  103262. /**
  103263. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103264. */
  103265. twoSidedLighting: boolean;
  103266. /**
  103267. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103268. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  103269. */
  103270. useAlphaFresnel: boolean;
  103271. /**
  103272. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103273. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  103274. */
  103275. useLinearAlphaFresnel: boolean;
  103276. /**
  103277. * Let user defines the brdf lookup texture used for IBL.
  103278. * A default 8bit version is embedded but you could point at :
  103279. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  103280. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  103281. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  103282. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  103283. */
  103284. environmentBRDFTexture: Nullable<BaseTexture>;
  103285. /**
  103286. * Force normal to face away from face.
  103287. */
  103288. forceNormalForward: boolean;
  103289. /**
  103290. * Enables specular anti aliasing in the PBR shader.
  103291. * It will both interacts on the Geometry for analytical and IBL lighting.
  103292. * It also prefilter the roughness map based on the bump values.
  103293. */
  103294. enableSpecularAntiAliasing: boolean;
  103295. /**
  103296. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  103297. * makes the reflect vector face the model (under horizon).
  103298. */
  103299. useHorizonOcclusion: boolean;
  103300. /**
  103301. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  103302. * too much the area relying on ambient texture to define their ambient occlusion.
  103303. */
  103304. useRadianceOcclusion: boolean;
  103305. /**
  103306. * If set to true, no lighting calculations will be applied.
  103307. */
  103308. unlit: boolean;
  103309. /**
  103310. * Gets the image processing configuration used either in this material.
  103311. */
  103312. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103313. /**
  103314. * Sets the Default image processing configuration used either in the this material.
  103315. *
  103316. * If sets to null, the scene one is in use.
  103317. */
  103318. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103319. /**
  103320. * Gets wether the color curves effect is enabled.
  103321. */
  103322. get cameraColorCurvesEnabled(): boolean;
  103323. /**
  103324. * Sets wether the color curves effect is enabled.
  103325. */
  103326. set cameraColorCurvesEnabled(value: boolean);
  103327. /**
  103328. * Gets wether the color grading effect is enabled.
  103329. */
  103330. get cameraColorGradingEnabled(): boolean;
  103331. /**
  103332. * Gets wether the color grading effect is enabled.
  103333. */
  103334. set cameraColorGradingEnabled(value: boolean);
  103335. /**
  103336. * Gets wether tonemapping is enabled or not.
  103337. */
  103338. get cameraToneMappingEnabled(): boolean;
  103339. /**
  103340. * Sets wether tonemapping is enabled or not
  103341. */
  103342. set cameraToneMappingEnabled(value: boolean);
  103343. /**
  103344. * The camera exposure used on this material.
  103345. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103346. * This corresponds to a photographic exposure.
  103347. */
  103348. get cameraExposure(): number;
  103349. /**
  103350. * The camera exposure used on this material.
  103351. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103352. * This corresponds to a photographic exposure.
  103353. */
  103354. set cameraExposure(value: number);
  103355. /**
  103356. * Gets The camera contrast used on this material.
  103357. */
  103358. get cameraContrast(): number;
  103359. /**
  103360. * Sets The camera contrast used on this material.
  103361. */
  103362. set cameraContrast(value: number);
  103363. /**
  103364. * Gets the Color Grading 2D Lookup Texture.
  103365. */
  103366. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  103367. /**
  103368. * Sets the Color Grading 2D Lookup Texture.
  103369. */
  103370. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  103371. /**
  103372. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103373. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103374. * 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;
  103375. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103376. */
  103377. get cameraColorCurves(): Nullable<ColorCurves>;
  103378. /**
  103379. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103380. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103381. * 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;
  103382. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103383. */
  103384. set cameraColorCurves(value: Nullable<ColorCurves>);
  103385. /**
  103386. * Instantiates a new PBRMaterial instance.
  103387. *
  103388. * @param name The material name
  103389. * @param scene The scene the material will be use in.
  103390. */
  103391. constructor(name: string, scene: Scene);
  103392. /**
  103393. * Returns the name of this material class.
  103394. */
  103395. getClassName(): string;
  103396. /**
  103397. * Makes a duplicate of the current material.
  103398. * @param name - name to use for the new material.
  103399. */
  103400. clone(name: string): PBRMaterial;
  103401. /**
  103402. * Serializes this PBR Material.
  103403. * @returns - An object with the serialized material.
  103404. */
  103405. serialize(): any;
  103406. /**
  103407. * Parses a PBR Material from a serialized object.
  103408. * @param source - Serialized object.
  103409. * @param scene - BJS scene instance.
  103410. * @param rootUrl - url for the scene object
  103411. * @returns - PBRMaterial
  103412. */
  103413. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  103414. }
  103415. }
  103416. declare module BABYLON {
  103417. /** @hidden */
  103418. export var mrtFragmentDeclaration: {
  103419. name: string;
  103420. shader: string;
  103421. };
  103422. }
  103423. declare module BABYLON {
  103424. /** @hidden */
  103425. export var geometryPixelShader: {
  103426. name: string;
  103427. shader: string;
  103428. };
  103429. }
  103430. declare module BABYLON {
  103431. /** @hidden */
  103432. export var geometryVertexShader: {
  103433. name: string;
  103434. shader: string;
  103435. };
  103436. }
  103437. declare module BABYLON {
  103438. /** @hidden */
  103439. interface ISavedTransformationMatrix {
  103440. world: Matrix;
  103441. viewProjection: Matrix;
  103442. }
  103443. /**
  103444. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  103445. */
  103446. export class GeometryBufferRenderer {
  103447. /**
  103448. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  103449. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  103450. */
  103451. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  103452. /**
  103453. * Constant used to retrieve the position texture index in the G-Buffer textures array
  103454. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  103455. */
  103456. static readonly POSITION_TEXTURE_TYPE: number;
  103457. /**
  103458. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  103459. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  103460. */
  103461. static readonly VELOCITY_TEXTURE_TYPE: number;
  103462. /**
  103463. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  103464. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  103465. */
  103466. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  103467. /**
  103468. * Dictionary used to store the previous transformation matrices of each rendered mesh
  103469. * in order to compute objects velocities when enableVelocity is set to "true"
  103470. * @hidden
  103471. */
  103472. _previousTransformationMatrices: {
  103473. [index: number]: ISavedTransformationMatrix;
  103474. };
  103475. /**
  103476. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  103477. * in order to compute objects velocities when enableVelocity is set to "true"
  103478. * @hidden
  103479. */
  103480. _previousBonesTransformationMatrices: {
  103481. [index: number]: Float32Array;
  103482. };
  103483. /**
  103484. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  103485. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  103486. */
  103487. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  103488. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  103489. renderTransparentMeshes: boolean;
  103490. private _scene;
  103491. private _resizeObserver;
  103492. private _multiRenderTarget;
  103493. private _ratio;
  103494. private _enablePosition;
  103495. private _enableVelocity;
  103496. private _enableReflectivity;
  103497. private _positionIndex;
  103498. private _velocityIndex;
  103499. private _reflectivityIndex;
  103500. private _depthNormalIndex;
  103501. private _linkedWithPrePass;
  103502. private _prePassRenderer;
  103503. private _attachments;
  103504. protected _effect: Effect;
  103505. protected _cachedDefines: string;
  103506. /**
  103507. * @hidden
  103508. * Sets up internal structures to share outputs with PrePassRenderer
  103509. * This method should only be called by the PrePassRenderer itself
  103510. */
  103511. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  103512. /**
  103513. * @hidden
  103514. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  103515. * This method should only be called by the PrePassRenderer itself
  103516. */
  103517. _unlinkPrePassRenderer(): void;
  103518. /**
  103519. * @hidden
  103520. * Resets the geometry buffer layout
  103521. */
  103522. _resetLayout(): void;
  103523. /**
  103524. * @hidden
  103525. * Replaces a texture in the geometry buffer renderer
  103526. * Useful when linking textures of the prepass renderer
  103527. */
  103528. _forceTextureType(geometryBufferType: number, index: number): void;
  103529. /**
  103530. * @hidden
  103531. * Sets texture attachments
  103532. * Useful when linking textures of the prepass renderer
  103533. */
  103534. _setAttachments(attachments: number[]): void;
  103535. /**
  103536. * @hidden
  103537. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  103538. * Useful when linking textures of the prepass renderer
  103539. */
  103540. _linkInternalTexture(internalTexture: InternalTexture): void;
  103541. /**
  103542. * Gets the render list (meshes to be rendered) used in the G buffer.
  103543. */
  103544. get renderList(): Nullable<AbstractMesh[]>;
  103545. /**
  103546. * Set the render list (meshes to be rendered) used in the G buffer.
  103547. */
  103548. set renderList(meshes: Nullable<AbstractMesh[]>);
  103549. /**
  103550. * Gets wether or not G buffer are supported by the running hardware.
  103551. * This requires draw buffer supports
  103552. */
  103553. get isSupported(): boolean;
  103554. /**
  103555. * Returns the index of the given texture type in the G-Buffer textures array
  103556. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  103557. * @returns the index of the given texture type in the G-Buffer textures array
  103558. */
  103559. getTextureIndex(textureType: number): number;
  103560. /**
  103561. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  103562. */
  103563. get enablePosition(): boolean;
  103564. /**
  103565. * Sets whether or not objects positions are enabled for the G buffer.
  103566. */
  103567. set enablePosition(enable: boolean);
  103568. /**
  103569. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  103570. */
  103571. get enableVelocity(): boolean;
  103572. /**
  103573. * Sets wether or not objects velocities are enabled for the G buffer.
  103574. */
  103575. set enableVelocity(enable: boolean);
  103576. /**
  103577. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  103578. */
  103579. get enableReflectivity(): boolean;
  103580. /**
  103581. * Sets wether or not objects roughness are enabled for the G buffer.
  103582. */
  103583. set enableReflectivity(enable: boolean);
  103584. /**
  103585. * Gets the scene associated with the buffer.
  103586. */
  103587. get scene(): Scene;
  103588. /**
  103589. * Gets the ratio used by the buffer during its creation.
  103590. * How big is the buffer related to the main canvas.
  103591. */
  103592. get ratio(): number;
  103593. /** @hidden */
  103594. static _SceneComponentInitialization: (scene: Scene) => void;
  103595. /**
  103596. * Creates a new G Buffer for the scene
  103597. * @param scene The scene the buffer belongs to
  103598. * @param ratio How big is the buffer related to the main canvas.
  103599. */
  103600. constructor(scene: Scene, ratio?: number);
  103601. /**
  103602. * Checks wether everything is ready to render a submesh to the G buffer.
  103603. * @param subMesh the submesh to check readiness for
  103604. * @param useInstances is the mesh drawn using instance or not
  103605. * @returns true if ready otherwise false
  103606. */
  103607. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103608. /**
  103609. * Gets the current underlying G Buffer.
  103610. * @returns the buffer
  103611. */
  103612. getGBuffer(): MultiRenderTarget;
  103613. /**
  103614. * Gets the number of samples used to render the buffer (anti aliasing).
  103615. */
  103616. get samples(): number;
  103617. /**
  103618. * Sets the number of samples used to render the buffer (anti aliasing).
  103619. */
  103620. set samples(value: number);
  103621. /**
  103622. * Disposes the renderer and frees up associated resources.
  103623. */
  103624. dispose(): void;
  103625. private _assignRenderTargetIndices;
  103626. protected _createRenderTargets(): void;
  103627. private _copyBonesTransformationMatrices;
  103628. }
  103629. }
  103630. declare module BABYLON {
  103631. /**
  103632. * Renders a pre pass of the scene
  103633. * This means every mesh in the scene will be rendered to a render target texture
  103634. * And then this texture will be composited to the rendering canvas with post processes
  103635. * It is necessary for effects like subsurface scattering or deferred shading
  103636. */
  103637. export class PrePassRenderer {
  103638. /** @hidden */
  103639. static _SceneComponentInitialization: (scene: Scene) => void;
  103640. private _textureFormats;
  103641. /**
  103642. * To save performance, we can excluded skinned meshes from the prepass
  103643. */
  103644. excludedSkinnedMesh: AbstractMesh[];
  103645. /**
  103646. * Force material to be excluded from the prepass
  103647. * Can be useful when `useGeometryBufferFallback` is set to `true`
  103648. * and you don't want a material to show in the effect.
  103649. */
  103650. excludedMaterials: Material[];
  103651. private _textureIndices;
  103652. private _scene;
  103653. private _engine;
  103654. private _isDirty;
  103655. /**
  103656. * Number of textures in the multi render target texture where the scene is directly rendered
  103657. */
  103658. mrtCount: number;
  103659. /**
  103660. * The render target where the scene is directly rendered
  103661. */
  103662. prePassRT: MultiRenderTarget;
  103663. private _multiRenderAttachments;
  103664. private _defaultAttachments;
  103665. private _clearAttachments;
  103666. private _postProcesses;
  103667. private readonly _clearColor;
  103668. /**
  103669. * Image processing post process for composition
  103670. */
  103671. imageProcessingPostProcess: ImageProcessingPostProcess;
  103672. /**
  103673. * Configuration for prepass effects
  103674. */
  103675. private _effectConfigurations;
  103676. private _mrtFormats;
  103677. private _mrtLayout;
  103678. private _enabled;
  103679. /**
  103680. * Indicates if the prepass is enabled
  103681. */
  103682. get enabled(): boolean;
  103683. /**
  103684. * How many samples are used for MSAA of the scene render target
  103685. */
  103686. get samples(): number;
  103687. set samples(n: number);
  103688. private _geometryBuffer;
  103689. private _useGeometryBufferFallback;
  103690. /**
  103691. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  103692. */
  103693. get useGeometryBufferFallback(): boolean;
  103694. set useGeometryBufferFallback(value: boolean);
  103695. /**
  103696. * Instanciates a prepass renderer
  103697. * @param scene The scene
  103698. */
  103699. constructor(scene: Scene);
  103700. private _initializeAttachments;
  103701. private _createCompositionEffect;
  103702. /**
  103703. * Indicates if rendering a prepass is supported
  103704. */
  103705. get isSupported(): boolean;
  103706. /**
  103707. * Sets the proper output textures to draw in the engine.
  103708. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  103709. * @param subMesh Submesh on which the effect is applied
  103710. */
  103711. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  103712. /**
  103713. * @hidden
  103714. */
  103715. _beforeCameraDraw(): void;
  103716. /**
  103717. * @hidden
  103718. */
  103719. _afterCameraDraw(): void;
  103720. private _checkRTSize;
  103721. private _bindFrameBuffer;
  103722. /**
  103723. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  103724. */
  103725. clear(): void;
  103726. private _setState;
  103727. private _updateGeometryBufferLayout;
  103728. /**
  103729. * Adds an effect configuration to the prepass.
  103730. * If an effect has already been added, it won't add it twice and will return the configuration
  103731. * already present.
  103732. * @param cfg the effect configuration
  103733. * @return the effect configuration now used by the prepass
  103734. */
  103735. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  103736. /**
  103737. * Returns the index of a texture in the multi render target texture array.
  103738. * @param type Texture type
  103739. * @return The index
  103740. */
  103741. getIndex(type: number): number;
  103742. private _enable;
  103743. private _disable;
  103744. private _resetLayout;
  103745. private _resetPostProcessChain;
  103746. private _bindPostProcessChain;
  103747. /**
  103748. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  103749. */
  103750. markAsDirty(): void;
  103751. /**
  103752. * Enables a texture on the MultiRenderTarget for prepass
  103753. */
  103754. private _enableTextures;
  103755. private _update;
  103756. private _markAllMaterialsAsPrePassDirty;
  103757. /**
  103758. * Disposes the prepass renderer.
  103759. */
  103760. dispose(): void;
  103761. }
  103762. }
  103763. declare module BABYLON {
  103764. /**
  103765. * Size options for a post process
  103766. */
  103767. export type PostProcessOptions = {
  103768. width: number;
  103769. height: number;
  103770. };
  103771. /**
  103772. * PostProcess can be used to apply a shader to a texture after it has been rendered
  103773. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103774. */
  103775. export class PostProcess {
  103776. /**
  103777. * Gets or sets the unique id of the post process
  103778. */
  103779. uniqueId: number;
  103780. /** Name of the PostProcess. */
  103781. name: string;
  103782. /**
  103783. * Width of the texture to apply the post process on
  103784. */
  103785. width: number;
  103786. /**
  103787. * Height of the texture to apply the post process on
  103788. */
  103789. height: number;
  103790. /**
  103791. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  103792. */
  103793. nodeMaterialSource: Nullable<NodeMaterial>;
  103794. /**
  103795. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  103796. * @hidden
  103797. */
  103798. _outputTexture: Nullable<InternalTexture>;
  103799. /**
  103800. * Sampling mode used by the shader
  103801. * See https://doc.babylonjs.com/classes/3.1/texture
  103802. */
  103803. renderTargetSamplingMode: number;
  103804. /**
  103805. * Clear color to use when screen clearing
  103806. */
  103807. clearColor: Color4;
  103808. /**
  103809. * If the buffer needs to be cleared before applying the post process. (default: true)
  103810. * Should be set to false if shader will overwrite all previous pixels.
  103811. */
  103812. autoClear: boolean;
  103813. /**
  103814. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  103815. */
  103816. alphaMode: number;
  103817. /**
  103818. * Sets the setAlphaBlendConstants of the babylon engine
  103819. */
  103820. alphaConstants: Color4;
  103821. /**
  103822. * Animations to be used for the post processing
  103823. */
  103824. animations: Animation[];
  103825. /**
  103826. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  103827. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  103828. */
  103829. enablePixelPerfectMode: boolean;
  103830. /**
  103831. * Force the postprocess to be applied without taking in account viewport
  103832. */
  103833. forceFullscreenViewport: boolean;
  103834. /**
  103835. * List of inspectable custom properties (used by the Inspector)
  103836. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103837. */
  103838. inspectableCustomProperties: IInspectable[];
  103839. /**
  103840. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  103841. *
  103842. * | Value | Type | Description |
  103843. * | ----- | ----------------------------------- | ----------- |
  103844. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  103845. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  103846. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  103847. *
  103848. */
  103849. scaleMode: number;
  103850. /**
  103851. * Force textures to be a power of two (default: false)
  103852. */
  103853. alwaysForcePOT: boolean;
  103854. private _samples;
  103855. /**
  103856. * Number of sample textures (default: 1)
  103857. */
  103858. get samples(): number;
  103859. set samples(n: number);
  103860. /**
  103861. * Modify the scale of the post process to be the same as the viewport (default: false)
  103862. */
  103863. adaptScaleToCurrentViewport: boolean;
  103864. private _camera;
  103865. protected _scene: Scene;
  103866. private _engine;
  103867. private _options;
  103868. private _reusable;
  103869. private _textureType;
  103870. private _textureFormat;
  103871. /**
  103872. * Smart array of input and output textures for the post process.
  103873. * @hidden
  103874. */
  103875. _textures: SmartArray<InternalTexture>;
  103876. /**
  103877. * The index in _textures that corresponds to the output texture.
  103878. * @hidden
  103879. */
  103880. _currentRenderTextureInd: number;
  103881. private _effect;
  103882. private _samplers;
  103883. private _fragmentUrl;
  103884. private _vertexUrl;
  103885. private _parameters;
  103886. private _scaleRatio;
  103887. protected _indexParameters: any;
  103888. private _shareOutputWithPostProcess;
  103889. private _texelSize;
  103890. private _forcedOutputTexture;
  103891. /**
  103892. * Prepass configuration in case this post process needs a texture from prepass
  103893. * @hidden
  103894. */
  103895. _prePassEffectConfiguration: PrePassEffectConfiguration;
  103896. /**
  103897. * Returns the fragment url or shader name used in the post process.
  103898. * @returns the fragment url or name in the shader store.
  103899. */
  103900. getEffectName(): string;
  103901. /**
  103902. * An event triggered when the postprocess is activated.
  103903. */
  103904. onActivateObservable: Observable<Camera>;
  103905. private _onActivateObserver;
  103906. /**
  103907. * A function that is added to the onActivateObservable
  103908. */
  103909. set onActivate(callback: Nullable<(camera: Camera) => void>);
  103910. /**
  103911. * An event triggered when the postprocess changes its size.
  103912. */
  103913. onSizeChangedObservable: Observable<PostProcess>;
  103914. private _onSizeChangedObserver;
  103915. /**
  103916. * A function that is added to the onSizeChangedObservable
  103917. */
  103918. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  103919. /**
  103920. * An event triggered when the postprocess applies its effect.
  103921. */
  103922. onApplyObservable: Observable<Effect>;
  103923. private _onApplyObserver;
  103924. /**
  103925. * A function that is added to the onApplyObservable
  103926. */
  103927. set onApply(callback: (effect: Effect) => void);
  103928. /**
  103929. * An event triggered before rendering the postprocess
  103930. */
  103931. onBeforeRenderObservable: Observable<Effect>;
  103932. private _onBeforeRenderObserver;
  103933. /**
  103934. * A function that is added to the onBeforeRenderObservable
  103935. */
  103936. set onBeforeRender(callback: (effect: Effect) => void);
  103937. /**
  103938. * An event triggered after rendering the postprocess
  103939. */
  103940. onAfterRenderObservable: Observable<Effect>;
  103941. private _onAfterRenderObserver;
  103942. /**
  103943. * A function that is added to the onAfterRenderObservable
  103944. */
  103945. set onAfterRender(callback: (efect: Effect) => void);
  103946. /**
  103947. * 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
  103948. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  103949. */
  103950. get inputTexture(): InternalTexture;
  103951. set inputTexture(value: InternalTexture);
  103952. /**
  103953. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  103954. * the only way to unset it is to use this function to restore its internal state
  103955. */
  103956. restoreDefaultInputTexture(): void;
  103957. /**
  103958. * Gets the camera which post process is applied to.
  103959. * @returns The camera the post process is applied to.
  103960. */
  103961. getCamera(): Camera;
  103962. /**
  103963. * Gets the texel size of the postprocess.
  103964. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  103965. */
  103966. get texelSize(): Vector2;
  103967. /**
  103968. * Creates a new instance PostProcess
  103969. * @param name The name of the PostProcess.
  103970. * @param fragmentUrl The url of the fragment shader to be used.
  103971. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  103972. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  103973. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103974. * @param camera The camera to apply the render pass to.
  103975. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103976. * @param engine The engine which the post process will be applied. (default: current engine)
  103977. * @param reusable If the post process can be reused on the same frame. (default: false)
  103978. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  103979. * @param textureType Type of textures used when performing the post process. (default: 0)
  103980. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  103981. * @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
  103982. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  103983. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  103984. */
  103985. 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);
  103986. /**
  103987. * Gets a string identifying the name of the class
  103988. * @returns "PostProcess" string
  103989. */
  103990. getClassName(): string;
  103991. /**
  103992. * Gets the engine which this post process belongs to.
  103993. * @returns The engine the post process was enabled with.
  103994. */
  103995. getEngine(): Engine;
  103996. /**
  103997. * The effect that is created when initializing the post process.
  103998. * @returns The created effect corresponding the the postprocess.
  103999. */
  104000. getEffect(): Effect;
  104001. /**
  104002. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  104003. * @param postProcess The post process to share the output with.
  104004. * @returns This post process.
  104005. */
  104006. shareOutputWith(postProcess: PostProcess): PostProcess;
  104007. /**
  104008. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  104009. * This should be called if the post process that shares output with this post process is disabled/disposed.
  104010. */
  104011. useOwnOutput(): void;
  104012. /**
  104013. * Updates the effect with the current post process compile time values and recompiles the shader.
  104014. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  104015. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  104016. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  104017. * @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
  104018. * @param onCompiled Called when the shader has been compiled.
  104019. * @param onError Called if there is an error when compiling a shader.
  104020. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  104021. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  104022. */
  104023. 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;
  104024. /**
  104025. * The post process is reusable if it can be used multiple times within one frame.
  104026. * @returns If the post process is reusable
  104027. */
  104028. isReusable(): boolean;
  104029. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  104030. markTextureDirty(): void;
  104031. /**
  104032. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  104033. * 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.
  104034. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  104035. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  104036. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  104037. * @returns The target texture that was bound to be written to.
  104038. */
  104039. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  104040. /**
  104041. * If the post process is supported.
  104042. */
  104043. get isSupported(): boolean;
  104044. /**
  104045. * The aspect ratio of the output texture.
  104046. */
  104047. get aspectRatio(): number;
  104048. /**
  104049. * Get a value indicating if the post-process is ready to be used
  104050. * @returns true if the post-process is ready (shader is compiled)
  104051. */
  104052. isReady(): boolean;
  104053. /**
  104054. * Binds all textures and uniforms to the shader, this will be run on every pass.
  104055. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  104056. */
  104057. apply(): Nullable<Effect>;
  104058. private _disposeTextures;
  104059. /**
  104060. * Sets the required values to the prepass renderer.
  104061. * @param prePassRenderer defines the prepass renderer to setup.
  104062. * @returns true if the pre pass is needed.
  104063. */
  104064. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  104065. /**
  104066. * Disposes the post process.
  104067. * @param camera The camera to dispose the post process on.
  104068. */
  104069. dispose(camera?: Camera): void;
  104070. /**
  104071. * Serializes the particle system to a JSON object
  104072. * @returns the JSON object
  104073. */
  104074. serialize(): any;
  104075. /**
  104076. * Creates a material from parsed material data
  104077. * @param parsedPostProcess defines parsed post process data
  104078. * @param scene defines the hosting scene
  104079. * @param rootUrl defines the root URL to use to load textures
  104080. * @returns a new post process
  104081. */
  104082. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  104083. }
  104084. }
  104085. declare module BABYLON {
  104086. /** @hidden */
  104087. export var kernelBlurVaryingDeclaration: {
  104088. name: string;
  104089. shader: string;
  104090. };
  104091. }
  104092. declare module BABYLON {
  104093. /** @hidden */
  104094. export var packingFunctions: {
  104095. name: string;
  104096. shader: string;
  104097. };
  104098. }
  104099. declare module BABYLON {
  104100. /** @hidden */
  104101. export var kernelBlurFragment: {
  104102. name: string;
  104103. shader: string;
  104104. };
  104105. }
  104106. declare module BABYLON {
  104107. /** @hidden */
  104108. export var kernelBlurFragment2: {
  104109. name: string;
  104110. shader: string;
  104111. };
  104112. }
  104113. declare module BABYLON {
  104114. /** @hidden */
  104115. export var kernelBlurPixelShader: {
  104116. name: string;
  104117. shader: string;
  104118. };
  104119. }
  104120. declare module BABYLON {
  104121. /** @hidden */
  104122. export var kernelBlurVertex: {
  104123. name: string;
  104124. shader: string;
  104125. };
  104126. }
  104127. declare module BABYLON {
  104128. /** @hidden */
  104129. export var kernelBlurVertexShader: {
  104130. name: string;
  104131. shader: string;
  104132. };
  104133. }
  104134. declare module BABYLON {
  104135. /**
  104136. * The Blur Post Process which blurs an image based on a kernel and direction.
  104137. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  104138. */
  104139. export class BlurPostProcess extends PostProcess {
  104140. private blockCompilation;
  104141. protected _kernel: number;
  104142. protected _idealKernel: number;
  104143. protected _packedFloat: boolean;
  104144. private _staticDefines;
  104145. /** The direction in which to blur the image. */
  104146. direction: Vector2;
  104147. /**
  104148. * Sets the length in pixels of the blur sample region
  104149. */
  104150. set kernel(v: number);
  104151. /**
  104152. * Gets the length in pixels of the blur sample region
  104153. */
  104154. get kernel(): number;
  104155. /**
  104156. * Sets wether or not the blur needs to unpack/repack floats
  104157. */
  104158. set packedFloat(v: boolean);
  104159. /**
  104160. * Gets wether or not the blur is unpacking/repacking floats
  104161. */
  104162. get packedFloat(): boolean;
  104163. /**
  104164. * Gets a string identifying the name of the class
  104165. * @returns "BlurPostProcess" string
  104166. */
  104167. getClassName(): string;
  104168. /**
  104169. * Creates a new instance BlurPostProcess
  104170. * @param name The name of the effect.
  104171. * @param direction The direction in which to blur the image.
  104172. * @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.
  104173. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  104174. * @param camera The camera to apply the render pass to.
  104175. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104176. * @param engine The engine which the post process will be applied. (default: current engine)
  104177. * @param reusable If the post process can be reused on the same frame. (default: false)
  104178. * @param textureType Type of textures used when performing the post process. (default: 0)
  104179. * @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)
  104180. */
  104181. 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);
  104182. /**
  104183. * Updates the effect with the current post process compile time values and recompiles the shader.
  104184. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  104185. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  104186. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  104187. * @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
  104188. * @param onCompiled Called when the shader has been compiled.
  104189. * @param onError Called if there is an error when compiling a shader.
  104190. */
  104191. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  104192. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  104193. /**
  104194. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  104195. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  104196. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  104197. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  104198. * The gaps between physical kernels are compensated for in the weighting of the samples
  104199. * @param idealKernel Ideal blur kernel.
  104200. * @return Nearest best kernel.
  104201. */
  104202. protected _nearestBestKernel(idealKernel: number): number;
  104203. /**
  104204. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  104205. * @param x The point on the Gaussian distribution to sample.
  104206. * @return the value of the Gaussian function at x.
  104207. */
  104208. protected _gaussianWeight(x: number): number;
  104209. /**
  104210. * Generates a string that can be used as a floating point number in GLSL.
  104211. * @param x Value to print.
  104212. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  104213. * @return GLSL float string.
  104214. */
  104215. protected _glslFloat(x: number, decimalFigures?: number): string;
  104216. /** @hidden */
  104217. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  104218. }
  104219. }
  104220. declare module BABYLON {
  104221. /**
  104222. * Mirror texture can be used to simulate the view from a mirror in a scene.
  104223. * It will dynamically be rendered every frame to adapt to the camera point of view.
  104224. * You can then easily use it as a reflectionTexture on a flat surface.
  104225. * In case the surface is not a plane, please consider relying on reflection probes.
  104226. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104227. */
  104228. export class MirrorTexture extends RenderTargetTexture {
  104229. private scene;
  104230. /**
  104231. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  104232. * 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.
  104233. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104234. */
  104235. mirrorPlane: Plane;
  104236. /**
  104237. * Define the blur ratio used to blur the reflection if needed.
  104238. */
  104239. set blurRatio(value: number);
  104240. get blurRatio(): number;
  104241. /**
  104242. * Define the adaptive blur kernel used to blur the reflection if needed.
  104243. * This will autocompute the closest best match for the `blurKernel`
  104244. */
  104245. set adaptiveBlurKernel(value: number);
  104246. /**
  104247. * Define the blur kernel used to blur the reflection if needed.
  104248. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104249. */
  104250. set blurKernel(value: number);
  104251. /**
  104252. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  104253. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104254. */
  104255. set blurKernelX(value: number);
  104256. get blurKernelX(): number;
  104257. /**
  104258. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  104259. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104260. */
  104261. set blurKernelY(value: number);
  104262. get blurKernelY(): number;
  104263. private _autoComputeBlurKernel;
  104264. protected _onRatioRescale(): void;
  104265. private _updateGammaSpace;
  104266. private _imageProcessingConfigChangeObserver;
  104267. private _transformMatrix;
  104268. private _mirrorMatrix;
  104269. private _savedViewMatrix;
  104270. private _blurX;
  104271. private _blurY;
  104272. private _adaptiveBlurKernel;
  104273. private _blurKernelX;
  104274. private _blurKernelY;
  104275. private _blurRatio;
  104276. /**
  104277. * Instantiates a Mirror Texture.
  104278. * Mirror texture can be used to simulate the view from a mirror in a scene.
  104279. * It will dynamically be rendered every frame to adapt to the camera point of view.
  104280. * You can then easily use it as a reflectionTexture on a flat surface.
  104281. * In case the surface is not a plane, please consider relying on reflection probes.
  104282. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104283. * @param name
  104284. * @param size
  104285. * @param scene
  104286. * @param generateMipMaps
  104287. * @param type
  104288. * @param samplingMode
  104289. * @param generateDepthBuffer
  104290. */
  104291. constructor(name: string, size: number | {
  104292. width: number;
  104293. height: number;
  104294. } | {
  104295. ratio: number;
  104296. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  104297. private _preparePostProcesses;
  104298. /**
  104299. * Clone the mirror texture.
  104300. * @returns the cloned texture
  104301. */
  104302. clone(): MirrorTexture;
  104303. /**
  104304. * Serialize the texture to a JSON representation you could use in Parse later on
  104305. * @returns the serialized JSON representation
  104306. */
  104307. serialize(): any;
  104308. /**
  104309. * Dispose the texture and release its associated resources.
  104310. */
  104311. dispose(): void;
  104312. }
  104313. }
  104314. declare module BABYLON {
  104315. /**
  104316. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  104317. * @see https://doc.babylonjs.com/babylon101/materials#texture
  104318. */
  104319. export class Texture extends BaseTexture {
  104320. /**
  104321. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  104322. */
  104323. static SerializeBuffers: boolean;
  104324. /**
  104325. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  104326. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  104327. */
  104328. static ForceSerializeBuffers: boolean;
  104329. /** @hidden */
  104330. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  104331. /** @hidden */
  104332. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  104333. /** @hidden */
  104334. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  104335. /** nearest is mag = nearest and min = nearest and mip = linear */
  104336. static readonly NEAREST_SAMPLINGMODE: number;
  104337. /** nearest is mag = nearest and min = nearest and mip = linear */
  104338. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  104339. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104340. static readonly BILINEAR_SAMPLINGMODE: number;
  104341. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104342. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  104343. /** Trilinear is mag = linear and min = linear and mip = linear */
  104344. static readonly TRILINEAR_SAMPLINGMODE: number;
  104345. /** Trilinear is mag = linear and min = linear and mip = linear */
  104346. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  104347. /** mag = nearest and min = nearest and mip = nearest */
  104348. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  104349. /** mag = nearest and min = linear and mip = nearest */
  104350. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  104351. /** mag = nearest and min = linear and mip = linear */
  104352. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  104353. /** mag = nearest and min = linear and mip = none */
  104354. static readonly NEAREST_LINEAR: number;
  104355. /** mag = nearest and min = nearest and mip = none */
  104356. static readonly NEAREST_NEAREST: number;
  104357. /** mag = linear and min = nearest and mip = nearest */
  104358. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  104359. /** mag = linear and min = nearest and mip = linear */
  104360. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  104361. /** mag = linear and min = linear and mip = none */
  104362. static readonly LINEAR_LINEAR: number;
  104363. /** mag = linear and min = nearest and mip = none */
  104364. static readonly LINEAR_NEAREST: number;
  104365. /** Explicit coordinates mode */
  104366. static readonly EXPLICIT_MODE: number;
  104367. /** Spherical coordinates mode */
  104368. static readonly SPHERICAL_MODE: number;
  104369. /** Planar coordinates mode */
  104370. static readonly PLANAR_MODE: number;
  104371. /** Cubic coordinates mode */
  104372. static readonly CUBIC_MODE: number;
  104373. /** Projection coordinates mode */
  104374. static readonly PROJECTION_MODE: number;
  104375. /** Inverse Cubic coordinates mode */
  104376. static readonly SKYBOX_MODE: number;
  104377. /** Inverse Cubic coordinates mode */
  104378. static readonly INVCUBIC_MODE: number;
  104379. /** Equirectangular coordinates mode */
  104380. static readonly EQUIRECTANGULAR_MODE: number;
  104381. /** Equirectangular Fixed coordinates mode */
  104382. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  104383. /** Equirectangular Fixed Mirrored coordinates mode */
  104384. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  104385. /** Texture is not repeating outside of 0..1 UVs */
  104386. static readonly CLAMP_ADDRESSMODE: number;
  104387. /** Texture is repeating outside of 0..1 UVs */
  104388. static readonly WRAP_ADDRESSMODE: number;
  104389. /** Texture is repeating and mirrored */
  104390. static readonly MIRROR_ADDRESSMODE: number;
  104391. /**
  104392. * 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
  104393. */
  104394. static UseSerializedUrlIfAny: boolean;
  104395. /**
  104396. * Define the url of the texture.
  104397. */
  104398. url: Nullable<string>;
  104399. /**
  104400. * Define an offset on the texture to offset the u coordinates of the UVs
  104401. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  104402. */
  104403. uOffset: number;
  104404. /**
  104405. * Define an offset on the texture to offset the v coordinates of the UVs
  104406. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  104407. */
  104408. vOffset: number;
  104409. /**
  104410. * Define an offset on the texture to scale the u coordinates of the UVs
  104411. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  104412. */
  104413. uScale: number;
  104414. /**
  104415. * Define an offset on the texture to scale the v coordinates of the UVs
  104416. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  104417. */
  104418. vScale: number;
  104419. /**
  104420. * Define an offset on the texture to rotate around the u coordinates of the UVs
  104421. * @see https://doc.babylonjs.com/how_to/more_materials
  104422. */
  104423. uAng: number;
  104424. /**
  104425. * Define an offset on the texture to rotate around the v coordinates of the UVs
  104426. * @see https://doc.babylonjs.com/how_to/more_materials
  104427. */
  104428. vAng: number;
  104429. /**
  104430. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  104431. * @see https://doc.babylonjs.com/how_to/more_materials
  104432. */
  104433. wAng: number;
  104434. /**
  104435. * Defines the center of rotation (U)
  104436. */
  104437. uRotationCenter: number;
  104438. /**
  104439. * Defines the center of rotation (V)
  104440. */
  104441. vRotationCenter: number;
  104442. /**
  104443. * Defines the center of rotation (W)
  104444. */
  104445. wRotationCenter: number;
  104446. /**
  104447. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  104448. */
  104449. homogeneousRotationInUVTransform: boolean;
  104450. /**
  104451. * Are mip maps generated for this texture or not.
  104452. */
  104453. get noMipmap(): boolean;
  104454. /**
  104455. * List of inspectable custom properties (used by the Inspector)
  104456. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  104457. */
  104458. inspectableCustomProperties: Nullable<IInspectable[]>;
  104459. private _noMipmap;
  104460. /** @hidden */
  104461. _invertY: boolean;
  104462. private _rowGenerationMatrix;
  104463. private _cachedTextureMatrix;
  104464. private _projectionModeMatrix;
  104465. private _t0;
  104466. private _t1;
  104467. private _t2;
  104468. private _cachedUOffset;
  104469. private _cachedVOffset;
  104470. private _cachedUScale;
  104471. private _cachedVScale;
  104472. private _cachedUAng;
  104473. private _cachedVAng;
  104474. private _cachedWAng;
  104475. private _cachedProjectionMatrixId;
  104476. private _cachedURotationCenter;
  104477. private _cachedVRotationCenter;
  104478. private _cachedWRotationCenter;
  104479. private _cachedHomogeneousRotationInUVTransform;
  104480. private _cachedCoordinatesMode;
  104481. /** @hidden */
  104482. protected _initialSamplingMode: number;
  104483. /** @hidden */
  104484. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  104485. private _deleteBuffer;
  104486. protected _format: Nullable<number>;
  104487. private _delayedOnLoad;
  104488. private _delayedOnError;
  104489. private _mimeType?;
  104490. private _loaderOptions?;
  104491. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  104492. get mimeType(): string | undefined;
  104493. /**
  104494. * Observable triggered once the texture has been loaded.
  104495. */
  104496. onLoadObservable: Observable<Texture>;
  104497. protected _isBlocking: boolean;
  104498. /**
  104499. * Is the texture preventing material to render while loading.
  104500. * If false, a default texture will be used instead of the loading one during the preparation step.
  104501. */
  104502. set isBlocking(value: boolean);
  104503. get isBlocking(): boolean;
  104504. /**
  104505. * Get the current sampling mode associated with the texture.
  104506. */
  104507. get samplingMode(): number;
  104508. /**
  104509. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  104510. */
  104511. get invertY(): boolean;
  104512. /**
  104513. * Instantiates a new texture.
  104514. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  104515. * @see https://doc.babylonjs.com/babylon101/materials#texture
  104516. * @param url defines the url of the picture to load as a texture
  104517. * @param sceneOrEngine defines the scene or engine the texture will belong to
  104518. * @param noMipmap defines if the texture will require mip maps or not
  104519. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  104520. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104521. * @param onLoad defines a callback triggered when the texture has been loaded
  104522. * @param onError defines a callback triggered when an error occurred during the loading session
  104523. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  104524. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  104525. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104526. * @param mimeType defines an optional mime type information
  104527. * @param loaderOptions options to be passed to the loader
  104528. */
  104529. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string, loaderOptions?: any);
  104530. /**
  104531. * Update the url (and optional buffer) of this texture if url was null during construction.
  104532. * @param url the url of the texture
  104533. * @param buffer the buffer of the texture (defaults to null)
  104534. * @param onLoad callback called when the texture is loaded (defaults to null)
  104535. */
  104536. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  104537. /**
  104538. * Finish the loading sequence of a texture flagged as delayed load.
  104539. * @hidden
  104540. */
  104541. delayLoad(): void;
  104542. private _prepareRowForTextureGeneration;
  104543. /**
  104544. * Checks if the texture has the same transform matrix than another texture
  104545. * @param texture texture to check against
  104546. * @returns true if the transforms are the same, else false
  104547. */
  104548. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  104549. /**
  104550. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  104551. * @returns the transform matrix of the texture.
  104552. */
  104553. getTextureMatrix(uBase?: number): Matrix;
  104554. /**
  104555. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  104556. * @returns The reflection texture transform
  104557. */
  104558. getReflectionTextureMatrix(): Matrix;
  104559. /**
  104560. * Clones the texture.
  104561. * @returns the cloned texture
  104562. */
  104563. clone(): Texture;
  104564. /**
  104565. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  104566. * @returns The JSON representation of the texture
  104567. */
  104568. serialize(): any;
  104569. /**
  104570. * Get the current class name of the texture useful for serialization or dynamic coding.
  104571. * @returns "Texture"
  104572. */
  104573. getClassName(): string;
  104574. /**
  104575. * Dispose the texture and release its associated resources.
  104576. */
  104577. dispose(): void;
  104578. /**
  104579. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  104580. * @param parsedTexture Define the JSON representation of the texture
  104581. * @param scene Define the scene the parsed texture should be instantiated in
  104582. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  104583. * @returns The parsed texture if successful
  104584. */
  104585. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  104586. /**
  104587. * Creates a texture from its base 64 representation.
  104588. * @param data Define the base64 payload without the data: prefix
  104589. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  104590. * @param scene Define the scene the texture should belong to
  104591. * @param noMipmap Forces the texture to not create mip map information if true
  104592. * @param invertY define if the texture needs to be inverted on the y axis during loading
  104593. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104594. * @param onLoad define a callback triggered when the texture has been loaded
  104595. * @param onError define a callback triggered when an error occurred during the loading session
  104596. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104597. * @returns the created texture
  104598. */
  104599. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  104600. /**
  104601. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  104602. * @param data Define the base64 payload without the data: prefix
  104603. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  104604. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  104605. * @param scene Define the scene the texture should belong to
  104606. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  104607. * @param noMipmap Forces the texture to not create mip map information if true
  104608. * @param invertY define if the texture needs to be inverted on the y axis during loading
  104609. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104610. * @param onLoad define a callback triggered when the texture has been loaded
  104611. * @param onError define a callback triggered when an error occurred during the loading session
  104612. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104613. * @returns the created texture
  104614. */
  104615. 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;
  104616. }
  104617. }
  104618. declare module BABYLON {
  104619. /**
  104620. * ThinSprite Class used to represent a thin sprite
  104621. * This is the base class for sprites but can also directly be used with ThinEngine
  104622. * @see https://doc.babylonjs.com/babylon101/sprites
  104623. */
  104624. export class ThinSprite {
  104625. /** Gets or sets the cell index in the sprite sheet */
  104626. cellIndex: number;
  104627. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  104628. cellRef: string;
  104629. /** Gets or sets the current world position */
  104630. position: IVector3Like;
  104631. /** Gets or sets the main color */
  104632. color: IColor4Like;
  104633. /** Gets or sets the width */
  104634. width: number;
  104635. /** Gets or sets the height */
  104636. height: number;
  104637. /** Gets or sets rotation angle */
  104638. angle: number;
  104639. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  104640. invertU: boolean;
  104641. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  104642. invertV: boolean;
  104643. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  104644. isVisible: boolean;
  104645. /**
  104646. * Returns a boolean indicating if the animation is started
  104647. */
  104648. get animationStarted(): boolean;
  104649. /** Gets the initial key for the animation (setting it will restart the animation) */
  104650. get fromIndex(): number;
  104651. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  104652. get toIndex(): number;
  104653. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  104654. get loopAnimation(): boolean;
  104655. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  104656. get delay(): number;
  104657. /** @hidden */
  104658. _xOffset: number;
  104659. /** @hidden */
  104660. _yOffset: number;
  104661. /** @hidden */
  104662. _xSize: number;
  104663. /** @hidden */
  104664. _ySize: number;
  104665. private _animationStarted;
  104666. protected _loopAnimation: boolean;
  104667. protected _fromIndex: number;
  104668. protected _toIndex: number;
  104669. protected _delay: number;
  104670. private _direction;
  104671. private _time;
  104672. private _onBaseAnimationEnd;
  104673. /**
  104674. * Creates a new Thin Sprite
  104675. */
  104676. constructor();
  104677. /**
  104678. * Starts an animation
  104679. * @param from defines the initial key
  104680. * @param to defines the end key
  104681. * @param loop defines if the animation must loop
  104682. * @param delay defines the start delay (in ms)
  104683. * @param onAnimationEnd defines a callback for when the animation ends
  104684. */
  104685. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  104686. /** Stops current animation (if any) */
  104687. stopAnimation(): void;
  104688. /** @hidden */
  104689. _animate(deltaTime: number): void;
  104690. }
  104691. }
  104692. declare module BABYLON {
  104693. /** @hidden */
  104694. export var imageProcessingCompatibility: {
  104695. name: string;
  104696. shader: string;
  104697. };
  104698. }
  104699. declare module BABYLON {
  104700. /** @hidden */
  104701. export var spritesPixelShader: {
  104702. name: string;
  104703. shader: string;
  104704. };
  104705. }
  104706. declare module BABYLON {
  104707. /** @hidden */
  104708. export var spritesVertexShader: {
  104709. name: string;
  104710. shader: string;
  104711. };
  104712. }
  104713. declare module BABYLON {
  104714. /**
  104715. * Class used to render sprites.
  104716. *
  104717. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  104718. */
  104719. export class SpriteRenderer {
  104720. /**
  104721. * Defines the texture of the spritesheet
  104722. */
  104723. texture: Nullable<ThinTexture>;
  104724. /**
  104725. * Defines the default width of a cell in the spritesheet
  104726. */
  104727. cellWidth: number;
  104728. /**
  104729. * Defines the default height of a cell in the spritesheet
  104730. */
  104731. cellHeight: number;
  104732. /**
  104733. * Blend mode use to render the particle, it can be any of
  104734. * the static Constants.ALPHA_x properties provided in this class.
  104735. * Default value is Constants.ALPHA_COMBINE
  104736. */
  104737. blendMode: number;
  104738. /**
  104739. * Gets or sets a boolean indicating if alpha mode is automatically
  104740. * reset.
  104741. */
  104742. autoResetAlpha: boolean;
  104743. /**
  104744. * Disables writing to the depth buffer when rendering the sprites.
  104745. * It can be handy to disable depth writing when using textures without alpha channel
  104746. * and setting some specific blend modes.
  104747. */
  104748. disableDepthWrite: boolean;
  104749. /**
  104750. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  104751. */
  104752. fogEnabled: boolean;
  104753. /**
  104754. * Gets the capacity of the manager
  104755. */
  104756. get capacity(): number;
  104757. private readonly _engine;
  104758. private readonly _useVAO;
  104759. private readonly _useInstancing;
  104760. private readonly _scene;
  104761. private readonly _capacity;
  104762. private readonly _epsilon;
  104763. private _vertexBufferSize;
  104764. private _vertexData;
  104765. private _buffer;
  104766. private _vertexBuffers;
  104767. private _spriteBuffer;
  104768. private _indexBuffer;
  104769. private _effectBase;
  104770. private _effectFog;
  104771. private _vertexArrayObject;
  104772. /**
  104773. * Creates a new sprite Renderer
  104774. * @param engine defines the engine the renderer works with
  104775. * @param capacity defines the maximum allowed number of sprites
  104776. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  104777. * @param scene defines the hosting scene
  104778. */
  104779. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  104780. /**
  104781. * Render all child sprites
  104782. * @param sprites defines the list of sprites to render
  104783. * @param deltaTime defines the time since last frame
  104784. * @param viewMatrix defines the viewMatrix to use to render the sprites
  104785. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  104786. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  104787. */
  104788. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  104789. private _appendSpriteVertex;
  104790. /**
  104791. * Release associated resources
  104792. */
  104793. dispose(): void;
  104794. }
  104795. }
  104796. declare module BABYLON {
  104797. /**
  104798. * Defines the minimum interface to fullfil in order to be a sprite manager.
  104799. */
  104800. export interface ISpriteManager extends IDisposable {
  104801. /**
  104802. * Gets manager's name
  104803. */
  104804. name: string;
  104805. /**
  104806. * Restricts the camera to viewing objects with the same layerMask.
  104807. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  104808. */
  104809. layerMask: number;
  104810. /**
  104811. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  104812. */
  104813. isPickable: boolean;
  104814. /**
  104815. * Gets the hosting scene
  104816. */
  104817. scene: Scene;
  104818. /**
  104819. * Specifies the rendering group id for this mesh (0 by default)
  104820. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  104821. */
  104822. renderingGroupId: number;
  104823. /**
  104824. * Defines the list of sprites managed by the manager.
  104825. */
  104826. sprites: Array<Sprite>;
  104827. /**
  104828. * Gets or sets the spritesheet texture
  104829. */
  104830. texture: Texture;
  104831. /** Defines the default width of a cell in the spritesheet */
  104832. cellWidth: number;
  104833. /** Defines the default height of a cell in the spritesheet */
  104834. cellHeight: number;
  104835. /**
  104836. * Tests the intersection of a sprite with a specific ray.
  104837. * @param ray The ray we are sending to test the collision
  104838. * @param camera The camera space we are sending rays in
  104839. * @param predicate A predicate allowing excluding sprites from the list of object to test
  104840. * @param fastCheck defines if the first intersection will be used (and not the closest)
  104841. * @returns picking info or null.
  104842. */
  104843. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  104844. /**
  104845. * Intersects the sprites with a ray
  104846. * @param ray defines the ray to intersect with
  104847. * @param camera defines the current active camera
  104848. * @param predicate defines a predicate used to select candidate sprites
  104849. * @returns null if no hit or a PickingInfo array
  104850. */
  104851. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  104852. /**
  104853. * Renders the list of sprites on screen.
  104854. */
  104855. render(): void;
  104856. }
  104857. /**
  104858. * Class used to manage multiple sprites on the same spritesheet
  104859. * @see https://doc.babylonjs.com/babylon101/sprites
  104860. */
  104861. export class SpriteManager implements ISpriteManager {
  104862. /** defines the manager's name */
  104863. name: string;
  104864. /** Define the Url to load snippets */
  104865. static SnippetUrl: string;
  104866. /** Snippet ID if the manager was created from the snippet server */
  104867. snippetId: string;
  104868. /** Gets the list of sprites */
  104869. sprites: Sprite[];
  104870. /** Gets or sets the rendering group id (0 by default) */
  104871. renderingGroupId: number;
  104872. /** Gets or sets camera layer mask */
  104873. layerMask: number;
  104874. /** Gets or sets a boolean indicating if the sprites are pickable */
  104875. isPickable: boolean;
  104876. /**
  104877. * An event triggered when the manager is disposed.
  104878. */
  104879. onDisposeObservable: Observable<SpriteManager>;
  104880. /**
  104881. * Callback called when the manager is disposed
  104882. */
  104883. set onDispose(callback: () => void);
  104884. /**
  104885. * Gets or sets the unique id of the sprite
  104886. */
  104887. uniqueId: number;
  104888. /**
  104889. * Gets the array of sprites
  104890. */
  104891. get children(): Sprite[];
  104892. /**
  104893. * Gets the hosting scene
  104894. */
  104895. get scene(): Scene;
  104896. /**
  104897. * Gets the capacity of the manager
  104898. */
  104899. get capacity(): number;
  104900. /**
  104901. * Gets or sets the spritesheet texture
  104902. */
  104903. get texture(): Texture;
  104904. set texture(value: Texture);
  104905. /** Defines the default width of a cell in the spritesheet */
  104906. get cellWidth(): number;
  104907. set cellWidth(value: number);
  104908. /** Defines the default height of a cell in the spritesheet */
  104909. get cellHeight(): number;
  104910. set cellHeight(value: number);
  104911. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  104912. get fogEnabled(): boolean;
  104913. set fogEnabled(value: boolean);
  104914. /**
  104915. * Blend mode use to render the particle, it can be any of
  104916. * the static Constants.ALPHA_x properties provided in this class.
  104917. * Default value is Constants.ALPHA_COMBINE
  104918. */
  104919. get blendMode(): number;
  104920. set blendMode(blendMode: number);
  104921. /** Disables writing to the depth buffer when rendering the sprites.
  104922. * It can be handy to disable depth writing when using textures without alpha channel
  104923. * and setting some specific blend modes.
  104924. */
  104925. disableDepthWrite: boolean;
  104926. private _spriteRenderer;
  104927. /** Associative array from JSON sprite data file */
  104928. private _cellData;
  104929. /** Array of sprite names from JSON sprite data file */
  104930. private _spriteMap;
  104931. /** True when packed cell data from JSON file is ready*/
  104932. private _packedAndReady;
  104933. private _textureContent;
  104934. private _onDisposeObserver;
  104935. private _fromPacked;
  104936. private _scene;
  104937. /**
  104938. * Creates a new sprite manager
  104939. * @param name defines the manager's name
  104940. * @param imgUrl defines the sprite sheet url
  104941. * @param capacity defines the maximum allowed number of sprites
  104942. * @param cellSize defines the size of a sprite cell
  104943. * @param scene defines the hosting scene
  104944. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  104945. * @param samplingMode defines the smapling mode to use with spritesheet
  104946. * @param fromPacked set to false; do not alter
  104947. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  104948. */
  104949. constructor(
  104950. /** defines the manager's name */
  104951. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  104952. /**
  104953. * Returns the string "SpriteManager"
  104954. * @returns "SpriteManager"
  104955. */
  104956. getClassName(): string;
  104957. private _makePacked;
  104958. private _checkTextureAlpha;
  104959. /**
  104960. * Intersects the sprites with a ray
  104961. * @param ray defines the ray to intersect with
  104962. * @param camera defines the current active camera
  104963. * @param predicate defines a predicate used to select candidate sprites
  104964. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  104965. * @returns null if no hit or a PickingInfo
  104966. */
  104967. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  104968. /**
  104969. * Intersects the sprites with a ray
  104970. * @param ray defines the ray to intersect with
  104971. * @param camera defines the current active camera
  104972. * @param predicate defines a predicate used to select candidate sprites
  104973. * @returns null if no hit or a PickingInfo array
  104974. */
  104975. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  104976. /**
  104977. * Render all child sprites
  104978. */
  104979. render(): void;
  104980. private _customUpdate;
  104981. /**
  104982. * Release associated resources
  104983. */
  104984. dispose(): void;
  104985. /**
  104986. * Serializes the sprite manager to a JSON object
  104987. * @param serializeTexture defines if the texture must be serialized as well
  104988. * @returns the JSON object
  104989. */
  104990. serialize(serializeTexture?: boolean): any;
  104991. /**
  104992. * Parses a JSON object to create a new sprite manager.
  104993. * @param parsedManager The JSON object to parse
  104994. * @param scene The scene to create the sprite managerin
  104995. * @param rootUrl The root url to use to load external dependencies like texture
  104996. * @returns the new sprite manager
  104997. */
  104998. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  104999. /**
  105000. * Creates a sprite manager from a snippet saved in a remote file
  105001. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  105002. * @param url defines the url to load from
  105003. * @param scene defines the hosting scene
  105004. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105005. * @returns a promise that will resolve to the new sprite manager
  105006. */
  105007. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  105008. /**
  105009. * Creates a sprite manager from a snippet saved by the sprite editor
  105010. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  105011. * @param scene defines the hosting scene
  105012. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105013. * @returns a promise that will resolve to the new sprite manager
  105014. */
  105015. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  105016. }
  105017. }
  105018. declare module BABYLON {
  105019. /**
  105020. * Class used to represent a sprite
  105021. * @see https://doc.babylonjs.com/babylon101/sprites
  105022. */
  105023. export class Sprite extends ThinSprite implements IAnimatable {
  105024. /** defines the name */
  105025. name: string;
  105026. /** Gets or sets the current world position */
  105027. position: Vector3;
  105028. /** Gets or sets the main color */
  105029. color: Color4;
  105030. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  105031. disposeWhenFinishedAnimating: boolean;
  105032. /** Gets the list of attached animations */
  105033. animations: Nullable<Array<Animation>>;
  105034. /** Gets or sets a boolean indicating if the sprite can be picked */
  105035. isPickable: boolean;
  105036. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  105037. useAlphaForPicking: boolean;
  105038. /**
  105039. * Gets or sets the associated action manager
  105040. */
  105041. actionManager: Nullable<ActionManager>;
  105042. /**
  105043. * An event triggered when the control has been disposed
  105044. */
  105045. onDisposeObservable: Observable<Sprite>;
  105046. private _manager;
  105047. private _onAnimationEnd;
  105048. /**
  105049. * Gets or sets the sprite size
  105050. */
  105051. get size(): number;
  105052. set size(value: number);
  105053. /**
  105054. * Gets or sets the unique id of the sprite
  105055. */
  105056. uniqueId: number;
  105057. /**
  105058. * Gets the manager of this sprite
  105059. */
  105060. get manager(): ISpriteManager;
  105061. /**
  105062. * Creates a new Sprite
  105063. * @param name defines the name
  105064. * @param manager defines the manager
  105065. */
  105066. constructor(
  105067. /** defines the name */
  105068. name: string, manager: ISpriteManager);
  105069. /**
  105070. * Returns the string "Sprite"
  105071. * @returns "Sprite"
  105072. */
  105073. getClassName(): string;
  105074. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  105075. get fromIndex(): number;
  105076. set fromIndex(value: number);
  105077. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  105078. get toIndex(): number;
  105079. set toIndex(value: number);
  105080. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  105081. get loopAnimation(): boolean;
  105082. set loopAnimation(value: boolean);
  105083. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  105084. get delay(): number;
  105085. set delay(value: number);
  105086. /**
  105087. * Starts an animation
  105088. * @param from defines the initial key
  105089. * @param to defines the end key
  105090. * @param loop defines if the animation must loop
  105091. * @param delay defines the start delay (in ms)
  105092. * @param onAnimationEnd defines a callback to call when animation ends
  105093. */
  105094. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  105095. private _endAnimation;
  105096. /** Release associated resources */
  105097. dispose(): void;
  105098. /**
  105099. * Serializes the sprite to a JSON object
  105100. * @returns the JSON object
  105101. */
  105102. serialize(): any;
  105103. /**
  105104. * Parses a JSON object to create a new sprite
  105105. * @param parsedSprite The JSON object to parse
  105106. * @param manager defines the hosting manager
  105107. * @returns the new sprite
  105108. */
  105109. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  105110. }
  105111. }
  105112. declare module BABYLON {
  105113. /**
  105114. * Information about the result of picking within a scene
  105115. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  105116. */
  105117. export class PickingInfo {
  105118. /** @hidden */
  105119. _pickingUnavailable: boolean;
  105120. /**
  105121. * If the pick collided with an object
  105122. */
  105123. hit: boolean;
  105124. /**
  105125. * Distance away where the pick collided
  105126. */
  105127. distance: number;
  105128. /**
  105129. * The location of pick collision
  105130. */
  105131. pickedPoint: Nullable<Vector3>;
  105132. /**
  105133. * The mesh corresponding the the pick collision
  105134. */
  105135. pickedMesh: Nullable<AbstractMesh>;
  105136. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  105137. bu: number;
  105138. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  105139. bv: number;
  105140. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  105141. faceId: number;
  105142. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  105143. subMeshFaceId: number;
  105144. /** Id of the the submesh that was picked */
  105145. subMeshId: number;
  105146. /** If a sprite was picked, this will be the sprite the pick collided with */
  105147. pickedSprite: Nullable<Sprite>;
  105148. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  105149. thinInstanceIndex: number;
  105150. /**
  105151. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  105152. */
  105153. originMesh: Nullable<AbstractMesh>;
  105154. /**
  105155. * The ray that was used to perform the picking.
  105156. */
  105157. ray: Nullable<Ray>;
  105158. /**
  105159. * Gets the normal correspodning to the face the pick collided with
  105160. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  105161. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  105162. * @returns The normal correspodning to the face the pick collided with
  105163. */
  105164. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  105165. /**
  105166. * Gets the texture coordinates of where the pick occured
  105167. * @returns the vector containing the coordnates of the texture
  105168. */
  105169. getTextureCoordinates(): Nullable<Vector2>;
  105170. }
  105171. }
  105172. declare module BABYLON {
  105173. /**
  105174. * Gather the list of pointer event types as constants.
  105175. */
  105176. export class PointerEventTypes {
  105177. /**
  105178. * 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.
  105179. */
  105180. static readonly POINTERDOWN: number;
  105181. /**
  105182. * The pointerup event is fired when a pointer is no longer active.
  105183. */
  105184. static readonly POINTERUP: number;
  105185. /**
  105186. * The pointermove event is fired when a pointer changes coordinates.
  105187. */
  105188. static readonly POINTERMOVE: number;
  105189. /**
  105190. * The pointerwheel event is fired when a mouse wheel has been rotated.
  105191. */
  105192. static readonly POINTERWHEEL: number;
  105193. /**
  105194. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  105195. */
  105196. static readonly POINTERPICK: number;
  105197. /**
  105198. * The pointertap event is fired when a the object has been touched and released without drag.
  105199. */
  105200. static readonly POINTERTAP: number;
  105201. /**
  105202. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  105203. */
  105204. static readonly POINTERDOUBLETAP: number;
  105205. }
  105206. /**
  105207. * Base class of pointer info types.
  105208. */
  105209. export class PointerInfoBase {
  105210. /**
  105211. * Defines the type of event (PointerEventTypes)
  105212. */
  105213. type: number;
  105214. /**
  105215. * Defines the related dom event
  105216. */
  105217. event: PointerEvent | MouseWheelEvent;
  105218. /**
  105219. * Instantiates the base class of pointers info.
  105220. * @param type Defines the type of event (PointerEventTypes)
  105221. * @param event Defines the related dom event
  105222. */
  105223. constructor(
  105224. /**
  105225. * Defines the type of event (PointerEventTypes)
  105226. */
  105227. type: number,
  105228. /**
  105229. * Defines the related dom event
  105230. */
  105231. event: PointerEvent | MouseWheelEvent);
  105232. }
  105233. /**
  105234. * This class is used to store pointer related info for the onPrePointerObservable event.
  105235. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  105236. */
  105237. export class PointerInfoPre extends PointerInfoBase {
  105238. /**
  105239. * Ray from a pointer if availible (eg. 6dof controller)
  105240. */
  105241. ray: Nullable<Ray>;
  105242. /**
  105243. * Defines the local position of the pointer on the canvas.
  105244. */
  105245. localPosition: Vector2;
  105246. /**
  105247. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  105248. */
  105249. skipOnPointerObservable: boolean;
  105250. /**
  105251. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  105252. * @param type Defines the type of event (PointerEventTypes)
  105253. * @param event Defines the related dom event
  105254. * @param localX Defines the local x coordinates of the pointer when the event occured
  105255. * @param localY Defines the local y coordinates of the pointer when the event occured
  105256. */
  105257. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  105258. }
  105259. /**
  105260. * This type contains all the data related to a pointer event in Babylon.js.
  105261. * 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.
  105262. */
  105263. export class PointerInfo extends PointerInfoBase {
  105264. /**
  105265. * Defines the picking info associated to the info (if any)\
  105266. */
  105267. pickInfo: Nullable<PickingInfo>;
  105268. /**
  105269. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  105270. * @param type Defines the type of event (PointerEventTypes)
  105271. * @param event Defines the related dom event
  105272. * @param pickInfo Defines the picking info associated to the info (if any)\
  105273. */
  105274. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  105275. /**
  105276. * Defines the picking info associated to the info (if any)\
  105277. */
  105278. pickInfo: Nullable<PickingInfo>);
  105279. }
  105280. /**
  105281. * Data relating to a touch event on the screen.
  105282. */
  105283. export interface PointerTouch {
  105284. /**
  105285. * X coordinate of touch.
  105286. */
  105287. x: number;
  105288. /**
  105289. * Y coordinate of touch.
  105290. */
  105291. y: number;
  105292. /**
  105293. * Id of touch. Unique for each finger.
  105294. */
  105295. pointerId: number;
  105296. /**
  105297. * Event type passed from DOM.
  105298. */
  105299. type: any;
  105300. }
  105301. }
  105302. declare module BABYLON {
  105303. /**
  105304. * Manage the mouse inputs to control the movement of a free camera.
  105305. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105306. */
  105307. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  105308. /**
  105309. * Define if touch is enabled in the mouse input
  105310. */
  105311. touchEnabled: boolean;
  105312. /**
  105313. * Defines the camera the input is attached to.
  105314. */
  105315. camera: FreeCamera;
  105316. /**
  105317. * Defines the buttons associated with the input to handle camera move.
  105318. */
  105319. buttons: number[];
  105320. /**
  105321. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  105322. */
  105323. angularSensibility: number;
  105324. private _pointerInput;
  105325. private _onMouseMove;
  105326. private _observer;
  105327. private previousPosition;
  105328. /**
  105329. * Observable for when a pointer move event occurs containing the move offset
  105330. */
  105331. onPointerMovedObservable: Observable<{
  105332. offsetX: number;
  105333. offsetY: number;
  105334. }>;
  105335. /**
  105336. * @hidden
  105337. * If the camera should be rotated automatically based on pointer movement
  105338. */
  105339. _allowCameraRotation: boolean;
  105340. /**
  105341. * Manage the mouse inputs to control the movement of a free camera.
  105342. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105343. * @param touchEnabled Defines if touch is enabled or not
  105344. */
  105345. constructor(
  105346. /**
  105347. * Define if touch is enabled in the mouse input
  105348. */
  105349. touchEnabled?: boolean);
  105350. /**
  105351. * Attach the input controls to a specific dom element to get the input from.
  105352. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105353. */
  105354. attachControl(noPreventDefault?: boolean): void;
  105355. /**
  105356. * Called on JS contextmenu event.
  105357. * Override this method to provide functionality.
  105358. */
  105359. protected onContextMenu(evt: PointerEvent): void;
  105360. /**
  105361. * Detach the current controls from the specified dom element.
  105362. */
  105363. detachControl(): void;
  105364. /**
  105365. * Gets the class name of the current intput.
  105366. * @returns the class name
  105367. */
  105368. getClassName(): string;
  105369. /**
  105370. * Get the friendly name associated with the input class.
  105371. * @returns the input friendly name
  105372. */
  105373. getSimpleName(): string;
  105374. }
  105375. }
  105376. declare module BABYLON {
  105377. /**
  105378. * Base class for mouse wheel input..
  105379. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  105380. * for example usage.
  105381. */
  105382. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  105383. /**
  105384. * Defines the camera the input is attached to.
  105385. */
  105386. abstract camera: Camera;
  105387. /**
  105388. * How fast is the camera moves in relation to X axis mouseWheel events.
  105389. * Use negative value to reverse direction.
  105390. */
  105391. wheelPrecisionX: number;
  105392. /**
  105393. * How fast is the camera moves in relation to Y axis mouseWheel events.
  105394. * Use negative value to reverse direction.
  105395. */
  105396. wheelPrecisionY: number;
  105397. /**
  105398. * How fast is the camera moves in relation to Z axis mouseWheel events.
  105399. * Use negative value to reverse direction.
  105400. */
  105401. wheelPrecisionZ: number;
  105402. /**
  105403. * Observable for when a mouse wheel move event occurs.
  105404. */
  105405. onChangedObservable: Observable<{
  105406. wheelDeltaX: number;
  105407. wheelDeltaY: number;
  105408. wheelDeltaZ: number;
  105409. }>;
  105410. private _wheel;
  105411. private _observer;
  105412. /**
  105413. * Attach the input controls to a specific dom element to get the input from.
  105414. * @param noPreventDefault Defines whether event caught by the controls
  105415. * should call preventdefault().
  105416. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105417. */
  105418. attachControl(noPreventDefault?: boolean): void;
  105419. /**
  105420. * Detach the current controls from the specified dom element.
  105421. */
  105422. detachControl(): void;
  105423. /**
  105424. * Called for each rendered frame.
  105425. */
  105426. checkInputs(): void;
  105427. /**
  105428. * Gets the class name of the current intput.
  105429. * @returns the class name
  105430. */
  105431. getClassName(): string;
  105432. /**
  105433. * Get the friendly name associated with the input class.
  105434. * @returns the input friendly name
  105435. */
  105436. getSimpleName(): string;
  105437. /**
  105438. * Incremental value of multiple mouse wheel movements of the X axis.
  105439. * Should be zero-ed when read.
  105440. */
  105441. protected _wheelDeltaX: number;
  105442. /**
  105443. * Incremental value of multiple mouse wheel movements of the Y axis.
  105444. * Should be zero-ed when read.
  105445. */
  105446. protected _wheelDeltaY: number;
  105447. /**
  105448. * Incremental value of multiple mouse wheel movements of the Z axis.
  105449. * Should be zero-ed when read.
  105450. */
  105451. protected _wheelDeltaZ: number;
  105452. /**
  105453. * Firefox uses a different scheme to report scroll distances to other
  105454. * browsers. Rather than use complicated methods to calculate the exact
  105455. * multiple we need to apply, let's just cheat and use a constant.
  105456. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  105457. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  105458. */
  105459. private readonly _ffMultiplier;
  105460. /**
  105461. * Different event attributes for wheel data fall into a few set ranges.
  105462. * Some relevant but dated date here:
  105463. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  105464. */
  105465. private readonly _normalize;
  105466. }
  105467. }
  105468. declare module BABYLON {
  105469. /**
  105470. * Manage the mouse wheel inputs to control a free camera.
  105471. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105472. */
  105473. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  105474. /**
  105475. * Defines the camera the input is attached to.
  105476. */
  105477. camera: FreeCamera;
  105478. /**
  105479. * Gets the class name of the current input.
  105480. * @returns the class name
  105481. */
  105482. getClassName(): string;
  105483. /**
  105484. * Set which movement axis (relative to camera's orientation) the mouse
  105485. * wheel's X axis controls.
  105486. * @param axis The axis to be moved. Set null to clear.
  105487. */
  105488. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  105489. /**
  105490. * Get the configured movement axis (relative to camera's orientation) the
  105491. * mouse wheel's X axis controls.
  105492. * @returns The configured axis or null if none.
  105493. */
  105494. get wheelXMoveRelative(): Nullable<Coordinate>;
  105495. /**
  105496. * Set which movement axis (relative to camera's orientation) the mouse
  105497. * wheel's Y axis controls.
  105498. * @param axis The axis to be moved. Set null to clear.
  105499. */
  105500. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  105501. /**
  105502. * Get the configured movement axis (relative to camera's orientation) the
  105503. * mouse wheel's Y axis controls.
  105504. * @returns The configured axis or null if none.
  105505. */
  105506. get wheelYMoveRelative(): Nullable<Coordinate>;
  105507. /**
  105508. * Set which movement axis (relative to camera's orientation) the mouse
  105509. * wheel's Z axis controls.
  105510. * @param axis The axis to be moved. Set null to clear.
  105511. */
  105512. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  105513. /**
  105514. * Get the configured movement axis (relative to camera's orientation) the
  105515. * mouse wheel's Z axis controls.
  105516. * @returns The configured axis or null if none.
  105517. */
  105518. get wheelZMoveRelative(): Nullable<Coordinate>;
  105519. /**
  105520. * Set which rotation axis (relative to camera's orientation) the mouse
  105521. * wheel's X axis controls.
  105522. * @param axis The axis to be moved. Set null to clear.
  105523. */
  105524. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  105525. /**
  105526. * Get the configured rotation axis (relative to camera's orientation) the
  105527. * mouse wheel's X axis controls.
  105528. * @returns The configured axis or null if none.
  105529. */
  105530. get wheelXRotateRelative(): Nullable<Coordinate>;
  105531. /**
  105532. * Set which rotation axis (relative to camera's orientation) the mouse
  105533. * wheel's Y axis controls.
  105534. * @param axis The axis to be moved. Set null to clear.
  105535. */
  105536. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  105537. /**
  105538. * Get the configured rotation axis (relative to camera's orientation) the
  105539. * mouse wheel's Y axis controls.
  105540. * @returns The configured axis or null if none.
  105541. */
  105542. get wheelYRotateRelative(): Nullable<Coordinate>;
  105543. /**
  105544. * Set which rotation axis (relative to camera's orientation) the mouse
  105545. * wheel's Z axis controls.
  105546. * @param axis The axis to be moved. Set null to clear.
  105547. */
  105548. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  105549. /**
  105550. * Get the configured rotation axis (relative to camera's orientation) the
  105551. * mouse wheel's Z axis controls.
  105552. * @returns The configured axis or null if none.
  105553. */
  105554. get wheelZRotateRelative(): Nullable<Coordinate>;
  105555. /**
  105556. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  105557. * controls.
  105558. * @param axis The axis to be moved. Set null to clear.
  105559. */
  105560. set wheelXMoveScene(axis: Nullable<Coordinate>);
  105561. /**
  105562. * Get the configured movement axis (relative to the scene) the mouse wheel's
  105563. * X axis controls.
  105564. * @returns The configured axis or null if none.
  105565. */
  105566. get wheelXMoveScene(): Nullable<Coordinate>;
  105567. /**
  105568. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  105569. * controls.
  105570. * @param axis The axis to be moved. Set null to clear.
  105571. */
  105572. set wheelYMoveScene(axis: Nullable<Coordinate>);
  105573. /**
  105574. * Get the configured movement axis (relative to the scene) the mouse wheel's
  105575. * Y axis controls.
  105576. * @returns The configured axis or null if none.
  105577. */
  105578. get wheelYMoveScene(): Nullable<Coordinate>;
  105579. /**
  105580. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  105581. * controls.
  105582. * @param axis The axis to be moved. Set null to clear.
  105583. */
  105584. set wheelZMoveScene(axis: Nullable<Coordinate>);
  105585. /**
  105586. * Get the configured movement axis (relative to the scene) the mouse wheel's
  105587. * Z axis controls.
  105588. * @returns The configured axis or null if none.
  105589. */
  105590. get wheelZMoveScene(): Nullable<Coordinate>;
  105591. /**
  105592. * Called for each rendered frame.
  105593. */
  105594. checkInputs(): void;
  105595. private _moveRelative;
  105596. private _rotateRelative;
  105597. private _moveScene;
  105598. /**
  105599. * These are set to the desired default behaviour.
  105600. */
  105601. private _wheelXAction;
  105602. private _wheelXActionCoordinate;
  105603. private _wheelYAction;
  105604. private _wheelYActionCoordinate;
  105605. private _wheelZAction;
  105606. private _wheelZActionCoordinate;
  105607. /**
  105608. * Update the camera according to any configured properties for the 3
  105609. * mouse-wheel axis.
  105610. */
  105611. private _updateCamera;
  105612. }
  105613. }
  105614. declare module BABYLON {
  105615. /**
  105616. * Manage the touch inputs to control the movement of a free camera.
  105617. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105618. */
  105619. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  105620. /**
  105621. * Define if mouse events can be treated as touch events
  105622. */
  105623. allowMouse: boolean;
  105624. /**
  105625. * Defines the camera the input is attached to.
  105626. */
  105627. camera: FreeCamera;
  105628. /**
  105629. * Defines the touch sensibility for rotation.
  105630. * The higher the faster.
  105631. */
  105632. touchAngularSensibility: number;
  105633. /**
  105634. * Defines the touch sensibility for move.
  105635. * The higher the faster.
  105636. */
  105637. touchMoveSensibility: number;
  105638. private _offsetX;
  105639. private _offsetY;
  105640. private _pointerPressed;
  105641. private _pointerInput?;
  105642. private _observer;
  105643. private _onLostFocus;
  105644. /**
  105645. * Manage the touch inputs to control the movement of a free camera.
  105646. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105647. * @param allowMouse Defines if mouse events can be treated as touch events
  105648. */
  105649. constructor(
  105650. /**
  105651. * Define if mouse events can be treated as touch events
  105652. */
  105653. allowMouse?: boolean);
  105654. /**
  105655. * Attach the input controls to a specific dom element to get the input from.
  105656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105657. */
  105658. attachControl(noPreventDefault?: boolean): void;
  105659. /**
  105660. * Detach the current controls from the specified dom element.
  105661. */
  105662. detachControl(): void;
  105663. /**
  105664. * Update the current camera state depending on the inputs that have been used this frame.
  105665. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105666. */
  105667. checkInputs(): void;
  105668. /**
  105669. * Gets the class name of the current intput.
  105670. * @returns the class name
  105671. */
  105672. getClassName(): string;
  105673. /**
  105674. * Get the friendly name associated with the input class.
  105675. * @returns the input friendly name
  105676. */
  105677. getSimpleName(): string;
  105678. }
  105679. }
  105680. declare module BABYLON {
  105681. /**
  105682. * Default Inputs manager for the FreeCamera.
  105683. * It groups all the default supported inputs for ease of use.
  105684. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105685. */
  105686. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  105687. /**
  105688. * @hidden
  105689. */
  105690. _mouseInput: Nullable<FreeCameraMouseInput>;
  105691. /**
  105692. * @hidden
  105693. */
  105694. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  105695. /**
  105696. * Instantiates a new FreeCameraInputsManager.
  105697. * @param camera Defines the camera the inputs belong to
  105698. */
  105699. constructor(camera: FreeCamera);
  105700. /**
  105701. * Add keyboard input support to the input manager.
  105702. * @returns the current input manager
  105703. */
  105704. addKeyboard(): FreeCameraInputsManager;
  105705. /**
  105706. * Add mouse input support to the input manager.
  105707. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  105708. * @returns the current input manager
  105709. */
  105710. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  105711. /**
  105712. * Removes the mouse input support from the manager
  105713. * @returns the current input manager
  105714. */
  105715. removeMouse(): FreeCameraInputsManager;
  105716. /**
  105717. * Add mouse wheel input support to the input manager.
  105718. * @returns the current input manager
  105719. */
  105720. addMouseWheel(): FreeCameraInputsManager;
  105721. /**
  105722. * Removes the mouse wheel input support from the manager
  105723. * @returns the current input manager
  105724. */
  105725. removeMouseWheel(): FreeCameraInputsManager;
  105726. /**
  105727. * Add touch input support to the input manager.
  105728. * @returns the current input manager
  105729. */
  105730. addTouch(): FreeCameraInputsManager;
  105731. /**
  105732. * Remove all attached input methods from a camera
  105733. */
  105734. clear(): void;
  105735. }
  105736. }
  105737. declare module BABYLON {
  105738. /**
  105739. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  105740. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  105741. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  105742. */
  105743. export class FreeCamera extends TargetCamera {
  105744. /**
  105745. * Define the collision ellipsoid of the camera.
  105746. * This is helpful to simulate a camera body like the player body around the camera
  105747. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  105748. */
  105749. ellipsoid: Vector3;
  105750. /**
  105751. * Define an offset for the position of the ellipsoid around the camera.
  105752. * This can be helpful to determine the center of the body near the gravity center of the body
  105753. * instead of its head.
  105754. */
  105755. ellipsoidOffset: Vector3;
  105756. /**
  105757. * Enable or disable collisions of the camera with the rest of the scene objects.
  105758. */
  105759. checkCollisions: boolean;
  105760. /**
  105761. * Enable or disable gravity on the camera.
  105762. */
  105763. applyGravity: boolean;
  105764. /**
  105765. * Define the input manager associated to the camera.
  105766. */
  105767. inputs: FreeCameraInputsManager;
  105768. /**
  105769. * Gets the input sensibility for a mouse input. (default is 2000.0)
  105770. * Higher values reduce sensitivity.
  105771. */
  105772. get angularSensibility(): number;
  105773. /**
  105774. * Sets the input sensibility for a mouse input. (default is 2000.0)
  105775. * Higher values reduce sensitivity.
  105776. */
  105777. set angularSensibility(value: number);
  105778. /**
  105779. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  105780. */
  105781. get keysUp(): number[];
  105782. set keysUp(value: number[]);
  105783. /**
  105784. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  105785. */
  105786. get keysUpward(): number[];
  105787. set keysUpward(value: number[]);
  105788. /**
  105789. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  105790. */
  105791. get keysDown(): number[];
  105792. set keysDown(value: number[]);
  105793. /**
  105794. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  105795. */
  105796. get keysDownward(): number[];
  105797. set keysDownward(value: number[]);
  105798. /**
  105799. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  105800. */
  105801. get keysLeft(): number[];
  105802. set keysLeft(value: number[]);
  105803. /**
  105804. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  105805. */
  105806. get keysRight(): number[];
  105807. set keysRight(value: number[]);
  105808. /**
  105809. * Event raised when the camera collide with a mesh in the scene.
  105810. */
  105811. onCollide: (collidedMesh: AbstractMesh) => void;
  105812. private _collider;
  105813. private _needMoveForGravity;
  105814. private _oldPosition;
  105815. private _diffPosition;
  105816. private _newPosition;
  105817. /** @hidden */
  105818. _localDirection: Vector3;
  105819. /** @hidden */
  105820. _transformedDirection: Vector3;
  105821. /**
  105822. * Instantiates a Free Camera.
  105823. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  105824. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  105825. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  105826. * @param name Define the name of the camera in the scene
  105827. * @param position Define the start position of the camera in the scene
  105828. * @param scene Define the scene the camera belongs to
  105829. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  105830. */
  105831. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105832. /**
  105833. * Attach the input controls to a specific dom element to get the input from.
  105834. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105835. */
  105836. attachControl(noPreventDefault?: boolean): void;
  105837. /**
  105838. * Attach the input controls to a specific dom element to get the input from.
  105839. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  105840. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105841. * BACK COMPAT SIGNATURE ONLY.
  105842. */
  105843. attachControl(ignored: any, noPreventDefault?: boolean): void;
  105844. /**
  105845. * Detach the current controls from the specified dom element.
  105846. */
  105847. detachControl(): void;
  105848. /**
  105849. * Detach the current controls from the specified dom element.
  105850. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  105851. */
  105852. detachControl(ignored: any): void;
  105853. private _collisionMask;
  105854. /**
  105855. * Define a collision mask to limit the list of object the camera can collide with
  105856. */
  105857. get collisionMask(): number;
  105858. set collisionMask(mask: number);
  105859. /** @hidden */
  105860. _collideWithWorld(displacement: Vector3): void;
  105861. private _onCollisionPositionChange;
  105862. /** @hidden */
  105863. _checkInputs(): void;
  105864. /** @hidden */
  105865. _decideIfNeedsToMove(): boolean;
  105866. /** @hidden */
  105867. _updatePosition(): void;
  105868. /**
  105869. * Destroy the camera and release the current resources hold by it.
  105870. */
  105871. dispose(): void;
  105872. /**
  105873. * Gets the current object class name.
  105874. * @return the class name
  105875. */
  105876. getClassName(): string;
  105877. }
  105878. }
  105879. declare module BABYLON {
  105880. /**
  105881. * Represents a gamepad control stick position
  105882. */
  105883. export class StickValues {
  105884. /**
  105885. * The x component of the control stick
  105886. */
  105887. x: number;
  105888. /**
  105889. * The y component of the control stick
  105890. */
  105891. y: number;
  105892. /**
  105893. * Initializes the gamepad x and y control stick values
  105894. * @param x The x component of the gamepad control stick value
  105895. * @param y The y component of the gamepad control stick value
  105896. */
  105897. constructor(
  105898. /**
  105899. * The x component of the control stick
  105900. */
  105901. x: number,
  105902. /**
  105903. * The y component of the control stick
  105904. */
  105905. y: number);
  105906. }
  105907. /**
  105908. * An interface which manages callbacks for gamepad button changes
  105909. */
  105910. export interface GamepadButtonChanges {
  105911. /**
  105912. * Called when a gamepad has been changed
  105913. */
  105914. changed: boolean;
  105915. /**
  105916. * Called when a gamepad press event has been triggered
  105917. */
  105918. pressChanged: boolean;
  105919. /**
  105920. * Called when a touch event has been triggered
  105921. */
  105922. touchChanged: boolean;
  105923. /**
  105924. * Called when a value has changed
  105925. */
  105926. valueChanged: boolean;
  105927. }
  105928. /**
  105929. * Represents a gamepad
  105930. */
  105931. export class Gamepad {
  105932. /**
  105933. * The id of the gamepad
  105934. */
  105935. id: string;
  105936. /**
  105937. * The index of the gamepad
  105938. */
  105939. index: number;
  105940. /**
  105941. * The browser gamepad
  105942. */
  105943. browserGamepad: any;
  105944. /**
  105945. * Specifies what type of gamepad this represents
  105946. */
  105947. type: number;
  105948. private _leftStick;
  105949. private _rightStick;
  105950. /** @hidden */
  105951. _isConnected: boolean;
  105952. private _leftStickAxisX;
  105953. private _leftStickAxisY;
  105954. private _rightStickAxisX;
  105955. private _rightStickAxisY;
  105956. /**
  105957. * Triggered when the left control stick has been changed
  105958. */
  105959. private _onleftstickchanged;
  105960. /**
  105961. * Triggered when the right control stick has been changed
  105962. */
  105963. private _onrightstickchanged;
  105964. /**
  105965. * Represents a gamepad controller
  105966. */
  105967. static GAMEPAD: number;
  105968. /**
  105969. * Represents a generic controller
  105970. */
  105971. static GENERIC: number;
  105972. /**
  105973. * Represents an XBox controller
  105974. */
  105975. static XBOX: number;
  105976. /**
  105977. * Represents a pose-enabled controller
  105978. */
  105979. static POSE_ENABLED: number;
  105980. /**
  105981. * Represents an Dual Shock controller
  105982. */
  105983. static DUALSHOCK: number;
  105984. /**
  105985. * Specifies whether the left control stick should be Y-inverted
  105986. */
  105987. protected _invertLeftStickY: boolean;
  105988. /**
  105989. * Specifies if the gamepad has been connected
  105990. */
  105991. get isConnected(): boolean;
  105992. /**
  105993. * Initializes the gamepad
  105994. * @param id The id of the gamepad
  105995. * @param index The index of the gamepad
  105996. * @param browserGamepad The browser gamepad
  105997. * @param leftStickX The x component of the left joystick
  105998. * @param leftStickY The y component of the left joystick
  105999. * @param rightStickX The x component of the right joystick
  106000. * @param rightStickY The y component of the right joystick
  106001. */
  106002. constructor(
  106003. /**
  106004. * The id of the gamepad
  106005. */
  106006. id: string,
  106007. /**
  106008. * The index of the gamepad
  106009. */
  106010. index: number,
  106011. /**
  106012. * The browser gamepad
  106013. */
  106014. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  106015. /**
  106016. * Callback triggered when the left joystick has changed
  106017. * @param callback
  106018. */
  106019. onleftstickchanged(callback: (values: StickValues) => void): void;
  106020. /**
  106021. * Callback triggered when the right joystick has changed
  106022. * @param callback
  106023. */
  106024. onrightstickchanged(callback: (values: StickValues) => void): void;
  106025. /**
  106026. * Gets the left joystick
  106027. */
  106028. get leftStick(): StickValues;
  106029. /**
  106030. * Sets the left joystick values
  106031. */
  106032. set leftStick(newValues: StickValues);
  106033. /**
  106034. * Gets the right joystick
  106035. */
  106036. get rightStick(): StickValues;
  106037. /**
  106038. * Sets the right joystick value
  106039. */
  106040. set rightStick(newValues: StickValues);
  106041. /**
  106042. * Updates the gamepad joystick positions
  106043. */
  106044. update(): void;
  106045. /**
  106046. * Disposes the gamepad
  106047. */
  106048. dispose(): void;
  106049. }
  106050. /**
  106051. * Represents a generic gamepad
  106052. */
  106053. export class GenericPad extends Gamepad {
  106054. private _buttons;
  106055. private _onbuttondown;
  106056. private _onbuttonup;
  106057. /**
  106058. * Observable triggered when a button has been pressed
  106059. */
  106060. onButtonDownObservable: Observable<number>;
  106061. /**
  106062. * Observable triggered when a button has been released
  106063. */
  106064. onButtonUpObservable: Observable<number>;
  106065. /**
  106066. * Callback triggered when a button has been pressed
  106067. * @param callback Called when a button has been pressed
  106068. */
  106069. onbuttondown(callback: (buttonPressed: number) => void): void;
  106070. /**
  106071. * Callback triggered when a button has been released
  106072. * @param callback Called when a button has been released
  106073. */
  106074. onbuttonup(callback: (buttonReleased: number) => void): void;
  106075. /**
  106076. * Initializes the generic gamepad
  106077. * @param id The id of the generic gamepad
  106078. * @param index The index of the generic gamepad
  106079. * @param browserGamepad The browser gamepad
  106080. */
  106081. constructor(id: string, index: number, browserGamepad: any);
  106082. private _setButtonValue;
  106083. /**
  106084. * Updates the generic gamepad
  106085. */
  106086. update(): void;
  106087. /**
  106088. * Disposes the generic gamepad
  106089. */
  106090. dispose(): void;
  106091. }
  106092. }
  106093. declare module BABYLON {
  106094. /**
  106095. * Defines a runtime animation
  106096. */
  106097. export class RuntimeAnimation {
  106098. private _events;
  106099. /**
  106100. * The current frame of the runtime animation
  106101. */
  106102. private _currentFrame;
  106103. /**
  106104. * The animation used by the runtime animation
  106105. */
  106106. private _animation;
  106107. /**
  106108. * The target of the runtime animation
  106109. */
  106110. private _target;
  106111. /**
  106112. * The initiating animatable
  106113. */
  106114. private _host;
  106115. /**
  106116. * The original value of the runtime animation
  106117. */
  106118. private _originalValue;
  106119. /**
  106120. * The original blend value of the runtime animation
  106121. */
  106122. private _originalBlendValue;
  106123. /**
  106124. * The offsets cache of the runtime animation
  106125. */
  106126. private _offsetsCache;
  106127. /**
  106128. * The high limits cache of the runtime animation
  106129. */
  106130. private _highLimitsCache;
  106131. /**
  106132. * Specifies if the runtime animation has been stopped
  106133. */
  106134. private _stopped;
  106135. /**
  106136. * The blending factor of the runtime animation
  106137. */
  106138. private _blendingFactor;
  106139. /**
  106140. * The BabylonJS scene
  106141. */
  106142. private _scene;
  106143. /**
  106144. * The current value of the runtime animation
  106145. */
  106146. private _currentValue;
  106147. /** @hidden */
  106148. _animationState: _IAnimationState;
  106149. /**
  106150. * The active target of the runtime animation
  106151. */
  106152. private _activeTargets;
  106153. private _currentActiveTarget;
  106154. private _directTarget;
  106155. /**
  106156. * The target path of the runtime animation
  106157. */
  106158. private _targetPath;
  106159. /**
  106160. * The weight of the runtime animation
  106161. */
  106162. private _weight;
  106163. /**
  106164. * The ratio offset of the runtime animation
  106165. */
  106166. private _ratioOffset;
  106167. /**
  106168. * The previous delay of the runtime animation
  106169. */
  106170. private _previousDelay;
  106171. /**
  106172. * The previous ratio of the runtime animation
  106173. */
  106174. private _previousRatio;
  106175. private _enableBlending;
  106176. private _keys;
  106177. private _minFrame;
  106178. private _maxFrame;
  106179. private _minValue;
  106180. private _maxValue;
  106181. private _targetIsArray;
  106182. /**
  106183. * Gets the current frame of the runtime animation
  106184. */
  106185. get currentFrame(): number;
  106186. /**
  106187. * Gets the weight of the runtime animation
  106188. */
  106189. get weight(): number;
  106190. /**
  106191. * Gets the current value of the runtime animation
  106192. */
  106193. get currentValue(): any;
  106194. /**
  106195. * Gets the target path of the runtime animation
  106196. */
  106197. get targetPath(): string;
  106198. /**
  106199. * Gets the actual target of the runtime animation
  106200. */
  106201. get target(): any;
  106202. /**
  106203. * Gets the additive state of the runtime animation
  106204. */
  106205. get isAdditive(): boolean;
  106206. /** @hidden */
  106207. _onLoop: () => void;
  106208. /**
  106209. * Create a new RuntimeAnimation object
  106210. * @param target defines the target of the animation
  106211. * @param animation defines the source animation object
  106212. * @param scene defines the hosting scene
  106213. * @param host defines the initiating Animatable
  106214. */
  106215. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  106216. private _preparePath;
  106217. /**
  106218. * Gets the animation from the runtime animation
  106219. */
  106220. get animation(): Animation;
  106221. /**
  106222. * Resets the runtime animation to the beginning
  106223. * @param restoreOriginal defines whether to restore the target property to the original value
  106224. */
  106225. reset(restoreOriginal?: boolean): void;
  106226. /**
  106227. * Specifies if the runtime animation is stopped
  106228. * @returns Boolean specifying if the runtime animation is stopped
  106229. */
  106230. isStopped(): boolean;
  106231. /**
  106232. * Disposes of the runtime animation
  106233. */
  106234. dispose(): void;
  106235. /**
  106236. * Apply the interpolated value to the target
  106237. * @param currentValue defines the value computed by the animation
  106238. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  106239. */
  106240. setValue(currentValue: any, weight: number): void;
  106241. private _getOriginalValues;
  106242. private _setValue;
  106243. /**
  106244. * Gets the loop pmode of the runtime animation
  106245. * @returns Loop Mode
  106246. */
  106247. private _getCorrectLoopMode;
  106248. /**
  106249. * Move the current animation to a given frame
  106250. * @param frame defines the frame to move to
  106251. */
  106252. goToFrame(frame: number): void;
  106253. /**
  106254. * @hidden Internal use only
  106255. */
  106256. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  106257. /**
  106258. * Execute the current animation
  106259. * @param delay defines the delay to add to the current frame
  106260. * @param from defines the lower bound of the animation range
  106261. * @param to defines the upper bound of the animation range
  106262. * @param loop defines if the current animation must loop
  106263. * @param speedRatio defines the current speed ratio
  106264. * @param weight defines the weight of the animation (default is -1 so no weight)
  106265. * @param onLoop optional callback called when animation loops
  106266. * @returns a boolean indicating if the animation is running
  106267. */
  106268. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  106269. }
  106270. }
  106271. declare module BABYLON {
  106272. /**
  106273. * Class used to store an actual running animation
  106274. */
  106275. export class Animatable {
  106276. /** defines the target object */
  106277. target: any;
  106278. /** defines the starting frame number (default is 0) */
  106279. fromFrame: number;
  106280. /** defines the ending frame number (default is 100) */
  106281. toFrame: number;
  106282. /** defines if the animation must loop (default is false) */
  106283. loopAnimation: boolean;
  106284. /** defines a callback to call when animation ends if it is not looping */
  106285. onAnimationEnd?: (() => void) | null | undefined;
  106286. /** defines a callback to call when animation loops */
  106287. onAnimationLoop?: (() => void) | null | undefined;
  106288. /** defines whether the animation should be evaluated additively */
  106289. isAdditive: boolean;
  106290. private _localDelayOffset;
  106291. private _pausedDelay;
  106292. private _runtimeAnimations;
  106293. private _paused;
  106294. private _scene;
  106295. private _speedRatio;
  106296. private _weight;
  106297. private _syncRoot;
  106298. /**
  106299. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  106300. * This will only apply for non looping animation (default is true)
  106301. */
  106302. disposeOnEnd: boolean;
  106303. /**
  106304. * Gets a boolean indicating if the animation has started
  106305. */
  106306. animationStarted: boolean;
  106307. /**
  106308. * Observer raised when the animation ends
  106309. */
  106310. onAnimationEndObservable: Observable<Animatable>;
  106311. /**
  106312. * Observer raised when the animation loops
  106313. */
  106314. onAnimationLoopObservable: Observable<Animatable>;
  106315. /**
  106316. * Gets the root Animatable used to synchronize and normalize animations
  106317. */
  106318. get syncRoot(): Nullable<Animatable>;
  106319. /**
  106320. * Gets the current frame of the first RuntimeAnimation
  106321. * Used to synchronize Animatables
  106322. */
  106323. get masterFrame(): number;
  106324. /**
  106325. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  106326. */
  106327. get weight(): number;
  106328. set weight(value: number);
  106329. /**
  106330. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  106331. */
  106332. get speedRatio(): number;
  106333. set speedRatio(value: number);
  106334. /**
  106335. * Creates a new Animatable
  106336. * @param scene defines the hosting scene
  106337. * @param target defines the target object
  106338. * @param fromFrame defines the starting frame number (default is 0)
  106339. * @param toFrame defines the ending frame number (default is 100)
  106340. * @param loopAnimation defines if the animation must loop (default is false)
  106341. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  106342. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  106343. * @param animations defines a group of animation to add to the new Animatable
  106344. * @param onAnimationLoop defines a callback to call when animation loops
  106345. * @param isAdditive defines whether the animation should be evaluated additively
  106346. */
  106347. constructor(scene: Scene,
  106348. /** defines the target object */
  106349. target: any,
  106350. /** defines the starting frame number (default is 0) */
  106351. fromFrame?: number,
  106352. /** defines the ending frame number (default is 100) */
  106353. toFrame?: number,
  106354. /** defines if the animation must loop (default is false) */
  106355. loopAnimation?: boolean, speedRatio?: number,
  106356. /** defines a callback to call when animation ends if it is not looping */
  106357. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  106358. /** defines a callback to call when animation loops */
  106359. onAnimationLoop?: (() => void) | null | undefined,
  106360. /** defines whether the animation should be evaluated additively */
  106361. isAdditive?: boolean);
  106362. /**
  106363. * Synchronize and normalize current Animatable with a source Animatable
  106364. * This is useful when using animation weights and when animations are not of the same length
  106365. * @param root defines the root Animatable to synchronize with
  106366. * @returns the current Animatable
  106367. */
  106368. syncWith(root: Animatable): Animatable;
  106369. /**
  106370. * Gets the list of runtime animations
  106371. * @returns an array of RuntimeAnimation
  106372. */
  106373. getAnimations(): RuntimeAnimation[];
  106374. /**
  106375. * Adds more animations to the current animatable
  106376. * @param target defines the target of the animations
  106377. * @param animations defines the new animations to add
  106378. */
  106379. appendAnimations(target: any, animations: Animation[]): void;
  106380. /**
  106381. * Gets the source animation for a specific property
  106382. * @param property defines the propertyu to look for
  106383. * @returns null or the source animation for the given property
  106384. */
  106385. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  106386. /**
  106387. * Gets the runtime animation for a specific property
  106388. * @param property defines the propertyu to look for
  106389. * @returns null or the runtime animation for the given property
  106390. */
  106391. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  106392. /**
  106393. * Resets the animatable to its original state
  106394. */
  106395. reset(): void;
  106396. /**
  106397. * Allows the animatable to blend with current running animations
  106398. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  106399. * @param blendingSpeed defines the blending speed to use
  106400. */
  106401. enableBlending(blendingSpeed: number): void;
  106402. /**
  106403. * Disable animation blending
  106404. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  106405. */
  106406. disableBlending(): void;
  106407. /**
  106408. * Jump directly to a given frame
  106409. * @param frame defines the frame to jump to
  106410. */
  106411. goToFrame(frame: number): void;
  106412. /**
  106413. * Pause the animation
  106414. */
  106415. pause(): void;
  106416. /**
  106417. * Restart the animation
  106418. */
  106419. restart(): void;
  106420. private _raiseOnAnimationEnd;
  106421. /**
  106422. * Stop and delete the current animation
  106423. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  106424. * @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)
  106425. */
  106426. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  106427. /**
  106428. * Wait asynchronously for the animation to end
  106429. * @returns a promise which will be fullfilled when the animation ends
  106430. */
  106431. waitAsync(): Promise<Animatable>;
  106432. /** @hidden */
  106433. _animate(delay: number): boolean;
  106434. }
  106435. interface Scene {
  106436. /** @hidden */
  106437. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  106438. /** @hidden */
  106439. _processLateAnimationBindingsForMatrices(holder: {
  106440. totalWeight: number;
  106441. totalAdditiveWeight: number;
  106442. animations: RuntimeAnimation[];
  106443. additiveAnimations: RuntimeAnimation[];
  106444. originalValue: Matrix;
  106445. }): any;
  106446. /** @hidden */
  106447. _processLateAnimationBindingsForQuaternions(holder: {
  106448. totalWeight: number;
  106449. totalAdditiveWeight: number;
  106450. animations: RuntimeAnimation[];
  106451. additiveAnimations: RuntimeAnimation[];
  106452. originalValue: Quaternion;
  106453. }, refQuaternion: Quaternion): Quaternion;
  106454. /** @hidden */
  106455. _processLateAnimationBindings(): void;
  106456. /**
  106457. * Will start the animation sequence of a given target
  106458. * @param target defines the target
  106459. * @param from defines from which frame should animation start
  106460. * @param to defines until which frame should animation run.
  106461. * @param weight defines the weight to apply to the animation (1.0 by default)
  106462. * @param loop defines if the animation loops
  106463. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  106464. * @param onAnimationEnd defines the function to be executed when the animation ends
  106465. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  106466. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  106467. * @param onAnimationLoop defines the callback to call when an animation loops
  106468. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106469. * @returns the animatable object created for this animation
  106470. */
  106471. 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;
  106472. /**
  106473. * Will start the animation sequence of a given target
  106474. * @param target defines the target
  106475. * @param from defines from which frame should animation start
  106476. * @param to defines until which frame should animation run.
  106477. * @param loop defines if the animation loops
  106478. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  106479. * @param onAnimationEnd defines the function to be executed when the animation ends
  106480. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  106481. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  106482. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  106483. * @param onAnimationLoop defines the callback to call when an animation loops
  106484. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106485. * @returns the animatable object created for this animation
  106486. */
  106487. 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;
  106488. /**
  106489. * Will start the animation sequence of a given target and its hierarchy
  106490. * @param target defines the target
  106491. * @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.
  106492. * @param from defines from which frame should animation start
  106493. * @param to defines until which frame should animation run.
  106494. * @param loop defines if the animation loops
  106495. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  106496. * @param onAnimationEnd defines the function to be executed when the animation ends
  106497. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  106498. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  106499. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  106500. * @param onAnimationLoop defines the callback to call when an animation loops
  106501. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106502. * @returns the list of created animatables
  106503. */
  106504. 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[];
  106505. /**
  106506. * Begin a new animation on a given node
  106507. * @param target defines the target where the animation will take place
  106508. * @param animations defines the list of animations to start
  106509. * @param from defines the initial value
  106510. * @param to defines the final value
  106511. * @param loop defines if you want animation to loop (off by default)
  106512. * @param speedRatio defines the speed ratio to apply to all animations
  106513. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  106514. * @param onAnimationLoop defines the callback to call when an animation loops
  106515. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106516. * @returns the list of created animatables
  106517. */
  106518. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  106519. /**
  106520. * Begin a new animation on a given node and its hierarchy
  106521. * @param target defines the root node where the animation will take place
  106522. * @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.
  106523. * @param animations defines the list of animations to start
  106524. * @param from defines the initial value
  106525. * @param to defines the final value
  106526. * @param loop defines if you want animation to loop (off by default)
  106527. * @param speedRatio defines the speed ratio to apply to all animations
  106528. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  106529. * @param onAnimationLoop defines the callback to call when an animation loops
  106530. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106531. * @returns the list of animatables created for all nodes
  106532. */
  106533. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  106534. /**
  106535. * Gets the animatable associated with a specific target
  106536. * @param target defines the target of the animatable
  106537. * @returns the required animatable if found
  106538. */
  106539. getAnimatableByTarget(target: any): Nullable<Animatable>;
  106540. /**
  106541. * Gets all animatables associated with a given target
  106542. * @param target defines the target to look animatables for
  106543. * @returns an array of Animatables
  106544. */
  106545. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  106546. /**
  106547. * Stops and removes all animations that have been applied to the scene
  106548. */
  106549. stopAllAnimations(): void;
  106550. /**
  106551. * Gets the current delta time used by animation engine
  106552. */
  106553. deltaTime: number;
  106554. }
  106555. interface Bone {
  106556. /**
  106557. * Copy an animation range from another bone
  106558. * @param source defines the source bone
  106559. * @param rangeName defines the range name to copy
  106560. * @param frameOffset defines the frame offset
  106561. * @param rescaleAsRequired defines if rescaling must be applied if required
  106562. * @param skelDimensionsRatio defines the scaling ratio
  106563. * @returns true if operation was successful
  106564. */
  106565. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  106566. }
  106567. }
  106568. declare module BABYLON {
  106569. /**
  106570. * Class used to override all child animations of a given target
  106571. */
  106572. export class AnimationPropertiesOverride {
  106573. /**
  106574. * Gets or sets a value indicating if animation blending must be used
  106575. */
  106576. enableBlending: boolean;
  106577. /**
  106578. * Gets or sets the blending speed to use when enableBlending is true
  106579. */
  106580. blendingSpeed: number;
  106581. /**
  106582. * Gets or sets the default loop mode to use
  106583. */
  106584. loopMode: number;
  106585. }
  106586. }
  106587. declare module BABYLON {
  106588. /**
  106589. * Class used to handle skinning animations
  106590. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  106591. */
  106592. export class Skeleton implements IAnimatable {
  106593. /** defines the skeleton name */
  106594. name: string;
  106595. /** defines the skeleton Id */
  106596. id: string;
  106597. /**
  106598. * Defines the list of child bones
  106599. */
  106600. bones: Bone[];
  106601. /**
  106602. * Defines an estimate of the dimension of the skeleton at rest
  106603. */
  106604. dimensionsAtRest: Vector3;
  106605. /**
  106606. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  106607. */
  106608. needInitialSkinMatrix: boolean;
  106609. /**
  106610. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  106611. */
  106612. overrideMesh: Nullable<AbstractMesh>;
  106613. /**
  106614. * Gets the list of animations attached to this skeleton
  106615. */
  106616. animations: Array<Animation>;
  106617. private _scene;
  106618. private _isDirty;
  106619. private _transformMatrices;
  106620. private _transformMatrixTexture;
  106621. private _meshesWithPoseMatrix;
  106622. private _animatables;
  106623. private _identity;
  106624. private _synchronizedWithMesh;
  106625. private _ranges;
  106626. private _lastAbsoluteTransformsUpdateId;
  106627. private _canUseTextureForBones;
  106628. private _uniqueId;
  106629. /** @hidden */
  106630. _numBonesWithLinkedTransformNode: number;
  106631. /** @hidden */
  106632. _hasWaitingData: Nullable<boolean>;
  106633. /** @hidden */
  106634. _waitingOverrideMeshId: Nullable<string>;
  106635. /**
  106636. * Specifies if the skeleton should be serialized
  106637. */
  106638. doNotSerialize: boolean;
  106639. private _useTextureToStoreBoneMatrices;
  106640. /**
  106641. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  106642. * Please note that this option is not available if the hardware does not support it
  106643. */
  106644. get useTextureToStoreBoneMatrices(): boolean;
  106645. set useTextureToStoreBoneMatrices(value: boolean);
  106646. private _animationPropertiesOverride;
  106647. /**
  106648. * Gets or sets the animation properties override
  106649. */
  106650. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106651. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  106652. /**
  106653. * List of inspectable custom properties (used by the Inspector)
  106654. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  106655. */
  106656. inspectableCustomProperties: IInspectable[];
  106657. /**
  106658. * An observable triggered before computing the skeleton's matrices
  106659. */
  106660. onBeforeComputeObservable: Observable<Skeleton>;
  106661. /**
  106662. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  106663. */
  106664. get isUsingTextureForMatrices(): boolean;
  106665. /**
  106666. * Gets the unique ID of this skeleton
  106667. */
  106668. get uniqueId(): number;
  106669. /**
  106670. * Creates a new skeleton
  106671. * @param name defines the skeleton name
  106672. * @param id defines the skeleton Id
  106673. * @param scene defines the hosting scene
  106674. */
  106675. constructor(
  106676. /** defines the skeleton name */
  106677. name: string,
  106678. /** defines the skeleton Id */
  106679. id: string, scene: Scene);
  106680. /**
  106681. * Gets the current object class name.
  106682. * @return the class name
  106683. */
  106684. getClassName(): string;
  106685. /**
  106686. * Returns an array containing the root bones
  106687. * @returns an array containing the root bones
  106688. */
  106689. getChildren(): Array<Bone>;
  106690. /**
  106691. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  106692. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  106693. * @returns a Float32Array containing matrices data
  106694. */
  106695. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  106696. /**
  106697. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  106698. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  106699. * @returns a raw texture containing the data
  106700. */
  106701. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  106702. /**
  106703. * Gets the current hosting scene
  106704. * @returns a scene object
  106705. */
  106706. getScene(): Scene;
  106707. /**
  106708. * Gets a string representing the current skeleton data
  106709. * @param fullDetails defines a boolean indicating if we want a verbose version
  106710. * @returns a string representing the current skeleton data
  106711. */
  106712. toString(fullDetails?: boolean): string;
  106713. /**
  106714. * Get bone's index searching by name
  106715. * @param name defines bone's name to search for
  106716. * @return the indice of the bone. Returns -1 if not found
  106717. */
  106718. getBoneIndexByName(name: string): number;
  106719. /**
  106720. * Creater a new animation range
  106721. * @param name defines the name of the range
  106722. * @param from defines the start key
  106723. * @param to defines the end key
  106724. */
  106725. createAnimationRange(name: string, from: number, to: number): void;
  106726. /**
  106727. * Delete a specific animation range
  106728. * @param name defines the name of the range
  106729. * @param deleteFrames defines if frames must be removed as well
  106730. */
  106731. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  106732. /**
  106733. * Gets a specific animation range
  106734. * @param name defines the name of the range to look for
  106735. * @returns the requested animation range or null if not found
  106736. */
  106737. getAnimationRange(name: string): Nullable<AnimationRange>;
  106738. /**
  106739. * Gets the list of all animation ranges defined on this skeleton
  106740. * @returns an array
  106741. */
  106742. getAnimationRanges(): Nullable<AnimationRange>[];
  106743. /**
  106744. * Copy animation range from a source skeleton.
  106745. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  106746. * @param source defines the source skeleton
  106747. * @param name defines the name of the range to copy
  106748. * @param rescaleAsRequired defines if rescaling must be applied if required
  106749. * @returns true if operation was successful
  106750. */
  106751. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  106752. /**
  106753. * Forces the skeleton to go to rest pose
  106754. */
  106755. returnToRest(): void;
  106756. private _getHighestAnimationFrame;
  106757. /**
  106758. * Begin a specific animation range
  106759. * @param name defines the name of the range to start
  106760. * @param loop defines if looping must be turned on (false by default)
  106761. * @param speedRatio defines the speed ratio to apply (1 by default)
  106762. * @param onAnimationEnd defines a callback which will be called when animation will end
  106763. * @returns a new animatable
  106764. */
  106765. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  106766. /**
  106767. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  106768. * @param skeleton defines the Skeleton containing the animation range to convert
  106769. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  106770. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  106771. * @returns the original skeleton
  106772. */
  106773. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  106774. /** @hidden */
  106775. _markAsDirty(): void;
  106776. /** @hidden */
  106777. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  106778. /** @hidden */
  106779. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  106780. private _computeTransformMatrices;
  106781. /**
  106782. * Build all resources required to render a skeleton
  106783. */
  106784. prepare(): void;
  106785. /**
  106786. * Gets the list of animatables currently running for this skeleton
  106787. * @returns an array of animatables
  106788. */
  106789. getAnimatables(): IAnimatable[];
  106790. /**
  106791. * Clone the current skeleton
  106792. * @param name defines the name of the new skeleton
  106793. * @param id defines the id of the new skeleton
  106794. * @returns the new skeleton
  106795. */
  106796. clone(name: string, id?: string): Skeleton;
  106797. /**
  106798. * Enable animation blending for this skeleton
  106799. * @param blendingSpeed defines the blending speed to apply
  106800. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  106801. */
  106802. enableBlending(blendingSpeed?: number): void;
  106803. /**
  106804. * Releases all resources associated with the current skeleton
  106805. */
  106806. dispose(): void;
  106807. /**
  106808. * Serialize the skeleton in a JSON object
  106809. * @returns a JSON object
  106810. */
  106811. serialize(): any;
  106812. /**
  106813. * Creates a new skeleton from serialized data
  106814. * @param parsedSkeleton defines the serialized data
  106815. * @param scene defines the hosting scene
  106816. * @returns a new skeleton
  106817. */
  106818. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  106819. /**
  106820. * Compute all node absolute transforms
  106821. * @param forceUpdate defines if computation must be done even if cache is up to date
  106822. */
  106823. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  106824. /**
  106825. * Gets the root pose matrix
  106826. * @returns a matrix
  106827. */
  106828. getPoseMatrix(): Nullable<Matrix>;
  106829. /**
  106830. * Sorts bones per internal index
  106831. */
  106832. sortBones(): void;
  106833. private _sortBones;
  106834. /**
  106835. * Set the current local matrix as the restPose for all bones in the skeleton.
  106836. */
  106837. setCurrentPoseAsRest(): void;
  106838. }
  106839. }
  106840. declare module BABYLON {
  106841. /**
  106842. * Class used to store bone information
  106843. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  106844. */
  106845. export class Bone extends Node {
  106846. /**
  106847. * defines the bone name
  106848. */
  106849. name: string;
  106850. private static _tmpVecs;
  106851. private static _tmpQuat;
  106852. private static _tmpMats;
  106853. /**
  106854. * Gets the list of child bones
  106855. */
  106856. children: Bone[];
  106857. /** Gets the animations associated with this bone */
  106858. animations: Animation[];
  106859. /**
  106860. * Gets or sets bone length
  106861. */
  106862. length: number;
  106863. /**
  106864. * @hidden Internal only
  106865. * Set this value to map this bone to a different index in the transform matrices
  106866. * Set this value to -1 to exclude the bone from the transform matrices
  106867. */
  106868. _index: Nullable<number>;
  106869. private _skeleton;
  106870. private _localMatrix;
  106871. private _restPose;
  106872. private _bindPose;
  106873. private _baseMatrix;
  106874. private _absoluteTransform;
  106875. private _invertedAbsoluteTransform;
  106876. private _parent;
  106877. private _scalingDeterminant;
  106878. private _worldTransform;
  106879. private _localScaling;
  106880. private _localRotation;
  106881. private _localPosition;
  106882. private _needToDecompose;
  106883. private _needToCompose;
  106884. /** @hidden */
  106885. _linkedTransformNode: Nullable<TransformNode>;
  106886. /** @hidden */
  106887. _waitingTransformNodeId: Nullable<string>;
  106888. /** @hidden */
  106889. get _matrix(): Matrix;
  106890. /** @hidden */
  106891. set _matrix(value: Matrix);
  106892. /**
  106893. * Create a new bone
  106894. * @param name defines the bone name
  106895. * @param skeleton defines the parent skeleton
  106896. * @param parentBone defines the parent (can be null if the bone is the root)
  106897. * @param localMatrix defines the local matrix
  106898. * @param restPose defines the rest pose matrix
  106899. * @param baseMatrix defines the base matrix
  106900. * @param index defines index of the bone in the hiearchy
  106901. */
  106902. constructor(
  106903. /**
  106904. * defines the bone name
  106905. */
  106906. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  106907. /**
  106908. * Gets the current object class name.
  106909. * @return the class name
  106910. */
  106911. getClassName(): string;
  106912. /**
  106913. * Gets the parent skeleton
  106914. * @returns a skeleton
  106915. */
  106916. getSkeleton(): Skeleton;
  106917. /**
  106918. * Gets parent bone
  106919. * @returns a bone or null if the bone is the root of the bone hierarchy
  106920. */
  106921. getParent(): Nullable<Bone>;
  106922. /**
  106923. * Returns an array containing the root bones
  106924. * @returns an array containing the root bones
  106925. */
  106926. getChildren(): Array<Bone>;
  106927. /**
  106928. * Gets the node index in matrix array generated for rendering
  106929. * @returns the node index
  106930. */
  106931. getIndex(): number;
  106932. /**
  106933. * Sets the parent bone
  106934. * @param parent defines the parent (can be null if the bone is the root)
  106935. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  106936. */
  106937. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  106938. /**
  106939. * Gets the local matrix
  106940. * @returns a matrix
  106941. */
  106942. getLocalMatrix(): Matrix;
  106943. /**
  106944. * Gets the base matrix (initial matrix which remains unchanged)
  106945. * @returns a matrix
  106946. */
  106947. getBaseMatrix(): Matrix;
  106948. /**
  106949. * Gets the rest pose matrix
  106950. * @returns a matrix
  106951. */
  106952. getRestPose(): Matrix;
  106953. /**
  106954. * Sets the rest pose matrix
  106955. * @param matrix the local-space rest pose to set for this bone
  106956. */
  106957. setRestPose(matrix: Matrix): void;
  106958. /**
  106959. * Gets the bind pose matrix
  106960. * @returns the bind pose matrix
  106961. */
  106962. getBindPose(): Matrix;
  106963. /**
  106964. * Sets the bind pose matrix
  106965. * @param matrix the local-space bind pose to set for this bone
  106966. */
  106967. setBindPose(matrix: Matrix): void;
  106968. /**
  106969. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  106970. */
  106971. getWorldMatrix(): Matrix;
  106972. /**
  106973. * Sets the local matrix to rest pose matrix
  106974. */
  106975. returnToRest(): void;
  106976. /**
  106977. * Gets the inverse of the absolute transform matrix.
  106978. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  106979. * @returns a matrix
  106980. */
  106981. getInvertedAbsoluteTransform(): Matrix;
  106982. /**
  106983. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  106984. * @returns a matrix
  106985. */
  106986. getAbsoluteTransform(): Matrix;
  106987. /**
  106988. * Links with the given transform node.
  106989. * The local matrix of this bone is copied from the transform node every frame.
  106990. * @param transformNode defines the transform node to link to
  106991. */
  106992. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  106993. /**
  106994. * Gets the node used to drive the bone's transformation
  106995. * @returns a transform node or null
  106996. */
  106997. getTransformNode(): Nullable<TransformNode>;
  106998. /** Gets or sets current position (in local space) */
  106999. get position(): Vector3;
  107000. set position(newPosition: Vector3);
  107001. /** Gets or sets current rotation (in local space) */
  107002. get rotation(): Vector3;
  107003. set rotation(newRotation: Vector3);
  107004. /** Gets or sets current rotation quaternion (in local space) */
  107005. get rotationQuaternion(): Quaternion;
  107006. set rotationQuaternion(newRotation: Quaternion);
  107007. /** Gets or sets current scaling (in local space) */
  107008. get scaling(): Vector3;
  107009. set scaling(newScaling: Vector3);
  107010. /**
  107011. * Gets the animation properties override
  107012. */
  107013. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  107014. private _decompose;
  107015. private _compose;
  107016. /**
  107017. * Update the base and local matrices
  107018. * @param matrix defines the new base or local matrix
  107019. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  107020. * @param updateLocalMatrix defines if the local matrix should be updated
  107021. */
  107022. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  107023. /** @hidden */
  107024. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  107025. /**
  107026. * Flag the bone as dirty (Forcing it to update everything)
  107027. */
  107028. markAsDirty(): void;
  107029. /** @hidden */
  107030. _markAsDirtyAndCompose(): void;
  107031. private _markAsDirtyAndDecompose;
  107032. /**
  107033. * Translate the bone in local or world space
  107034. * @param vec The amount to translate the bone
  107035. * @param space The space that the translation is in
  107036. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107037. */
  107038. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  107039. /**
  107040. * Set the postion of the bone in local or world space
  107041. * @param position The position to set the bone
  107042. * @param space The space that the position is in
  107043. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107044. */
  107045. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  107046. /**
  107047. * Set the absolute position of the bone (world space)
  107048. * @param position The position to set the bone
  107049. * @param mesh The mesh that this bone is attached to
  107050. */
  107051. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  107052. /**
  107053. * Scale the bone on the x, y and z axes (in local space)
  107054. * @param x The amount to scale the bone on the x axis
  107055. * @param y The amount to scale the bone on the y axis
  107056. * @param z The amount to scale the bone on the z axis
  107057. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  107058. */
  107059. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  107060. /**
  107061. * Set the bone scaling in local space
  107062. * @param scale defines the scaling vector
  107063. */
  107064. setScale(scale: Vector3): void;
  107065. /**
  107066. * Gets the current scaling in local space
  107067. * @returns the current scaling vector
  107068. */
  107069. getScale(): Vector3;
  107070. /**
  107071. * Gets the current scaling in local space and stores it in a target vector
  107072. * @param result defines the target vector
  107073. */
  107074. getScaleToRef(result: Vector3): void;
  107075. /**
  107076. * Set the yaw, pitch, and roll of the bone in local or world space
  107077. * @param yaw The rotation of the bone on the y axis
  107078. * @param pitch The rotation of the bone on the x axis
  107079. * @param roll The rotation of the bone on the z axis
  107080. * @param space The space that the axes of rotation are in
  107081. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107082. */
  107083. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  107084. /**
  107085. * Add a rotation to the bone on an axis in local or world space
  107086. * @param axis The axis to rotate the bone on
  107087. * @param amount The amount to rotate the bone
  107088. * @param space The space that the axis is in
  107089. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107090. */
  107091. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  107092. /**
  107093. * Set the rotation of the bone to a particular axis angle in local or world space
  107094. * @param axis The axis to rotate the bone on
  107095. * @param angle The angle that the bone should be rotated to
  107096. * @param space The space that the axis is in
  107097. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107098. */
  107099. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  107100. /**
  107101. * Set the euler rotation of the bone in local or world space
  107102. * @param rotation The euler rotation that the bone should be set to
  107103. * @param space The space that the rotation is in
  107104. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107105. */
  107106. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  107107. /**
  107108. * Set the quaternion rotation of the bone in local or world space
  107109. * @param quat The quaternion rotation that the bone should be set to
  107110. * @param space The space that the rotation is in
  107111. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107112. */
  107113. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  107114. /**
  107115. * Set the rotation matrix of the bone in local or world space
  107116. * @param rotMat The rotation matrix that the bone should be set to
  107117. * @param space The space that the rotation is in
  107118. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107119. */
  107120. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  107121. private _rotateWithMatrix;
  107122. private _getNegativeRotationToRef;
  107123. /**
  107124. * Get the position of the bone in local or world space
  107125. * @param space The space that the returned position is in
  107126. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107127. * @returns The position of the bone
  107128. */
  107129. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  107130. /**
  107131. * Copy the position of the bone to a vector3 in local or world space
  107132. * @param space The space that the returned position is in
  107133. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107134. * @param result The vector3 to copy the position to
  107135. */
  107136. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  107137. /**
  107138. * Get the absolute position of the bone (world space)
  107139. * @param mesh The mesh that this bone is attached to
  107140. * @returns The absolute position of the bone
  107141. */
  107142. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  107143. /**
  107144. * Copy the absolute position of the bone (world space) to the result param
  107145. * @param mesh The mesh that this bone is attached to
  107146. * @param result The vector3 to copy the absolute position to
  107147. */
  107148. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  107149. /**
  107150. * Compute the absolute transforms of this bone and its children
  107151. */
  107152. computeAbsoluteTransforms(): void;
  107153. /**
  107154. * Get the world direction from an axis that is in the local space of the bone
  107155. * @param localAxis The local direction that is used to compute the world direction
  107156. * @param mesh The mesh that this bone is attached to
  107157. * @returns The world direction
  107158. */
  107159. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  107160. /**
  107161. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  107162. * @param localAxis The local direction that is used to compute the world direction
  107163. * @param mesh The mesh that this bone is attached to
  107164. * @param result The vector3 that the world direction will be copied to
  107165. */
  107166. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107167. /**
  107168. * Get the euler rotation of the bone in local or world space
  107169. * @param space The space that the rotation should be in
  107170. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107171. * @returns The euler rotation
  107172. */
  107173. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  107174. /**
  107175. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  107176. * @param space The space that the rotation should be in
  107177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107178. * @param result The vector3 that the rotation should be copied to
  107179. */
  107180. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107181. /**
  107182. * Get the quaternion rotation of the bone in either local or world space
  107183. * @param space The space that the rotation should be in
  107184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107185. * @returns The quaternion rotation
  107186. */
  107187. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  107188. /**
  107189. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  107190. * @param space The space that the rotation should be in
  107191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107192. * @param result The quaternion that the rotation should be copied to
  107193. */
  107194. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  107195. /**
  107196. * Get the rotation matrix of the bone in local or world space
  107197. * @param space The space that the rotation should be in
  107198. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107199. * @returns The rotation matrix
  107200. */
  107201. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  107202. /**
  107203. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  107204. * @param space The space that the rotation should be in
  107205. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107206. * @param result The quaternion that the rotation should be copied to
  107207. */
  107208. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  107209. /**
  107210. * Get the world position of a point that is in the local space of the bone
  107211. * @param position The local position
  107212. * @param mesh The mesh that this bone is attached to
  107213. * @returns The world position
  107214. */
  107215. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  107216. /**
  107217. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  107218. * @param position The local position
  107219. * @param mesh The mesh that this bone is attached to
  107220. * @param result The vector3 that the world position should be copied to
  107221. */
  107222. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107223. /**
  107224. * Get the local position of a point that is in world space
  107225. * @param position The world position
  107226. * @param mesh The mesh that this bone is attached to
  107227. * @returns The local position
  107228. */
  107229. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  107230. /**
  107231. * Get the local position of a point that is in world space and copy it to the result param
  107232. * @param position The world position
  107233. * @param mesh The mesh that this bone is attached to
  107234. * @param result The vector3 that the local position should be copied to
  107235. */
  107236. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107237. /**
  107238. * Set the current local matrix as the restPose for this bone.
  107239. */
  107240. setCurrentPoseAsRest(): void;
  107241. }
  107242. }
  107243. declare module BABYLON {
  107244. /**
  107245. * 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.
  107246. * @see https://doc.babylonjs.com/how_to/transformnode
  107247. */
  107248. export class TransformNode extends Node {
  107249. /**
  107250. * Object will not rotate to face the camera
  107251. */
  107252. static BILLBOARDMODE_NONE: number;
  107253. /**
  107254. * Object will rotate to face the camera but only on the x axis
  107255. */
  107256. static BILLBOARDMODE_X: number;
  107257. /**
  107258. * Object will rotate to face the camera but only on the y axis
  107259. */
  107260. static BILLBOARDMODE_Y: number;
  107261. /**
  107262. * Object will rotate to face the camera but only on the z axis
  107263. */
  107264. static BILLBOARDMODE_Z: number;
  107265. /**
  107266. * Object will rotate to face the camera
  107267. */
  107268. static BILLBOARDMODE_ALL: number;
  107269. /**
  107270. * Object will rotate to face the camera's position instead of orientation
  107271. */
  107272. static BILLBOARDMODE_USE_POSITION: number;
  107273. private static _TmpRotation;
  107274. private static _TmpScaling;
  107275. private static _TmpTranslation;
  107276. private _forward;
  107277. private _forwardInverted;
  107278. private _up;
  107279. private _right;
  107280. private _rightInverted;
  107281. private _position;
  107282. private _rotation;
  107283. private _rotationQuaternion;
  107284. protected _scaling: Vector3;
  107285. protected _isDirty: boolean;
  107286. private _transformToBoneReferal;
  107287. private _isAbsoluteSynced;
  107288. private _billboardMode;
  107289. /**
  107290. * Gets or sets the billboard mode. Default is 0.
  107291. *
  107292. * | Value | Type | Description |
  107293. * | --- | --- | --- |
  107294. * | 0 | BILLBOARDMODE_NONE | |
  107295. * | 1 | BILLBOARDMODE_X | |
  107296. * | 2 | BILLBOARDMODE_Y | |
  107297. * | 4 | BILLBOARDMODE_Z | |
  107298. * | 7 | BILLBOARDMODE_ALL | |
  107299. *
  107300. */
  107301. get billboardMode(): number;
  107302. set billboardMode(value: number);
  107303. private _preserveParentRotationForBillboard;
  107304. /**
  107305. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  107306. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  107307. */
  107308. get preserveParentRotationForBillboard(): boolean;
  107309. set preserveParentRotationForBillboard(value: boolean);
  107310. /**
  107311. * 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
  107312. */
  107313. scalingDeterminant: number;
  107314. private _infiniteDistance;
  107315. /**
  107316. * Gets or sets the distance of the object to max, often used by skybox
  107317. */
  107318. get infiniteDistance(): boolean;
  107319. set infiniteDistance(value: boolean);
  107320. /**
  107321. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  107322. * By default the system will update normals to compensate
  107323. */
  107324. ignoreNonUniformScaling: boolean;
  107325. /**
  107326. * 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
  107327. */
  107328. reIntegrateRotationIntoRotationQuaternion: boolean;
  107329. /** @hidden */
  107330. _poseMatrix: Nullable<Matrix>;
  107331. /** @hidden */
  107332. _localMatrix: Matrix;
  107333. private _usePivotMatrix;
  107334. private _absolutePosition;
  107335. private _absoluteScaling;
  107336. private _absoluteRotationQuaternion;
  107337. private _pivotMatrix;
  107338. private _pivotMatrixInverse;
  107339. /** @hidden */
  107340. _postMultiplyPivotMatrix: boolean;
  107341. protected _isWorldMatrixFrozen: boolean;
  107342. /** @hidden */
  107343. _indexInSceneTransformNodesArray: number;
  107344. /**
  107345. * An event triggered after the world matrix is updated
  107346. */
  107347. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  107348. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  107349. /**
  107350. * Gets a string identifying the name of the class
  107351. * @returns "TransformNode" string
  107352. */
  107353. getClassName(): string;
  107354. /**
  107355. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  107356. */
  107357. get position(): Vector3;
  107358. set position(newPosition: Vector3);
  107359. /**
  107360. * 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)).
  107361. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  107362. */
  107363. get rotation(): Vector3;
  107364. set rotation(newRotation: Vector3);
  107365. /**
  107366. * 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)).
  107367. */
  107368. get scaling(): Vector3;
  107369. set scaling(newScaling: Vector3);
  107370. /**
  107371. * 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).
  107372. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  107373. */
  107374. get rotationQuaternion(): Nullable<Quaternion>;
  107375. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  107376. /**
  107377. * The forward direction of that transform in world space.
  107378. */
  107379. get forward(): Vector3;
  107380. /**
  107381. * The up direction of that transform in world space.
  107382. */
  107383. get up(): Vector3;
  107384. /**
  107385. * The right direction of that transform in world space.
  107386. */
  107387. get right(): Vector3;
  107388. /**
  107389. * Copies the parameter passed Matrix into the mesh Pose matrix.
  107390. * @param matrix the matrix to copy the pose from
  107391. * @returns this TransformNode.
  107392. */
  107393. updatePoseMatrix(matrix: Matrix): TransformNode;
  107394. /**
  107395. * Returns the mesh Pose matrix.
  107396. * @returns the pose matrix
  107397. */
  107398. getPoseMatrix(): Matrix;
  107399. /** @hidden */
  107400. _isSynchronized(): boolean;
  107401. /** @hidden */
  107402. _initCache(): void;
  107403. /**
  107404. * Flag the transform node as dirty (Forcing it to update everything)
  107405. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  107406. * @returns this transform node
  107407. */
  107408. markAsDirty(property: string): TransformNode;
  107409. /**
  107410. * Returns the current mesh absolute position.
  107411. * Returns a Vector3.
  107412. */
  107413. get absolutePosition(): Vector3;
  107414. /**
  107415. * Returns the current mesh absolute scaling.
  107416. * Returns a Vector3.
  107417. */
  107418. get absoluteScaling(): Vector3;
  107419. /**
  107420. * Returns the current mesh absolute rotation.
  107421. * Returns a Quaternion.
  107422. */
  107423. get absoluteRotationQuaternion(): Quaternion;
  107424. /**
  107425. * Sets a new matrix to apply before all other transformation
  107426. * @param matrix defines the transform matrix
  107427. * @returns the current TransformNode
  107428. */
  107429. setPreTransformMatrix(matrix: Matrix): TransformNode;
  107430. /**
  107431. * Sets a new pivot matrix to the current node
  107432. * @param matrix defines the new pivot matrix to use
  107433. * @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
  107434. * @returns the current TransformNode
  107435. */
  107436. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  107437. /**
  107438. * Returns the mesh pivot matrix.
  107439. * Default : Identity.
  107440. * @returns the matrix
  107441. */
  107442. getPivotMatrix(): Matrix;
  107443. /**
  107444. * Instantiate (when possible) or clone that node with its hierarchy
  107445. * @param newParent defines the new parent to use for the instance (or clone)
  107446. * @param options defines options to configure how copy is done
  107447. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  107448. * @returns an instance (or a clone) of the current node with its hiearchy
  107449. */
  107450. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  107451. doNotInstantiate: boolean;
  107452. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  107453. /**
  107454. * Prevents the World matrix to be computed any longer
  107455. * @param newWorldMatrix defines an optional matrix to use as world matrix
  107456. * @returns the TransformNode.
  107457. */
  107458. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  107459. /**
  107460. * Allows back the World matrix computation.
  107461. * @returns the TransformNode.
  107462. */
  107463. unfreezeWorldMatrix(): this;
  107464. /**
  107465. * True if the World matrix has been frozen.
  107466. */
  107467. get isWorldMatrixFrozen(): boolean;
  107468. /**
  107469. * Retuns the mesh absolute position in the World.
  107470. * @returns a Vector3.
  107471. */
  107472. getAbsolutePosition(): Vector3;
  107473. /**
  107474. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  107475. * @param absolutePosition the absolute position to set
  107476. * @returns the TransformNode.
  107477. */
  107478. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  107479. /**
  107480. * Sets the mesh position in its local space.
  107481. * @param vector3 the position to set in localspace
  107482. * @returns the TransformNode.
  107483. */
  107484. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  107485. /**
  107486. * Returns the mesh position in the local space from the current World matrix values.
  107487. * @returns a new Vector3.
  107488. */
  107489. getPositionExpressedInLocalSpace(): Vector3;
  107490. /**
  107491. * Translates the mesh along the passed Vector3 in its local space.
  107492. * @param vector3 the distance to translate in localspace
  107493. * @returns the TransformNode.
  107494. */
  107495. locallyTranslate(vector3: Vector3): TransformNode;
  107496. private static _lookAtVectorCache;
  107497. /**
  107498. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  107499. * @param targetPoint the position (must be in same space as current mesh) to look at
  107500. * @param yawCor optional yaw (y-axis) correction in radians
  107501. * @param pitchCor optional pitch (x-axis) correction in radians
  107502. * @param rollCor optional roll (z-axis) correction in radians
  107503. * @param space the choosen space of the target
  107504. * @returns the TransformNode.
  107505. */
  107506. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  107507. /**
  107508. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  107509. * This Vector3 is expressed in the World space.
  107510. * @param localAxis axis to rotate
  107511. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  107512. */
  107513. getDirection(localAxis: Vector3): Vector3;
  107514. /**
  107515. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  107516. * localAxis is expressed in the mesh local space.
  107517. * result is computed in the Wordl space from the mesh World matrix.
  107518. * @param localAxis axis to rotate
  107519. * @param result the resulting transformnode
  107520. * @returns this TransformNode.
  107521. */
  107522. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  107523. /**
  107524. * Sets this transform node rotation to the given local axis.
  107525. * @param localAxis the axis in local space
  107526. * @param yawCor optional yaw (y-axis) correction in radians
  107527. * @param pitchCor optional pitch (x-axis) correction in radians
  107528. * @param rollCor optional roll (z-axis) correction in radians
  107529. * @returns this TransformNode
  107530. */
  107531. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  107532. /**
  107533. * Sets a new pivot point to the current node
  107534. * @param point defines the new pivot point to use
  107535. * @param space defines if the point is in world or local space (local by default)
  107536. * @returns the current TransformNode
  107537. */
  107538. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  107539. /**
  107540. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  107541. * @returns the pivot point
  107542. */
  107543. getPivotPoint(): Vector3;
  107544. /**
  107545. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  107546. * @param result the vector3 to store the result
  107547. * @returns this TransformNode.
  107548. */
  107549. getPivotPointToRef(result: Vector3): TransformNode;
  107550. /**
  107551. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  107552. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  107553. */
  107554. getAbsolutePivotPoint(): Vector3;
  107555. /**
  107556. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  107557. * @param result vector3 to store the result
  107558. * @returns this TransformNode.
  107559. */
  107560. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  107561. /**
  107562. * Defines the passed node as the parent of the current node.
  107563. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  107564. * @see https://doc.babylonjs.com/how_to/parenting
  107565. * @param node the node ot set as the parent
  107566. * @returns this TransformNode.
  107567. */
  107568. setParent(node: Nullable<Node>): TransformNode;
  107569. private _nonUniformScaling;
  107570. /**
  107571. * True if the scaling property of this object is non uniform eg. (1,2,1)
  107572. */
  107573. get nonUniformScaling(): boolean;
  107574. /** @hidden */
  107575. _updateNonUniformScalingState(value: boolean): boolean;
  107576. /**
  107577. * Attach the current TransformNode to another TransformNode associated with a bone
  107578. * @param bone Bone affecting the TransformNode
  107579. * @param affectedTransformNode TransformNode associated with the bone
  107580. * @returns this object
  107581. */
  107582. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  107583. /**
  107584. * Detach the transform node if its associated with a bone
  107585. * @returns this object
  107586. */
  107587. detachFromBone(): TransformNode;
  107588. private static _rotationAxisCache;
  107589. /**
  107590. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  107591. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  107592. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  107593. * The passed axis is also normalized.
  107594. * @param axis the axis to rotate around
  107595. * @param amount the amount to rotate in radians
  107596. * @param space Space to rotate in (Default: local)
  107597. * @returns the TransformNode.
  107598. */
  107599. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  107600. /**
  107601. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  107602. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  107603. * The passed axis is also normalized. .
  107604. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  107605. * @param point the point to rotate around
  107606. * @param axis the axis to rotate around
  107607. * @param amount the amount to rotate in radians
  107608. * @returns the TransformNode
  107609. */
  107610. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  107611. /**
  107612. * Translates the mesh along the axis vector for the passed distance in the given space.
  107613. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  107614. * @param axis the axis to translate in
  107615. * @param distance the distance to translate
  107616. * @param space Space to rotate in (Default: local)
  107617. * @returns the TransformNode.
  107618. */
  107619. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  107620. /**
  107621. * Adds a rotation step to the mesh current rotation.
  107622. * x, y, z are Euler angles expressed in radians.
  107623. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  107624. * This means this rotation is made in the mesh local space only.
  107625. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  107626. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  107627. * ```javascript
  107628. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  107629. * ```
  107630. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  107631. * 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.
  107632. * @param x Rotation to add
  107633. * @param y Rotation to add
  107634. * @param z Rotation to add
  107635. * @returns the TransformNode.
  107636. */
  107637. addRotation(x: number, y: number, z: number): TransformNode;
  107638. /**
  107639. * @hidden
  107640. */
  107641. protected _getEffectiveParent(): Nullable<Node>;
  107642. /**
  107643. * Computes the world matrix of the node
  107644. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  107645. * @returns the world matrix
  107646. */
  107647. computeWorldMatrix(force?: boolean): Matrix;
  107648. /**
  107649. * Resets this nodeTransform's local matrix to Matrix.Identity().
  107650. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  107651. */
  107652. resetLocalMatrix(independentOfChildren?: boolean): void;
  107653. protected _afterComputeWorldMatrix(): void;
  107654. /**
  107655. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  107656. * @param func callback function to add
  107657. *
  107658. * @returns the TransformNode.
  107659. */
  107660. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  107661. /**
  107662. * Removes a registered callback function.
  107663. * @param func callback function to remove
  107664. * @returns the TransformNode.
  107665. */
  107666. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  107667. /**
  107668. * Gets the position of the current mesh in camera space
  107669. * @param camera defines the camera to use
  107670. * @returns a position
  107671. */
  107672. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  107673. /**
  107674. * Returns the distance from the mesh to the active camera
  107675. * @param camera defines the camera to use
  107676. * @returns the distance
  107677. */
  107678. getDistanceToCamera(camera?: Nullable<Camera>): number;
  107679. /**
  107680. * Clone the current transform node
  107681. * @param name Name of the new clone
  107682. * @param newParent New parent for the clone
  107683. * @param doNotCloneChildren Do not clone children hierarchy
  107684. * @returns the new transform node
  107685. */
  107686. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  107687. /**
  107688. * Serializes the objects information.
  107689. * @param currentSerializationObject defines the object to serialize in
  107690. * @returns the serialized object
  107691. */
  107692. serialize(currentSerializationObject?: any): any;
  107693. /**
  107694. * Returns a new TransformNode object parsed from the source provided.
  107695. * @param parsedTransformNode is the source.
  107696. * @param scene the scne the object belongs to
  107697. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  107698. * @returns a new TransformNode object parsed from the source provided.
  107699. */
  107700. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  107701. /**
  107702. * Get all child-transformNodes of this node
  107703. * @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
  107704. * @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
  107705. * @returns an array of TransformNode
  107706. */
  107707. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  107708. /**
  107709. * Releases resources associated with this transform node.
  107710. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107711. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107712. */
  107713. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107714. /**
  107715. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  107716. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  107717. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  107718. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  107719. * @returns the current mesh
  107720. */
  107721. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  107722. private _syncAbsoluteScalingAndRotation;
  107723. }
  107724. }
  107725. declare module BABYLON {
  107726. /**
  107727. * Defines the types of pose enabled controllers that are supported
  107728. */
  107729. export enum PoseEnabledControllerType {
  107730. /**
  107731. * HTC Vive
  107732. */
  107733. VIVE = 0,
  107734. /**
  107735. * Oculus Rift
  107736. */
  107737. OCULUS = 1,
  107738. /**
  107739. * Windows mixed reality
  107740. */
  107741. WINDOWS = 2,
  107742. /**
  107743. * Samsung gear VR
  107744. */
  107745. GEAR_VR = 3,
  107746. /**
  107747. * Google Daydream
  107748. */
  107749. DAYDREAM = 4,
  107750. /**
  107751. * Generic
  107752. */
  107753. GENERIC = 5
  107754. }
  107755. /**
  107756. * Defines the MutableGamepadButton interface for the state of a gamepad button
  107757. */
  107758. export interface MutableGamepadButton {
  107759. /**
  107760. * Value of the button/trigger
  107761. */
  107762. value: number;
  107763. /**
  107764. * If the button/trigger is currently touched
  107765. */
  107766. touched: boolean;
  107767. /**
  107768. * If the button/trigger is currently pressed
  107769. */
  107770. pressed: boolean;
  107771. }
  107772. /**
  107773. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  107774. * @hidden
  107775. */
  107776. export interface ExtendedGamepadButton extends GamepadButton {
  107777. /**
  107778. * If the button/trigger is currently pressed
  107779. */
  107780. readonly pressed: boolean;
  107781. /**
  107782. * If the button/trigger is currently touched
  107783. */
  107784. readonly touched: boolean;
  107785. /**
  107786. * Value of the button/trigger
  107787. */
  107788. readonly value: number;
  107789. }
  107790. /** @hidden */
  107791. export interface _GamePadFactory {
  107792. /**
  107793. * Returns whether or not the current gamepad can be created for this type of controller.
  107794. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  107795. * @returns true if it can be created, otherwise false
  107796. */
  107797. canCreate(gamepadInfo: any): boolean;
  107798. /**
  107799. * Creates a new instance of the Gamepad.
  107800. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  107801. * @returns the new gamepad instance
  107802. */
  107803. create(gamepadInfo: any): Gamepad;
  107804. }
  107805. /**
  107806. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  107807. */
  107808. export class PoseEnabledControllerHelper {
  107809. /** @hidden */
  107810. static _ControllerFactories: _GamePadFactory[];
  107811. /** @hidden */
  107812. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  107813. /**
  107814. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  107815. * @param vrGamepad the gamepad to initialized
  107816. * @returns a vr controller of the type the gamepad identified as
  107817. */
  107818. static InitiateController(vrGamepad: any): Gamepad;
  107819. }
  107820. /**
  107821. * Defines the PoseEnabledController object that contains state of a vr capable controller
  107822. */
  107823. export class PoseEnabledController extends Gamepad implements PoseControlled {
  107824. /**
  107825. * If the controller is used in a webXR session
  107826. */
  107827. isXR: boolean;
  107828. private _deviceRoomPosition;
  107829. private _deviceRoomRotationQuaternion;
  107830. /**
  107831. * The device position in babylon space
  107832. */
  107833. devicePosition: Vector3;
  107834. /**
  107835. * The device rotation in babylon space
  107836. */
  107837. deviceRotationQuaternion: Quaternion;
  107838. /**
  107839. * The scale factor of the device in babylon space
  107840. */
  107841. deviceScaleFactor: number;
  107842. /**
  107843. * (Likely devicePosition should be used instead) The device position in its room space
  107844. */
  107845. position: Vector3;
  107846. /**
  107847. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  107848. */
  107849. rotationQuaternion: Quaternion;
  107850. /**
  107851. * The type of controller (Eg. Windows mixed reality)
  107852. */
  107853. controllerType: PoseEnabledControllerType;
  107854. protected _calculatedPosition: Vector3;
  107855. private _calculatedRotation;
  107856. /**
  107857. * The raw pose from the device
  107858. */
  107859. rawPose: DevicePose;
  107860. private _trackPosition;
  107861. private _maxRotationDistFromHeadset;
  107862. private _draggedRoomRotation;
  107863. /**
  107864. * @hidden
  107865. */
  107866. _disableTrackPosition(fixedPosition: Vector3): void;
  107867. /**
  107868. * Internal, the mesh attached to the controller
  107869. * @hidden
  107870. */
  107871. _mesh: Nullable<AbstractMesh>;
  107872. private _poseControlledCamera;
  107873. private _leftHandSystemQuaternion;
  107874. /**
  107875. * Internal, matrix used to convert room space to babylon space
  107876. * @hidden
  107877. */
  107878. _deviceToWorld: Matrix;
  107879. /**
  107880. * Node to be used when casting a ray from the controller
  107881. * @hidden
  107882. */
  107883. _pointingPoseNode: Nullable<TransformNode>;
  107884. /**
  107885. * Name of the child mesh that can be used to cast a ray from the controller
  107886. */
  107887. static readonly POINTING_POSE: string;
  107888. /**
  107889. * Creates a new PoseEnabledController from a gamepad
  107890. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  107891. */
  107892. constructor(browserGamepad: any);
  107893. private _workingMatrix;
  107894. /**
  107895. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  107896. */
  107897. update(): void;
  107898. /**
  107899. * Updates only the pose device and mesh without doing any button event checking
  107900. */
  107901. protected _updatePoseAndMesh(): void;
  107902. /**
  107903. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  107904. * @param poseData raw pose fromthe device
  107905. */
  107906. updateFromDevice(poseData: DevicePose): void;
  107907. /**
  107908. * @hidden
  107909. */
  107910. _meshAttachedObservable: Observable<AbstractMesh>;
  107911. /**
  107912. * Attaches a mesh to the controller
  107913. * @param mesh the mesh to be attached
  107914. */
  107915. attachToMesh(mesh: AbstractMesh): void;
  107916. /**
  107917. * Attaches the controllers mesh to a camera
  107918. * @param camera the camera the mesh should be attached to
  107919. */
  107920. attachToPoseControlledCamera(camera: TargetCamera): void;
  107921. /**
  107922. * Disposes of the controller
  107923. */
  107924. dispose(): void;
  107925. /**
  107926. * The mesh that is attached to the controller
  107927. */
  107928. get mesh(): Nullable<AbstractMesh>;
  107929. /**
  107930. * Gets the ray of the controller in the direction the controller is pointing
  107931. * @param length the length the resulting ray should be
  107932. * @returns a ray in the direction the controller is pointing
  107933. */
  107934. getForwardRay(length?: number): Ray;
  107935. }
  107936. }
  107937. declare module BABYLON {
  107938. /**
  107939. * Defines the WebVRController object that represents controllers tracked in 3D space
  107940. */
  107941. export abstract class WebVRController extends PoseEnabledController {
  107942. /**
  107943. * Internal, the default controller model for the controller
  107944. */
  107945. protected _defaultModel: Nullable<AbstractMesh>;
  107946. /**
  107947. * Fired when the trigger state has changed
  107948. */
  107949. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  107950. /**
  107951. * Fired when the main button state has changed
  107952. */
  107953. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107954. /**
  107955. * Fired when the secondary button state has changed
  107956. */
  107957. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107958. /**
  107959. * Fired when the pad state has changed
  107960. */
  107961. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  107962. /**
  107963. * Fired when controllers stick values have changed
  107964. */
  107965. onPadValuesChangedObservable: Observable<StickValues>;
  107966. /**
  107967. * Array of button availible on the controller
  107968. */
  107969. protected _buttons: Array<MutableGamepadButton>;
  107970. private _onButtonStateChange;
  107971. /**
  107972. * Fired when a controller button's state has changed
  107973. * @param callback the callback containing the button that was modified
  107974. */
  107975. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  107976. /**
  107977. * X and Y axis corresponding to the controllers joystick
  107978. */
  107979. pad: StickValues;
  107980. /**
  107981. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  107982. */
  107983. hand: string;
  107984. /**
  107985. * The default controller model for the controller
  107986. */
  107987. get defaultModel(): Nullable<AbstractMesh>;
  107988. /**
  107989. * Creates a new WebVRController from a gamepad
  107990. * @param vrGamepad the gamepad that the WebVRController should be created from
  107991. */
  107992. constructor(vrGamepad: any);
  107993. /**
  107994. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  107995. */
  107996. update(): void;
  107997. /**
  107998. * Function to be called when a button is modified
  107999. */
  108000. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108001. /**
  108002. * Loads a mesh and attaches it to the controller
  108003. * @param scene the scene the mesh should be added to
  108004. * @param meshLoaded callback for when the mesh has been loaded
  108005. */
  108006. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108007. private _setButtonValue;
  108008. private _changes;
  108009. private _checkChanges;
  108010. /**
  108011. * Disposes of th webVRCOntroller
  108012. */
  108013. dispose(): void;
  108014. }
  108015. }
  108016. declare module BABYLON {
  108017. /**
  108018. * The HemisphericLight simulates the ambient environment light,
  108019. * so the passed direction is the light reflection direction, not the incoming direction.
  108020. */
  108021. export class HemisphericLight extends Light {
  108022. /**
  108023. * The groundColor is the light in the opposite direction to the one specified during creation.
  108024. * 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.
  108025. */
  108026. groundColor: Color3;
  108027. /**
  108028. * The light reflection direction, not the incoming direction.
  108029. */
  108030. direction: Vector3;
  108031. /**
  108032. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  108033. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  108034. * The HemisphericLight can't cast shadows.
  108035. * Documentation : https://doc.babylonjs.com/babylon101/lights
  108036. * @param name The friendly name of the light
  108037. * @param direction The direction of the light reflection
  108038. * @param scene The scene the light belongs to
  108039. */
  108040. constructor(name: string, direction: Vector3, scene: Scene);
  108041. protected _buildUniformLayout(): void;
  108042. /**
  108043. * Returns the string "HemisphericLight".
  108044. * @return The class name
  108045. */
  108046. getClassName(): string;
  108047. /**
  108048. * Sets the HemisphericLight direction towards the passed target (Vector3).
  108049. * Returns the updated direction.
  108050. * @param target The target the direction should point to
  108051. * @return The computed direction
  108052. */
  108053. setDirectionToTarget(target: Vector3): Vector3;
  108054. /**
  108055. * Returns the shadow generator associated to the light.
  108056. * @returns Always null for hemispheric lights because it does not support shadows.
  108057. */
  108058. getShadowGenerator(): Nullable<IShadowGenerator>;
  108059. /**
  108060. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  108061. * @param effect The effect to update
  108062. * @param lightIndex The index of the light in the effect to update
  108063. * @returns The hemispheric light
  108064. */
  108065. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  108066. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  108067. /**
  108068. * Computes the world matrix of the node
  108069. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  108070. * @param useWasUpdatedFlag defines a reserved property
  108071. * @returns the world matrix
  108072. */
  108073. computeWorldMatrix(): Matrix;
  108074. /**
  108075. * Returns the integer 3.
  108076. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  108077. */
  108078. getTypeID(): number;
  108079. /**
  108080. * Prepares the list of defines specific to the light type.
  108081. * @param defines the list of defines
  108082. * @param lightIndex defines the index of the light for the effect
  108083. */
  108084. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  108085. }
  108086. }
  108087. declare module BABYLON {
  108088. /** @hidden */
  108089. export var vrMultiviewToSingleviewPixelShader: {
  108090. name: string;
  108091. shader: string;
  108092. };
  108093. }
  108094. declare module BABYLON {
  108095. /**
  108096. * Renders to multiple views with a single draw call
  108097. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  108098. */
  108099. export class MultiviewRenderTarget extends RenderTargetTexture {
  108100. /**
  108101. * Creates a multiview render target
  108102. * @param scene scene used with the render target
  108103. * @param size the size of the render target (used for each view)
  108104. */
  108105. constructor(scene: Scene, size?: number | {
  108106. width: number;
  108107. height: number;
  108108. } | {
  108109. ratio: number;
  108110. });
  108111. /**
  108112. * @hidden
  108113. * @param faceIndex the face index, if its a cube texture
  108114. */
  108115. _bindFrameBuffer(faceIndex?: number): void;
  108116. /**
  108117. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  108118. * @returns the view count
  108119. */
  108120. getViewCount(): number;
  108121. }
  108122. }
  108123. declare module BABYLON {
  108124. interface Engine {
  108125. /**
  108126. * Creates a new multiview render target
  108127. * @param width defines the width of the texture
  108128. * @param height defines the height of the texture
  108129. * @returns the created multiview texture
  108130. */
  108131. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  108132. /**
  108133. * Binds a multiview framebuffer to be drawn to
  108134. * @param multiviewTexture texture to bind
  108135. */
  108136. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  108137. }
  108138. interface Camera {
  108139. /**
  108140. * @hidden
  108141. * 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)
  108142. */
  108143. _useMultiviewToSingleView: boolean;
  108144. /**
  108145. * @hidden
  108146. * 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)
  108147. */
  108148. _multiviewTexture: Nullable<RenderTargetTexture>;
  108149. /**
  108150. * @hidden
  108151. * ensures the multiview texture of the camera exists and has the specified width/height
  108152. * @param width height to set on the multiview texture
  108153. * @param height width to set on the multiview texture
  108154. */
  108155. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  108156. }
  108157. interface Scene {
  108158. /** @hidden */
  108159. _transformMatrixR: Matrix;
  108160. /** @hidden */
  108161. _multiviewSceneUbo: Nullable<UniformBuffer>;
  108162. /** @hidden */
  108163. _createMultiviewUbo(): void;
  108164. /** @hidden */
  108165. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  108166. /** @hidden */
  108167. _renderMultiviewToSingleView(camera: Camera): void;
  108168. }
  108169. }
  108170. declare module BABYLON {
  108171. /**
  108172. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  108173. * This will not be used for webXR as it supports displaying texture arrays directly
  108174. */
  108175. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  108176. /**
  108177. * Gets a string identifying the name of the class
  108178. * @returns "VRMultiviewToSingleviewPostProcess" string
  108179. */
  108180. getClassName(): string;
  108181. /**
  108182. * Initializes a VRMultiviewToSingleview
  108183. * @param name name of the post process
  108184. * @param camera camera to be applied to
  108185. * @param scaleFactor scaling factor to the size of the output texture
  108186. */
  108187. constructor(name: string, camera: Camera, scaleFactor: number);
  108188. }
  108189. }
  108190. declare module BABYLON {
  108191. /**
  108192. * Interface used to define additional presentation attributes
  108193. */
  108194. export interface IVRPresentationAttributes {
  108195. /**
  108196. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  108197. */
  108198. highRefreshRate: boolean;
  108199. /**
  108200. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  108201. */
  108202. foveationLevel: number;
  108203. }
  108204. interface Engine {
  108205. /** @hidden */
  108206. _vrDisplay: any;
  108207. /** @hidden */
  108208. _vrSupported: boolean;
  108209. /** @hidden */
  108210. _oldSize: Size;
  108211. /** @hidden */
  108212. _oldHardwareScaleFactor: number;
  108213. /** @hidden */
  108214. _vrExclusivePointerMode: boolean;
  108215. /** @hidden */
  108216. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  108217. /** @hidden */
  108218. _onVRDisplayPointerRestricted: () => void;
  108219. /** @hidden */
  108220. _onVRDisplayPointerUnrestricted: () => void;
  108221. /** @hidden */
  108222. _onVrDisplayConnect: Nullable<(display: any) => void>;
  108223. /** @hidden */
  108224. _onVrDisplayDisconnect: Nullable<() => void>;
  108225. /** @hidden */
  108226. _onVrDisplayPresentChange: Nullable<() => void>;
  108227. /**
  108228. * Observable signaled when VR display mode changes
  108229. */
  108230. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  108231. /**
  108232. * Observable signaled when VR request present is complete
  108233. */
  108234. onVRRequestPresentComplete: Observable<boolean>;
  108235. /**
  108236. * Observable signaled when VR request present starts
  108237. */
  108238. onVRRequestPresentStart: Observable<Engine>;
  108239. /**
  108240. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  108241. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  108242. */
  108243. isInVRExclusivePointerMode: boolean;
  108244. /**
  108245. * Gets a boolean indicating if a webVR device was detected
  108246. * @returns true if a webVR device was detected
  108247. */
  108248. isVRDevicePresent(): boolean;
  108249. /**
  108250. * Gets the current webVR device
  108251. * @returns the current webVR device (or null)
  108252. */
  108253. getVRDevice(): any;
  108254. /**
  108255. * Initializes a webVR display and starts listening to display change events
  108256. * The onVRDisplayChangedObservable will be notified upon these changes
  108257. * @returns A promise containing a VRDisplay and if vr is supported
  108258. */
  108259. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  108260. /** @hidden */
  108261. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  108262. /**
  108263. * Gets or sets the presentation attributes used to configure VR rendering
  108264. */
  108265. vrPresentationAttributes?: IVRPresentationAttributes;
  108266. /**
  108267. * Call this function to switch to webVR mode
  108268. * Will do nothing if webVR is not supported or if there is no webVR device
  108269. * @param options the webvr options provided to the camera. mainly used for multiview
  108270. * @see https://doc.babylonjs.com/how_to/webvr_camera
  108271. */
  108272. enableVR(options: WebVROptions): void;
  108273. /** @hidden */
  108274. _onVRFullScreenTriggered(): void;
  108275. }
  108276. }
  108277. declare module BABYLON {
  108278. /**
  108279. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  108280. * IMPORTANT!! The data is right-hand data.
  108281. * @export
  108282. * @interface DevicePose
  108283. */
  108284. export interface DevicePose {
  108285. /**
  108286. * The position of the device, values in array are [x,y,z].
  108287. */
  108288. readonly position: Nullable<Float32Array>;
  108289. /**
  108290. * The linearVelocity of the device, values in array are [x,y,z].
  108291. */
  108292. readonly linearVelocity: Nullable<Float32Array>;
  108293. /**
  108294. * The linearAcceleration of the device, values in array are [x,y,z].
  108295. */
  108296. readonly linearAcceleration: Nullable<Float32Array>;
  108297. /**
  108298. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  108299. */
  108300. readonly orientation: Nullable<Float32Array>;
  108301. /**
  108302. * The angularVelocity of the device, values in array are [x,y,z].
  108303. */
  108304. readonly angularVelocity: Nullable<Float32Array>;
  108305. /**
  108306. * The angularAcceleration of the device, values in array are [x,y,z].
  108307. */
  108308. readonly angularAcceleration: Nullable<Float32Array>;
  108309. }
  108310. /**
  108311. * Interface representing a pose controlled object in Babylon.
  108312. * A pose controlled object has both regular pose values as well as pose values
  108313. * from an external device such as a VR head mounted display
  108314. */
  108315. export interface PoseControlled {
  108316. /**
  108317. * The position of the object in babylon space.
  108318. */
  108319. position: Vector3;
  108320. /**
  108321. * The rotation quaternion of the object in babylon space.
  108322. */
  108323. rotationQuaternion: Quaternion;
  108324. /**
  108325. * The position of the device in babylon space.
  108326. */
  108327. devicePosition?: Vector3;
  108328. /**
  108329. * The rotation quaternion of the device in babylon space.
  108330. */
  108331. deviceRotationQuaternion: Quaternion;
  108332. /**
  108333. * The raw pose coming from the device.
  108334. */
  108335. rawPose: Nullable<DevicePose>;
  108336. /**
  108337. * The scale of the device to be used when translating from device space to babylon space.
  108338. */
  108339. deviceScaleFactor: number;
  108340. /**
  108341. * Updates the poseControlled values based on the input device pose.
  108342. * @param poseData the pose data to update the object with
  108343. */
  108344. updateFromDevice(poseData: DevicePose): void;
  108345. }
  108346. /**
  108347. * Set of options to customize the webVRCamera
  108348. */
  108349. export interface WebVROptions {
  108350. /**
  108351. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  108352. */
  108353. trackPosition?: boolean;
  108354. /**
  108355. * Sets the scale of the vrDevice in babylon space. (default: 1)
  108356. */
  108357. positionScale?: number;
  108358. /**
  108359. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  108360. */
  108361. displayName?: string;
  108362. /**
  108363. * Should the native controller meshes be initialized. (default: true)
  108364. */
  108365. controllerMeshes?: boolean;
  108366. /**
  108367. * Creating a default HemiLight only on controllers. (default: true)
  108368. */
  108369. defaultLightingOnControllers?: boolean;
  108370. /**
  108371. * If you don't want to use the default VR button of the helper. (default: false)
  108372. */
  108373. useCustomVRButton?: boolean;
  108374. /**
  108375. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  108376. */
  108377. customVRButton?: HTMLButtonElement;
  108378. /**
  108379. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  108380. */
  108381. rayLength?: number;
  108382. /**
  108383. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  108384. */
  108385. defaultHeight?: number;
  108386. /**
  108387. * If multiview should be used if availible (default: false)
  108388. */
  108389. useMultiview?: boolean;
  108390. }
  108391. /**
  108392. * This represents a WebVR camera.
  108393. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  108394. * @example https://doc.babylonjs.com/how_to/webvr_camera
  108395. */
  108396. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  108397. private webVROptions;
  108398. /**
  108399. * @hidden
  108400. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  108401. */
  108402. _vrDevice: any;
  108403. /**
  108404. * The rawPose of the vrDevice.
  108405. */
  108406. rawPose: Nullable<DevicePose>;
  108407. private _onVREnabled;
  108408. private _specsVersion;
  108409. private _attached;
  108410. private _frameData;
  108411. protected _descendants: Array<Node>;
  108412. private _deviceRoomPosition;
  108413. /** @hidden */
  108414. _deviceRoomRotationQuaternion: Quaternion;
  108415. private _standingMatrix;
  108416. /**
  108417. * Represents device position in babylon space.
  108418. */
  108419. devicePosition: Vector3;
  108420. /**
  108421. * Represents device rotation in babylon space.
  108422. */
  108423. deviceRotationQuaternion: Quaternion;
  108424. /**
  108425. * The scale of the device to be used when translating from device space to babylon space.
  108426. */
  108427. deviceScaleFactor: number;
  108428. private _deviceToWorld;
  108429. private _worldToDevice;
  108430. /**
  108431. * References to the webVR controllers for the vrDevice.
  108432. */
  108433. controllers: Array<WebVRController>;
  108434. /**
  108435. * Emits an event when a controller is attached.
  108436. */
  108437. onControllersAttachedObservable: Observable<WebVRController[]>;
  108438. /**
  108439. * Emits an event when a controller's mesh has been loaded;
  108440. */
  108441. onControllerMeshLoadedObservable: Observable<WebVRController>;
  108442. /**
  108443. * Emits an event when the HMD's pose has been updated.
  108444. */
  108445. onPoseUpdatedFromDeviceObservable: Observable<any>;
  108446. private _poseSet;
  108447. /**
  108448. * If the rig cameras be used as parent instead of this camera.
  108449. */
  108450. rigParenting: boolean;
  108451. private _lightOnControllers;
  108452. private _defaultHeight?;
  108453. /**
  108454. * Instantiates a WebVRFreeCamera.
  108455. * @param name The name of the WebVRFreeCamera
  108456. * @param position The starting anchor position for the camera
  108457. * @param scene The scene the camera belongs to
  108458. * @param webVROptions a set of customizable options for the webVRCamera
  108459. */
  108460. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  108461. /**
  108462. * Gets the device distance from the ground in meters.
  108463. * @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.
  108464. */
  108465. deviceDistanceToRoomGround(): number;
  108466. /**
  108467. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  108468. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  108469. */
  108470. useStandingMatrix(callback?: (bool: boolean) => void): void;
  108471. /**
  108472. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  108473. * @returns A promise with a boolean set to if the standing matrix is supported.
  108474. */
  108475. useStandingMatrixAsync(): Promise<boolean>;
  108476. /**
  108477. * Disposes the camera
  108478. */
  108479. dispose(): void;
  108480. /**
  108481. * Gets a vrController by name.
  108482. * @param name The name of the controller to retreive
  108483. * @returns the controller matching the name specified or null if not found
  108484. */
  108485. getControllerByName(name: string): Nullable<WebVRController>;
  108486. private _leftController;
  108487. /**
  108488. * The controller corresponding to the users left hand.
  108489. */
  108490. get leftController(): Nullable<WebVRController>;
  108491. private _rightController;
  108492. /**
  108493. * The controller corresponding to the users right hand.
  108494. */
  108495. get rightController(): Nullable<WebVRController>;
  108496. /**
  108497. * Casts a ray forward from the vrCamera's gaze.
  108498. * @param length Length of the ray (default: 100)
  108499. * @returns the ray corresponding to the gaze
  108500. */
  108501. getForwardRay(length?: number): Ray;
  108502. /**
  108503. * @hidden
  108504. * Updates the camera based on device's frame data
  108505. */
  108506. _checkInputs(): void;
  108507. /**
  108508. * Updates the poseControlled values based on the input device pose.
  108509. * @param poseData Pose coming from the device
  108510. */
  108511. updateFromDevice(poseData: DevicePose): void;
  108512. private _detachIfAttached;
  108513. /**
  108514. * WebVR's attach control will start broadcasting frames to the device.
  108515. * Note that in certain browsers (chrome for example) this function must be called
  108516. * within a user-interaction callback. Example:
  108517. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  108518. *
  108519. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  108520. */
  108521. attachControl(noPreventDefault?: boolean): void;
  108522. /**
  108523. * Detach the current controls from the specified dom element.
  108524. */
  108525. detachControl(): void;
  108526. /**
  108527. * @returns the name of this class
  108528. */
  108529. getClassName(): string;
  108530. /**
  108531. * Calls resetPose on the vrDisplay
  108532. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  108533. */
  108534. resetToCurrentRotation(): void;
  108535. /**
  108536. * @hidden
  108537. * Updates the rig cameras (left and right eye)
  108538. */
  108539. _updateRigCameras(): void;
  108540. private _workingVector;
  108541. private _oneVector;
  108542. private _workingMatrix;
  108543. private updateCacheCalled;
  108544. private _correctPositionIfNotTrackPosition;
  108545. /**
  108546. * @hidden
  108547. * Updates the cached values of the camera
  108548. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  108549. */
  108550. _updateCache(ignoreParentClass?: boolean): void;
  108551. /**
  108552. * @hidden
  108553. * Get current device position in babylon world
  108554. */
  108555. _computeDevicePosition(): void;
  108556. /**
  108557. * Updates the current device position and rotation in the babylon world
  108558. */
  108559. update(): void;
  108560. /**
  108561. * @hidden
  108562. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  108563. * @returns an identity matrix
  108564. */
  108565. _getViewMatrix(): Matrix;
  108566. private _tmpMatrix;
  108567. /**
  108568. * This function is called by the two RIG cameras.
  108569. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  108570. * @hidden
  108571. */
  108572. _getWebVRViewMatrix(): Matrix;
  108573. /** @hidden */
  108574. _getWebVRProjectionMatrix(): Matrix;
  108575. private _onGamepadConnectedObserver;
  108576. private _onGamepadDisconnectedObserver;
  108577. private _updateCacheWhenTrackingDisabledObserver;
  108578. /**
  108579. * Initializes the controllers and their meshes
  108580. */
  108581. initControllers(): void;
  108582. }
  108583. }
  108584. declare module BABYLON {
  108585. /**
  108586. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  108587. *
  108588. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  108589. *
  108590. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  108591. */
  108592. export class MaterialHelper {
  108593. /**
  108594. * Bind the current view position to an effect.
  108595. * @param effect The effect to be bound
  108596. * @param scene The scene the eyes position is used from
  108597. * @param variableName name of the shader variable that will hold the eye position
  108598. */
  108599. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  108600. /**
  108601. * Helps preparing the defines values about the UVs in used in the effect.
  108602. * UVs are shared as much as we can accross channels in the shaders.
  108603. * @param texture The texture we are preparing the UVs for
  108604. * @param defines The defines to update
  108605. * @param key The channel key "diffuse", "specular"... used in the shader
  108606. */
  108607. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  108608. /**
  108609. * Binds a texture matrix value to its corrsponding uniform
  108610. * @param texture The texture to bind the matrix for
  108611. * @param uniformBuffer The uniform buffer receivin the data
  108612. * @param key The channel key "diffuse", "specular"... used in the shader
  108613. */
  108614. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  108615. /**
  108616. * Gets the current status of the fog (should it be enabled?)
  108617. * @param mesh defines the mesh to evaluate for fog support
  108618. * @param scene defines the hosting scene
  108619. * @returns true if fog must be enabled
  108620. */
  108621. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  108622. /**
  108623. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  108624. * @param mesh defines the current mesh
  108625. * @param scene defines the current scene
  108626. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  108627. * @param pointsCloud defines if point cloud rendering has to be turned on
  108628. * @param fogEnabled defines if fog has to be turned on
  108629. * @param alphaTest defines if alpha testing has to be turned on
  108630. * @param defines defines the current list of defines
  108631. */
  108632. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  108633. /**
  108634. * Helper used to prepare the list of defines associated with frame values for shader compilation
  108635. * @param scene defines the current scene
  108636. * @param engine defines the current engine
  108637. * @param defines specifies the list of active defines
  108638. * @param useInstances defines if instances have to be turned on
  108639. * @param useClipPlane defines if clip plane have to be turned on
  108640. * @param useInstances defines if instances have to be turned on
  108641. * @param useThinInstances defines if thin instances have to be turned on
  108642. */
  108643. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  108644. /**
  108645. * Prepares the defines for bones
  108646. * @param mesh The mesh containing the geometry data we will draw
  108647. * @param defines The defines to update
  108648. */
  108649. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  108650. /**
  108651. * Prepares the defines for morph targets
  108652. * @param mesh The mesh containing the geometry data we will draw
  108653. * @param defines The defines to update
  108654. */
  108655. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  108656. /**
  108657. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  108658. * @param mesh The mesh containing the geometry data we will draw
  108659. * @param defines The defines to update
  108660. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  108661. * @param useBones Precise whether bones should be used or not (override mesh info)
  108662. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  108663. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  108664. * @returns false if defines are considered not dirty and have not been checked
  108665. */
  108666. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  108667. /**
  108668. * Prepares the defines related to multiview
  108669. * @param scene The scene we are intending to draw
  108670. * @param defines The defines to update
  108671. */
  108672. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  108673. /**
  108674. * Prepares the defines related to the prepass
  108675. * @param scene The scene we are intending to draw
  108676. * @param defines The defines to update
  108677. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  108678. */
  108679. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  108680. /**
  108681. * Prepares the defines related to the light information passed in parameter
  108682. * @param scene The scene we are intending to draw
  108683. * @param mesh The mesh the effect is compiling for
  108684. * @param light The light the effect is compiling for
  108685. * @param lightIndex The index of the light
  108686. * @param defines The defines to update
  108687. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  108688. * @param state Defines the current state regarding what is needed (normals, etc...)
  108689. */
  108690. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  108691. needNormals: boolean;
  108692. needRebuild: boolean;
  108693. shadowEnabled: boolean;
  108694. specularEnabled: boolean;
  108695. lightmapMode: boolean;
  108696. }): void;
  108697. /**
  108698. * Prepares the defines related to the light information passed in parameter
  108699. * @param scene The scene we are intending to draw
  108700. * @param mesh The mesh the effect is compiling for
  108701. * @param defines The defines to update
  108702. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  108703. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  108704. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  108705. * @returns true if normals will be required for the rest of the effect
  108706. */
  108707. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  108708. /**
  108709. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  108710. * @param lightIndex defines the light index
  108711. * @param uniformsList The uniform list
  108712. * @param samplersList The sampler list
  108713. * @param projectedLightTexture defines if projected texture must be used
  108714. * @param uniformBuffersList defines an optional list of uniform buffers
  108715. */
  108716. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  108717. /**
  108718. * Prepares the uniforms and samplers list to be used in the effect
  108719. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  108720. * @param samplersList The sampler list
  108721. * @param defines The defines helping in the list generation
  108722. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  108723. */
  108724. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  108725. /**
  108726. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  108727. * @param defines The defines to update while falling back
  108728. * @param fallbacks The authorized effect fallbacks
  108729. * @param maxSimultaneousLights The maximum number of lights allowed
  108730. * @param rank the current rank of the Effect
  108731. * @returns The newly affected rank
  108732. */
  108733. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  108734. private static _TmpMorphInfluencers;
  108735. /**
  108736. * Prepares the list of attributes required for morph targets according to the effect defines.
  108737. * @param attribs The current list of supported attribs
  108738. * @param mesh The mesh to prepare the morph targets attributes for
  108739. * @param influencers The number of influencers
  108740. */
  108741. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  108742. /**
  108743. * Prepares the list of attributes required for morph targets according to the effect defines.
  108744. * @param attribs The current list of supported attribs
  108745. * @param mesh The mesh to prepare the morph targets attributes for
  108746. * @param defines The current Defines of the effect
  108747. */
  108748. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  108749. /**
  108750. * Prepares the list of attributes required for bones according to the effect defines.
  108751. * @param attribs The current list of supported attribs
  108752. * @param mesh The mesh to prepare the bones attributes for
  108753. * @param defines The current Defines of the effect
  108754. * @param fallbacks The current efffect fallback strategy
  108755. */
  108756. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  108757. /**
  108758. * Check and prepare the list of attributes required for instances according to the effect defines.
  108759. * @param attribs The current list of supported attribs
  108760. * @param defines The current MaterialDefines of the effect
  108761. */
  108762. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  108763. /**
  108764. * Add the list of attributes required for instances to the attribs array.
  108765. * @param attribs The current list of supported attribs
  108766. */
  108767. static PushAttributesForInstances(attribs: string[]): void;
  108768. /**
  108769. * Binds the light information to the effect.
  108770. * @param light The light containing the generator
  108771. * @param effect The effect we are binding the data to
  108772. * @param lightIndex The light index in the effect used to render
  108773. */
  108774. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  108775. /**
  108776. * Binds the lights information from the scene to the effect for the given mesh.
  108777. * @param light Light to bind
  108778. * @param lightIndex Light index
  108779. * @param scene The scene where the light belongs to
  108780. * @param effect The effect we are binding the data to
  108781. * @param useSpecular Defines if specular is supported
  108782. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  108783. */
  108784. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  108785. /**
  108786. * Binds the lights information from the scene to the effect for the given mesh.
  108787. * @param scene The scene the lights belongs to
  108788. * @param mesh The mesh we are binding the information to render
  108789. * @param effect The effect we are binding the data to
  108790. * @param defines The generated defines for the effect
  108791. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  108792. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  108793. */
  108794. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  108795. private static _tempFogColor;
  108796. /**
  108797. * Binds the fog information from the scene to the effect for the given mesh.
  108798. * @param scene The scene the lights belongs to
  108799. * @param mesh The mesh we are binding the information to render
  108800. * @param effect The effect we are binding the data to
  108801. * @param linearSpace Defines if the fog effect is applied in linear space
  108802. */
  108803. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  108804. /**
  108805. * Binds the bones information from the mesh to the effect.
  108806. * @param mesh The mesh we are binding the information to render
  108807. * @param effect The effect we are binding the data to
  108808. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  108809. */
  108810. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  108811. private static _CopyBonesTransformationMatrices;
  108812. /**
  108813. * Binds the morph targets information from the mesh to the effect.
  108814. * @param abstractMesh The mesh we are binding the information to render
  108815. * @param effect The effect we are binding the data to
  108816. */
  108817. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  108818. /**
  108819. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  108820. * @param defines The generated defines used in the effect
  108821. * @param effect The effect we are binding the data to
  108822. * @param scene The scene we are willing to render with logarithmic scale for
  108823. */
  108824. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  108825. /**
  108826. * Binds the clip plane information from the scene to the effect.
  108827. * @param scene The scene the clip plane information are extracted from
  108828. * @param effect The effect we are binding the data to
  108829. */
  108830. static BindClipPlane(effect: Effect, scene: Scene): void;
  108831. }
  108832. }
  108833. declare module BABYLON {
  108834. /** @hidden */
  108835. export var bayerDitherFunctions: {
  108836. name: string;
  108837. shader: string;
  108838. };
  108839. }
  108840. declare module BABYLON {
  108841. /** @hidden */
  108842. export var shadowMapFragmentDeclaration: {
  108843. name: string;
  108844. shader: string;
  108845. };
  108846. }
  108847. declare module BABYLON {
  108848. /** @hidden */
  108849. export var shadowMapFragment: {
  108850. name: string;
  108851. shader: string;
  108852. };
  108853. }
  108854. declare module BABYLON {
  108855. /** @hidden */
  108856. export var shadowMapPixelShader: {
  108857. name: string;
  108858. shader: string;
  108859. };
  108860. }
  108861. declare module BABYLON {
  108862. /** @hidden */
  108863. export var shadowMapVertexDeclaration: {
  108864. name: string;
  108865. shader: string;
  108866. };
  108867. }
  108868. declare module BABYLON {
  108869. /** @hidden */
  108870. export var shadowMapVertexNormalBias: {
  108871. name: string;
  108872. shader: string;
  108873. };
  108874. }
  108875. declare module BABYLON {
  108876. /** @hidden */
  108877. export var shadowMapVertexMetric: {
  108878. name: string;
  108879. shader: string;
  108880. };
  108881. }
  108882. declare module BABYLON {
  108883. /** @hidden */
  108884. export var shadowMapVertexShader: {
  108885. name: string;
  108886. shader: string;
  108887. };
  108888. }
  108889. declare module BABYLON {
  108890. /** @hidden */
  108891. export var depthBoxBlurPixelShader: {
  108892. name: string;
  108893. shader: string;
  108894. };
  108895. }
  108896. declare module BABYLON {
  108897. /** @hidden */
  108898. export var shadowMapFragmentSoftTransparentShadow: {
  108899. name: string;
  108900. shader: string;
  108901. };
  108902. }
  108903. declare module BABYLON {
  108904. /**
  108905. * Creates an instance based on a source mesh.
  108906. */
  108907. export class InstancedMesh extends AbstractMesh {
  108908. private _sourceMesh;
  108909. private _currentLOD;
  108910. /** @hidden */
  108911. _indexInSourceMeshInstanceArray: number;
  108912. constructor(name: string, source: Mesh);
  108913. /**
  108914. * Returns the string "InstancedMesh".
  108915. */
  108916. getClassName(): string;
  108917. /** Gets the list of lights affecting that mesh */
  108918. get lightSources(): Light[];
  108919. _resyncLightSources(): void;
  108920. _resyncLightSource(light: Light): void;
  108921. _removeLightSource(light: Light, dispose: boolean): void;
  108922. /**
  108923. * If the source mesh receives shadows
  108924. */
  108925. get receiveShadows(): boolean;
  108926. /**
  108927. * The material of the source mesh
  108928. */
  108929. get material(): Nullable<Material>;
  108930. /**
  108931. * Visibility of the source mesh
  108932. */
  108933. get visibility(): number;
  108934. /**
  108935. * Skeleton of the source mesh
  108936. */
  108937. get skeleton(): Nullable<Skeleton>;
  108938. /**
  108939. * Rendering ground id of the source mesh
  108940. */
  108941. get renderingGroupId(): number;
  108942. set renderingGroupId(value: number);
  108943. /**
  108944. * Returns the total number of vertices (integer).
  108945. */
  108946. getTotalVertices(): number;
  108947. /**
  108948. * Returns a positive integer : the total number of indices in this mesh geometry.
  108949. * @returns the numner of indices or zero if the mesh has no geometry.
  108950. */
  108951. getTotalIndices(): number;
  108952. /**
  108953. * The source mesh of the instance
  108954. */
  108955. get sourceMesh(): Mesh;
  108956. /**
  108957. * Creates a new InstancedMesh object from the mesh model.
  108958. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108959. * @param name defines the name of the new instance
  108960. * @returns a new InstancedMesh
  108961. */
  108962. createInstance(name: string): InstancedMesh;
  108963. /**
  108964. * Is this node ready to be used/rendered
  108965. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  108966. * @return {boolean} is it ready
  108967. */
  108968. isReady(completeCheck?: boolean): boolean;
  108969. /**
  108970. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  108971. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  108972. * @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.
  108973. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  108974. */
  108975. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  108976. /**
  108977. * Sets the vertex data of the mesh geometry for the requested `kind`.
  108978. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  108979. * The `data` are either a numeric array either a Float32Array.
  108980. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  108981. * 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).
  108982. * Note that a new underlying VertexBuffer object is created each call.
  108983. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  108984. *
  108985. * Possible `kind` values :
  108986. * - VertexBuffer.PositionKind
  108987. * - VertexBuffer.UVKind
  108988. * - VertexBuffer.UV2Kind
  108989. * - VertexBuffer.UV3Kind
  108990. * - VertexBuffer.UV4Kind
  108991. * - VertexBuffer.UV5Kind
  108992. * - VertexBuffer.UV6Kind
  108993. * - VertexBuffer.ColorKind
  108994. * - VertexBuffer.MatricesIndicesKind
  108995. * - VertexBuffer.MatricesIndicesExtraKind
  108996. * - VertexBuffer.MatricesWeightsKind
  108997. * - VertexBuffer.MatricesWeightsExtraKind
  108998. *
  108999. * Returns the Mesh.
  109000. */
  109001. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  109002. /**
  109003. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  109004. * If the mesh has no geometry, it is simply returned as it is.
  109005. * The `data` are either a numeric array either a Float32Array.
  109006. * No new underlying VertexBuffer object is created.
  109007. * 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.
  109008. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  109009. *
  109010. * Possible `kind` values :
  109011. * - VertexBuffer.PositionKind
  109012. * - VertexBuffer.UVKind
  109013. * - VertexBuffer.UV2Kind
  109014. * - VertexBuffer.UV3Kind
  109015. * - VertexBuffer.UV4Kind
  109016. * - VertexBuffer.UV5Kind
  109017. * - VertexBuffer.UV6Kind
  109018. * - VertexBuffer.ColorKind
  109019. * - VertexBuffer.MatricesIndicesKind
  109020. * - VertexBuffer.MatricesIndicesExtraKind
  109021. * - VertexBuffer.MatricesWeightsKind
  109022. * - VertexBuffer.MatricesWeightsExtraKind
  109023. *
  109024. * Returns the Mesh.
  109025. */
  109026. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  109027. /**
  109028. * Sets the mesh indices.
  109029. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  109030. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  109031. * This method creates a new index buffer each call.
  109032. * Returns the Mesh.
  109033. */
  109034. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  109035. /**
  109036. * Boolean : True if the mesh owns the requested kind of data.
  109037. */
  109038. isVerticesDataPresent(kind: string): boolean;
  109039. /**
  109040. * Returns an array of indices (IndicesArray).
  109041. */
  109042. getIndices(): Nullable<IndicesArray>;
  109043. get _positions(): Nullable<Vector3[]>;
  109044. /**
  109045. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  109046. * This means the mesh underlying bounding box and sphere are recomputed.
  109047. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  109048. * @returns the current mesh
  109049. */
  109050. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  109051. /** @hidden */
  109052. _preActivate(): InstancedMesh;
  109053. /** @hidden */
  109054. _activate(renderId: number, intermediateRendering: boolean): boolean;
  109055. /** @hidden */
  109056. _postActivate(): void;
  109057. getWorldMatrix(): Matrix;
  109058. get isAnInstance(): boolean;
  109059. /**
  109060. * Returns the current associated LOD AbstractMesh.
  109061. */
  109062. getLOD(camera: Camera): AbstractMesh;
  109063. /** @hidden */
  109064. _preActivateForIntermediateRendering(renderId: number): Mesh;
  109065. /** @hidden */
  109066. _syncSubMeshes(): InstancedMesh;
  109067. /** @hidden */
  109068. _generatePointsArray(): boolean;
  109069. /** @hidden */
  109070. _updateBoundingInfo(): AbstractMesh;
  109071. /**
  109072. * Creates a new InstancedMesh from the current mesh.
  109073. * - name (string) : the cloned mesh name
  109074. * - newParent (optional Node) : the optional Node to parent the clone to.
  109075. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  109076. *
  109077. * Returns the clone.
  109078. */
  109079. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  109080. /**
  109081. * Disposes the InstancedMesh.
  109082. * Returns nothing.
  109083. */
  109084. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109085. }
  109086. interface Mesh {
  109087. /**
  109088. * Register a custom buffer that will be instanced
  109089. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  109090. * @param kind defines the buffer kind
  109091. * @param stride defines the stride in floats
  109092. */
  109093. registerInstancedBuffer(kind: string, stride: number): void;
  109094. /**
  109095. * true to use the edge renderer for all instances of this mesh
  109096. */
  109097. edgesShareWithInstances: boolean;
  109098. /** @hidden */
  109099. _userInstancedBuffersStorage: {
  109100. data: {
  109101. [key: string]: Float32Array;
  109102. };
  109103. sizes: {
  109104. [key: string]: number;
  109105. };
  109106. vertexBuffers: {
  109107. [key: string]: Nullable<VertexBuffer>;
  109108. };
  109109. strides: {
  109110. [key: string]: number;
  109111. };
  109112. };
  109113. }
  109114. interface AbstractMesh {
  109115. /**
  109116. * Object used to store instanced buffers defined by user
  109117. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  109118. */
  109119. instancedBuffers: {
  109120. [key: string]: any;
  109121. };
  109122. }
  109123. }
  109124. declare module BABYLON {
  109125. /**
  109126. * Defines the options associated with the creation of a shader material.
  109127. */
  109128. export interface IShaderMaterialOptions {
  109129. /**
  109130. * Does the material work in alpha blend mode
  109131. */
  109132. needAlphaBlending: boolean;
  109133. /**
  109134. * Does the material work in alpha test mode
  109135. */
  109136. needAlphaTesting: boolean;
  109137. /**
  109138. * The list of attribute names used in the shader
  109139. */
  109140. attributes: string[];
  109141. /**
  109142. * The list of unifrom names used in the shader
  109143. */
  109144. uniforms: string[];
  109145. /**
  109146. * The list of UBO names used in the shader
  109147. */
  109148. uniformBuffers: string[];
  109149. /**
  109150. * The list of sampler names used in the shader
  109151. */
  109152. samplers: string[];
  109153. /**
  109154. * The list of defines used in the shader
  109155. */
  109156. defines: string[];
  109157. }
  109158. /**
  109159. * 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.
  109160. *
  109161. * This returned material effects how the mesh will look based on the code in the shaders.
  109162. *
  109163. * @see https://doc.babylonjs.com/how_to/shader_material
  109164. */
  109165. export class ShaderMaterial extends Material {
  109166. private _shaderPath;
  109167. private _options;
  109168. private _textures;
  109169. private _textureArrays;
  109170. private _floats;
  109171. private _ints;
  109172. private _floatsArrays;
  109173. private _colors3;
  109174. private _colors3Arrays;
  109175. private _colors4;
  109176. private _colors4Arrays;
  109177. private _vectors2;
  109178. private _vectors3;
  109179. private _vectors4;
  109180. private _matrices;
  109181. private _matrixArrays;
  109182. private _matrices3x3;
  109183. private _matrices2x2;
  109184. private _vectors2Arrays;
  109185. private _vectors3Arrays;
  109186. private _vectors4Arrays;
  109187. private _cachedWorldViewMatrix;
  109188. private _cachedWorldViewProjectionMatrix;
  109189. private _renderId;
  109190. private _multiview;
  109191. private _cachedDefines;
  109192. /** Define the Url to load snippets */
  109193. static SnippetUrl: string;
  109194. /** Snippet ID if the material was created from the snippet server */
  109195. snippetId: string;
  109196. /**
  109197. * Instantiate a new shader material.
  109198. * 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.
  109199. * This returned material effects how the mesh will look based on the code in the shaders.
  109200. * @see https://doc.babylonjs.com/how_to/shader_material
  109201. * @param name Define the name of the material in the scene
  109202. * @param scene Define the scene the material belongs to
  109203. * @param shaderPath Defines the route to the shader code in one of three ways:
  109204. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  109205. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  109206. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  109207. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  109208. * @param options Define the options used to create the shader
  109209. */
  109210. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  109211. /**
  109212. * Gets the shader path used to define the shader code
  109213. * It can be modified to trigger a new compilation
  109214. */
  109215. get shaderPath(): any;
  109216. /**
  109217. * Sets the shader path used to define the shader code
  109218. * It can be modified to trigger a new compilation
  109219. */
  109220. set shaderPath(shaderPath: any);
  109221. /**
  109222. * Gets the options used to compile the shader.
  109223. * They can be modified to trigger a new compilation
  109224. */
  109225. get options(): IShaderMaterialOptions;
  109226. /**
  109227. * Gets the current class name of the material e.g. "ShaderMaterial"
  109228. * Mainly use in serialization.
  109229. * @returns the class name
  109230. */
  109231. getClassName(): string;
  109232. /**
  109233. * Specifies if the material will require alpha blending
  109234. * @returns a boolean specifying if alpha blending is needed
  109235. */
  109236. needAlphaBlending(): boolean;
  109237. /**
  109238. * Specifies if this material should be rendered in alpha test mode
  109239. * @returns a boolean specifying if an alpha test is needed.
  109240. */
  109241. needAlphaTesting(): boolean;
  109242. private _checkUniform;
  109243. /**
  109244. * Set a texture in the shader.
  109245. * @param name Define the name of the uniform samplers as defined in the shader
  109246. * @param texture Define the texture to bind to this sampler
  109247. * @return the material itself allowing "fluent" like uniform updates
  109248. */
  109249. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  109250. /**
  109251. * Set a texture array in the shader.
  109252. * @param name Define the name of the uniform sampler array as defined in the shader
  109253. * @param textures Define the list of textures to bind to this sampler
  109254. * @return the material itself allowing "fluent" like uniform updates
  109255. */
  109256. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  109257. /**
  109258. * Set a float in the shader.
  109259. * @param name Define the name of the uniform as defined in the shader
  109260. * @param value Define the value to give to the uniform
  109261. * @return the material itself allowing "fluent" like uniform updates
  109262. */
  109263. setFloat(name: string, value: number): ShaderMaterial;
  109264. /**
  109265. * Set a int in the shader.
  109266. * @param name Define the name of the uniform as defined in the shader
  109267. * @param value Define the value to give to the uniform
  109268. * @return the material itself allowing "fluent" like uniform updates
  109269. */
  109270. setInt(name: string, value: number): ShaderMaterial;
  109271. /**
  109272. * Set an array of floats in the shader.
  109273. * @param name Define the name of the uniform as defined in the shader
  109274. * @param value Define the value to give to the uniform
  109275. * @return the material itself allowing "fluent" like uniform updates
  109276. */
  109277. setFloats(name: string, value: number[]): ShaderMaterial;
  109278. /**
  109279. * Set a vec3 in the shader from a Color3.
  109280. * @param name Define the name of the uniform as defined in the shader
  109281. * @param value Define the value to give to the uniform
  109282. * @return the material itself allowing "fluent" like uniform updates
  109283. */
  109284. setColor3(name: string, value: Color3): ShaderMaterial;
  109285. /**
  109286. * Set a vec3 array in the shader from a Color3 array.
  109287. * @param name Define the name of the uniform as defined in the shader
  109288. * @param value Define the value to give to the uniform
  109289. * @return the material itself allowing "fluent" like uniform updates
  109290. */
  109291. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  109292. /**
  109293. * Set a vec4 in the shader from a Color4.
  109294. * @param name Define the name of the uniform as defined in the shader
  109295. * @param value Define the value to give to the uniform
  109296. * @return the material itself allowing "fluent" like uniform updates
  109297. */
  109298. setColor4(name: string, value: Color4): ShaderMaterial;
  109299. /**
  109300. * Set a vec4 array in the shader from a Color4 array.
  109301. * @param name Define the name of the uniform as defined in the shader
  109302. * @param value Define the value to give to the uniform
  109303. * @return the material itself allowing "fluent" like uniform updates
  109304. */
  109305. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  109306. /**
  109307. * Set a vec2 in the shader from a Vector2.
  109308. * @param name Define the name of the uniform as defined in the shader
  109309. * @param value Define the value to give to the uniform
  109310. * @return the material itself allowing "fluent" like uniform updates
  109311. */
  109312. setVector2(name: string, value: Vector2): ShaderMaterial;
  109313. /**
  109314. * Set a vec3 in the shader from a Vector3.
  109315. * @param name Define the name of the uniform as defined in the shader
  109316. * @param value Define the value to give to the uniform
  109317. * @return the material itself allowing "fluent" like uniform updates
  109318. */
  109319. setVector3(name: string, value: Vector3): ShaderMaterial;
  109320. /**
  109321. * Set a vec4 in the shader from a Vector4.
  109322. * @param name Define the name of the uniform as defined in the shader
  109323. * @param value Define the value to give to the uniform
  109324. * @return the material itself allowing "fluent" like uniform updates
  109325. */
  109326. setVector4(name: string, value: Vector4): ShaderMaterial;
  109327. /**
  109328. * Set a mat4 in the shader from a Matrix.
  109329. * @param name Define the name of the uniform as defined in the shader
  109330. * @param value Define the value to give to the uniform
  109331. * @return the material itself allowing "fluent" like uniform updates
  109332. */
  109333. setMatrix(name: string, value: Matrix): ShaderMaterial;
  109334. /**
  109335. * Set a float32Array in the shader from a matrix array.
  109336. * @param name Define the name of the uniform as defined in the shader
  109337. * @param value Define the value to give to the uniform
  109338. * @return the material itself allowing "fluent" like uniform updates
  109339. */
  109340. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  109341. /**
  109342. * Set a mat3 in the shader from a Float32Array.
  109343. * @param name Define the name of the uniform as defined in the shader
  109344. * @param value Define the value to give to the uniform
  109345. * @return the material itself allowing "fluent" like uniform updates
  109346. */
  109347. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  109348. /**
  109349. * Set a mat2 in the shader from a Float32Array.
  109350. * @param name Define the name of the uniform as defined in the shader
  109351. * @param value Define the value to give to the uniform
  109352. * @return the material itself allowing "fluent" like uniform updates
  109353. */
  109354. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  109355. /**
  109356. * Set a vec2 array in the shader from a number array.
  109357. * @param name Define the name of the uniform as defined in the shader
  109358. * @param value Define the value to give to the uniform
  109359. * @return the material itself allowing "fluent" like uniform updates
  109360. */
  109361. setArray2(name: string, value: number[]): ShaderMaterial;
  109362. /**
  109363. * Set a vec3 array in the shader from a number array.
  109364. * @param name Define the name of the uniform as defined in the shader
  109365. * @param value Define the value to give to the uniform
  109366. * @return the material itself allowing "fluent" like uniform updates
  109367. */
  109368. setArray3(name: string, value: number[]): ShaderMaterial;
  109369. /**
  109370. * Set a vec4 array in the shader from a number array.
  109371. * @param name Define the name of the uniform as defined in the shader
  109372. * @param value Define the value to give to the uniform
  109373. * @return the material itself allowing "fluent" like uniform updates
  109374. */
  109375. setArray4(name: string, value: number[]): ShaderMaterial;
  109376. private _checkCache;
  109377. /**
  109378. * Specifies that the submesh is ready to be used
  109379. * @param mesh defines the mesh to check
  109380. * @param subMesh defines which submesh to check
  109381. * @param useInstances specifies that instances should be used
  109382. * @returns a boolean indicating that the submesh is ready or not
  109383. */
  109384. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109385. /**
  109386. * Checks if the material is ready to render the requested mesh
  109387. * @param mesh Define the mesh to render
  109388. * @param useInstances Define whether or not the material is used with instances
  109389. * @returns true if ready, otherwise false
  109390. */
  109391. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  109392. /**
  109393. * Binds the world matrix to the material
  109394. * @param world defines the world transformation matrix
  109395. * @param effectOverride - If provided, use this effect instead of internal effect
  109396. */
  109397. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  109398. /**
  109399. * Binds the submesh to this material by preparing the effect and shader to draw
  109400. * @param world defines the world transformation matrix
  109401. * @param mesh defines the mesh containing the submesh
  109402. * @param subMesh defines the submesh to bind the material to
  109403. */
  109404. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109405. /**
  109406. * Binds the material to the mesh
  109407. * @param world defines the world transformation matrix
  109408. * @param mesh defines the mesh to bind the material to
  109409. * @param effectOverride - If provided, use this effect instead of internal effect
  109410. */
  109411. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  109412. protected _afterBind(mesh?: Mesh): void;
  109413. /**
  109414. * Gets the active textures from the material
  109415. * @returns an array of textures
  109416. */
  109417. getActiveTextures(): BaseTexture[];
  109418. /**
  109419. * Specifies if the material uses a texture
  109420. * @param texture defines the texture to check against the material
  109421. * @returns a boolean specifying if the material uses the texture
  109422. */
  109423. hasTexture(texture: BaseTexture): boolean;
  109424. /**
  109425. * Makes a duplicate of the material, and gives it a new name
  109426. * @param name defines the new name for the duplicated material
  109427. * @returns the cloned material
  109428. */
  109429. clone(name: string): ShaderMaterial;
  109430. /**
  109431. * Disposes the material
  109432. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109433. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109434. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  109435. */
  109436. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  109437. /**
  109438. * Serializes this material in a JSON representation
  109439. * @returns the serialized material object
  109440. */
  109441. serialize(): any;
  109442. /**
  109443. * Creates a shader material from parsed shader material data
  109444. * @param source defines the JSON represnetation of the material
  109445. * @param scene defines the hosting scene
  109446. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109447. * @returns a new material
  109448. */
  109449. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  109450. /**
  109451. * Creates a new ShaderMaterial from a snippet saved in a remote file
  109452. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  109453. * @param url defines the url to load from
  109454. * @param scene defines the hosting scene
  109455. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109456. * @returns a promise that will resolve to the new ShaderMaterial
  109457. */
  109458. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  109459. /**
  109460. * Creates a ShaderMaterial from a snippet saved by the Inspector
  109461. * @param snippetId defines the snippet to load
  109462. * @param scene defines the hosting scene
  109463. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109464. * @returns a promise that will resolve to the new ShaderMaterial
  109465. */
  109466. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  109467. }
  109468. }
  109469. declare module BABYLON {
  109470. /** @hidden */
  109471. export var colorPixelShader: {
  109472. name: string;
  109473. shader: string;
  109474. };
  109475. }
  109476. declare module BABYLON {
  109477. /** @hidden */
  109478. export var colorVertexShader: {
  109479. name: string;
  109480. shader: string;
  109481. };
  109482. }
  109483. declare module BABYLON {
  109484. /**
  109485. * Line mesh
  109486. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  109487. */
  109488. export class LinesMesh extends Mesh {
  109489. /**
  109490. * If vertex color should be applied to the mesh
  109491. */
  109492. readonly useVertexColor?: boolean | undefined;
  109493. /**
  109494. * If vertex alpha should be applied to the mesh
  109495. */
  109496. readonly useVertexAlpha?: boolean | undefined;
  109497. /**
  109498. * Color of the line (Default: White)
  109499. */
  109500. color: Color3;
  109501. /**
  109502. * Alpha of the line (Default: 1)
  109503. */
  109504. alpha: number;
  109505. /**
  109506. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  109507. * This margin is expressed in world space coordinates, so its value may vary.
  109508. * Default value is 0.1
  109509. */
  109510. intersectionThreshold: number;
  109511. private _colorShader;
  109512. private color4;
  109513. /**
  109514. * Creates a new LinesMesh
  109515. * @param name defines the name
  109516. * @param scene defines the hosting scene
  109517. * @param parent defines the parent mesh if any
  109518. * @param source defines the optional source LinesMesh used to clone data from
  109519. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  109520. * When false, achieved by calling a clone(), also passing False.
  109521. * This will make creation of children, recursive.
  109522. * @param useVertexColor defines if this LinesMesh supports vertex color
  109523. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  109524. */
  109525. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  109526. /**
  109527. * If vertex color should be applied to the mesh
  109528. */
  109529. useVertexColor?: boolean | undefined,
  109530. /**
  109531. * If vertex alpha should be applied to the mesh
  109532. */
  109533. useVertexAlpha?: boolean | undefined);
  109534. private _addClipPlaneDefine;
  109535. private _removeClipPlaneDefine;
  109536. isReady(): boolean;
  109537. /**
  109538. * Returns the string "LineMesh"
  109539. */
  109540. getClassName(): string;
  109541. /**
  109542. * @hidden
  109543. */
  109544. get material(): Material;
  109545. /**
  109546. * @hidden
  109547. */
  109548. set material(value: Material);
  109549. /**
  109550. * @hidden
  109551. */
  109552. get checkCollisions(): boolean;
  109553. /** @hidden */
  109554. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  109555. /** @hidden */
  109556. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  109557. /**
  109558. * Disposes of the line mesh
  109559. * @param doNotRecurse If children should be disposed
  109560. */
  109561. dispose(doNotRecurse?: boolean): void;
  109562. /**
  109563. * Returns a new LineMesh object cloned from the current one.
  109564. */
  109565. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  109566. /**
  109567. * Creates a new InstancedLinesMesh object from the mesh model.
  109568. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  109569. * @param name defines the name of the new instance
  109570. * @returns a new InstancedLinesMesh
  109571. */
  109572. createInstance(name: string): InstancedLinesMesh;
  109573. }
  109574. /**
  109575. * Creates an instance based on a source LinesMesh
  109576. */
  109577. export class InstancedLinesMesh extends InstancedMesh {
  109578. /**
  109579. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  109580. * This margin is expressed in world space coordinates, so its value may vary.
  109581. * Initilized with the intersectionThreshold value of the source LinesMesh
  109582. */
  109583. intersectionThreshold: number;
  109584. constructor(name: string, source: LinesMesh);
  109585. /**
  109586. * Returns the string "InstancedLinesMesh".
  109587. */
  109588. getClassName(): string;
  109589. }
  109590. }
  109591. declare module BABYLON {
  109592. /** @hidden */
  109593. export var linePixelShader: {
  109594. name: string;
  109595. shader: string;
  109596. };
  109597. }
  109598. declare module BABYLON {
  109599. /** @hidden */
  109600. export var lineVertexShader: {
  109601. name: string;
  109602. shader: string;
  109603. };
  109604. }
  109605. declare module BABYLON {
  109606. interface Scene {
  109607. /** @hidden */
  109608. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  109609. }
  109610. interface AbstractMesh {
  109611. /**
  109612. * Gets the edgesRenderer associated with the mesh
  109613. */
  109614. edgesRenderer: Nullable<EdgesRenderer>;
  109615. }
  109616. interface LinesMesh {
  109617. /**
  109618. * Enables the edge rendering mode on the mesh.
  109619. * This mode makes the mesh edges visible
  109620. * @param epsilon defines the maximal distance between two angles to detect a face
  109621. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  109622. * @returns the currentAbstractMesh
  109623. * @see https://www.babylonjs-playground.com/#19O9TU#0
  109624. */
  109625. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  109626. }
  109627. interface InstancedLinesMesh {
  109628. /**
  109629. * Enables the edge rendering mode on the mesh.
  109630. * This mode makes the mesh edges visible
  109631. * @param epsilon defines the maximal distance between two angles to detect a face
  109632. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  109633. * @returns the current InstancedLinesMesh
  109634. * @see https://www.babylonjs-playground.com/#19O9TU#0
  109635. */
  109636. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  109637. }
  109638. /**
  109639. * Defines the minimum contract an Edges renderer should follow.
  109640. */
  109641. export interface IEdgesRenderer extends IDisposable {
  109642. /**
  109643. * Gets or sets a boolean indicating if the edgesRenderer is active
  109644. */
  109645. isEnabled: boolean;
  109646. /**
  109647. * Renders the edges of the attached mesh,
  109648. */
  109649. render(): void;
  109650. /**
  109651. * Checks wether or not the edges renderer is ready to render.
  109652. * @return true if ready, otherwise false.
  109653. */
  109654. isReady(): boolean;
  109655. /**
  109656. * List of instances to render in case the source mesh has instances
  109657. */
  109658. customInstances: SmartArray<Matrix>;
  109659. }
  109660. /**
  109661. * Defines the additional options of the edges renderer
  109662. */
  109663. export interface IEdgesRendererOptions {
  109664. /**
  109665. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  109666. * If not defined, the default value is true
  109667. */
  109668. useAlternateEdgeFinder?: boolean;
  109669. /**
  109670. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  109671. * If not defined, the default value is true.
  109672. * 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)
  109673. * This option is used only if useAlternateEdgeFinder = true
  109674. */
  109675. useFastVertexMerger?: boolean;
  109676. /**
  109677. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  109678. * The default value is 1e-6
  109679. * This option is used only if useAlternateEdgeFinder = true
  109680. */
  109681. epsilonVertexMerge?: number;
  109682. /**
  109683. * 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
  109684. * 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.
  109685. * This option is used only if useAlternateEdgeFinder = true
  109686. */
  109687. applyTessellation?: boolean;
  109688. /**
  109689. * 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
  109690. * The default value is 1e-6
  109691. * This option is used only if useAlternateEdgeFinder = true
  109692. */
  109693. epsilonVertexAligned?: number;
  109694. }
  109695. /**
  109696. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  109697. */
  109698. export class EdgesRenderer implements IEdgesRenderer {
  109699. /**
  109700. * Define the size of the edges with an orthographic camera
  109701. */
  109702. edgesWidthScalerForOrthographic: number;
  109703. /**
  109704. * Define the size of the edges with a perspective camera
  109705. */
  109706. edgesWidthScalerForPerspective: number;
  109707. protected _source: AbstractMesh;
  109708. protected _linesPositions: number[];
  109709. protected _linesNormals: number[];
  109710. protected _linesIndices: number[];
  109711. protected _epsilon: number;
  109712. protected _indicesCount: number;
  109713. protected _lineShader: ShaderMaterial;
  109714. protected _ib: DataBuffer;
  109715. protected _buffers: {
  109716. [key: string]: Nullable<VertexBuffer>;
  109717. };
  109718. protected _buffersForInstances: {
  109719. [key: string]: Nullable<VertexBuffer>;
  109720. };
  109721. protected _checkVerticesInsteadOfIndices: boolean;
  109722. protected _options: Nullable<IEdgesRendererOptions>;
  109723. private _meshRebuildObserver;
  109724. private _meshDisposeObserver;
  109725. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  109726. isEnabled: boolean;
  109727. /** Gets the vertices generated by the edge renderer */
  109728. get linesPositions(): Immutable<Array<number>>;
  109729. /** Gets the normals generated by the edge renderer */
  109730. get linesNormals(): Immutable<Array<number>>;
  109731. /** Gets the indices generated by the edge renderer */
  109732. get linesIndices(): Immutable<Array<number>>;
  109733. /**
  109734. * List of instances to render in case the source mesh has instances
  109735. */
  109736. customInstances: SmartArray<Matrix>;
  109737. private static GetShader;
  109738. /**
  109739. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  109740. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  109741. * @param source Mesh used to create edges
  109742. * @param epsilon sum of angles in adjacency to check for edge
  109743. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  109744. * @param generateEdgesLines - should generate Lines or only prepare resources.
  109745. * @param options The options to apply when generating the edges
  109746. */
  109747. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  109748. protected _prepareRessources(): void;
  109749. /** @hidden */
  109750. _rebuild(): void;
  109751. /**
  109752. * Releases the required resources for the edges renderer
  109753. */
  109754. dispose(): void;
  109755. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  109756. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  109757. /**
  109758. * Checks if the pair of p0 and p1 is en edge
  109759. * @param faceIndex
  109760. * @param edge
  109761. * @param faceNormals
  109762. * @param p0
  109763. * @param p1
  109764. * @private
  109765. */
  109766. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  109767. /**
  109768. * push line into the position, normal and index buffer
  109769. * @protected
  109770. */
  109771. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  109772. /**
  109773. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  109774. */
  109775. private _tessellateTriangle;
  109776. private _generateEdgesLinesAlternate;
  109777. /**
  109778. * Generates lines edges from adjacencjes
  109779. * @private
  109780. */
  109781. _generateEdgesLines(): void;
  109782. /**
  109783. * Checks wether or not the edges renderer is ready to render.
  109784. * @return true if ready, otherwise false.
  109785. */
  109786. isReady(): boolean;
  109787. /**
  109788. * Renders the edges of the attached mesh,
  109789. */
  109790. render(): void;
  109791. }
  109792. /**
  109793. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  109794. */
  109795. export class LineEdgesRenderer extends EdgesRenderer {
  109796. /**
  109797. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  109798. * @param source LineMesh used to generate edges
  109799. * @param epsilon not important (specified angle for edge detection)
  109800. * @param checkVerticesInsteadOfIndices not important for LineMesh
  109801. */
  109802. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  109803. /**
  109804. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  109805. */
  109806. _generateEdgesLines(): void;
  109807. }
  109808. }
  109809. declare module BABYLON {
  109810. /**
  109811. * This represents the object necessary to create a rendering group.
  109812. * This is exclusively used and created by the rendering manager.
  109813. * To modify the behavior, you use the available helpers in your scene or meshes.
  109814. * @hidden
  109815. */
  109816. export class RenderingGroup {
  109817. index: number;
  109818. private static _zeroVector;
  109819. private _scene;
  109820. private _opaqueSubMeshes;
  109821. private _transparentSubMeshes;
  109822. private _alphaTestSubMeshes;
  109823. private _depthOnlySubMeshes;
  109824. private _particleSystems;
  109825. private _spriteManagers;
  109826. private _opaqueSortCompareFn;
  109827. private _alphaTestSortCompareFn;
  109828. private _transparentSortCompareFn;
  109829. private _renderOpaque;
  109830. private _renderAlphaTest;
  109831. private _renderTransparent;
  109832. /** @hidden */
  109833. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  109834. onBeforeTransparentRendering: () => void;
  109835. /**
  109836. * Set the opaque sort comparison function.
  109837. * If null the sub meshes will be render in the order they were created
  109838. */
  109839. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  109840. /**
  109841. * Set the alpha test sort comparison function.
  109842. * If null the sub meshes will be render in the order they were created
  109843. */
  109844. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  109845. /**
  109846. * Set the transparent sort comparison function.
  109847. * If null the sub meshes will be render in the order they were created
  109848. */
  109849. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  109850. /**
  109851. * Creates a new rendering group.
  109852. * @param index The rendering group index
  109853. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  109854. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  109855. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  109856. */
  109857. 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>);
  109858. /**
  109859. * Render all the sub meshes contained in the group.
  109860. * @param customRenderFunction Used to override the default render behaviour of the group.
  109861. * @returns true if rendered some submeshes.
  109862. */
  109863. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  109864. /**
  109865. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  109866. * @param subMeshes The submeshes to render
  109867. */
  109868. private renderOpaqueSorted;
  109869. /**
  109870. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  109871. * @param subMeshes The submeshes to render
  109872. */
  109873. private renderAlphaTestSorted;
  109874. /**
  109875. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  109876. * @param subMeshes The submeshes to render
  109877. */
  109878. private renderTransparentSorted;
  109879. /**
  109880. * Renders the submeshes in a specified order.
  109881. * @param subMeshes The submeshes to sort before render
  109882. * @param sortCompareFn The comparison function use to sort
  109883. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  109884. * @param transparent Specifies to activate blending if true
  109885. */
  109886. private static renderSorted;
  109887. /**
  109888. * Renders the submeshes in the order they were dispatched (no sort applied).
  109889. * @param subMeshes The submeshes to render
  109890. */
  109891. private static renderUnsorted;
  109892. /**
  109893. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  109894. * are rendered back to front if in the same alpha index.
  109895. *
  109896. * @param a The first submesh
  109897. * @param b The second submesh
  109898. * @returns The result of the comparison
  109899. */
  109900. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  109901. /**
  109902. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  109903. * are rendered back to front.
  109904. *
  109905. * @param a The first submesh
  109906. * @param b The second submesh
  109907. * @returns The result of the comparison
  109908. */
  109909. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  109910. /**
  109911. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  109912. * are rendered front to back (prevent overdraw).
  109913. *
  109914. * @param a The first submesh
  109915. * @param b The second submesh
  109916. * @returns The result of the comparison
  109917. */
  109918. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  109919. /**
  109920. * Resets the different lists of submeshes to prepare a new frame.
  109921. */
  109922. prepare(): void;
  109923. dispose(): void;
  109924. /**
  109925. * Inserts the submesh in its correct queue depending on its material.
  109926. * @param subMesh The submesh to dispatch
  109927. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  109928. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  109929. */
  109930. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  109931. dispatchSprites(spriteManager: ISpriteManager): void;
  109932. dispatchParticles(particleSystem: IParticleSystem): void;
  109933. private _renderParticles;
  109934. private _renderSprites;
  109935. }
  109936. }
  109937. declare module BABYLON {
  109938. /**
  109939. * Interface describing the different options available in the rendering manager
  109940. * regarding Auto Clear between groups.
  109941. */
  109942. export interface IRenderingManagerAutoClearSetup {
  109943. /**
  109944. * Defines whether or not autoclear is enable.
  109945. */
  109946. autoClear: boolean;
  109947. /**
  109948. * Defines whether or not to autoclear the depth buffer.
  109949. */
  109950. depth: boolean;
  109951. /**
  109952. * Defines whether or not to autoclear the stencil buffer.
  109953. */
  109954. stencil: boolean;
  109955. }
  109956. /**
  109957. * This class is used by the onRenderingGroupObservable
  109958. */
  109959. export class RenderingGroupInfo {
  109960. /**
  109961. * The Scene that being rendered
  109962. */
  109963. scene: Scene;
  109964. /**
  109965. * The camera currently used for the rendering pass
  109966. */
  109967. camera: Nullable<Camera>;
  109968. /**
  109969. * The ID of the renderingGroup being processed
  109970. */
  109971. renderingGroupId: number;
  109972. }
  109973. /**
  109974. * This is the manager responsible of all the rendering for meshes sprites and particles.
  109975. * It is enable to manage the different groups as well as the different necessary sort functions.
  109976. * This should not be used directly aside of the few static configurations
  109977. */
  109978. export class RenderingManager {
  109979. /**
  109980. * The max id used for rendering groups (not included)
  109981. */
  109982. static MAX_RENDERINGGROUPS: number;
  109983. /**
  109984. * The min id used for rendering groups (included)
  109985. */
  109986. static MIN_RENDERINGGROUPS: number;
  109987. /**
  109988. * Used to globally prevent autoclearing scenes.
  109989. */
  109990. static AUTOCLEAR: boolean;
  109991. /**
  109992. * @hidden
  109993. */
  109994. _useSceneAutoClearSetup: boolean;
  109995. private _scene;
  109996. private _renderingGroups;
  109997. private _depthStencilBufferAlreadyCleaned;
  109998. private _autoClearDepthStencil;
  109999. private _customOpaqueSortCompareFn;
  110000. private _customAlphaTestSortCompareFn;
  110001. private _customTransparentSortCompareFn;
  110002. private _renderingGroupInfo;
  110003. /**
  110004. * Instantiates a new rendering group for a particular scene
  110005. * @param scene Defines the scene the groups belongs to
  110006. */
  110007. constructor(scene: Scene);
  110008. private _clearDepthStencilBuffer;
  110009. /**
  110010. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  110011. * @hidden
  110012. */
  110013. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  110014. /**
  110015. * Resets the different information of the group to prepare a new frame
  110016. * @hidden
  110017. */
  110018. reset(): void;
  110019. /**
  110020. * Dispose and release the group and its associated resources.
  110021. * @hidden
  110022. */
  110023. dispose(): void;
  110024. /**
  110025. * Clear the info related to rendering groups preventing retention points during dispose.
  110026. */
  110027. freeRenderingGroups(): void;
  110028. private _prepareRenderingGroup;
  110029. /**
  110030. * Add a sprite manager to the rendering manager in order to render it this frame.
  110031. * @param spriteManager Define the sprite manager to render
  110032. */
  110033. dispatchSprites(spriteManager: ISpriteManager): void;
  110034. /**
  110035. * Add a particle system to the rendering manager in order to render it this frame.
  110036. * @param particleSystem Define the particle system to render
  110037. */
  110038. dispatchParticles(particleSystem: IParticleSystem): void;
  110039. /**
  110040. * Add a submesh to the manager in order to render it this frame
  110041. * @param subMesh The submesh to dispatch
  110042. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  110043. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  110044. */
  110045. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  110046. /**
  110047. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110048. * This allowed control for front to back rendering or reversly depending of the special needs.
  110049. *
  110050. * @param renderingGroupId The rendering group id corresponding to its index
  110051. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110052. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110053. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110054. */
  110055. 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;
  110056. /**
  110057. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110058. *
  110059. * @param renderingGroupId The rendering group id corresponding to its index
  110060. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110061. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110062. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110063. */
  110064. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110065. /**
  110066. * Gets the current auto clear configuration for one rendering group of the rendering
  110067. * manager.
  110068. * @param index the rendering group index to get the information for
  110069. * @returns The auto clear setup for the requested rendering group
  110070. */
  110071. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110072. }
  110073. }
  110074. declare module BABYLON {
  110075. /**
  110076. * Defines the options associated with the creation of a custom shader for a shadow generator.
  110077. */
  110078. export interface ICustomShaderOptions {
  110079. /**
  110080. * Gets or sets the custom shader name to use
  110081. */
  110082. shaderName: string;
  110083. /**
  110084. * The list of attribute names used in the shader
  110085. */
  110086. attributes?: string[];
  110087. /**
  110088. * The list of unifrom names used in the shader
  110089. */
  110090. uniforms?: string[];
  110091. /**
  110092. * The list of sampler names used in the shader
  110093. */
  110094. samplers?: string[];
  110095. /**
  110096. * The list of defines used in the shader
  110097. */
  110098. defines?: string[];
  110099. }
  110100. /**
  110101. * Interface to implement to create a shadow generator compatible with BJS.
  110102. */
  110103. export interface IShadowGenerator {
  110104. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  110105. id: string;
  110106. /**
  110107. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  110108. * @returns The render target texture if present otherwise, null
  110109. */
  110110. getShadowMap(): Nullable<RenderTargetTexture>;
  110111. /**
  110112. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  110113. * @param subMesh The submesh we want to render in the shadow map
  110114. * @param useInstances Defines wether will draw in the map using instances
  110115. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  110116. * @returns true if ready otherwise, false
  110117. */
  110118. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  110119. /**
  110120. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  110121. * @param defines Defines of the material we want to update
  110122. * @param lightIndex Index of the light in the enabled light list of the material
  110123. */
  110124. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  110125. /**
  110126. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  110127. * defined in the generator but impacting the effect).
  110128. * It implies the unifroms available on the materials are the standard BJS ones.
  110129. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  110130. * @param effect The effect we are binfing the information for
  110131. */
  110132. bindShadowLight(lightIndex: string, effect: Effect): void;
  110133. /**
  110134. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  110135. * (eq to shadow prjection matrix * light transform matrix)
  110136. * @returns The transform matrix used to create the shadow map
  110137. */
  110138. getTransformMatrix(): Matrix;
  110139. /**
  110140. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  110141. * Cube and 2D textures for instance.
  110142. */
  110143. recreateShadowMap(): void;
  110144. /**
  110145. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110146. * @param onCompiled Callback triggered at the and of the effects compilation
  110147. * @param options Sets of optional options forcing the compilation with different modes
  110148. */
  110149. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  110150. useInstances: boolean;
  110151. }>): void;
  110152. /**
  110153. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110154. * @param options Sets of optional options forcing the compilation with different modes
  110155. * @returns A promise that resolves when the compilation completes
  110156. */
  110157. forceCompilationAsync(options?: Partial<{
  110158. useInstances: boolean;
  110159. }>): Promise<void>;
  110160. /**
  110161. * Serializes the shadow generator setup to a json object.
  110162. * @returns The serialized JSON object
  110163. */
  110164. serialize(): any;
  110165. /**
  110166. * Disposes the Shadow map and related Textures and effects.
  110167. */
  110168. dispose(): void;
  110169. }
  110170. /**
  110171. * Default implementation IShadowGenerator.
  110172. * This is the main object responsible of generating shadows in the framework.
  110173. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  110174. */
  110175. export class ShadowGenerator implements IShadowGenerator {
  110176. /**
  110177. * Name of the shadow generator class
  110178. */
  110179. static CLASSNAME: string;
  110180. /**
  110181. * Shadow generator mode None: no filtering applied.
  110182. */
  110183. static readonly FILTER_NONE: number;
  110184. /**
  110185. * Shadow generator mode ESM: Exponential Shadow Mapping.
  110186. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110187. */
  110188. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  110189. /**
  110190. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  110191. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  110192. */
  110193. static readonly FILTER_POISSONSAMPLING: number;
  110194. /**
  110195. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  110196. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110197. */
  110198. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  110199. /**
  110200. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  110201. * edge artifacts on steep falloff.
  110202. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110203. */
  110204. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  110205. /**
  110206. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  110207. * edge artifacts on steep falloff.
  110208. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110209. */
  110210. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  110211. /**
  110212. * Shadow generator mode PCF: Percentage Closer Filtering
  110213. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  110214. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  110215. */
  110216. static readonly FILTER_PCF: number;
  110217. /**
  110218. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  110219. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  110220. * Contact Hardening
  110221. */
  110222. static readonly FILTER_PCSS: number;
  110223. /**
  110224. * Reserved for PCF and PCSS
  110225. * Highest Quality.
  110226. *
  110227. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  110228. *
  110229. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  110230. */
  110231. static readonly QUALITY_HIGH: number;
  110232. /**
  110233. * Reserved for PCF and PCSS
  110234. * Good tradeoff for quality/perf cross devices
  110235. *
  110236. * Execute PCF on a 3*3 kernel.
  110237. *
  110238. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  110239. */
  110240. static readonly QUALITY_MEDIUM: number;
  110241. /**
  110242. * Reserved for PCF and PCSS
  110243. * The lowest quality but the fastest.
  110244. *
  110245. * Execute PCF on a 1*1 kernel.
  110246. *
  110247. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  110248. */
  110249. static readonly QUALITY_LOW: number;
  110250. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  110251. id: string;
  110252. /** Gets or sets the custom shader name to use */
  110253. customShaderOptions: ICustomShaderOptions;
  110254. /**
  110255. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  110256. */
  110257. onBeforeShadowMapRenderObservable: Observable<Effect>;
  110258. /**
  110259. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  110260. */
  110261. onAfterShadowMapRenderObservable: Observable<Effect>;
  110262. /**
  110263. * Observable triggered before a mesh is rendered in the shadow map.
  110264. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  110265. */
  110266. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  110267. /**
  110268. * Observable triggered after a mesh is rendered in the shadow map.
  110269. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  110270. */
  110271. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  110272. protected _bias: number;
  110273. /**
  110274. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  110275. */
  110276. get bias(): number;
  110277. /**
  110278. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  110279. */
  110280. set bias(bias: number);
  110281. protected _normalBias: number;
  110282. /**
  110283. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  110284. */
  110285. get normalBias(): number;
  110286. /**
  110287. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  110288. */
  110289. set normalBias(normalBias: number);
  110290. protected _blurBoxOffset: number;
  110291. /**
  110292. * Gets the blur box offset: offset applied during the blur pass.
  110293. * Only useful if useKernelBlur = false
  110294. */
  110295. get blurBoxOffset(): number;
  110296. /**
  110297. * Sets the blur box offset: offset applied during the blur pass.
  110298. * Only useful if useKernelBlur = false
  110299. */
  110300. set blurBoxOffset(value: number);
  110301. protected _blurScale: number;
  110302. /**
  110303. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  110304. * 2 means half of the size.
  110305. */
  110306. get blurScale(): number;
  110307. /**
  110308. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  110309. * 2 means half of the size.
  110310. */
  110311. set blurScale(value: number);
  110312. protected _blurKernel: number;
  110313. /**
  110314. * Gets the blur kernel: kernel size of the blur pass.
  110315. * Only useful if useKernelBlur = true
  110316. */
  110317. get blurKernel(): number;
  110318. /**
  110319. * Sets the blur kernel: kernel size of the blur pass.
  110320. * Only useful if useKernelBlur = true
  110321. */
  110322. set blurKernel(value: number);
  110323. protected _useKernelBlur: boolean;
  110324. /**
  110325. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  110326. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  110327. */
  110328. get useKernelBlur(): boolean;
  110329. /**
  110330. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  110331. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  110332. */
  110333. set useKernelBlur(value: boolean);
  110334. protected _depthScale: number;
  110335. /**
  110336. * Gets the depth scale used in ESM mode.
  110337. */
  110338. get depthScale(): number;
  110339. /**
  110340. * Sets the depth scale used in ESM mode.
  110341. * This can override the scale stored on the light.
  110342. */
  110343. set depthScale(value: number);
  110344. protected _validateFilter(filter: number): number;
  110345. protected _filter: number;
  110346. /**
  110347. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  110348. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  110349. */
  110350. get filter(): number;
  110351. /**
  110352. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  110353. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  110354. */
  110355. set filter(value: number);
  110356. /**
  110357. * Gets if the current filter is set to Poisson Sampling.
  110358. */
  110359. get usePoissonSampling(): boolean;
  110360. /**
  110361. * Sets the current filter to Poisson Sampling.
  110362. */
  110363. set usePoissonSampling(value: boolean);
  110364. /**
  110365. * Gets if the current filter is set to ESM.
  110366. */
  110367. get useExponentialShadowMap(): boolean;
  110368. /**
  110369. * Sets the current filter is to ESM.
  110370. */
  110371. set useExponentialShadowMap(value: boolean);
  110372. /**
  110373. * Gets if the current filter is set to filtered ESM.
  110374. */
  110375. get useBlurExponentialShadowMap(): boolean;
  110376. /**
  110377. * Gets if the current filter is set to filtered ESM.
  110378. */
  110379. set useBlurExponentialShadowMap(value: boolean);
  110380. /**
  110381. * Gets if the current filter is set to "close ESM" (using the inverse of the
  110382. * exponential to prevent steep falloff artifacts).
  110383. */
  110384. get useCloseExponentialShadowMap(): boolean;
  110385. /**
  110386. * Sets the current filter to "close ESM" (using the inverse of the
  110387. * exponential to prevent steep falloff artifacts).
  110388. */
  110389. set useCloseExponentialShadowMap(value: boolean);
  110390. /**
  110391. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  110392. * exponential to prevent steep falloff artifacts).
  110393. */
  110394. get useBlurCloseExponentialShadowMap(): boolean;
  110395. /**
  110396. * Sets the current filter to filtered "close ESM" (using the inverse of the
  110397. * exponential to prevent steep falloff artifacts).
  110398. */
  110399. set useBlurCloseExponentialShadowMap(value: boolean);
  110400. /**
  110401. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  110402. */
  110403. get usePercentageCloserFiltering(): boolean;
  110404. /**
  110405. * Sets the current filter to "PCF" (percentage closer filtering).
  110406. */
  110407. set usePercentageCloserFiltering(value: boolean);
  110408. protected _filteringQuality: number;
  110409. /**
  110410. * Gets the PCF or PCSS Quality.
  110411. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  110412. */
  110413. get filteringQuality(): number;
  110414. /**
  110415. * Sets the PCF or PCSS Quality.
  110416. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  110417. */
  110418. set filteringQuality(filteringQuality: number);
  110419. /**
  110420. * Gets if the current filter is set to "PCSS" (contact hardening).
  110421. */
  110422. get useContactHardeningShadow(): boolean;
  110423. /**
  110424. * Sets the current filter to "PCSS" (contact hardening).
  110425. */
  110426. set useContactHardeningShadow(value: boolean);
  110427. protected _contactHardeningLightSizeUVRatio: number;
  110428. /**
  110429. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  110430. * Using a ratio helps keeping shape stability independently of the map size.
  110431. *
  110432. * It does not account for the light projection as it was having too much
  110433. * instability during the light setup or during light position changes.
  110434. *
  110435. * Only valid if useContactHardeningShadow is true.
  110436. */
  110437. get contactHardeningLightSizeUVRatio(): number;
  110438. /**
  110439. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  110440. * Using a ratio helps keeping shape stability independently of the map size.
  110441. *
  110442. * It does not account for the light projection as it was having too much
  110443. * instability during the light setup or during light position changes.
  110444. *
  110445. * Only valid if useContactHardeningShadow is true.
  110446. */
  110447. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  110448. protected _darkness: number;
  110449. /** Gets or sets the actual darkness of a shadow */
  110450. get darkness(): number;
  110451. set darkness(value: number);
  110452. /**
  110453. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  110454. * 0 means strongest and 1 would means no shadow.
  110455. * @returns the darkness.
  110456. */
  110457. getDarkness(): number;
  110458. /**
  110459. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  110460. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  110461. * @returns the shadow generator allowing fluent coding.
  110462. */
  110463. setDarkness(darkness: number): ShadowGenerator;
  110464. protected _transparencyShadow: boolean;
  110465. /** Gets or sets the ability to have transparent shadow */
  110466. get transparencyShadow(): boolean;
  110467. set transparencyShadow(value: boolean);
  110468. /**
  110469. * Sets the ability to have transparent shadow (boolean).
  110470. * @param transparent True if transparent else False
  110471. * @returns the shadow generator allowing fluent coding
  110472. */
  110473. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  110474. /**
  110475. * Enables or disables shadows with varying strength based on the transparency
  110476. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  110477. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  110478. * mesh.visibility * alphaTexture.a
  110479. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  110480. */
  110481. enableSoftTransparentShadow: boolean;
  110482. protected _shadowMap: Nullable<RenderTargetTexture>;
  110483. protected _shadowMap2: Nullable<RenderTargetTexture>;
  110484. /**
  110485. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  110486. * @returns The render target texture if present otherwise, null
  110487. */
  110488. getShadowMap(): Nullable<RenderTargetTexture>;
  110489. /**
  110490. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  110491. * @returns The render target texture if the shadow map is present otherwise, null
  110492. */
  110493. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  110494. /**
  110495. * Gets the class name of that object
  110496. * @returns "ShadowGenerator"
  110497. */
  110498. getClassName(): string;
  110499. /**
  110500. * Helper function to add a mesh and its descendants to the list of shadow casters.
  110501. * @param mesh Mesh to add
  110502. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  110503. * @returns the Shadow Generator itself
  110504. */
  110505. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  110506. /**
  110507. * Helper function to remove a mesh and its descendants from the list of shadow casters
  110508. * @param mesh Mesh to remove
  110509. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  110510. * @returns the Shadow Generator itself
  110511. */
  110512. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  110513. /**
  110514. * Controls the extent to which the shadows fade out at the edge of the frustum
  110515. */
  110516. frustumEdgeFalloff: number;
  110517. protected _light: IShadowLight;
  110518. /**
  110519. * Returns the associated light object.
  110520. * @returns the light generating the shadow
  110521. */
  110522. getLight(): IShadowLight;
  110523. /**
  110524. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  110525. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  110526. * It might on the other hand introduce peter panning.
  110527. */
  110528. forceBackFacesOnly: boolean;
  110529. protected _scene: Scene;
  110530. protected _lightDirection: Vector3;
  110531. protected _effect: Effect;
  110532. protected _viewMatrix: Matrix;
  110533. protected _projectionMatrix: Matrix;
  110534. protected _transformMatrix: Matrix;
  110535. protected _cachedPosition: Vector3;
  110536. protected _cachedDirection: Vector3;
  110537. protected _cachedDefines: string;
  110538. protected _currentRenderID: number;
  110539. protected _boxBlurPostprocess: Nullable<PostProcess>;
  110540. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  110541. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  110542. protected _blurPostProcesses: PostProcess[];
  110543. protected _mapSize: number;
  110544. protected _currentFaceIndex: number;
  110545. protected _currentFaceIndexCache: number;
  110546. protected _textureType: number;
  110547. protected _defaultTextureMatrix: Matrix;
  110548. protected _storedUniqueId: Nullable<number>;
  110549. /** @hidden */
  110550. static _SceneComponentInitialization: (scene: Scene) => void;
  110551. /**
  110552. * Gets or sets the size of the texture what stores the shadows
  110553. */
  110554. get mapSize(): number;
  110555. set mapSize(size: number);
  110556. /**
  110557. * Creates a ShadowGenerator object.
  110558. * A ShadowGenerator is the required tool to use the shadows.
  110559. * Each light casting shadows needs to use its own ShadowGenerator.
  110560. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  110561. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  110562. * @param light The light object generating the shadows.
  110563. * @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.
  110564. */
  110565. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  110566. protected _initializeGenerator(): void;
  110567. protected _createTargetRenderTexture(): void;
  110568. protected _initializeShadowMap(): void;
  110569. protected _initializeBlurRTTAndPostProcesses(): void;
  110570. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  110571. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  110572. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  110573. protected _applyFilterValues(): void;
  110574. /**
  110575. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110576. * @param onCompiled Callback triggered at the and of the effects compilation
  110577. * @param options Sets of optional options forcing the compilation with different modes
  110578. */
  110579. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  110580. useInstances: boolean;
  110581. }>): void;
  110582. /**
  110583. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110584. * @param options Sets of optional options forcing the compilation with different modes
  110585. * @returns A promise that resolves when the compilation completes
  110586. */
  110587. forceCompilationAsync(options?: Partial<{
  110588. useInstances: boolean;
  110589. }>): Promise<void>;
  110590. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  110591. private _prepareShadowDefines;
  110592. /**
  110593. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  110594. * @param subMesh The submesh we want to render in the shadow map
  110595. * @param useInstances Defines wether will draw in the map using instances
  110596. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  110597. * @returns true if ready otherwise, false
  110598. */
  110599. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  110600. /**
  110601. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  110602. * @param defines Defines of the material we want to update
  110603. * @param lightIndex Index of the light in the enabled light list of the material
  110604. */
  110605. prepareDefines(defines: any, lightIndex: number): void;
  110606. /**
  110607. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  110608. * defined in the generator but impacting the effect).
  110609. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  110610. * @param effect The effect we are binfing the information for
  110611. */
  110612. bindShadowLight(lightIndex: string, effect: Effect): void;
  110613. /**
  110614. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  110615. * (eq to shadow prjection matrix * light transform matrix)
  110616. * @returns The transform matrix used to create the shadow map
  110617. */
  110618. getTransformMatrix(): Matrix;
  110619. /**
  110620. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  110621. * Cube and 2D textures for instance.
  110622. */
  110623. recreateShadowMap(): void;
  110624. protected _disposeBlurPostProcesses(): void;
  110625. protected _disposeRTTandPostProcesses(): void;
  110626. /**
  110627. * Disposes the ShadowGenerator.
  110628. * Returns nothing.
  110629. */
  110630. dispose(): void;
  110631. /**
  110632. * Serializes the shadow generator setup to a json object.
  110633. * @returns The serialized JSON object
  110634. */
  110635. serialize(): any;
  110636. /**
  110637. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  110638. * @param parsedShadowGenerator The JSON object to parse
  110639. * @param scene The scene to create the shadow map for
  110640. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  110641. * @returns The parsed shadow generator
  110642. */
  110643. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  110644. }
  110645. }
  110646. declare module BABYLON {
  110647. /**
  110648. * Options to be used when creating a shadow depth material
  110649. */
  110650. export interface IIOptionShadowDepthMaterial {
  110651. /** Variables in the vertex shader code that need to have their names remapped.
  110652. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  110653. * "var_name" should be either: worldPos or vNormalW
  110654. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  110655. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  110656. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  110657. */
  110658. remappedVariables?: string[];
  110659. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  110660. standalone?: boolean;
  110661. }
  110662. /**
  110663. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  110664. */
  110665. export class ShadowDepthWrapper {
  110666. private _scene;
  110667. private _options?;
  110668. private _baseMaterial;
  110669. private _onEffectCreatedObserver;
  110670. private _subMeshToEffect;
  110671. private _subMeshToDepthEffect;
  110672. private _meshes;
  110673. /** @hidden */
  110674. _matriceNames: any;
  110675. /** Gets the standalone status of the wrapper */
  110676. get standalone(): boolean;
  110677. /** Gets the base material the wrapper is built upon */
  110678. get baseMaterial(): Material;
  110679. /**
  110680. * Instantiate a new shadow depth wrapper.
  110681. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  110682. * generate the shadow depth map. For more information, please refer to the documentation:
  110683. * https://doc.babylonjs.com/babylon101/shadows
  110684. * @param baseMaterial Material to wrap
  110685. * @param scene Define the scene the material belongs to
  110686. * @param options Options used to create the wrapper
  110687. */
  110688. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  110689. /**
  110690. * Gets the effect to use to generate the depth map
  110691. * @param subMesh subMesh to get the effect for
  110692. * @param shadowGenerator shadow generator to get the effect for
  110693. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  110694. */
  110695. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  110696. /**
  110697. * Specifies that the submesh is ready to be used for depth rendering
  110698. * @param subMesh submesh to check
  110699. * @param defines the list of defines to take into account when checking the effect
  110700. * @param shadowGenerator combined with subMesh, it defines the effect to check
  110701. * @param useInstances specifies that instances should be used
  110702. * @returns a boolean indicating that the submesh is ready or not
  110703. */
  110704. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  110705. /**
  110706. * Disposes the resources
  110707. */
  110708. dispose(): void;
  110709. private _makeEffect;
  110710. }
  110711. }
  110712. declare module BABYLON {
  110713. /**
  110714. * Options for compiling materials.
  110715. */
  110716. export interface IMaterialCompilationOptions {
  110717. /**
  110718. * Defines whether clip planes are enabled.
  110719. */
  110720. clipPlane: boolean;
  110721. /**
  110722. * Defines whether instances are enabled.
  110723. */
  110724. useInstances: boolean;
  110725. }
  110726. /**
  110727. * Options passed when calling customShaderNameResolve
  110728. */
  110729. export interface ICustomShaderNameResolveOptions {
  110730. /**
  110731. * 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
  110732. */
  110733. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  110734. }
  110735. /**
  110736. * Base class for the main features of a material in Babylon.js
  110737. */
  110738. export class Material implements IAnimatable {
  110739. /**
  110740. * Returns the triangle fill mode
  110741. */
  110742. static readonly TriangleFillMode: number;
  110743. /**
  110744. * Returns the wireframe mode
  110745. */
  110746. static readonly WireFrameFillMode: number;
  110747. /**
  110748. * Returns the point fill mode
  110749. */
  110750. static readonly PointFillMode: number;
  110751. /**
  110752. * Returns the point list draw mode
  110753. */
  110754. static readonly PointListDrawMode: number;
  110755. /**
  110756. * Returns the line list draw mode
  110757. */
  110758. static readonly LineListDrawMode: number;
  110759. /**
  110760. * Returns the line loop draw mode
  110761. */
  110762. static readonly LineLoopDrawMode: number;
  110763. /**
  110764. * Returns the line strip draw mode
  110765. */
  110766. static readonly LineStripDrawMode: number;
  110767. /**
  110768. * Returns the triangle strip draw mode
  110769. */
  110770. static readonly TriangleStripDrawMode: number;
  110771. /**
  110772. * Returns the triangle fan draw mode
  110773. */
  110774. static readonly TriangleFanDrawMode: number;
  110775. /**
  110776. * Stores the clock-wise side orientation
  110777. */
  110778. static readonly ClockWiseSideOrientation: number;
  110779. /**
  110780. * Stores the counter clock-wise side orientation
  110781. */
  110782. static readonly CounterClockWiseSideOrientation: number;
  110783. /**
  110784. * The dirty texture flag value
  110785. */
  110786. static readonly TextureDirtyFlag: number;
  110787. /**
  110788. * The dirty light flag value
  110789. */
  110790. static readonly LightDirtyFlag: number;
  110791. /**
  110792. * The dirty fresnel flag value
  110793. */
  110794. static readonly FresnelDirtyFlag: number;
  110795. /**
  110796. * The dirty attribute flag value
  110797. */
  110798. static readonly AttributesDirtyFlag: number;
  110799. /**
  110800. * The dirty misc flag value
  110801. */
  110802. static readonly MiscDirtyFlag: number;
  110803. /**
  110804. * The dirty prepass flag value
  110805. */
  110806. static readonly PrePassDirtyFlag: number;
  110807. /**
  110808. * The all dirty flag value
  110809. */
  110810. static readonly AllDirtyFlag: number;
  110811. /**
  110812. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  110813. */
  110814. static readonly MATERIAL_OPAQUE: number;
  110815. /**
  110816. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  110817. */
  110818. static readonly MATERIAL_ALPHATEST: number;
  110819. /**
  110820. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110821. */
  110822. static readonly MATERIAL_ALPHABLEND: number;
  110823. /**
  110824. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110825. * They are also discarded below the alpha cutoff threshold to improve performances.
  110826. */
  110827. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  110828. /**
  110829. * The Whiteout method is used to blend normals.
  110830. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  110831. */
  110832. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  110833. /**
  110834. * The Reoriented Normal Mapping method is used to blend normals.
  110835. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  110836. */
  110837. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  110838. /**
  110839. * Custom callback helping to override the default shader used in the material.
  110840. */
  110841. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  110842. /**
  110843. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  110844. */
  110845. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  110846. /**
  110847. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  110848. * This means that the material can keep using a previous shader while a new one is being compiled.
  110849. * This is mostly used when shader parallel compilation is supported (true by default)
  110850. */
  110851. allowShaderHotSwapping: boolean;
  110852. /**
  110853. * The ID of the material
  110854. */
  110855. id: string;
  110856. /**
  110857. * Gets or sets the unique id of the material
  110858. */
  110859. uniqueId: number;
  110860. /**
  110861. * The name of the material
  110862. */
  110863. name: string;
  110864. /**
  110865. * Gets or sets user defined metadata
  110866. */
  110867. metadata: any;
  110868. /**
  110869. * For internal use only. Please do not use.
  110870. */
  110871. reservedDataStore: any;
  110872. /**
  110873. * Specifies if the ready state should be checked on each call
  110874. */
  110875. checkReadyOnEveryCall: boolean;
  110876. /**
  110877. * Specifies if the ready state should be checked once
  110878. */
  110879. checkReadyOnlyOnce: boolean;
  110880. /**
  110881. * The state of the material
  110882. */
  110883. state: string;
  110884. /**
  110885. * If the material can be rendered to several textures with MRT extension
  110886. */
  110887. get canRenderToMRT(): boolean;
  110888. /**
  110889. * The alpha value of the material
  110890. */
  110891. protected _alpha: number;
  110892. /**
  110893. * List of inspectable custom properties (used by the Inspector)
  110894. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110895. */
  110896. inspectableCustomProperties: IInspectable[];
  110897. /**
  110898. * Sets the alpha value of the material
  110899. */
  110900. set alpha(value: number);
  110901. /**
  110902. * Gets the alpha value of the material
  110903. */
  110904. get alpha(): number;
  110905. /**
  110906. * Specifies if back face culling is enabled
  110907. */
  110908. protected _backFaceCulling: boolean;
  110909. /**
  110910. * Sets the back-face culling state
  110911. */
  110912. set backFaceCulling(value: boolean);
  110913. /**
  110914. * Gets the back-face culling state
  110915. */
  110916. get backFaceCulling(): boolean;
  110917. /**
  110918. * Stores the value for side orientation
  110919. */
  110920. sideOrientation: number;
  110921. /**
  110922. * Callback triggered when the material is compiled
  110923. */
  110924. onCompiled: Nullable<(effect: Effect) => void>;
  110925. /**
  110926. * Callback triggered when an error occurs
  110927. */
  110928. onError: Nullable<(effect: Effect, errors: string) => void>;
  110929. /**
  110930. * Callback triggered to get the render target textures
  110931. */
  110932. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  110933. /**
  110934. * Gets a boolean indicating that current material needs to register RTT
  110935. */
  110936. get hasRenderTargetTextures(): boolean;
  110937. /**
  110938. * Specifies if the material should be serialized
  110939. */
  110940. doNotSerialize: boolean;
  110941. /**
  110942. * @hidden
  110943. */
  110944. _storeEffectOnSubMeshes: boolean;
  110945. /**
  110946. * Stores the animations for the material
  110947. */
  110948. animations: Nullable<Array<Animation>>;
  110949. /**
  110950. * An event triggered when the material is disposed
  110951. */
  110952. onDisposeObservable: Observable<Material>;
  110953. /**
  110954. * An observer which watches for dispose events
  110955. */
  110956. private _onDisposeObserver;
  110957. private _onUnBindObservable;
  110958. /**
  110959. * Called during a dispose event
  110960. */
  110961. set onDispose(callback: () => void);
  110962. private _onBindObservable;
  110963. /**
  110964. * An event triggered when the material is bound
  110965. */
  110966. get onBindObservable(): Observable<AbstractMesh>;
  110967. /**
  110968. * An observer which watches for bind events
  110969. */
  110970. private _onBindObserver;
  110971. /**
  110972. * Called during a bind event
  110973. */
  110974. set onBind(callback: (Mesh: AbstractMesh) => void);
  110975. /**
  110976. * An event triggered when the material is unbound
  110977. */
  110978. get onUnBindObservable(): Observable<Material>;
  110979. protected _onEffectCreatedObservable: Nullable<Observable<{
  110980. effect: Effect;
  110981. subMesh: Nullable<SubMesh>;
  110982. }>>;
  110983. /**
  110984. * An event triggered when the effect is (re)created
  110985. */
  110986. get onEffectCreatedObservable(): Observable<{
  110987. effect: Effect;
  110988. subMesh: Nullable<SubMesh>;
  110989. }>;
  110990. /**
  110991. * Stores the value of the alpha mode
  110992. */
  110993. private _alphaMode;
  110994. /**
  110995. * Sets the value of the alpha mode.
  110996. *
  110997. * | Value | Type | Description |
  110998. * | --- | --- | --- |
  110999. * | 0 | ALPHA_DISABLE | |
  111000. * | 1 | ALPHA_ADD | |
  111001. * | 2 | ALPHA_COMBINE | |
  111002. * | 3 | ALPHA_SUBTRACT | |
  111003. * | 4 | ALPHA_MULTIPLY | |
  111004. * | 5 | ALPHA_MAXIMIZED | |
  111005. * | 6 | ALPHA_ONEONE | |
  111006. * | 7 | ALPHA_PREMULTIPLIED | |
  111007. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  111008. * | 9 | ALPHA_INTERPOLATE | |
  111009. * | 10 | ALPHA_SCREENMODE | |
  111010. *
  111011. */
  111012. set alphaMode(value: number);
  111013. /**
  111014. * Gets the value of the alpha mode
  111015. */
  111016. get alphaMode(): number;
  111017. /**
  111018. * Stores the state of the need depth pre-pass value
  111019. */
  111020. private _needDepthPrePass;
  111021. /**
  111022. * Sets the need depth pre-pass value
  111023. */
  111024. set needDepthPrePass(value: boolean);
  111025. /**
  111026. * Gets the depth pre-pass value
  111027. */
  111028. get needDepthPrePass(): boolean;
  111029. /**
  111030. * Specifies if depth writing should be disabled
  111031. */
  111032. disableDepthWrite: boolean;
  111033. /**
  111034. * Specifies if color writing should be disabled
  111035. */
  111036. disableColorWrite: boolean;
  111037. /**
  111038. * Specifies if depth writing should be forced
  111039. */
  111040. forceDepthWrite: boolean;
  111041. /**
  111042. * Specifies the depth function that should be used. 0 means the default engine function
  111043. */
  111044. depthFunction: number;
  111045. /**
  111046. * Specifies if there should be a separate pass for culling
  111047. */
  111048. separateCullingPass: boolean;
  111049. /**
  111050. * Stores the state specifing if fog should be enabled
  111051. */
  111052. private _fogEnabled;
  111053. /**
  111054. * Sets the state for enabling fog
  111055. */
  111056. set fogEnabled(value: boolean);
  111057. /**
  111058. * Gets the value of the fog enabled state
  111059. */
  111060. get fogEnabled(): boolean;
  111061. /**
  111062. * Stores the size of points
  111063. */
  111064. pointSize: number;
  111065. /**
  111066. * Stores the z offset value
  111067. */
  111068. zOffset: number;
  111069. get wireframe(): boolean;
  111070. /**
  111071. * Sets the state of wireframe mode
  111072. */
  111073. set wireframe(value: boolean);
  111074. /**
  111075. * Gets the value specifying if point clouds are enabled
  111076. */
  111077. get pointsCloud(): boolean;
  111078. /**
  111079. * Sets the state of point cloud mode
  111080. */
  111081. set pointsCloud(value: boolean);
  111082. /**
  111083. * Gets the material fill mode
  111084. */
  111085. get fillMode(): number;
  111086. /**
  111087. * Sets the material fill mode
  111088. */
  111089. set fillMode(value: number);
  111090. /**
  111091. * @hidden
  111092. * Stores the effects for the material
  111093. */
  111094. _effect: Nullable<Effect>;
  111095. /**
  111096. * Specifies if uniform buffers should be used
  111097. */
  111098. private _useUBO;
  111099. /**
  111100. * Stores a reference to the scene
  111101. */
  111102. private _scene;
  111103. /**
  111104. * Stores the fill mode state
  111105. */
  111106. private _fillMode;
  111107. /**
  111108. * Specifies if the depth write state should be cached
  111109. */
  111110. private _cachedDepthWriteState;
  111111. /**
  111112. * Specifies if the color write state should be cached
  111113. */
  111114. private _cachedColorWriteState;
  111115. /**
  111116. * Specifies if the depth function state should be cached
  111117. */
  111118. private _cachedDepthFunctionState;
  111119. /**
  111120. * Stores the uniform buffer
  111121. */
  111122. protected _uniformBuffer: UniformBuffer;
  111123. /** @hidden */
  111124. _indexInSceneMaterialArray: number;
  111125. /** @hidden */
  111126. meshMap: Nullable<{
  111127. [id: string]: AbstractMesh | undefined;
  111128. }>;
  111129. /**
  111130. * Creates a material instance
  111131. * @param name defines the name of the material
  111132. * @param scene defines the scene to reference
  111133. * @param doNotAdd specifies if the material should be added to the scene
  111134. */
  111135. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  111136. /**
  111137. * Returns a string representation of the current material
  111138. * @param fullDetails defines a boolean indicating which levels of logging is desired
  111139. * @returns a string with material information
  111140. */
  111141. toString(fullDetails?: boolean): string;
  111142. /**
  111143. * Gets the class name of the material
  111144. * @returns a string with the class name of the material
  111145. */
  111146. getClassName(): string;
  111147. /**
  111148. * Specifies if updates for the material been locked
  111149. */
  111150. get isFrozen(): boolean;
  111151. /**
  111152. * Locks updates for the material
  111153. */
  111154. freeze(): void;
  111155. /**
  111156. * Unlocks updates for the material
  111157. */
  111158. unfreeze(): void;
  111159. /**
  111160. * Specifies if the material is ready to be used
  111161. * @param mesh defines the mesh to check
  111162. * @param useInstances specifies if instances should be used
  111163. * @returns a boolean indicating if the material is ready to be used
  111164. */
  111165. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  111166. /**
  111167. * Specifies that the submesh is ready to be used
  111168. * @param mesh defines the mesh to check
  111169. * @param subMesh defines which submesh to check
  111170. * @param useInstances specifies that instances should be used
  111171. * @returns a boolean indicating that the submesh is ready or not
  111172. */
  111173. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111174. /**
  111175. * Returns the material effect
  111176. * @returns the effect associated with the material
  111177. */
  111178. getEffect(): Nullable<Effect>;
  111179. /**
  111180. * Returns the current scene
  111181. * @returns a Scene
  111182. */
  111183. getScene(): Scene;
  111184. /**
  111185. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  111186. */
  111187. protected _forceAlphaTest: boolean;
  111188. /**
  111189. * The transparency mode of the material.
  111190. */
  111191. protected _transparencyMode: Nullable<number>;
  111192. /**
  111193. * Gets the current transparency mode.
  111194. */
  111195. get transparencyMode(): Nullable<number>;
  111196. /**
  111197. * Sets the transparency mode of the material.
  111198. *
  111199. * | Value | Type | Description |
  111200. * | ----- | ----------------------------------- | ----------- |
  111201. * | 0 | OPAQUE | |
  111202. * | 1 | ALPHATEST | |
  111203. * | 2 | ALPHABLEND | |
  111204. * | 3 | ALPHATESTANDBLEND | |
  111205. *
  111206. */
  111207. set transparencyMode(value: Nullable<number>);
  111208. /**
  111209. * Returns true if alpha blending should be disabled.
  111210. */
  111211. protected get _disableAlphaBlending(): boolean;
  111212. /**
  111213. * Specifies whether or not this material should be rendered in alpha blend mode.
  111214. * @returns a boolean specifying if alpha blending is needed
  111215. */
  111216. needAlphaBlending(): boolean;
  111217. /**
  111218. * Specifies if the mesh will require alpha blending
  111219. * @param mesh defines the mesh to check
  111220. * @returns a boolean specifying if alpha blending is needed for the mesh
  111221. */
  111222. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  111223. /**
  111224. * Specifies whether or not this material should be rendered in alpha test mode.
  111225. * @returns a boolean specifying if an alpha test is needed.
  111226. */
  111227. needAlphaTesting(): boolean;
  111228. /**
  111229. * Specifies if material alpha testing should be turned on for the mesh
  111230. * @param mesh defines the mesh to check
  111231. */
  111232. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  111233. /**
  111234. * Gets the texture used for the alpha test
  111235. * @returns the texture to use for alpha testing
  111236. */
  111237. getAlphaTestTexture(): Nullable<BaseTexture>;
  111238. /**
  111239. * Marks the material to indicate that it needs to be re-calculated
  111240. */
  111241. markDirty(): void;
  111242. /** @hidden */
  111243. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  111244. /**
  111245. * Binds the material to the mesh
  111246. * @param world defines the world transformation matrix
  111247. * @param mesh defines the mesh to bind the material to
  111248. */
  111249. bind(world: Matrix, mesh?: Mesh): void;
  111250. /**
  111251. * Binds the submesh to the material
  111252. * @param world defines the world transformation matrix
  111253. * @param mesh defines the mesh containing the submesh
  111254. * @param subMesh defines the submesh to bind the material to
  111255. */
  111256. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111257. /**
  111258. * Binds the world matrix to the material
  111259. * @param world defines the world transformation matrix
  111260. */
  111261. bindOnlyWorldMatrix(world: Matrix): void;
  111262. /**
  111263. * Binds the scene's uniform buffer to the effect.
  111264. * @param effect defines the effect to bind to the scene uniform buffer
  111265. * @param sceneUbo defines the uniform buffer storing scene data
  111266. */
  111267. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  111268. /**
  111269. * Binds the view matrix to the effect
  111270. * @param effect defines the effect to bind the view matrix to
  111271. */
  111272. bindView(effect: Effect): void;
  111273. /**
  111274. * Binds the view projection matrix to the effect
  111275. * @param effect defines the effect to bind the view projection matrix to
  111276. */
  111277. bindViewProjection(effect: Effect): void;
  111278. /**
  111279. * Processes to execute after binding the material to a mesh
  111280. * @param mesh defines the rendered mesh
  111281. */
  111282. protected _afterBind(mesh?: Mesh): void;
  111283. /**
  111284. * Unbinds the material from the mesh
  111285. */
  111286. unbind(): void;
  111287. /**
  111288. * Gets the active textures from the material
  111289. * @returns an array of textures
  111290. */
  111291. getActiveTextures(): BaseTexture[];
  111292. /**
  111293. * Specifies if the material uses a texture
  111294. * @param texture defines the texture to check against the material
  111295. * @returns a boolean specifying if the material uses the texture
  111296. */
  111297. hasTexture(texture: BaseTexture): boolean;
  111298. /**
  111299. * Makes a duplicate of the material, and gives it a new name
  111300. * @param name defines the new name for the duplicated material
  111301. * @returns the cloned material
  111302. */
  111303. clone(name: string): Nullable<Material>;
  111304. /**
  111305. * Gets the meshes bound to the material
  111306. * @returns an array of meshes bound to the material
  111307. */
  111308. getBindedMeshes(): AbstractMesh[];
  111309. /**
  111310. * Force shader compilation
  111311. * @param mesh defines the mesh associated with this material
  111312. * @param onCompiled defines a function to execute once the material is compiled
  111313. * @param options defines the options to configure the compilation
  111314. * @param onError defines a function to execute if the material fails compiling
  111315. */
  111316. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  111317. /**
  111318. * Force shader compilation
  111319. * @param mesh defines the mesh that will use this material
  111320. * @param options defines additional options for compiling the shaders
  111321. * @returns a promise that resolves when the compilation completes
  111322. */
  111323. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  111324. private static readonly _AllDirtyCallBack;
  111325. private static readonly _ImageProcessingDirtyCallBack;
  111326. private static readonly _TextureDirtyCallBack;
  111327. private static readonly _FresnelDirtyCallBack;
  111328. private static readonly _MiscDirtyCallBack;
  111329. private static readonly _PrePassDirtyCallBack;
  111330. private static readonly _LightsDirtyCallBack;
  111331. private static readonly _AttributeDirtyCallBack;
  111332. private static _FresnelAndMiscDirtyCallBack;
  111333. private static _TextureAndMiscDirtyCallBack;
  111334. private static readonly _DirtyCallbackArray;
  111335. private static readonly _RunDirtyCallBacks;
  111336. /**
  111337. * Marks a define in the material to indicate that it needs to be re-computed
  111338. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  111339. */
  111340. markAsDirty(flag: number): void;
  111341. /**
  111342. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  111343. * @param func defines a function which checks material defines against the submeshes
  111344. */
  111345. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  111346. /**
  111347. * Indicates that the scene should check if the rendering now needs a prepass
  111348. */
  111349. protected _markScenePrePassDirty(): void;
  111350. /**
  111351. * Indicates that we need to re-calculated for all submeshes
  111352. */
  111353. protected _markAllSubMeshesAsAllDirty(): void;
  111354. /**
  111355. * Indicates that image processing needs to be re-calculated for all submeshes
  111356. */
  111357. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  111358. /**
  111359. * Indicates that textures need to be re-calculated for all submeshes
  111360. */
  111361. protected _markAllSubMeshesAsTexturesDirty(): void;
  111362. /**
  111363. * Indicates that fresnel needs to be re-calculated for all submeshes
  111364. */
  111365. protected _markAllSubMeshesAsFresnelDirty(): void;
  111366. /**
  111367. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  111368. */
  111369. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  111370. /**
  111371. * Indicates that lights need to be re-calculated for all submeshes
  111372. */
  111373. protected _markAllSubMeshesAsLightsDirty(): void;
  111374. /**
  111375. * Indicates that attributes need to be re-calculated for all submeshes
  111376. */
  111377. protected _markAllSubMeshesAsAttributesDirty(): void;
  111378. /**
  111379. * Indicates that misc needs to be re-calculated for all submeshes
  111380. */
  111381. protected _markAllSubMeshesAsMiscDirty(): void;
  111382. /**
  111383. * Indicates that prepass needs to be re-calculated for all submeshes
  111384. */
  111385. protected _markAllSubMeshesAsPrePassDirty(): void;
  111386. /**
  111387. * Indicates that textures and misc need to be re-calculated for all submeshes
  111388. */
  111389. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  111390. /**
  111391. * Sets the required values to the prepass renderer.
  111392. * @param prePassRenderer defines the prepass renderer to setup.
  111393. * @returns true if the pre pass is needed.
  111394. */
  111395. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  111396. /**
  111397. * Disposes the material
  111398. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  111399. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  111400. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  111401. */
  111402. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  111403. /** @hidden */
  111404. private releaseVertexArrayObject;
  111405. /**
  111406. * Serializes this material
  111407. * @returns the serialized material object
  111408. */
  111409. serialize(): any;
  111410. /**
  111411. * Creates a material from parsed material data
  111412. * @param parsedMaterial defines parsed material data
  111413. * @param scene defines the hosting scene
  111414. * @param rootUrl defines the root URL to use to load textures
  111415. * @returns a new material
  111416. */
  111417. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  111418. }
  111419. }
  111420. declare module BABYLON {
  111421. /**
  111422. * A multi-material is used to apply different materials to different parts of the same object without the need of
  111423. * separate meshes. This can be use to improve performances.
  111424. * @see https://doc.babylonjs.com/how_to/multi_materials
  111425. */
  111426. export class MultiMaterial extends Material {
  111427. private _subMaterials;
  111428. /**
  111429. * Gets or Sets the list of Materials used within the multi material.
  111430. * They need to be ordered according to the submeshes order in the associated mesh
  111431. */
  111432. get subMaterials(): Nullable<Material>[];
  111433. set subMaterials(value: Nullable<Material>[]);
  111434. /**
  111435. * Function used to align with Node.getChildren()
  111436. * @returns the list of Materials used within the multi material
  111437. */
  111438. getChildren(): Nullable<Material>[];
  111439. /**
  111440. * Instantiates a new Multi Material
  111441. * A multi-material is used to apply different materials to different parts of the same object without the need of
  111442. * separate meshes. This can be use to improve performances.
  111443. * @see https://doc.babylonjs.com/how_to/multi_materials
  111444. * @param name Define the name in the scene
  111445. * @param scene Define the scene the material belongs to
  111446. */
  111447. constructor(name: string, scene: Scene);
  111448. private _hookArray;
  111449. /**
  111450. * Get one of the submaterial by its index in the submaterials array
  111451. * @param index The index to look the sub material at
  111452. * @returns The Material if the index has been defined
  111453. */
  111454. getSubMaterial(index: number): Nullable<Material>;
  111455. /**
  111456. * Get the list of active textures for the whole sub materials list.
  111457. * @returns All the textures that will be used during the rendering
  111458. */
  111459. getActiveTextures(): BaseTexture[];
  111460. /**
  111461. * Gets the current class name of the material e.g. "MultiMaterial"
  111462. * Mainly use in serialization.
  111463. * @returns the class name
  111464. */
  111465. getClassName(): string;
  111466. /**
  111467. * Checks if the material is ready to render the requested sub mesh
  111468. * @param mesh Define the mesh the submesh belongs to
  111469. * @param subMesh Define the sub mesh to look readyness for
  111470. * @param useInstances Define whether or not the material is used with instances
  111471. * @returns true if ready, otherwise false
  111472. */
  111473. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111474. /**
  111475. * Clones the current material and its related sub materials
  111476. * @param name Define the name of the newly cloned material
  111477. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  111478. * @returns the cloned material
  111479. */
  111480. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  111481. /**
  111482. * Serializes the materials into a JSON representation.
  111483. * @returns the JSON representation
  111484. */
  111485. serialize(): any;
  111486. /**
  111487. * Dispose the material and release its associated resources
  111488. * @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)
  111489. * @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)
  111490. * @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)
  111491. */
  111492. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  111493. /**
  111494. * Creates a MultiMaterial from parsed MultiMaterial data.
  111495. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  111496. * @param scene defines the hosting scene
  111497. * @returns a new MultiMaterial
  111498. */
  111499. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  111500. }
  111501. }
  111502. declare module BABYLON {
  111503. /**
  111504. * Defines a subdivision inside a mesh
  111505. */
  111506. export class SubMesh implements ICullable {
  111507. /** the material index to use */
  111508. materialIndex: number;
  111509. /** vertex index start */
  111510. verticesStart: number;
  111511. /** vertices count */
  111512. verticesCount: number;
  111513. /** index start */
  111514. indexStart: number;
  111515. /** indices count */
  111516. indexCount: number;
  111517. /** @hidden */
  111518. _materialDefines: Nullable<MaterialDefines>;
  111519. /** @hidden */
  111520. _materialEffect: Nullable<Effect>;
  111521. /** @hidden */
  111522. _effectOverride: Nullable<Effect>;
  111523. /**
  111524. * Gets material defines used by the effect associated to the sub mesh
  111525. */
  111526. get materialDefines(): Nullable<MaterialDefines>;
  111527. /**
  111528. * Sets material defines used by the effect associated to the sub mesh
  111529. */
  111530. set materialDefines(defines: Nullable<MaterialDefines>);
  111531. /**
  111532. * Gets associated effect
  111533. */
  111534. get effect(): Nullable<Effect>;
  111535. /**
  111536. * Sets associated effect (effect used to render this submesh)
  111537. * @param effect defines the effect to associate with
  111538. * @param defines defines the set of defines used to compile this effect
  111539. */
  111540. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  111541. /** @hidden */
  111542. _linesIndexCount: number;
  111543. private _mesh;
  111544. private _renderingMesh;
  111545. private _boundingInfo;
  111546. private _linesIndexBuffer;
  111547. /** @hidden */
  111548. _lastColliderWorldVertices: Nullable<Vector3[]>;
  111549. /** @hidden */
  111550. _trianglePlanes: Plane[];
  111551. /** @hidden */
  111552. _lastColliderTransformMatrix: Nullable<Matrix>;
  111553. /** @hidden */
  111554. _renderId: number;
  111555. /** @hidden */
  111556. _alphaIndex: number;
  111557. /** @hidden */
  111558. _distanceToCamera: number;
  111559. /** @hidden */
  111560. _id: number;
  111561. private _currentMaterial;
  111562. /**
  111563. * Add a new submesh to a mesh
  111564. * @param materialIndex defines the material index to use
  111565. * @param verticesStart defines vertex index start
  111566. * @param verticesCount defines vertices count
  111567. * @param indexStart defines index start
  111568. * @param indexCount defines indices count
  111569. * @param mesh defines the parent mesh
  111570. * @param renderingMesh defines an optional rendering mesh
  111571. * @param createBoundingBox defines if bounding box should be created for this submesh
  111572. * @returns the new submesh
  111573. */
  111574. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  111575. /**
  111576. * Creates a new submesh
  111577. * @param materialIndex defines the material index to use
  111578. * @param verticesStart defines vertex index start
  111579. * @param verticesCount defines vertices count
  111580. * @param indexStart defines index start
  111581. * @param indexCount defines indices count
  111582. * @param mesh defines the parent mesh
  111583. * @param renderingMesh defines an optional rendering mesh
  111584. * @param createBoundingBox defines if bounding box should be created for this submesh
  111585. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  111586. */
  111587. constructor(
  111588. /** the material index to use */
  111589. materialIndex: number,
  111590. /** vertex index start */
  111591. verticesStart: number,
  111592. /** vertices count */
  111593. verticesCount: number,
  111594. /** index start */
  111595. indexStart: number,
  111596. /** indices count */
  111597. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  111598. /**
  111599. * Returns true if this submesh covers the entire parent mesh
  111600. * @ignorenaming
  111601. */
  111602. get IsGlobal(): boolean;
  111603. /**
  111604. * Returns the submesh BoudingInfo object
  111605. * @returns current bounding info (or mesh's one if the submesh is global)
  111606. */
  111607. getBoundingInfo(): BoundingInfo;
  111608. /**
  111609. * Sets the submesh BoundingInfo
  111610. * @param boundingInfo defines the new bounding info to use
  111611. * @returns the SubMesh
  111612. */
  111613. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  111614. /**
  111615. * Returns the mesh of the current submesh
  111616. * @return the parent mesh
  111617. */
  111618. getMesh(): AbstractMesh;
  111619. /**
  111620. * Returns the rendering mesh of the submesh
  111621. * @returns the rendering mesh (could be different from parent mesh)
  111622. */
  111623. getRenderingMesh(): Mesh;
  111624. /**
  111625. * Returns the replacement mesh of the submesh
  111626. * @returns the replacement mesh (could be different from parent mesh)
  111627. */
  111628. getReplacementMesh(): Nullable<AbstractMesh>;
  111629. /**
  111630. * Returns the effective mesh of the submesh
  111631. * @returns the effective mesh (could be different from parent mesh)
  111632. */
  111633. getEffectiveMesh(): AbstractMesh;
  111634. /**
  111635. * Returns the submesh material
  111636. * @returns null or the current material
  111637. */
  111638. getMaterial(): Nullable<Material>;
  111639. private _IsMultiMaterial;
  111640. /**
  111641. * Sets a new updated BoundingInfo object to the submesh
  111642. * @param data defines an optional position array to use to determine the bounding info
  111643. * @returns the SubMesh
  111644. */
  111645. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  111646. /** @hidden */
  111647. _checkCollision(collider: Collider): boolean;
  111648. /**
  111649. * Updates the submesh BoundingInfo
  111650. * @param world defines the world matrix to use to update the bounding info
  111651. * @returns the submesh
  111652. */
  111653. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  111654. /**
  111655. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  111656. * @param frustumPlanes defines the frustum planes
  111657. * @returns true if the submesh is intersecting with the frustum
  111658. */
  111659. isInFrustum(frustumPlanes: Plane[]): boolean;
  111660. /**
  111661. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  111662. * @param frustumPlanes defines the frustum planes
  111663. * @returns true if the submesh is inside the frustum
  111664. */
  111665. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  111666. /**
  111667. * Renders the submesh
  111668. * @param enableAlphaMode defines if alpha needs to be used
  111669. * @returns the submesh
  111670. */
  111671. render(enableAlphaMode: boolean): SubMesh;
  111672. /**
  111673. * @hidden
  111674. */
  111675. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  111676. /**
  111677. * Checks if the submesh intersects with a ray
  111678. * @param ray defines the ray to test
  111679. * @returns true is the passed ray intersects the submesh bounding box
  111680. */
  111681. canIntersects(ray: Ray): boolean;
  111682. /**
  111683. * Intersects current submesh with a ray
  111684. * @param ray defines the ray to test
  111685. * @param positions defines mesh's positions array
  111686. * @param indices defines mesh's indices array
  111687. * @param fastCheck defines if the first intersection will be used (and not the closest)
  111688. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111689. * @returns intersection info or null if no intersection
  111690. */
  111691. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  111692. /** @hidden */
  111693. private _intersectLines;
  111694. /** @hidden */
  111695. private _intersectUnIndexedLines;
  111696. /** @hidden */
  111697. private _intersectTriangles;
  111698. /** @hidden */
  111699. private _intersectUnIndexedTriangles;
  111700. /** @hidden */
  111701. _rebuild(): void;
  111702. /**
  111703. * Creates a new submesh from the passed mesh
  111704. * @param newMesh defines the new hosting mesh
  111705. * @param newRenderingMesh defines an optional rendering mesh
  111706. * @returns the new submesh
  111707. */
  111708. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  111709. /**
  111710. * Release associated resources
  111711. */
  111712. dispose(): void;
  111713. /**
  111714. * Gets the class name
  111715. * @returns the string "SubMesh".
  111716. */
  111717. getClassName(): string;
  111718. /**
  111719. * Creates a new submesh from indices data
  111720. * @param materialIndex the index of the main mesh material
  111721. * @param startIndex the index where to start the copy in the mesh indices array
  111722. * @param indexCount the number of indices to copy then from the startIndex
  111723. * @param mesh the main mesh to create the submesh from
  111724. * @param renderingMesh the optional rendering mesh
  111725. * @returns a new submesh
  111726. */
  111727. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  111728. }
  111729. }
  111730. declare module BABYLON {
  111731. /**
  111732. * Class used to represent data loading progression
  111733. */
  111734. export class SceneLoaderFlags {
  111735. private static _ForceFullSceneLoadingForIncremental;
  111736. private static _ShowLoadingScreen;
  111737. private static _CleanBoneMatrixWeights;
  111738. private static _loggingLevel;
  111739. /**
  111740. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  111741. */
  111742. static get ForceFullSceneLoadingForIncremental(): boolean;
  111743. static set ForceFullSceneLoadingForIncremental(value: boolean);
  111744. /**
  111745. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  111746. */
  111747. static get ShowLoadingScreen(): boolean;
  111748. static set ShowLoadingScreen(value: boolean);
  111749. /**
  111750. * Defines the current logging level (while loading the scene)
  111751. * @ignorenaming
  111752. */
  111753. static get loggingLevel(): number;
  111754. static set loggingLevel(value: number);
  111755. /**
  111756. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  111757. */
  111758. static get CleanBoneMatrixWeights(): boolean;
  111759. static set CleanBoneMatrixWeights(value: boolean);
  111760. }
  111761. }
  111762. declare module BABYLON {
  111763. /**
  111764. * Class used to store geometry data (vertex buffers + index buffer)
  111765. */
  111766. export class Geometry implements IGetSetVerticesData {
  111767. /**
  111768. * Gets or sets the ID of the geometry
  111769. */
  111770. id: string;
  111771. /**
  111772. * Gets or sets the unique ID of the geometry
  111773. */
  111774. uniqueId: number;
  111775. /**
  111776. * Gets the delay loading state of the geometry (none by default which means not delayed)
  111777. */
  111778. delayLoadState: number;
  111779. /**
  111780. * Gets the file containing the data to load when running in delay load state
  111781. */
  111782. delayLoadingFile: Nullable<string>;
  111783. /**
  111784. * Callback called when the geometry is updated
  111785. */
  111786. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  111787. private _scene;
  111788. private _engine;
  111789. private _meshes;
  111790. private _totalVertices;
  111791. /** @hidden */
  111792. _indices: IndicesArray;
  111793. /** @hidden */
  111794. _vertexBuffers: {
  111795. [key: string]: VertexBuffer;
  111796. };
  111797. private _isDisposed;
  111798. private _extend;
  111799. private _boundingBias;
  111800. /** @hidden */
  111801. _delayInfo: Array<string>;
  111802. private _indexBuffer;
  111803. private _indexBufferIsUpdatable;
  111804. /** @hidden */
  111805. _boundingInfo: Nullable<BoundingInfo>;
  111806. /** @hidden */
  111807. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  111808. /** @hidden */
  111809. _softwareSkinningFrameId: number;
  111810. private _vertexArrayObjects;
  111811. private _updatable;
  111812. /** @hidden */
  111813. _positions: Nullable<Vector3[]>;
  111814. private _positionsCache;
  111815. /**
  111816. * 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
  111817. */
  111818. get boundingBias(): Vector2;
  111819. /**
  111820. * 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
  111821. */
  111822. set boundingBias(value: Vector2);
  111823. /**
  111824. * Static function used to attach a new empty geometry to a mesh
  111825. * @param mesh defines the mesh to attach the geometry to
  111826. * @returns the new Geometry
  111827. */
  111828. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  111829. /** Get the list of meshes using this geometry */
  111830. get meshes(): Mesh[];
  111831. /**
  111832. * 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
  111833. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  111834. */
  111835. useBoundingInfoFromGeometry: boolean;
  111836. /**
  111837. * Creates a new geometry
  111838. * @param id defines the unique ID
  111839. * @param scene defines the hosting scene
  111840. * @param vertexData defines the VertexData used to get geometry data
  111841. * @param updatable defines if geometry must be updatable (false by default)
  111842. * @param mesh defines the mesh that will be associated with the geometry
  111843. */
  111844. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  111845. /**
  111846. * Gets the current extend of the geometry
  111847. */
  111848. get extend(): {
  111849. minimum: Vector3;
  111850. maximum: Vector3;
  111851. };
  111852. /**
  111853. * Gets the hosting scene
  111854. * @returns the hosting Scene
  111855. */
  111856. getScene(): Scene;
  111857. /**
  111858. * Gets the hosting engine
  111859. * @returns the hosting Engine
  111860. */
  111861. getEngine(): Engine;
  111862. /**
  111863. * Defines if the geometry is ready to use
  111864. * @returns true if the geometry is ready to be used
  111865. */
  111866. isReady(): boolean;
  111867. /**
  111868. * Gets a value indicating that the geometry should not be serialized
  111869. */
  111870. get doNotSerialize(): boolean;
  111871. /** @hidden */
  111872. _rebuild(): void;
  111873. /**
  111874. * Affects all geometry data in one call
  111875. * @param vertexData defines the geometry data
  111876. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  111877. */
  111878. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  111879. /**
  111880. * Set specific vertex data
  111881. * @param kind defines the data kind (Position, normal, etc...)
  111882. * @param data defines the vertex data to use
  111883. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  111884. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  111885. */
  111886. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  111887. /**
  111888. * Removes a specific vertex data
  111889. * @param kind defines the data kind (Position, normal, etc...)
  111890. */
  111891. removeVerticesData(kind: string): void;
  111892. /**
  111893. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  111894. * @param buffer defines the vertex buffer to use
  111895. * @param totalVertices defines the total number of vertices for position kind (could be null)
  111896. */
  111897. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  111898. /**
  111899. * Update a specific vertex buffer
  111900. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  111901. * It will do nothing if the buffer is not updatable
  111902. * @param kind defines the data kind (Position, normal, etc...)
  111903. * @param data defines the data to use
  111904. * @param offset defines the offset in the target buffer where to store the data
  111905. * @param useBytes set to true if the offset is in bytes
  111906. */
  111907. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  111908. /**
  111909. * Update a specific vertex buffer
  111910. * This function will create a new buffer if the current one is not updatable
  111911. * @param kind defines the data kind (Position, normal, etc...)
  111912. * @param data defines the data to use
  111913. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  111914. */
  111915. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  111916. private _updateBoundingInfo;
  111917. /** @hidden */
  111918. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  111919. /**
  111920. * Gets total number of vertices
  111921. * @returns the total number of vertices
  111922. */
  111923. getTotalVertices(): number;
  111924. /**
  111925. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  111926. * @param kind defines the data kind (Position, normal, etc...)
  111927. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  111928. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111929. * @returns a float array containing vertex data
  111930. */
  111931. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  111932. /**
  111933. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  111934. * @param kind defines the data kind (Position, normal, etc...)
  111935. * @returns true if the vertex buffer with the specified kind is updatable
  111936. */
  111937. isVertexBufferUpdatable(kind: string): boolean;
  111938. /**
  111939. * Gets a specific vertex buffer
  111940. * @param kind defines the data kind (Position, normal, etc...)
  111941. * @returns a VertexBuffer
  111942. */
  111943. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  111944. /**
  111945. * Returns all vertex buffers
  111946. * @return an object holding all vertex buffers indexed by kind
  111947. */
  111948. getVertexBuffers(): Nullable<{
  111949. [key: string]: VertexBuffer;
  111950. }>;
  111951. /**
  111952. * Gets a boolean indicating if specific vertex buffer is present
  111953. * @param kind defines the data kind (Position, normal, etc...)
  111954. * @returns true if data is present
  111955. */
  111956. isVerticesDataPresent(kind: string): boolean;
  111957. /**
  111958. * Gets a list of all attached data kinds (Position, normal, etc...)
  111959. * @returns a list of string containing all kinds
  111960. */
  111961. getVerticesDataKinds(): string[];
  111962. /**
  111963. * Update index buffer
  111964. * @param indices defines the indices to store in the index buffer
  111965. * @param offset defines the offset in the target buffer where to store the data
  111966. * @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)
  111967. */
  111968. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  111969. /**
  111970. * Creates a new index buffer
  111971. * @param indices defines the indices to store in the index buffer
  111972. * @param totalVertices defines the total number of vertices (could be null)
  111973. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  111974. */
  111975. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  111976. /**
  111977. * Return the total number of indices
  111978. * @returns the total number of indices
  111979. */
  111980. getTotalIndices(): number;
  111981. /**
  111982. * Gets the index buffer array
  111983. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  111984. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111985. * @returns the index buffer array
  111986. */
  111987. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  111988. /**
  111989. * Gets the index buffer
  111990. * @return the index buffer
  111991. */
  111992. getIndexBuffer(): Nullable<DataBuffer>;
  111993. /** @hidden */
  111994. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  111995. /**
  111996. * Release the associated resources for a specific mesh
  111997. * @param mesh defines the source mesh
  111998. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  111999. */
  112000. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  112001. /**
  112002. * Apply current geometry to a given mesh
  112003. * @param mesh defines the mesh to apply geometry to
  112004. */
  112005. applyToMesh(mesh: Mesh): void;
  112006. private _updateExtend;
  112007. private _applyToMesh;
  112008. private notifyUpdate;
  112009. /**
  112010. * Load the geometry if it was flagged as delay loaded
  112011. * @param scene defines the hosting scene
  112012. * @param onLoaded defines a callback called when the geometry is loaded
  112013. */
  112014. load(scene: Scene, onLoaded?: () => void): void;
  112015. private _queueLoad;
  112016. /**
  112017. * Invert the geometry to move from a right handed system to a left handed one.
  112018. */
  112019. toLeftHanded(): void;
  112020. /** @hidden */
  112021. _resetPointsArrayCache(): void;
  112022. /** @hidden */
  112023. _generatePointsArray(): boolean;
  112024. /**
  112025. * Gets a value indicating if the geometry is disposed
  112026. * @returns true if the geometry was disposed
  112027. */
  112028. isDisposed(): boolean;
  112029. private _disposeVertexArrayObjects;
  112030. /**
  112031. * Free all associated resources
  112032. */
  112033. dispose(): void;
  112034. /**
  112035. * Clone the current geometry into a new geometry
  112036. * @param id defines the unique ID of the new geometry
  112037. * @returns a new geometry object
  112038. */
  112039. copy(id: string): Geometry;
  112040. /**
  112041. * Serialize the current geometry info (and not the vertices data) into a JSON object
  112042. * @return a JSON representation of the current geometry data (without the vertices data)
  112043. */
  112044. serialize(): any;
  112045. private toNumberArray;
  112046. /**
  112047. * Serialize all vertices data into a JSON oject
  112048. * @returns a JSON representation of the current geometry data
  112049. */
  112050. serializeVerticeData(): any;
  112051. /**
  112052. * Extracts a clone of a mesh geometry
  112053. * @param mesh defines the source mesh
  112054. * @param id defines the unique ID of the new geometry object
  112055. * @returns the new geometry object
  112056. */
  112057. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  112058. /**
  112059. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  112060. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  112061. * Be aware Math.random() could cause collisions, but:
  112062. * "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"
  112063. * @returns a string containing a new GUID
  112064. */
  112065. static RandomId(): string;
  112066. /** @hidden */
  112067. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  112068. private static _CleanMatricesWeights;
  112069. /**
  112070. * Create a new geometry from persisted data (Using .babylon file format)
  112071. * @param parsedVertexData defines the persisted data
  112072. * @param scene defines the hosting scene
  112073. * @param rootUrl defines the root url to use to load assets (like delayed data)
  112074. * @returns the new geometry object
  112075. */
  112076. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  112077. }
  112078. }
  112079. declare module BABYLON {
  112080. /**
  112081. * Defines a target to use with MorphTargetManager
  112082. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  112083. */
  112084. export class MorphTarget implements IAnimatable {
  112085. /** defines the name of the target */
  112086. name: string;
  112087. /**
  112088. * Gets or sets the list of animations
  112089. */
  112090. animations: Animation[];
  112091. private _scene;
  112092. private _positions;
  112093. private _normals;
  112094. private _tangents;
  112095. private _uvs;
  112096. private _influence;
  112097. private _uniqueId;
  112098. /**
  112099. * Observable raised when the influence changes
  112100. */
  112101. onInfluenceChanged: Observable<boolean>;
  112102. /** @hidden */
  112103. _onDataLayoutChanged: Observable<void>;
  112104. /**
  112105. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  112106. */
  112107. get influence(): number;
  112108. set influence(influence: number);
  112109. /**
  112110. * Gets or sets the id of the morph Target
  112111. */
  112112. id: string;
  112113. private _animationPropertiesOverride;
  112114. /**
  112115. * Gets or sets the animation properties override
  112116. */
  112117. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  112118. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  112119. /**
  112120. * Creates a new MorphTarget
  112121. * @param name defines the name of the target
  112122. * @param influence defines the influence to use
  112123. * @param scene defines the scene the morphtarget belongs to
  112124. */
  112125. constructor(
  112126. /** defines the name of the target */
  112127. name: string, influence?: number, scene?: Nullable<Scene>);
  112128. /**
  112129. * Gets the unique ID of this manager
  112130. */
  112131. get uniqueId(): number;
  112132. /**
  112133. * Gets a boolean defining if the target contains position data
  112134. */
  112135. get hasPositions(): boolean;
  112136. /**
  112137. * Gets a boolean defining if the target contains normal data
  112138. */
  112139. get hasNormals(): boolean;
  112140. /**
  112141. * Gets a boolean defining if the target contains tangent data
  112142. */
  112143. get hasTangents(): boolean;
  112144. /**
  112145. * Gets a boolean defining if the target contains texture coordinates data
  112146. */
  112147. get hasUVs(): boolean;
  112148. /**
  112149. * Affects position data to this target
  112150. * @param data defines the position data to use
  112151. */
  112152. setPositions(data: Nullable<FloatArray>): void;
  112153. /**
  112154. * Gets the position data stored in this target
  112155. * @returns a FloatArray containing the position data (or null if not present)
  112156. */
  112157. getPositions(): Nullable<FloatArray>;
  112158. /**
  112159. * Affects normal data to this target
  112160. * @param data defines the normal data to use
  112161. */
  112162. setNormals(data: Nullable<FloatArray>): void;
  112163. /**
  112164. * Gets the normal data stored in this target
  112165. * @returns a FloatArray containing the normal data (or null if not present)
  112166. */
  112167. getNormals(): Nullable<FloatArray>;
  112168. /**
  112169. * Affects tangent data to this target
  112170. * @param data defines the tangent data to use
  112171. */
  112172. setTangents(data: Nullable<FloatArray>): void;
  112173. /**
  112174. * Gets the tangent data stored in this target
  112175. * @returns a FloatArray containing the tangent data (or null if not present)
  112176. */
  112177. getTangents(): Nullable<FloatArray>;
  112178. /**
  112179. * Affects texture coordinates data to this target
  112180. * @param data defines the texture coordinates data to use
  112181. */
  112182. setUVs(data: Nullable<FloatArray>): void;
  112183. /**
  112184. * Gets the texture coordinates data stored in this target
  112185. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  112186. */
  112187. getUVs(): Nullable<FloatArray>;
  112188. /**
  112189. * Clone the current target
  112190. * @returns a new MorphTarget
  112191. */
  112192. clone(): MorphTarget;
  112193. /**
  112194. * Serializes the current target into a Serialization object
  112195. * @returns the serialized object
  112196. */
  112197. serialize(): any;
  112198. /**
  112199. * Returns the string "MorphTarget"
  112200. * @returns "MorphTarget"
  112201. */
  112202. getClassName(): string;
  112203. /**
  112204. * Creates a new target from serialized data
  112205. * @param serializationObject defines the serialized data to use
  112206. * @returns a new MorphTarget
  112207. */
  112208. static Parse(serializationObject: any): MorphTarget;
  112209. /**
  112210. * Creates a MorphTarget from mesh data
  112211. * @param mesh defines the source mesh
  112212. * @param name defines the name to use for the new target
  112213. * @param influence defines the influence to attach to the target
  112214. * @returns a new MorphTarget
  112215. */
  112216. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  112217. }
  112218. }
  112219. declare module BABYLON {
  112220. /**
  112221. * This class is used to deform meshes using morphing between different targets
  112222. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  112223. */
  112224. export class MorphTargetManager {
  112225. private _targets;
  112226. private _targetInfluenceChangedObservers;
  112227. private _targetDataLayoutChangedObservers;
  112228. private _activeTargets;
  112229. private _scene;
  112230. private _influences;
  112231. private _supportsNormals;
  112232. private _supportsTangents;
  112233. private _supportsUVs;
  112234. private _vertexCount;
  112235. private _uniqueId;
  112236. private _tempInfluences;
  112237. /**
  112238. * Gets or sets a boolean indicating if normals must be morphed
  112239. */
  112240. enableNormalMorphing: boolean;
  112241. /**
  112242. * Gets or sets a boolean indicating if tangents must be morphed
  112243. */
  112244. enableTangentMorphing: boolean;
  112245. /**
  112246. * Gets or sets a boolean indicating if UV must be morphed
  112247. */
  112248. enableUVMorphing: boolean;
  112249. /**
  112250. * Creates a new MorphTargetManager
  112251. * @param scene defines the current scene
  112252. */
  112253. constructor(scene?: Nullable<Scene>);
  112254. /**
  112255. * Gets the unique ID of this manager
  112256. */
  112257. get uniqueId(): number;
  112258. /**
  112259. * Gets the number of vertices handled by this manager
  112260. */
  112261. get vertexCount(): number;
  112262. /**
  112263. * Gets a boolean indicating if this manager supports morphing of normals
  112264. */
  112265. get supportsNormals(): boolean;
  112266. /**
  112267. * Gets a boolean indicating if this manager supports morphing of tangents
  112268. */
  112269. get supportsTangents(): boolean;
  112270. /**
  112271. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  112272. */
  112273. get supportsUVs(): boolean;
  112274. /**
  112275. * Gets the number of targets stored in this manager
  112276. */
  112277. get numTargets(): number;
  112278. /**
  112279. * Gets the number of influencers (ie. the number of targets with influences > 0)
  112280. */
  112281. get numInfluencers(): number;
  112282. /**
  112283. * Gets the list of influences (one per target)
  112284. */
  112285. get influences(): Float32Array;
  112286. /**
  112287. * Gets the active target at specified index. An active target is a target with an influence > 0
  112288. * @param index defines the index to check
  112289. * @returns the requested target
  112290. */
  112291. getActiveTarget(index: number): MorphTarget;
  112292. /**
  112293. * Gets the target at specified index
  112294. * @param index defines the index to check
  112295. * @returns the requested target
  112296. */
  112297. getTarget(index: number): MorphTarget;
  112298. /**
  112299. * Add a new target to this manager
  112300. * @param target defines the target to add
  112301. */
  112302. addTarget(target: MorphTarget): void;
  112303. /**
  112304. * Removes a target from the manager
  112305. * @param target defines the target to remove
  112306. */
  112307. removeTarget(target: MorphTarget): void;
  112308. /**
  112309. * Clone the current manager
  112310. * @returns a new MorphTargetManager
  112311. */
  112312. clone(): MorphTargetManager;
  112313. /**
  112314. * Serializes the current manager into a Serialization object
  112315. * @returns the serialized object
  112316. */
  112317. serialize(): any;
  112318. private _syncActiveTargets;
  112319. /**
  112320. * Syncrhonize the targets with all the meshes using this morph target manager
  112321. */
  112322. synchronize(): void;
  112323. /**
  112324. * Creates a new MorphTargetManager from serialized data
  112325. * @param serializationObject defines the serialized data
  112326. * @param scene defines the hosting scene
  112327. * @returns the new MorphTargetManager
  112328. */
  112329. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  112330. }
  112331. }
  112332. declare module BABYLON {
  112333. /**
  112334. * Class used to represent a specific level of detail of a mesh
  112335. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  112336. */
  112337. export class MeshLODLevel {
  112338. /** Defines the distance where this level should start being displayed */
  112339. distance: number;
  112340. /** Defines the mesh to use to render this level */
  112341. mesh: Nullable<Mesh>;
  112342. /**
  112343. * Creates a new LOD level
  112344. * @param distance defines the distance where this level should star being displayed
  112345. * @param mesh defines the mesh to use to render this level
  112346. */
  112347. constructor(
  112348. /** Defines the distance where this level should start being displayed */
  112349. distance: number,
  112350. /** Defines the mesh to use to render this level */
  112351. mesh: Nullable<Mesh>);
  112352. }
  112353. }
  112354. declare module BABYLON {
  112355. /**
  112356. * Helper class used to generate a canvas to manipulate images
  112357. */
  112358. export class CanvasGenerator {
  112359. /**
  112360. * Create a new canvas (or offscreen canvas depending on the context)
  112361. * @param width defines the expected width
  112362. * @param height defines the expected height
  112363. * @return a new canvas or offscreen canvas
  112364. */
  112365. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  112366. }
  112367. }
  112368. declare module BABYLON {
  112369. /**
  112370. * Mesh representing the gorund
  112371. */
  112372. export class GroundMesh extends Mesh {
  112373. /** If octree should be generated */
  112374. generateOctree: boolean;
  112375. private _heightQuads;
  112376. /** @hidden */
  112377. _subdivisionsX: number;
  112378. /** @hidden */
  112379. _subdivisionsY: number;
  112380. /** @hidden */
  112381. _width: number;
  112382. /** @hidden */
  112383. _height: number;
  112384. /** @hidden */
  112385. _minX: number;
  112386. /** @hidden */
  112387. _maxX: number;
  112388. /** @hidden */
  112389. _minZ: number;
  112390. /** @hidden */
  112391. _maxZ: number;
  112392. constructor(name: string, scene: Scene);
  112393. /**
  112394. * "GroundMesh"
  112395. * @returns "GroundMesh"
  112396. */
  112397. getClassName(): string;
  112398. /**
  112399. * The minimum of x and y subdivisions
  112400. */
  112401. get subdivisions(): number;
  112402. /**
  112403. * X subdivisions
  112404. */
  112405. get subdivisionsX(): number;
  112406. /**
  112407. * Y subdivisions
  112408. */
  112409. get subdivisionsY(): number;
  112410. /**
  112411. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  112412. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  112413. * @param chunksCount the number of subdivisions for x and y
  112414. * @param octreeBlocksSize (Default: 32)
  112415. */
  112416. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  112417. /**
  112418. * Returns a height (y) value in the Worl system :
  112419. * the ground altitude at the coordinates (x, z) expressed in the World system.
  112420. * @param x x coordinate
  112421. * @param z z coordinate
  112422. * @returns the ground y position if (x, z) are outside the ground surface.
  112423. */
  112424. getHeightAtCoordinates(x: number, z: number): number;
  112425. /**
  112426. * Returns a normalized vector (Vector3) orthogonal to the ground
  112427. * at the ground coordinates (x, z) expressed in the World system.
  112428. * @param x x coordinate
  112429. * @param z z coordinate
  112430. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  112431. */
  112432. getNormalAtCoordinates(x: number, z: number): Vector3;
  112433. /**
  112434. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  112435. * at the ground coordinates (x, z) expressed in the World system.
  112436. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  112437. * @param x x coordinate
  112438. * @param z z coordinate
  112439. * @param ref vector to store the result
  112440. * @returns the GroundMesh.
  112441. */
  112442. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  112443. /**
  112444. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  112445. * if the ground has been updated.
  112446. * This can be used in the render loop.
  112447. * @returns the GroundMesh.
  112448. */
  112449. updateCoordinateHeights(): GroundMesh;
  112450. private _getFacetAt;
  112451. private _initHeightQuads;
  112452. private _computeHeightQuads;
  112453. /**
  112454. * Serializes this ground mesh
  112455. * @param serializationObject object to write serialization to
  112456. */
  112457. serialize(serializationObject: any): void;
  112458. /**
  112459. * Parses a serialized ground mesh
  112460. * @param parsedMesh the serialized mesh
  112461. * @param scene the scene to create the ground mesh in
  112462. * @returns the created ground mesh
  112463. */
  112464. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  112465. }
  112466. }
  112467. declare module BABYLON {
  112468. /**
  112469. * Interface for Physics-Joint data
  112470. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112471. */
  112472. export interface PhysicsJointData {
  112473. /**
  112474. * The main pivot of the joint
  112475. */
  112476. mainPivot?: Vector3;
  112477. /**
  112478. * The connected pivot of the joint
  112479. */
  112480. connectedPivot?: Vector3;
  112481. /**
  112482. * The main axis of the joint
  112483. */
  112484. mainAxis?: Vector3;
  112485. /**
  112486. * The connected axis of the joint
  112487. */
  112488. connectedAxis?: Vector3;
  112489. /**
  112490. * The collision of the joint
  112491. */
  112492. collision?: boolean;
  112493. /**
  112494. * Native Oimo/Cannon/Energy data
  112495. */
  112496. nativeParams?: any;
  112497. }
  112498. /**
  112499. * This is a holder class for the physics joint created by the physics plugin
  112500. * It holds a set of functions to control the underlying joint
  112501. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112502. */
  112503. export class PhysicsJoint {
  112504. /**
  112505. * The type of the physics joint
  112506. */
  112507. type: number;
  112508. /**
  112509. * The data for the physics joint
  112510. */
  112511. jointData: PhysicsJointData;
  112512. private _physicsJoint;
  112513. protected _physicsPlugin: IPhysicsEnginePlugin;
  112514. /**
  112515. * Initializes the physics joint
  112516. * @param type The type of the physics joint
  112517. * @param jointData The data for the physics joint
  112518. */
  112519. constructor(
  112520. /**
  112521. * The type of the physics joint
  112522. */
  112523. type: number,
  112524. /**
  112525. * The data for the physics joint
  112526. */
  112527. jointData: PhysicsJointData);
  112528. /**
  112529. * Gets the physics joint
  112530. */
  112531. get physicsJoint(): any;
  112532. /**
  112533. * Sets the physics joint
  112534. */
  112535. set physicsJoint(newJoint: any);
  112536. /**
  112537. * Sets the physics plugin
  112538. */
  112539. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  112540. /**
  112541. * Execute a function that is physics-plugin specific.
  112542. * @param {Function} func the function that will be executed.
  112543. * It accepts two parameters: the physics world and the physics joint
  112544. */
  112545. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  112546. /**
  112547. * Distance-Joint type
  112548. */
  112549. static DistanceJoint: number;
  112550. /**
  112551. * Hinge-Joint type
  112552. */
  112553. static HingeJoint: number;
  112554. /**
  112555. * Ball-and-Socket joint type
  112556. */
  112557. static BallAndSocketJoint: number;
  112558. /**
  112559. * Wheel-Joint type
  112560. */
  112561. static WheelJoint: number;
  112562. /**
  112563. * Slider-Joint type
  112564. */
  112565. static SliderJoint: number;
  112566. /**
  112567. * Prismatic-Joint type
  112568. */
  112569. static PrismaticJoint: number;
  112570. /**
  112571. * Universal-Joint type
  112572. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  112573. */
  112574. static UniversalJoint: number;
  112575. /**
  112576. * Hinge-Joint 2 type
  112577. */
  112578. static Hinge2Joint: number;
  112579. /**
  112580. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  112581. */
  112582. static PointToPointJoint: number;
  112583. /**
  112584. * Spring-Joint type
  112585. */
  112586. static SpringJoint: number;
  112587. /**
  112588. * Lock-Joint type
  112589. */
  112590. static LockJoint: number;
  112591. }
  112592. /**
  112593. * A class representing a physics distance joint
  112594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112595. */
  112596. export class DistanceJoint extends PhysicsJoint {
  112597. /**
  112598. *
  112599. * @param jointData The data for the Distance-Joint
  112600. */
  112601. constructor(jointData: DistanceJointData);
  112602. /**
  112603. * Update the predefined distance.
  112604. * @param maxDistance The maximum preferred distance
  112605. * @param minDistance The minimum preferred distance
  112606. */
  112607. updateDistance(maxDistance: number, minDistance?: number): void;
  112608. }
  112609. /**
  112610. * Represents a Motor-Enabled Joint
  112611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112612. */
  112613. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  112614. /**
  112615. * Initializes the Motor-Enabled Joint
  112616. * @param type The type of the joint
  112617. * @param jointData The physica joint data for the joint
  112618. */
  112619. constructor(type: number, jointData: PhysicsJointData);
  112620. /**
  112621. * Set the motor values.
  112622. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112623. * @param force the force to apply
  112624. * @param maxForce max force for this motor.
  112625. */
  112626. setMotor(force?: number, maxForce?: number): void;
  112627. /**
  112628. * Set the motor's limits.
  112629. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112630. * @param upperLimit The upper limit of the motor
  112631. * @param lowerLimit The lower limit of the motor
  112632. */
  112633. setLimit(upperLimit: number, lowerLimit?: number): void;
  112634. }
  112635. /**
  112636. * This class represents a single physics Hinge-Joint
  112637. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112638. */
  112639. export class HingeJoint extends MotorEnabledJoint {
  112640. /**
  112641. * Initializes the Hinge-Joint
  112642. * @param jointData The joint data for the Hinge-Joint
  112643. */
  112644. constructor(jointData: PhysicsJointData);
  112645. /**
  112646. * Set the motor values.
  112647. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112648. * @param {number} force the force to apply
  112649. * @param {number} maxForce max force for this motor.
  112650. */
  112651. setMotor(force?: number, maxForce?: number): void;
  112652. /**
  112653. * Set the motor's limits.
  112654. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112655. * @param upperLimit The upper limit of the motor
  112656. * @param lowerLimit The lower limit of the motor
  112657. */
  112658. setLimit(upperLimit: number, lowerLimit?: number): void;
  112659. }
  112660. /**
  112661. * This class represents a dual hinge physics joint (same as wheel joint)
  112662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112663. */
  112664. export class Hinge2Joint extends MotorEnabledJoint {
  112665. /**
  112666. * Initializes the Hinge2-Joint
  112667. * @param jointData The joint data for the Hinge2-Joint
  112668. */
  112669. constructor(jointData: PhysicsJointData);
  112670. /**
  112671. * Set the motor values.
  112672. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112673. * @param {number} targetSpeed the speed the motor is to reach
  112674. * @param {number} maxForce max force for this motor.
  112675. * @param {motorIndex} the motor's index, 0 or 1.
  112676. */
  112677. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  112678. /**
  112679. * Set the motor limits.
  112680. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112681. * @param {number} upperLimit the upper limit
  112682. * @param {number} lowerLimit lower limit
  112683. * @param {motorIndex} the motor's index, 0 or 1.
  112684. */
  112685. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112686. }
  112687. /**
  112688. * Interface for a motor enabled joint
  112689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112690. */
  112691. export interface IMotorEnabledJoint {
  112692. /**
  112693. * Physics joint
  112694. */
  112695. physicsJoint: any;
  112696. /**
  112697. * Sets the motor of the motor-enabled joint
  112698. * @param force The force of the motor
  112699. * @param maxForce The maximum force of the motor
  112700. * @param motorIndex The index of the motor
  112701. */
  112702. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  112703. /**
  112704. * Sets the limit of the motor
  112705. * @param upperLimit The upper limit of the motor
  112706. * @param lowerLimit The lower limit of the motor
  112707. * @param motorIndex The index of the motor
  112708. */
  112709. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112710. }
  112711. /**
  112712. * Joint data for a Distance-Joint
  112713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112714. */
  112715. export interface DistanceJointData extends PhysicsJointData {
  112716. /**
  112717. * Max distance the 2 joint objects can be apart
  112718. */
  112719. maxDistance: number;
  112720. }
  112721. /**
  112722. * Joint data from a spring joint
  112723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112724. */
  112725. export interface SpringJointData extends PhysicsJointData {
  112726. /**
  112727. * Length of the spring
  112728. */
  112729. length: number;
  112730. /**
  112731. * Stiffness of the spring
  112732. */
  112733. stiffness: number;
  112734. /**
  112735. * Damping of the spring
  112736. */
  112737. damping: number;
  112738. /** this callback will be called when applying the force to the impostors. */
  112739. forceApplicationCallback: () => void;
  112740. }
  112741. }
  112742. declare module BABYLON {
  112743. /**
  112744. * Holds the data for the raycast result
  112745. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112746. */
  112747. export class PhysicsRaycastResult {
  112748. private _hasHit;
  112749. private _hitDistance;
  112750. private _hitNormalWorld;
  112751. private _hitPointWorld;
  112752. private _rayFromWorld;
  112753. private _rayToWorld;
  112754. /**
  112755. * Gets if there was a hit
  112756. */
  112757. get hasHit(): boolean;
  112758. /**
  112759. * Gets the distance from the hit
  112760. */
  112761. get hitDistance(): number;
  112762. /**
  112763. * Gets the hit normal/direction in the world
  112764. */
  112765. get hitNormalWorld(): Vector3;
  112766. /**
  112767. * Gets the hit point in the world
  112768. */
  112769. get hitPointWorld(): Vector3;
  112770. /**
  112771. * Gets the ray "start point" of the ray in the world
  112772. */
  112773. get rayFromWorld(): Vector3;
  112774. /**
  112775. * Gets the ray "end point" of the ray in the world
  112776. */
  112777. get rayToWorld(): Vector3;
  112778. /**
  112779. * Sets the hit data (normal & point in world space)
  112780. * @param hitNormalWorld defines the normal in world space
  112781. * @param hitPointWorld defines the point in world space
  112782. */
  112783. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  112784. /**
  112785. * Sets the distance from the start point to the hit point
  112786. * @param distance
  112787. */
  112788. setHitDistance(distance: number): void;
  112789. /**
  112790. * Calculates the distance manually
  112791. */
  112792. calculateHitDistance(): void;
  112793. /**
  112794. * Resets all the values to default
  112795. * @param from The from point on world space
  112796. * @param to The to point on world space
  112797. */
  112798. reset(from?: Vector3, to?: Vector3): void;
  112799. }
  112800. /**
  112801. * Interface for the size containing width and height
  112802. */
  112803. interface IXYZ {
  112804. /**
  112805. * X
  112806. */
  112807. x: number;
  112808. /**
  112809. * Y
  112810. */
  112811. y: number;
  112812. /**
  112813. * Z
  112814. */
  112815. z: number;
  112816. }
  112817. }
  112818. declare module BABYLON {
  112819. /**
  112820. * Interface used to describe a physics joint
  112821. */
  112822. export interface PhysicsImpostorJoint {
  112823. /** Defines the main impostor to which the joint is linked */
  112824. mainImpostor: PhysicsImpostor;
  112825. /** Defines the impostor that is connected to the main impostor using this joint */
  112826. connectedImpostor: PhysicsImpostor;
  112827. /** Defines the joint itself */
  112828. joint: PhysicsJoint;
  112829. }
  112830. /** @hidden */
  112831. export interface IPhysicsEnginePlugin {
  112832. world: any;
  112833. name: string;
  112834. setGravity(gravity: Vector3): void;
  112835. setTimeStep(timeStep: number): void;
  112836. getTimeStep(): number;
  112837. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112838. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112839. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112840. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112841. removePhysicsBody(impostor: PhysicsImpostor): void;
  112842. generateJoint(joint: PhysicsImpostorJoint): void;
  112843. removeJoint(joint: PhysicsImpostorJoint): void;
  112844. isSupported(): boolean;
  112845. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112846. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112847. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112848. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112849. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112850. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112851. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112852. getBodyMass(impostor: PhysicsImpostor): number;
  112853. getBodyFriction(impostor: PhysicsImpostor): number;
  112854. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112855. getBodyRestitution(impostor: PhysicsImpostor): number;
  112856. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112857. getBodyPressure?(impostor: PhysicsImpostor): number;
  112858. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  112859. getBodyStiffness?(impostor: PhysicsImpostor): number;
  112860. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  112861. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  112862. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  112863. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  112864. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  112865. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112866. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112867. sleepBody(impostor: PhysicsImpostor): void;
  112868. wakeUpBody(impostor: PhysicsImpostor): void;
  112869. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112870. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112871. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  112872. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112873. getRadius(impostor: PhysicsImpostor): number;
  112874. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112875. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112876. dispose(): void;
  112877. }
  112878. /**
  112879. * Interface used to define a physics engine
  112880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112881. */
  112882. export interface IPhysicsEngine {
  112883. /**
  112884. * Gets the gravity vector used by the simulation
  112885. */
  112886. gravity: Vector3;
  112887. /**
  112888. * Sets the gravity vector used by the simulation
  112889. * @param gravity defines the gravity vector to use
  112890. */
  112891. setGravity(gravity: Vector3): void;
  112892. /**
  112893. * Set the time step of the physics engine.
  112894. * Default is 1/60.
  112895. * To slow it down, enter 1/600 for example.
  112896. * To speed it up, 1/30
  112897. * @param newTimeStep the new timestep to apply to this world.
  112898. */
  112899. setTimeStep(newTimeStep: number): void;
  112900. /**
  112901. * Get the time step of the physics engine.
  112902. * @returns the current time step
  112903. */
  112904. getTimeStep(): number;
  112905. /**
  112906. * Set the sub time step of the physics engine.
  112907. * Default is 0 meaning there is no sub steps
  112908. * To increase physics resolution precision, set a small value (like 1 ms)
  112909. * @param subTimeStep defines the new sub timestep used for physics resolution.
  112910. */
  112911. setSubTimeStep(subTimeStep: number): void;
  112912. /**
  112913. * Get the sub time step of the physics engine.
  112914. * @returns the current sub time step
  112915. */
  112916. getSubTimeStep(): number;
  112917. /**
  112918. * Release all resources
  112919. */
  112920. dispose(): void;
  112921. /**
  112922. * Gets the name of the current physics plugin
  112923. * @returns the name of the plugin
  112924. */
  112925. getPhysicsPluginName(): string;
  112926. /**
  112927. * Adding a new impostor for the impostor tracking.
  112928. * This will be done by the impostor itself.
  112929. * @param impostor the impostor to add
  112930. */
  112931. addImpostor(impostor: PhysicsImpostor): void;
  112932. /**
  112933. * Remove an impostor from the engine.
  112934. * This impostor and its mesh will not longer be updated by the physics engine.
  112935. * @param impostor the impostor to remove
  112936. */
  112937. removeImpostor(impostor: PhysicsImpostor): void;
  112938. /**
  112939. * Add a joint to the physics engine
  112940. * @param mainImpostor defines the main impostor to which the joint is added.
  112941. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  112942. * @param joint defines the joint that will connect both impostors.
  112943. */
  112944. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112945. /**
  112946. * Removes a joint from the simulation
  112947. * @param mainImpostor defines the impostor used with the joint
  112948. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  112949. * @param joint defines the joint to remove
  112950. */
  112951. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112952. /**
  112953. * Gets the current plugin used to run the simulation
  112954. * @returns current plugin
  112955. */
  112956. getPhysicsPlugin(): IPhysicsEnginePlugin;
  112957. /**
  112958. * Gets the list of physic impostors
  112959. * @returns an array of PhysicsImpostor
  112960. */
  112961. getImpostors(): Array<PhysicsImpostor>;
  112962. /**
  112963. * Gets the impostor for a physics enabled object
  112964. * @param object defines the object impersonated by the impostor
  112965. * @returns the PhysicsImpostor or null if not found
  112966. */
  112967. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  112968. /**
  112969. * Gets the impostor for a physics body object
  112970. * @param body defines physics body used by the impostor
  112971. * @returns the PhysicsImpostor or null if not found
  112972. */
  112973. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  112974. /**
  112975. * Does a raycast in the physics world
  112976. * @param from when should the ray start?
  112977. * @param to when should the ray end?
  112978. * @returns PhysicsRaycastResult
  112979. */
  112980. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112981. /**
  112982. * Called by the scene. No need to call it.
  112983. * @param delta defines the timespam between frames
  112984. */
  112985. _step(delta: number): void;
  112986. }
  112987. }
  112988. declare module BABYLON {
  112989. /**
  112990. * The interface for the physics imposter parameters
  112991. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112992. */
  112993. export interface PhysicsImpostorParameters {
  112994. /**
  112995. * The mass of the physics imposter
  112996. */
  112997. mass: number;
  112998. /**
  112999. * The friction of the physics imposter
  113000. */
  113001. friction?: number;
  113002. /**
  113003. * The coefficient of restitution of the physics imposter
  113004. */
  113005. restitution?: number;
  113006. /**
  113007. * The native options of the physics imposter
  113008. */
  113009. nativeOptions?: any;
  113010. /**
  113011. * Specifies if the parent should be ignored
  113012. */
  113013. ignoreParent?: boolean;
  113014. /**
  113015. * Specifies if bi-directional transformations should be disabled
  113016. */
  113017. disableBidirectionalTransformation?: boolean;
  113018. /**
  113019. * The pressure inside the physics imposter, soft object only
  113020. */
  113021. pressure?: number;
  113022. /**
  113023. * The stiffness the physics imposter, soft object only
  113024. */
  113025. stiffness?: number;
  113026. /**
  113027. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  113028. */
  113029. velocityIterations?: number;
  113030. /**
  113031. * The number of iterations used in maintaining consistent vertex positions, soft object only
  113032. */
  113033. positionIterations?: number;
  113034. /**
  113035. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  113036. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  113037. * Add to fix multiple points
  113038. */
  113039. fixedPoints?: number;
  113040. /**
  113041. * The collision margin around a soft object
  113042. */
  113043. margin?: number;
  113044. /**
  113045. * The collision margin around a soft object
  113046. */
  113047. damping?: number;
  113048. /**
  113049. * The path for a rope based on an extrusion
  113050. */
  113051. path?: any;
  113052. /**
  113053. * The shape of an extrusion used for a rope based on an extrusion
  113054. */
  113055. shape?: any;
  113056. }
  113057. /**
  113058. * Interface for a physics-enabled object
  113059. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113060. */
  113061. export interface IPhysicsEnabledObject {
  113062. /**
  113063. * The position of the physics-enabled object
  113064. */
  113065. position: Vector3;
  113066. /**
  113067. * The rotation of the physics-enabled object
  113068. */
  113069. rotationQuaternion: Nullable<Quaternion>;
  113070. /**
  113071. * The scale of the physics-enabled object
  113072. */
  113073. scaling: Vector3;
  113074. /**
  113075. * The rotation of the physics-enabled object
  113076. */
  113077. rotation?: Vector3;
  113078. /**
  113079. * The parent of the physics-enabled object
  113080. */
  113081. parent?: any;
  113082. /**
  113083. * The bounding info of the physics-enabled object
  113084. * @returns The bounding info of the physics-enabled object
  113085. */
  113086. getBoundingInfo(): BoundingInfo;
  113087. /**
  113088. * Computes the world matrix
  113089. * @param force Specifies if the world matrix should be computed by force
  113090. * @returns A world matrix
  113091. */
  113092. computeWorldMatrix(force: boolean): Matrix;
  113093. /**
  113094. * Gets the world matrix
  113095. * @returns A world matrix
  113096. */
  113097. getWorldMatrix?(): Matrix;
  113098. /**
  113099. * Gets the child meshes
  113100. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  113101. * @returns An array of abstract meshes
  113102. */
  113103. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  113104. /**
  113105. * Gets the vertex data
  113106. * @param kind The type of vertex data
  113107. * @returns A nullable array of numbers, or a float32 array
  113108. */
  113109. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  113110. /**
  113111. * Gets the indices from the mesh
  113112. * @returns A nullable array of index arrays
  113113. */
  113114. getIndices?(): Nullable<IndicesArray>;
  113115. /**
  113116. * Gets the scene from the mesh
  113117. * @returns the indices array or null
  113118. */
  113119. getScene?(): Scene;
  113120. /**
  113121. * Gets the absolute position from the mesh
  113122. * @returns the absolute position
  113123. */
  113124. getAbsolutePosition(): Vector3;
  113125. /**
  113126. * Gets the absolute pivot point from the mesh
  113127. * @returns the absolute pivot point
  113128. */
  113129. getAbsolutePivotPoint(): Vector3;
  113130. /**
  113131. * Rotates the mesh
  113132. * @param axis The axis of rotation
  113133. * @param amount The amount of rotation
  113134. * @param space The space of the rotation
  113135. * @returns The rotation transform node
  113136. */
  113137. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  113138. /**
  113139. * Translates the mesh
  113140. * @param axis The axis of translation
  113141. * @param distance The distance of translation
  113142. * @param space The space of the translation
  113143. * @returns The transform node
  113144. */
  113145. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  113146. /**
  113147. * Sets the absolute position of the mesh
  113148. * @param absolutePosition The absolute position of the mesh
  113149. * @returns The transform node
  113150. */
  113151. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  113152. /**
  113153. * Gets the class name of the mesh
  113154. * @returns The class name
  113155. */
  113156. getClassName(): string;
  113157. }
  113158. /**
  113159. * Represents a physics imposter
  113160. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113161. */
  113162. export class PhysicsImpostor {
  113163. /**
  113164. * The physics-enabled object used as the physics imposter
  113165. */
  113166. object: IPhysicsEnabledObject;
  113167. /**
  113168. * The type of the physics imposter
  113169. */
  113170. type: number;
  113171. private _options;
  113172. private _scene?;
  113173. /**
  113174. * The default object size of the imposter
  113175. */
  113176. static DEFAULT_OBJECT_SIZE: Vector3;
  113177. /**
  113178. * The identity quaternion of the imposter
  113179. */
  113180. static IDENTITY_QUATERNION: Quaternion;
  113181. /** @hidden */
  113182. _pluginData: any;
  113183. private _physicsEngine;
  113184. private _physicsBody;
  113185. private _bodyUpdateRequired;
  113186. private _onBeforePhysicsStepCallbacks;
  113187. private _onAfterPhysicsStepCallbacks;
  113188. /** @hidden */
  113189. _onPhysicsCollideCallbacks: Array<{
  113190. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  113191. otherImpostors: Array<PhysicsImpostor>;
  113192. }>;
  113193. private _deltaPosition;
  113194. private _deltaRotation;
  113195. private _deltaRotationConjugated;
  113196. /** @hidden */
  113197. _isFromLine: boolean;
  113198. private _parent;
  113199. private _isDisposed;
  113200. private static _tmpVecs;
  113201. private static _tmpQuat;
  113202. /**
  113203. * Specifies if the physics imposter is disposed
  113204. */
  113205. get isDisposed(): boolean;
  113206. /**
  113207. * Gets the mass of the physics imposter
  113208. */
  113209. get mass(): number;
  113210. set mass(value: number);
  113211. /**
  113212. * Gets the coefficient of friction
  113213. */
  113214. get friction(): number;
  113215. /**
  113216. * Sets the coefficient of friction
  113217. */
  113218. set friction(value: number);
  113219. /**
  113220. * Gets the coefficient of restitution
  113221. */
  113222. get restitution(): number;
  113223. /**
  113224. * Sets the coefficient of restitution
  113225. */
  113226. set restitution(value: number);
  113227. /**
  113228. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  113229. */
  113230. get pressure(): number;
  113231. /**
  113232. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  113233. */
  113234. set pressure(value: number);
  113235. /**
  113236. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  113237. */
  113238. get stiffness(): number;
  113239. /**
  113240. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  113241. */
  113242. set stiffness(value: number);
  113243. /**
  113244. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  113245. */
  113246. get velocityIterations(): number;
  113247. /**
  113248. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  113249. */
  113250. set velocityIterations(value: number);
  113251. /**
  113252. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  113253. */
  113254. get positionIterations(): number;
  113255. /**
  113256. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  113257. */
  113258. set positionIterations(value: number);
  113259. /**
  113260. * The unique id of the physics imposter
  113261. * set by the physics engine when adding this impostor to the array
  113262. */
  113263. uniqueId: number;
  113264. /**
  113265. * @hidden
  113266. */
  113267. soft: boolean;
  113268. /**
  113269. * @hidden
  113270. */
  113271. segments: number;
  113272. private _joints;
  113273. /**
  113274. * Initializes the physics imposter
  113275. * @param object The physics-enabled object used as the physics imposter
  113276. * @param type The type of the physics imposter
  113277. * @param _options The options for the physics imposter
  113278. * @param _scene The Babylon scene
  113279. */
  113280. constructor(
  113281. /**
  113282. * The physics-enabled object used as the physics imposter
  113283. */
  113284. object: IPhysicsEnabledObject,
  113285. /**
  113286. * The type of the physics imposter
  113287. */
  113288. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  113289. /**
  113290. * This function will completly initialize this impostor.
  113291. * It will create a new body - but only if this mesh has no parent.
  113292. * If it has, this impostor will not be used other than to define the impostor
  113293. * of the child mesh.
  113294. * @hidden
  113295. */
  113296. _init(): void;
  113297. private _getPhysicsParent;
  113298. /**
  113299. * Should a new body be generated.
  113300. * @returns boolean specifying if body initialization is required
  113301. */
  113302. isBodyInitRequired(): boolean;
  113303. /**
  113304. * Sets the updated scaling
  113305. * @param updated Specifies if the scaling is updated
  113306. */
  113307. setScalingUpdated(): void;
  113308. /**
  113309. * Force a regeneration of this or the parent's impostor's body.
  113310. * Use under cautious - This will remove all joints already implemented.
  113311. */
  113312. forceUpdate(): void;
  113313. /**
  113314. * Gets the body that holds this impostor. Either its own, or its parent.
  113315. */
  113316. get physicsBody(): any;
  113317. /**
  113318. * Get the parent of the physics imposter
  113319. * @returns Physics imposter or null
  113320. */
  113321. get parent(): Nullable<PhysicsImpostor>;
  113322. /**
  113323. * Sets the parent of the physics imposter
  113324. */
  113325. set parent(value: Nullable<PhysicsImpostor>);
  113326. /**
  113327. * Set the physics body. Used mainly by the physics engine/plugin
  113328. */
  113329. set physicsBody(physicsBody: any);
  113330. /**
  113331. * Resets the update flags
  113332. */
  113333. resetUpdateFlags(): void;
  113334. /**
  113335. * Gets the object extend size
  113336. * @returns the object extend size
  113337. */
  113338. getObjectExtendSize(): Vector3;
  113339. /**
  113340. * Gets the object center
  113341. * @returns The object center
  113342. */
  113343. getObjectCenter(): Vector3;
  113344. /**
  113345. * Get a specific parameter from the options parameters
  113346. * @param paramName The object parameter name
  113347. * @returns The object parameter
  113348. */
  113349. getParam(paramName: string): any;
  113350. /**
  113351. * Sets a specific parameter in the options given to the physics plugin
  113352. * @param paramName The parameter name
  113353. * @param value The value of the parameter
  113354. */
  113355. setParam(paramName: string, value: number): void;
  113356. /**
  113357. * Specifically change the body's mass option. Won't recreate the physics body object
  113358. * @param mass The mass of the physics imposter
  113359. */
  113360. setMass(mass: number): void;
  113361. /**
  113362. * Gets the linear velocity
  113363. * @returns linear velocity or null
  113364. */
  113365. getLinearVelocity(): Nullable<Vector3>;
  113366. /**
  113367. * Sets the linear velocity
  113368. * @param velocity linear velocity or null
  113369. */
  113370. setLinearVelocity(velocity: Nullable<Vector3>): void;
  113371. /**
  113372. * Gets the angular velocity
  113373. * @returns angular velocity or null
  113374. */
  113375. getAngularVelocity(): Nullable<Vector3>;
  113376. /**
  113377. * Sets the angular velocity
  113378. * @param velocity The velocity or null
  113379. */
  113380. setAngularVelocity(velocity: Nullable<Vector3>): void;
  113381. /**
  113382. * Execute a function with the physics plugin native code
  113383. * Provide a function the will have two variables - the world object and the physics body object
  113384. * @param func The function to execute with the physics plugin native code
  113385. */
  113386. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  113387. /**
  113388. * Register a function that will be executed before the physics world is stepping forward
  113389. * @param func The function to execute before the physics world is stepped forward
  113390. */
  113391. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113392. /**
  113393. * Unregister a function that will be executed before the physics world is stepping forward
  113394. * @param func The function to execute before the physics world is stepped forward
  113395. */
  113396. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113397. /**
  113398. * Register a function that will be executed after the physics step
  113399. * @param func The function to execute after physics step
  113400. */
  113401. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113402. /**
  113403. * Unregisters a function that will be executed after the physics step
  113404. * @param func The function to execute after physics step
  113405. */
  113406. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113407. /**
  113408. * register a function that will be executed when this impostor collides against a different body
  113409. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  113410. * @param func Callback that is executed on collision
  113411. */
  113412. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  113413. /**
  113414. * Unregisters the physics imposter on contact
  113415. * @param collideAgainst The physics object to collide against
  113416. * @param func Callback to execute on collision
  113417. */
  113418. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  113419. private _tmpQuat;
  113420. private _tmpQuat2;
  113421. /**
  113422. * Get the parent rotation
  113423. * @returns The parent rotation
  113424. */
  113425. getParentsRotation(): Quaternion;
  113426. /**
  113427. * this function is executed by the physics engine.
  113428. */
  113429. beforeStep: () => void;
  113430. /**
  113431. * this function is executed by the physics engine
  113432. */
  113433. afterStep: () => void;
  113434. /**
  113435. * Legacy collision detection event support
  113436. */
  113437. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  113438. /**
  113439. * event and body object due to cannon's event-based architecture.
  113440. */
  113441. onCollide: (e: {
  113442. body: any;
  113443. point: Nullable<Vector3>;
  113444. }) => void;
  113445. /**
  113446. * Apply a force
  113447. * @param force The force to apply
  113448. * @param contactPoint The contact point for the force
  113449. * @returns The physics imposter
  113450. */
  113451. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113452. /**
  113453. * Apply an impulse
  113454. * @param force The impulse force
  113455. * @param contactPoint The contact point for the impulse force
  113456. * @returns The physics imposter
  113457. */
  113458. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113459. /**
  113460. * A help function to create a joint
  113461. * @param otherImpostor A physics imposter used to create a joint
  113462. * @param jointType The type of joint
  113463. * @param jointData The data for the joint
  113464. * @returns The physics imposter
  113465. */
  113466. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  113467. /**
  113468. * Add a joint to this impostor with a different impostor
  113469. * @param otherImpostor A physics imposter used to add a joint
  113470. * @param joint The joint to add
  113471. * @returns The physics imposter
  113472. */
  113473. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  113474. /**
  113475. * Add an anchor to a cloth impostor
  113476. * @param otherImpostor rigid impostor to anchor to
  113477. * @param width ratio across width from 0 to 1
  113478. * @param height ratio up height from 0 to 1
  113479. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  113480. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  113481. * @returns impostor the soft imposter
  113482. */
  113483. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113484. /**
  113485. * Add a hook to a rope impostor
  113486. * @param otherImpostor rigid impostor to anchor to
  113487. * @param length ratio across rope from 0 to 1
  113488. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  113489. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113490. * @returns impostor the rope imposter
  113491. */
  113492. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113493. /**
  113494. * Will keep this body still, in a sleep mode.
  113495. * @returns the physics imposter
  113496. */
  113497. sleep(): PhysicsImpostor;
  113498. /**
  113499. * Wake the body up.
  113500. * @returns The physics imposter
  113501. */
  113502. wakeUp(): PhysicsImpostor;
  113503. /**
  113504. * Clones the physics imposter
  113505. * @param newObject The physics imposter clones to this physics-enabled object
  113506. * @returns A nullable physics imposter
  113507. */
  113508. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113509. /**
  113510. * Disposes the physics imposter
  113511. */
  113512. dispose(): void;
  113513. /**
  113514. * Sets the delta position
  113515. * @param position The delta position amount
  113516. */
  113517. setDeltaPosition(position: Vector3): void;
  113518. /**
  113519. * Sets the delta rotation
  113520. * @param rotation The delta rotation amount
  113521. */
  113522. setDeltaRotation(rotation: Quaternion): void;
  113523. /**
  113524. * Gets the box size of the physics imposter and stores the result in the input parameter
  113525. * @param result Stores the box size
  113526. * @returns The physics imposter
  113527. */
  113528. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  113529. /**
  113530. * Gets the radius of the physics imposter
  113531. * @returns Radius of the physics imposter
  113532. */
  113533. getRadius(): number;
  113534. /**
  113535. * Sync a bone with this impostor
  113536. * @param bone The bone to sync to the impostor.
  113537. * @param boneMesh The mesh that the bone is influencing.
  113538. * @param jointPivot The pivot of the joint / bone in local space.
  113539. * @param distToJoint Optional distance from the impostor to the joint.
  113540. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113541. */
  113542. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  113543. /**
  113544. * Sync impostor to a bone
  113545. * @param bone The bone that the impostor will be synced to.
  113546. * @param boneMesh The mesh that the bone is influencing.
  113547. * @param jointPivot The pivot of the joint / bone in local space.
  113548. * @param distToJoint Optional distance from the impostor to the joint.
  113549. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113550. * @param boneAxis Optional vector3 axis the bone is aligned with
  113551. */
  113552. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  113553. /**
  113554. * No-Imposter type
  113555. */
  113556. static NoImpostor: number;
  113557. /**
  113558. * Sphere-Imposter type
  113559. */
  113560. static SphereImpostor: number;
  113561. /**
  113562. * Box-Imposter type
  113563. */
  113564. static BoxImpostor: number;
  113565. /**
  113566. * Plane-Imposter type
  113567. */
  113568. static PlaneImpostor: number;
  113569. /**
  113570. * Mesh-imposter type
  113571. */
  113572. static MeshImpostor: number;
  113573. /**
  113574. * Capsule-Impostor type (Ammo.js plugin only)
  113575. */
  113576. static CapsuleImpostor: number;
  113577. /**
  113578. * Cylinder-Imposter type
  113579. */
  113580. static CylinderImpostor: number;
  113581. /**
  113582. * Particle-Imposter type
  113583. */
  113584. static ParticleImpostor: number;
  113585. /**
  113586. * Heightmap-Imposter type
  113587. */
  113588. static HeightmapImpostor: number;
  113589. /**
  113590. * ConvexHull-Impostor type (Ammo.js plugin only)
  113591. */
  113592. static ConvexHullImpostor: number;
  113593. /**
  113594. * Custom-Imposter type (Ammo.js plugin only)
  113595. */
  113596. static CustomImpostor: number;
  113597. /**
  113598. * Rope-Imposter type
  113599. */
  113600. static RopeImpostor: number;
  113601. /**
  113602. * Cloth-Imposter type
  113603. */
  113604. static ClothImpostor: number;
  113605. /**
  113606. * Softbody-Imposter type
  113607. */
  113608. static SoftbodyImpostor: number;
  113609. }
  113610. }
  113611. declare module BABYLON {
  113612. /**
  113613. * @hidden
  113614. **/
  113615. export class _CreationDataStorage {
  113616. closePath?: boolean;
  113617. closeArray?: boolean;
  113618. idx: number[];
  113619. dashSize: number;
  113620. gapSize: number;
  113621. path3D: Path3D;
  113622. pathArray: Vector3[][];
  113623. arc: number;
  113624. radius: number;
  113625. cap: number;
  113626. tessellation: number;
  113627. }
  113628. /**
  113629. * @hidden
  113630. **/
  113631. class _InstanceDataStorage {
  113632. visibleInstances: any;
  113633. batchCache: _InstancesBatch;
  113634. instancesBufferSize: number;
  113635. instancesBuffer: Nullable<Buffer>;
  113636. instancesData: Float32Array;
  113637. overridenInstanceCount: number;
  113638. isFrozen: boolean;
  113639. previousBatch: Nullable<_InstancesBatch>;
  113640. hardwareInstancedRendering: boolean;
  113641. sideOrientation: number;
  113642. manualUpdate: boolean;
  113643. previousRenderId: number;
  113644. }
  113645. /**
  113646. * @hidden
  113647. **/
  113648. export class _InstancesBatch {
  113649. mustReturn: boolean;
  113650. visibleInstances: Nullable<InstancedMesh[]>[];
  113651. renderSelf: boolean[];
  113652. hardwareInstancedRendering: boolean[];
  113653. }
  113654. /**
  113655. * @hidden
  113656. **/
  113657. class _ThinInstanceDataStorage {
  113658. instancesCount: number;
  113659. matrixBuffer: Nullable<Buffer>;
  113660. matrixBufferSize: number;
  113661. matrixData: Nullable<Float32Array>;
  113662. boundingVectors: Array<Vector3>;
  113663. worldMatrices: Nullable<Matrix[]>;
  113664. }
  113665. /**
  113666. * Class used to represent renderable models
  113667. */
  113668. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  113669. /**
  113670. * Mesh side orientation : usually the external or front surface
  113671. */
  113672. static readonly FRONTSIDE: number;
  113673. /**
  113674. * Mesh side orientation : usually the internal or back surface
  113675. */
  113676. static readonly BACKSIDE: number;
  113677. /**
  113678. * Mesh side orientation : both internal and external or front and back surfaces
  113679. */
  113680. static readonly DOUBLESIDE: number;
  113681. /**
  113682. * Mesh side orientation : by default, `FRONTSIDE`
  113683. */
  113684. static readonly DEFAULTSIDE: number;
  113685. /**
  113686. * Mesh cap setting : no cap
  113687. */
  113688. static readonly NO_CAP: number;
  113689. /**
  113690. * Mesh cap setting : one cap at the beginning of the mesh
  113691. */
  113692. static readonly CAP_START: number;
  113693. /**
  113694. * Mesh cap setting : one cap at the end of the mesh
  113695. */
  113696. static readonly CAP_END: number;
  113697. /**
  113698. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  113699. */
  113700. static readonly CAP_ALL: number;
  113701. /**
  113702. * Mesh pattern setting : no flip or rotate
  113703. */
  113704. static readonly NO_FLIP: number;
  113705. /**
  113706. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  113707. */
  113708. static readonly FLIP_TILE: number;
  113709. /**
  113710. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  113711. */
  113712. static readonly ROTATE_TILE: number;
  113713. /**
  113714. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  113715. */
  113716. static readonly FLIP_ROW: number;
  113717. /**
  113718. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  113719. */
  113720. static readonly ROTATE_ROW: number;
  113721. /**
  113722. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  113723. */
  113724. static readonly FLIP_N_ROTATE_TILE: number;
  113725. /**
  113726. * Mesh pattern setting : rotate pattern and rotate
  113727. */
  113728. static readonly FLIP_N_ROTATE_ROW: number;
  113729. /**
  113730. * Mesh tile positioning : part tiles same on left/right or top/bottom
  113731. */
  113732. static readonly CENTER: number;
  113733. /**
  113734. * Mesh tile positioning : part tiles on left
  113735. */
  113736. static readonly LEFT: number;
  113737. /**
  113738. * Mesh tile positioning : part tiles on right
  113739. */
  113740. static readonly RIGHT: number;
  113741. /**
  113742. * Mesh tile positioning : part tiles on top
  113743. */
  113744. static readonly TOP: number;
  113745. /**
  113746. * Mesh tile positioning : part tiles on bottom
  113747. */
  113748. static readonly BOTTOM: number;
  113749. /**
  113750. * Gets the default side orientation.
  113751. * @param orientation the orientation to value to attempt to get
  113752. * @returns the default orientation
  113753. * @hidden
  113754. */
  113755. static _GetDefaultSideOrientation(orientation?: number): number;
  113756. private _internalMeshDataInfo;
  113757. get computeBonesUsingShaders(): boolean;
  113758. set computeBonesUsingShaders(value: boolean);
  113759. /**
  113760. * An event triggered before rendering the mesh
  113761. */
  113762. get onBeforeRenderObservable(): Observable<Mesh>;
  113763. /**
  113764. * An event triggered before binding the mesh
  113765. */
  113766. get onBeforeBindObservable(): Observable<Mesh>;
  113767. /**
  113768. * An event triggered after rendering the mesh
  113769. */
  113770. get onAfterRenderObservable(): Observable<Mesh>;
  113771. /**
  113772. * An event triggered before drawing the mesh
  113773. */
  113774. get onBeforeDrawObservable(): Observable<Mesh>;
  113775. private _onBeforeDrawObserver;
  113776. /**
  113777. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  113778. */
  113779. set onBeforeDraw(callback: () => void);
  113780. get hasInstances(): boolean;
  113781. get hasThinInstances(): boolean;
  113782. /**
  113783. * Gets the delay loading state of the mesh (when delay loading is turned on)
  113784. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  113785. */
  113786. delayLoadState: number;
  113787. /**
  113788. * Gets the list of instances created from this mesh
  113789. * it is not supposed to be modified manually.
  113790. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  113791. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113792. */
  113793. instances: InstancedMesh[];
  113794. /**
  113795. * Gets the file containing delay loading data for this mesh
  113796. */
  113797. delayLoadingFile: string;
  113798. /** @hidden */
  113799. _binaryInfo: any;
  113800. /**
  113801. * User defined function used to change how LOD level selection is done
  113802. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113803. */
  113804. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  113805. /**
  113806. * Gets or sets the morph target manager
  113807. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  113808. */
  113809. get morphTargetManager(): Nullable<MorphTargetManager>;
  113810. set morphTargetManager(value: Nullable<MorphTargetManager>);
  113811. /** @hidden */
  113812. _creationDataStorage: Nullable<_CreationDataStorage>;
  113813. /** @hidden */
  113814. _geometry: Nullable<Geometry>;
  113815. /** @hidden */
  113816. _delayInfo: Array<string>;
  113817. /** @hidden */
  113818. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  113819. /** @hidden */
  113820. _instanceDataStorage: _InstanceDataStorage;
  113821. /** @hidden */
  113822. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  113823. private _effectiveMaterial;
  113824. /** @hidden */
  113825. _shouldGenerateFlatShading: boolean;
  113826. /** @hidden */
  113827. _originalBuilderSideOrientation: number;
  113828. /**
  113829. * Use this property to change the original side orientation defined at construction time
  113830. */
  113831. overrideMaterialSideOrientation: Nullable<number>;
  113832. /**
  113833. * Gets the source mesh (the one used to clone this one from)
  113834. */
  113835. get source(): Nullable<Mesh>;
  113836. /**
  113837. * Gets the list of clones of this mesh
  113838. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  113839. * Note that useClonedMeshMap=true is the default setting
  113840. */
  113841. get cloneMeshMap(): Nullable<{
  113842. [id: string]: Mesh | undefined;
  113843. }>;
  113844. /**
  113845. * Gets or sets a boolean indicating that this mesh does not use index buffer
  113846. */
  113847. get isUnIndexed(): boolean;
  113848. set isUnIndexed(value: boolean);
  113849. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  113850. get worldMatrixInstancedBuffer(): Float32Array;
  113851. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  113852. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  113853. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  113854. /**
  113855. * @constructor
  113856. * @param name The value used by scene.getMeshByName() to do a lookup.
  113857. * @param scene The scene to add this mesh to.
  113858. * @param parent The parent of this mesh, if it has one
  113859. * @param source An optional Mesh from which geometry is shared, cloned.
  113860. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  113861. * When false, achieved by calling a clone(), also passing False.
  113862. * This will make creation of children, recursive.
  113863. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  113864. */
  113865. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  113866. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  113867. doNotInstantiate: boolean;
  113868. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  113869. /**
  113870. * Gets the class name
  113871. * @returns the string "Mesh".
  113872. */
  113873. getClassName(): string;
  113874. /** @hidden */
  113875. get _isMesh(): boolean;
  113876. /**
  113877. * Returns a description of this mesh
  113878. * @param fullDetails define if full details about this mesh must be used
  113879. * @returns a descriptive string representing this mesh
  113880. */
  113881. toString(fullDetails?: boolean): string;
  113882. /** @hidden */
  113883. _unBindEffect(): void;
  113884. /**
  113885. * Gets a boolean indicating if this mesh has LOD
  113886. */
  113887. get hasLODLevels(): boolean;
  113888. /**
  113889. * Gets the list of MeshLODLevel associated with the current mesh
  113890. * @returns an array of MeshLODLevel
  113891. */
  113892. getLODLevels(): MeshLODLevel[];
  113893. private _sortLODLevels;
  113894. /**
  113895. * Add a mesh as LOD level triggered at the given distance.
  113896. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113897. * @param distance The distance from the center of the object to show this level
  113898. * @param mesh The mesh to be added as LOD level (can be null)
  113899. * @return This mesh (for chaining)
  113900. */
  113901. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  113902. /**
  113903. * Returns the LOD level mesh at the passed distance or null if not found.
  113904. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113905. * @param distance The distance from the center of the object to show this level
  113906. * @returns a Mesh or `null`
  113907. */
  113908. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  113909. /**
  113910. * Remove a mesh from the LOD array
  113911. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113912. * @param mesh defines the mesh to be removed
  113913. * @return This mesh (for chaining)
  113914. */
  113915. removeLODLevel(mesh: Mesh): Mesh;
  113916. /**
  113917. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  113918. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113919. * @param camera defines the camera to use to compute distance
  113920. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  113921. * @return This mesh (for chaining)
  113922. */
  113923. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  113924. /**
  113925. * Gets the mesh internal Geometry object
  113926. */
  113927. get geometry(): Nullable<Geometry>;
  113928. /**
  113929. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  113930. * @returns the total number of vertices
  113931. */
  113932. getTotalVertices(): number;
  113933. /**
  113934. * Returns the content of an associated vertex buffer
  113935. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113936. * - VertexBuffer.PositionKind
  113937. * - VertexBuffer.UVKind
  113938. * - VertexBuffer.UV2Kind
  113939. * - VertexBuffer.UV3Kind
  113940. * - VertexBuffer.UV4Kind
  113941. * - VertexBuffer.UV5Kind
  113942. * - VertexBuffer.UV6Kind
  113943. * - VertexBuffer.ColorKind
  113944. * - VertexBuffer.MatricesIndicesKind
  113945. * - VertexBuffer.MatricesIndicesExtraKind
  113946. * - VertexBuffer.MatricesWeightsKind
  113947. * - VertexBuffer.MatricesWeightsExtraKind
  113948. * @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
  113949. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  113950. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  113951. */
  113952. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  113953. /**
  113954. * Returns the mesh VertexBuffer object from the requested `kind`
  113955. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113956. * - VertexBuffer.PositionKind
  113957. * - VertexBuffer.NormalKind
  113958. * - VertexBuffer.UVKind
  113959. * - VertexBuffer.UV2Kind
  113960. * - VertexBuffer.UV3Kind
  113961. * - VertexBuffer.UV4Kind
  113962. * - VertexBuffer.UV5Kind
  113963. * - VertexBuffer.UV6Kind
  113964. * - VertexBuffer.ColorKind
  113965. * - VertexBuffer.MatricesIndicesKind
  113966. * - VertexBuffer.MatricesIndicesExtraKind
  113967. * - VertexBuffer.MatricesWeightsKind
  113968. * - VertexBuffer.MatricesWeightsExtraKind
  113969. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  113970. */
  113971. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  113972. /**
  113973. * Tests if a specific vertex buffer is associated with this mesh
  113974. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  113975. * - VertexBuffer.PositionKind
  113976. * - VertexBuffer.NormalKind
  113977. * - VertexBuffer.UVKind
  113978. * - VertexBuffer.UV2Kind
  113979. * - VertexBuffer.UV3Kind
  113980. * - VertexBuffer.UV4Kind
  113981. * - VertexBuffer.UV5Kind
  113982. * - VertexBuffer.UV6Kind
  113983. * - VertexBuffer.ColorKind
  113984. * - VertexBuffer.MatricesIndicesKind
  113985. * - VertexBuffer.MatricesIndicesExtraKind
  113986. * - VertexBuffer.MatricesWeightsKind
  113987. * - VertexBuffer.MatricesWeightsExtraKind
  113988. * @returns a boolean
  113989. */
  113990. isVerticesDataPresent(kind: string): boolean;
  113991. /**
  113992. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  113993. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  113994. * - VertexBuffer.PositionKind
  113995. * - VertexBuffer.UVKind
  113996. * - VertexBuffer.UV2Kind
  113997. * - VertexBuffer.UV3Kind
  113998. * - VertexBuffer.UV4Kind
  113999. * - VertexBuffer.UV5Kind
  114000. * - VertexBuffer.UV6Kind
  114001. * - VertexBuffer.ColorKind
  114002. * - VertexBuffer.MatricesIndicesKind
  114003. * - VertexBuffer.MatricesIndicesExtraKind
  114004. * - VertexBuffer.MatricesWeightsKind
  114005. * - VertexBuffer.MatricesWeightsExtraKind
  114006. * @returns a boolean
  114007. */
  114008. isVertexBufferUpdatable(kind: string): boolean;
  114009. /**
  114010. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  114011. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114012. * - VertexBuffer.PositionKind
  114013. * - VertexBuffer.NormalKind
  114014. * - VertexBuffer.UVKind
  114015. * - VertexBuffer.UV2Kind
  114016. * - VertexBuffer.UV3Kind
  114017. * - VertexBuffer.UV4Kind
  114018. * - VertexBuffer.UV5Kind
  114019. * - VertexBuffer.UV6Kind
  114020. * - VertexBuffer.ColorKind
  114021. * - VertexBuffer.MatricesIndicesKind
  114022. * - VertexBuffer.MatricesIndicesExtraKind
  114023. * - VertexBuffer.MatricesWeightsKind
  114024. * - VertexBuffer.MatricesWeightsExtraKind
  114025. * @returns an array of strings
  114026. */
  114027. getVerticesDataKinds(): string[];
  114028. /**
  114029. * Returns a positive integer : the total number of indices in this mesh geometry.
  114030. * @returns the numner of indices or zero if the mesh has no geometry.
  114031. */
  114032. getTotalIndices(): number;
  114033. /**
  114034. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  114035. * @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.
  114036. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  114037. * @returns the indices array or an empty array if the mesh has no geometry
  114038. */
  114039. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  114040. get isBlocked(): boolean;
  114041. /**
  114042. * Determine if the current mesh is ready to be rendered
  114043. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  114044. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  114045. * @returns true if all associated assets are ready (material, textures, shaders)
  114046. */
  114047. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  114048. /**
  114049. * 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.
  114050. */
  114051. get areNormalsFrozen(): boolean;
  114052. /**
  114053. * 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.
  114054. * @returns the current mesh
  114055. */
  114056. freezeNormals(): Mesh;
  114057. /**
  114058. * 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
  114059. * @returns the current mesh
  114060. */
  114061. unfreezeNormals(): Mesh;
  114062. /**
  114063. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  114064. */
  114065. set overridenInstanceCount(count: number);
  114066. /** @hidden */
  114067. _preActivate(): Mesh;
  114068. /** @hidden */
  114069. _preActivateForIntermediateRendering(renderId: number): Mesh;
  114070. /** @hidden */
  114071. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  114072. protected _afterComputeWorldMatrix(): void;
  114073. /** @hidden */
  114074. _postActivate(): void;
  114075. /**
  114076. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  114077. * This means the mesh underlying bounding box and sphere are recomputed.
  114078. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  114079. * @returns the current mesh
  114080. */
  114081. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  114082. /** @hidden */
  114083. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  114084. /**
  114085. * This function will subdivide the mesh into multiple submeshes
  114086. * @param count defines the expected number of submeshes
  114087. */
  114088. subdivide(count: number): void;
  114089. /**
  114090. * Copy a FloatArray into a specific associated vertex buffer
  114091. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  114092. * - VertexBuffer.PositionKind
  114093. * - VertexBuffer.UVKind
  114094. * - VertexBuffer.UV2Kind
  114095. * - VertexBuffer.UV3Kind
  114096. * - VertexBuffer.UV4Kind
  114097. * - VertexBuffer.UV5Kind
  114098. * - VertexBuffer.UV6Kind
  114099. * - VertexBuffer.ColorKind
  114100. * - VertexBuffer.MatricesIndicesKind
  114101. * - VertexBuffer.MatricesIndicesExtraKind
  114102. * - VertexBuffer.MatricesWeightsKind
  114103. * - VertexBuffer.MatricesWeightsExtraKind
  114104. * @param data defines the data source
  114105. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  114106. * @param stride defines the data stride size (can be null)
  114107. * @returns the current mesh
  114108. */
  114109. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  114110. /**
  114111. * Delete a vertex buffer associated with this mesh
  114112. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  114113. * - VertexBuffer.PositionKind
  114114. * - VertexBuffer.UVKind
  114115. * - VertexBuffer.UV2Kind
  114116. * - VertexBuffer.UV3Kind
  114117. * - VertexBuffer.UV4Kind
  114118. * - VertexBuffer.UV5Kind
  114119. * - VertexBuffer.UV6Kind
  114120. * - VertexBuffer.ColorKind
  114121. * - VertexBuffer.MatricesIndicesKind
  114122. * - VertexBuffer.MatricesIndicesExtraKind
  114123. * - VertexBuffer.MatricesWeightsKind
  114124. * - VertexBuffer.MatricesWeightsExtraKind
  114125. */
  114126. removeVerticesData(kind: string): void;
  114127. /**
  114128. * Flags an associated vertex buffer as updatable
  114129. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  114130. * - VertexBuffer.PositionKind
  114131. * - VertexBuffer.UVKind
  114132. * - VertexBuffer.UV2Kind
  114133. * - VertexBuffer.UV3Kind
  114134. * - VertexBuffer.UV4Kind
  114135. * - VertexBuffer.UV5Kind
  114136. * - VertexBuffer.UV6Kind
  114137. * - VertexBuffer.ColorKind
  114138. * - VertexBuffer.MatricesIndicesKind
  114139. * - VertexBuffer.MatricesIndicesExtraKind
  114140. * - VertexBuffer.MatricesWeightsKind
  114141. * - VertexBuffer.MatricesWeightsExtraKind
  114142. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  114143. */
  114144. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  114145. /**
  114146. * Sets the mesh global Vertex Buffer
  114147. * @param buffer defines the buffer to use
  114148. * @returns the current mesh
  114149. */
  114150. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  114151. /**
  114152. * Update a specific associated vertex buffer
  114153. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  114154. * - VertexBuffer.PositionKind
  114155. * - VertexBuffer.UVKind
  114156. * - VertexBuffer.UV2Kind
  114157. * - VertexBuffer.UV3Kind
  114158. * - VertexBuffer.UV4Kind
  114159. * - VertexBuffer.UV5Kind
  114160. * - VertexBuffer.UV6Kind
  114161. * - VertexBuffer.ColorKind
  114162. * - VertexBuffer.MatricesIndicesKind
  114163. * - VertexBuffer.MatricesIndicesExtraKind
  114164. * - VertexBuffer.MatricesWeightsKind
  114165. * - VertexBuffer.MatricesWeightsExtraKind
  114166. * @param data defines the data source
  114167. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  114168. * @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)
  114169. * @returns the current mesh
  114170. */
  114171. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  114172. /**
  114173. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  114174. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  114175. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  114176. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  114177. * @returns the current mesh
  114178. */
  114179. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  114180. /**
  114181. * Creates a un-shared specific occurence of the geometry for the mesh.
  114182. * @returns the current mesh
  114183. */
  114184. makeGeometryUnique(): Mesh;
  114185. /**
  114186. * Set the index buffer of this mesh
  114187. * @param indices defines the source data
  114188. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  114189. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  114190. * @returns the current mesh
  114191. */
  114192. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  114193. /**
  114194. * Update the current index buffer
  114195. * @param indices defines the source data
  114196. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  114197. * @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)
  114198. * @returns the current mesh
  114199. */
  114200. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  114201. /**
  114202. * Invert the geometry to move from a right handed system to a left handed one.
  114203. * @returns the current mesh
  114204. */
  114205. toLeftHanded(): Mesh;
  114206. /** @hidden */
  114207. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  114208. /** @hidden */
  114209. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  114210. /**
  114211. * Registers for this mesh a javascript function called just before the rendering process
  114212. * @param func defines the function to call before rendering this mesh
  114213. * @returns the current mesh
  114214. */
  114215. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  114216. /**
  114217. * Disposes a previously registered javascript function called before the rendering
  114218. * @param func defines the function to remove
  114219. * @returns the current mesh
  114220. */
  114221. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  114222. /**
  114223. * Registers for this mesh a javascript function called just after the rendering is complete
  114224. * @param func defines the function to call after rendering this mesh
  114225. * @returns the current mesh
  114226. */
  114227. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  114228. /**
  114229. * Disposes a previously registered javascript function called after the rendering.
  114230. * @param func defines the function to remove
  114231. * @returns the current mesh
  114232. */
  114233. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  114234. /** @hidden */
  114235. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  114236. /** @hidden */
  114237. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  114238. /** @hidden */
  114239. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  114240. /** @hidden */
  114241. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  114242. /** @hidden */
  114243. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  114244. /** @hidden */
  114245. _rebuild(): void;
  114246. /** @hidden */
  114247. _freeze(): void;
  114248. /** @hidden */
  114249. _unFreeze(): void;
  114250. /**
  114251. * 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
  114252. * @param subMesh defines the subMesh to render
  114253. * @param enableAlphaMode defines if alpha mode can be changed
  114254. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  114255. * @returns the current mesh
  114256. */
  114257. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  114258. private _onBeforeDraw;
  114259. /**
  114260. * Renormalize the mesh and patch it up if there are no weights
  114261. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  114262. * However in the case of zero weights then we set just a single influence to 1.
  114263. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  114264. */
  114265. cleanMatrixWeights(): void;
  114266. private normalizeSkinFourWeights;
  114267. private normalizeSkinWeightsAndExtra;
  114268. /**
  114269. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  114270. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  114271. * the user know there was an issue with importing the mesh
  114272. * @returns a validation object with skinned, valid and report string
  114273. */
  114274. validateSkinning(): {
  114275. skinned: boolean;
  114276. valid: boolean;
  114277. report: string;
  114278. };
  114279. /** @hidden */
  114280. _checkDelayState(): Mesh;
  114281. private _queueLoad;
  114282. /**
  114283. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  114284. * A mesh is in the frustum if its bounding box intersects the frustum
  114285. * @param frustumPlanes defines the frustum to test
  114286. * @returns true if the mesh is in the frustum planes
  114287. */
  114288. isInFrustum(frustumPlanes: Plane[]): boolean;
  114289. /**
  114290. * Sets the mesh material by the material or multiMaterial `id` property
  114291. * @param id is a string identifying the material or the multiMaterial
  114292. * @returns the current mesh
  114293. */
  114294. setMaterialByID(id: string): Mesh;
  114295. /**
  114296. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  114297. * @returns an array of IAnimatable
  114298. */
  114299. getAnimatables(): IAnimatable[];
  114300. /**
  114301. * Modifies the mesh geometry according to the passed transformation matrix.
  114302. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  114303. * The mesh normals are modified using the same transformation.
  114304. * Note that, under the hood, this method sets a new VertexBuffer each call.
  114305. * @param transform defines the transform matrix to use
  114306. * @see https://doc.babylonjs.com/resources/baking_transformations
  114307. * @returns the current mesh
  114308. */
  114309. bakeTransformIntoVertices(transform: Matrix): Mesh;
  114310. /**
  114311. * Modifies the mesh geometry according to its own current World Matrix.
  114312. * The mesh World Matrix is then reset.
  114313. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  114314. * Note that, under the hood, this method sets a new VertexBuffer each call.
  114315. * @see https://doc.babylonjs.com/resources/baking_transformations
  114316. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  114317. * @returns the current mesh
  114318. */
  114319. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  114320. /** @hidden */
  114321. get _positions(): Nullable<Vector3[]>;
  114322. /** @hidden */
  114323. _resetPointsArrayCache(): Mesh;
  114324. /** @hidden */
  114325. _generatePointsArray(): boolean;
  114326. /**
  114327. * Returns a new Mesh object generated from the current mesh properties.
  114328. * This method must not get confused with createInstance()
  114329. * @param name is a string, the name given to the new mesh
  114330. * @param newParent can be any Node object (default `null`)
  114331. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  114332. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  114333. * @returns a new mesh
  114334. */
  114335. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  114336. /**
  114337. * Releases resources associated with this mesh.
  114338. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114339. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114340. */
  114341. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114342. /** @hidden */
  114343. _disposeInstanceSpecificData(): void;
  114344. /** @hidden */
  114345. _disposeThinInstanceSpecificData(): void;
  114346. /**
  114347. * Modifies the mesh geometry according to a displacement map.
  114348. * 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.
  114349. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  114350. * @param url is a string, the URL from the image file is to be downloaded.
  114351. * @param minHeight is the lower limit of the displacement.
  114352. * @param maxHeight is the upper limit of the displacement.
  114353. * @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.
  114354. * @param uvOffset is an optional vector2 used to offset UV.
  114355. * @param uvScale is an optional vector2 used to scale UV.
  114356. * @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.
  114357. * @returns the Mesh.
  114358. */
  114359. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  114360. /**
  114361. * Modifies the mesh geometry according to a displacementMap buffer.
  114362. * 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.
  114363. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  114364. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  114365. * @param heightMapWidth is the width of the buffer image.
  114366. * @param heightMapHeight is the height of the buffer image.
  114367. * @param minHeight is the lower limit of the displacement.
  114368. * @param maxHeight is the upper limit of the displacement.
  114369. * @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.
  114370. * @param uvOffset is an optional vector2 used to offset UV.
  114371. * @param uvScale is an optional vector2 used to scale UV.
  114372. * @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.
  114373. * @returns the Mesh.
  114374. */
  114375. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  114376. /**
  114377. * Modify the mesh to get a flat shading rendering.
  114378. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  114379. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  114380. * @returns current mesh
  114381. */
  114382. convertToFlatShadedMesh(): Mesh;
  114383. /**
  114384. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  114385. * In other words, more vertices, no more indices and a single bigger VBO.
  114386. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  114387. * @returns current mesh
  114388. */
  114389. convertToUnIndexedMesh(): Mesh;
  114390. /**
  114391. * Inverses facet orientations.
  114392. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114393. * @param flipNormals will also inverts the normals
  114394. * @returns current mesh
  114395. */
  114396. flipFaces(flipNormals?: boolean): Mesh;
  114397. /**
  114398. * Increase the number of facets and hence vertices in a mesh
  114399. * Vertex normals are interpolated from existing vertex normals
  114400. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114401. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  114402. */
  114403. increaseVertices(numberPerEdge: number): void;
  114404. /**
  114405. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  114406. * This will undo any application of covertToFlatShadedMesh
  114407. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114408. */
  114409. forceSharedVertices(): void;
  114410. /** @hidden */
  114411. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  114412. /** @hidden */
  114413. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  114414. /**
  114415. * Creates a new InstancedMesh object from the mesh model.
  114416. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114417. * @param name defines the name of the new instance
  114418. * @returns a new InstancedMesh
  114419. */
  114420. createInstance(name: string): InstancedMesh;
  114421. /**
  114422. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  114423. * After this call, all the mesh instances have the same submeshes than the current mesh.
  114424. * @returns the current mesh
  114425. */
  114426. synchronizeInstances(): Mesh;
  114427. /**
  114428. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  114429. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  114430. * This should be used together with the simplification to avoid disappearing triangles.
  114431. * @param successCallback an optional success callback to be called after the optimization finished.
  114432. * @returns the current mesh
  114433. */
  114434. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  114435. /**
  114436. * Serialize current mesh
  114437. * @param serializationObject defines the object which will receive the serialization data
  114438. */
  114439. serialize(serializationObject: any): void;
  114440. /** @hidden */
  114441. _syncGeometryWithMorphTargetManager(): void;
  114442. /** @hidden */
  114443. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  114444. /**
  114445. * Returns a new Mesh object parsed from the source provided.
  114446. * @param parsedMesh is the source
  114447. * @param scene defines the hosting scene
  114448. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  114449. * @returns a new Mesh
  114450. */
  114451. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  114452. /**
  114453. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  114454. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114455. * @param name defines the name of the mesh to create
  114456. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  114457. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  114458. * @param closePath creates a seam between the first and the last points of each path of the path array
  114459. * @param offset is taken in account only if the `pathArray` is containing a single path
  114460. * @param scene defines the hosting scene
  114461. * @param updatable defines if the mesh must be flagged as updatable
  114462. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114463. * @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)
  114464. * @returns a new Mesh
  114465. */
  114466. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114467. /**
  114468. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  114469. * @param name defines the name of the mesh to create
  114470. * @param radius sets the radius size (float) of the polygon (default 0.5)
  114471. * @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
  114472. * @param scene defines the hosting scene
  114473. * @param updatable defines if the mesh must be flagged as updatable
  114474. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114475. * @returns a new Mesh
  114476. */
  114477. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114478. /**
  114479. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  114480. * @param name defines the name of the mesh to create
  114481. * @param size sets the size (float) of each box side (default 1)
  114482. * @param scene defines the hosting scene
  114483. * @param updatable defines if the mesh must be flagged as updatable
  114484. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114485. * @returns a new Mesh
  114486. */
  114487. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114488. /**
  114489. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  114490. * @param name defines the name of the mesh to create
  114491. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114492. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114493. * @param scene defines the hosting scene
  114494. * @param updatable defines if the mesh must be flagged as updatable
  114495. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114496. * @returns a new Mesh
  114497. */
  114498. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114499. /**
  114500. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  114501. * @param name defines the name of the mesh to create
  114502. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114503. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114504. * @param scene defines the hosting scene
  114505. * @returns a new Mesh
  114506. */
  114507. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  114508. /**
  114509. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  114510. * @param name defines the name of the mesh to create
  114511. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  114512. * @param diameterTop set the top cap diameter (floats, default 1)
  114513. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  114514. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  114515. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  114516. * @param scene defines the hosting scene
  114517. * @param updatable defines if the mesh must be flagged as updatable
  114518. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114519. * @returns a new Mesh
  114520. */
  114521. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  114522. /**
  114523. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  114524. * @param name defines the name of the mesh to create
  114525. * @param diameter sets the diameter size (float) of the torus (default 1)
  114526. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  114527. * @param tessellation sets the number of torus sides (postive integer, default 16)
  114528. * @param scene defines the hosting scene
  114529. * @param updatable defines if the mesh must be flagged as updatable
  114530. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114531. * @returns a new Mesh
  114532. */
  114533. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114534. /**
  114535. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  114536. * @param name defines the name of the mesh to create
  114537. * @param radius sets the global radius size (float) of the torus knot (default 2)
  114538. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  114539. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  114540. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  114541. * @param p the number of windings on X axis (positive integers, default 2)
  114542. * @param q the number of windings on Y axis (positive integers, default 3)
  114543. * @param scene defines the hosting scene
  114544. * @param updatable defines if the mesh must be flagged as updatable
  114545. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114546. * @returns a new Mesh
  114547. */
  114548. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114549. /**
  114550. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  114551. * @param name defines the name of the mesh to create
  114552. * @param points is an array successive Vector3
  114553. * @param scene defines the hosting scene
  114554. * @param updatable defines if the mesh must be flagged as updatable
  114555. * @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).
  114556. * @returns a new Mesh
  114557. */
  114558. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  114559. /**
  114560. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  114561. * @param name defines the name of the mesh to create
  114562. * @param points is an array successive Vector3
  114563. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  114564. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  114565. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  114566. * @param scene defines the hosting scene
  114567. * @param updatable defines if the mesh must be flagged as updatable
  114568. * @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)
  114569. * @returns a new Mesh
  114570. */
  114571. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  114572. /**
  114573. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  114574. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  114575. * 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.
  114576. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114577. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114578. * Remember you can only change the shape positions, not their number when updating a polygon.
  114579. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  114580. * @param name defines the name of the mesh to create
  114581. * @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
  114582. * @param scene defines the hosting scene
  114583. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114584. * @param updatable defines if the mesh must be flagged as updatable
  114585. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114586. * @param earcutInjection can be used to inject your own earcut reference
  114587. * @returns a new Mesh
  114588. */
  114589. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114590. /**
  114591. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  114592. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  114593. * @param name defines the name of the mesh to create
  114594. * @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
  114595. * @param depth defines the height of extrusion
  114596. * @param scene defines the hosting scene
  114597. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114598. * @param updatable defines if the mesh must be flagged as updatable
  114599. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114600. * @param earcutInjection can be used to inject your own earcut reference
  114601. * @returns a new Mesh
  114602. */
  114603. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114604. /**
  114605. * Creates an extruded shape mesh.
  114606. * 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
  114607. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114608. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114609. * @param name defines the name of the mesh to create
  114610. * @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
  114611. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114612. * @param scale is the value to scale the shape
  114613. * @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
  114614. * @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
  114615. * @param scene defines the hosting scene
  114616. * @param updatable defines if the mesh must be flagged as updatable
  114617. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114618. * @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)
  114619. * @returns a new Mesh
  114620. */
  114621. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114622. /**
  114623. * Creates an custom extruded shape mesh.
  114624. * The custom extrusion is a parametric shape.
  114625. * It has no predefined shape. Its final shape will depend on the input parameters.
  114626. * Please consider using the same method from the MeshBuilder class instead
  114627. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114628. * @param name defines the name of the mesh to create
  114629. * @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
  114630. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114631. * @param scaleFunction is a custom Javascript function called on each path point
  114632. * @param rotationFunction is a custom Javascript function called on each path point
  114633. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114634. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  114635. * @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
  114636. * @param scene defines the hosting scene
  114637. * @param updatable defines if the mesh must be flagged as updatable
  114638. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114639. * @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)
  114640. * @returns a new Mesh
  114641. */
  114642. 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;
  114643. /**
  114644. * Creates lathe mesh.
  114645. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  114646. * Please consider using the same method from the MeshBuilder class instead
  114647. * @param name defines the name of the mesh to create
  114648. * @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
  114649. * @param radius is the radius value of the lathe
  114650. * @param tessellation is the side number of the lathe.
  114651. * @param scene defines the hosting scene
  114652. * @param updatable defines if the mesh must be flagged as updatable
  114653. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114654. * @returns a new Mesh
  114655. */
  114656. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114657. /**
  114658. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  114659. * @param name defines the name of the mesh to create
  114660. * @param size sets the size (float) of both sides of the plane at once (default 1)
  114661. * @param scene defines the hosting scene
  114662. * @param updatable defines if the mesh must be flagged as updatable
  114663. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114664. * @returns a new Mesh
  114665. */
  114666. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114667. /**
  114668. * Creates a ground mesh.
  114669. * Please consider using the same method from the MeshBuilder class instead
  114670. * @param name defines the name of the mesh to create
  114671. * @param width set the width of the ground
  114672. * @param height set the height of the ground
  114673. * @param subdivisions sets the number of subdivisions per side
  114674. * @param scene defines the hosting scene
  114675. * @param updatable defines if the mesh must be flagged as updatable
  114676. * @returns a new Mesh
  114677. */
  114678. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  114679. /**
  114680. * Creates a tiled ground mesh.
  114681. * Please consider using the same method from the MeshBuilder class instead
  114682. * @param name defines the name of the mesh to create
  114683. * @param xmin set the ground minimum X coordinate
  114684. * @param zmin set the ground minimum Y coordinate
  114685. * @param xmax set the ground maximum X coordinate
  114686. * @param zmax set the ground maximum Z coordinate
  114687. * @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
  114688. * @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
  114689. * @param scene defines the hosting scene
  114690. * @param updatable defines if the mesh must be flagged as updatable
  114691. * @returns a new Mesh
  114692. */
  114693. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  114694. w: number;
  114695. h: number;
  114696. }, precision: {
  114697. w: number;
  114698. h: number;
  114699. }, scene: Scene, updatable?: boolean): Mesh;
  114700. /**
  114701. * Creates a ground mesh from a height map.
  114702. * Please consider using the same method from the MeshBuilder class instead
  114703. * @see https://doc.babylonjs.com/babylon101/height_map
  114704. * @param name defines the name of the mesh to create
  114705. * @param url sets the URL of the height map image resource
  114706. * @param width set the ground width size
  114707. * @param height set the ground height size
  114708. * @param subdivisions sets the number of subdivision per side
  114709. * @param minHeight is the minimum altitude on the ground
  114710. * @param maxHeight is the maximum altitude on the ground
  114711. * @param scene defines the hosting scene
  114712. * @param updatable defines if the mesh must be flagged as updatable
  114713. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  114714. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114715. * @returns a new Mesh
  114716. */
  114717. 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;
  114718. /**
  114719. * Creates a tube mesh.
  114720. * The tube is a parametric shape.
  114721. * It has no predefined shape. Its final shape will depend on the input parameters.
  114722. * Please consider using the same method from the MeshBuilder class instead
  114723. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114724. * @param name defines the name of the mesh to create
  114725. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  114726. * @param radius sets the tube radius size
  114727. * @param tessellation is the number of sides on the tubular surface
  114728. * @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
  114729. * @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
  114730. * @param scene defines the hosting scene
  114731. * @param updatable defines if the mesh must be flagged as updatable
  114732. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114733. * @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)
  114734. * @returns a new Mesh
  114735. */
  114736. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  114737. (i: number, distance: number): number;
  114738. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114739. /**
  114740. * Creates a polyhedron mesh.
  114741. * Please consider using the same method from the MeshBuilder class instead.
  114742. * * 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
  114743. * * The parameter `size` (positive float, default 1) sets the polygon size
  114744. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114745. * * 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`
  114746. * * 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
  114747. * * 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)`)
  114748. * * 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
  114749. * * 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
  114750. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114753. * @param name defines the name of the mesh to create
  114754. * @param options defines the options used to create the mesh
  114755. * @param scene defines the hosting scene
  114756. * @returns a new Mesh
  114757. */
  114758. static CreatePolyhedron(name: string, options: {
  114759. type?: number;
  114760. size?: number;
  114761. sizeX?: number;
  114762. sizeY?: number;
  114763. sizeZ?: number;
  114764. custom?: any;
  114765. faceUV?: Vector4[];
  114766. faceColors?: Color4[];
  114767. updatable?: boolean;
  114768. sideOrientation?: number;
  114769. }, scene: Scene): Mesh;
  114770. /**
  114771. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114772. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114773. * * 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`)
  114774. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114775. * * 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
  114776. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114777. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114779. * @param name defines the name of the mesh
  114780. * @param options defines the options used to create the mesh
  114781. * @param scene defines the hosting scene
  114782. * @returns a new Mesh
  114783. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114784. */
  114785. static CreateIcoSphere(name: string, options: {
  114786. radius?: number;
  114787. flat?: boolean;
  114788. subdivisions?: number;
  114789. sideOrientation?: number;
  114790. updatable?: boolean;
  114791. }, scene: Scene): Mesh;
  114792. /**
  114793. * Creates a decal mesh.
  114794. * Please consider using the same method from the MeshBuilder class instead.
  114795. * A decal is a mesh usually applied as a model onto the surface of another mesh
  114796. * @param name defines the name of the mesh
  114797. * @param sourceMesh defines the mesh receiving the decal
  114798. * @param position sets the position of the decal in world coordinates
  114799. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  114800. * @param size sets the decal scaling
  114801. * @param angle sets the angle to rotate the decal
  114802. * @returns a new Mesh
  114803. */
  114804. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  114805. /** Creates a Capsule Mesh
  114806. * @param name defines the name of the mesh.
  114807. * @param options the constructors options used to shape the mesh.
  114808. * @param scene defines the scene the mesh is scoped to.
  114809. * @returns the capsule mesh
  114810. * @see https://doc.babylonjs.com/how_to/capsule_shape
  114811. */
  114812. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  114813. /**
  114814. * Prepare internal position array for software CPU skinning
  114815. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  114816. */
  114817. setPositionsForCPUSkinning(): Float32Array;
  114818. /**
  114819. * Prepare internal normal array for software CPU skinning
  114820. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  114821. */
  114822. setNormalsForCPUSkinning(): Float32Array;
  114823. /**
  114824. * Updates the vertex buffer by applying transformation from the bones
  114825. * @param skeleton defines the skeleton to apply to current mesh
  114826. * @returns the current mesh
  114827. */
  114828. applySkeleton(skeleton: Skeleton): Mesh;
  114829. /**
  114830. * 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
  114831. * @param meshes defines the list of meshes to scan
  114832. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  114833. */
  114834. static MinMax(meshes: AbstractMesh[]): {
  114835. min: Vector3;
  114836. max: Vector3;
  114837. };
  114838. /**
  114839. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  114840. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  114841. * @returns a vector3
  114842. */
  114843. static Center(meshesOrMinMaxVector: {
  114844. min: Vector3;
  114845. max: Vector3;
  114846. } | AbstractMesh[]): Vector3;
  114847. /**
  114848. * Merge the array of meshes into a single mesh for performance reasons.
  114849. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  114850. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  114851. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  114852. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  114853. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  114854. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  114855. * @returns a new mesh
  114856. */
  114857. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  114858. /** @hidden */
  114859. addInstance(instance: InstancedMesh): void;
  114860. /** @hidden */
  114861. removeInstance(instance: InstancedMesh): void;
  114862. }
  114863. }
  114864. declare module BABYLON {
  114865. /**
  114866. * The options Interface for creating a Capsule Mesh
  114867. */
  114868. export interface ICreateCapsuleOptions {
  114869. /** The Orientation of the capsule. Default : Vector3.Up() */
  114870. orientation?: Vector3;
  114871. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  114872. subdivisions: number;
  114873. /** Number of cylindrical segments on the capsule. */
  114874. tessellation: number;
  114875. /** Height or Length of the capsule. */
  114876. height: number;
  114877. /** Radius of the capsule. */
  114878. radius: number;
  114879. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  114880. capSubdivisions: number;
  114881. /** Overwrite for the top radius. */
  114882. radiusTop?: number;
  114883. /** Overwrite for the bottom radius. */
  114884. radiusBottom?: number;
  114885. /** Overwrite for the top capSubdivisions. */
  114886. topCapSubdivisions?: number;
  114887. /** Overwrite for the bottom capSubdivisions. */
  114888. bottomCapSubdivisions?: number;
  114889. }
  114890. /**
  114891. * Class containing static functions to help procedurally build meshes
  114892. */
  114893. export class CapsuleBuilder {
  114894. /**
  114895. * Creates a capsule or a pill mesh
  114896. * @param name defines the name of the mesh
  114897. * @param options The constructors options.
  114898. * @param scene The scene the mesh is scoped to.
  114899. * @returns Capsule Mesh
  114900. */
  114901. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  114902. }
  114903. }
  114904. declare module BABYLON {
  114905. /**
  114906. * Define an interface for all classes that will get and set the data on vertices
  114907. */
  114908. export interface IGetSetVerticesData {
  114909. /**
  114910. * Gets a boolean indicating if specific vertex data is present
  114911. * @param kind defines the vertex data kind to use
  114912. * @returns true is data kind is present
  114913. */
  114914. isVerticesDataPresent(kind: string): boolean;
  114915. /**
  114916. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  114917. * @param kind defines the data kind (Position, normal, etc...)
  114918. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  114919. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  114920. * @returns a float array containing vertex data
  114921. */
  114922. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  114923. /**
  114924. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  114925. * @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.
  114926. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  114927. * @returns the indices array or an empty array if the mesh has no geometry
  114928. */
  114929. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  114930. /**
  114931. * Set specific vertex data
  114932. * @param kind defines the data kind (Position, normal, etc...)
  114933. * @param data defines the vertex data to use
  114934. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  114935. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  114936. */
  114937. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  114938. /**
  114939. * Update a specific associated vertex buffer
  114940. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  114941. * - VertexBuffer.PositionKind
  114942. * - VertexBuffer.UVKind
  114943. * - VertexBuffer.UV2Kind
  114944. * - VertexBuffer.UV3Kind
  114945. * - VertexBuffer.UV4Kind
  114946. * - VertexBuffer.UV5Kind
  114947. * - VertexBuffer.UV6Kind
  114948. * - VertexBuffer.ColorKind
  114949. * - VertexBuffer.MatricesIndicesKind
  114950. * - VertexBuffer.MatricesIndicesExtraKind
  114951. * - VertexBuffer.MatricesWeightsKind
  114952. * - VertexBuffer.MatricesWeightsExtraKind
  114953. * @param data defines the data source
  114954. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  114955. * @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)
  114956. */
  114957. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  114958. /**
  114959. * Creates a new index buffer
  114960. * @param indices defines the indices to store in the index buffer
  114961. * @param totalVertices defines the total number of vertices (could be null)
  114962. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  114963. */
  114964. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  114965. }
  114966. /**
  114967. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  114968. */
  114969. export class VertexData {
  114970. /**
  114971. * Mesh side orientation : usually the external or front surface
  114972. */
  114973. static readonly FRONTSIDE: number;
  114974. /**
  114975. * Mesh side orientation : usually the internal or back surface
  114976. */
  114977. static readonly BACKSIDE: number;
  114978. /**
  114979. * Mesh side orientation : both internal and external or front and back surfaces
  114980. */
  114981. static readonly DOUBLESIDE: number;
  114982. /**
  114983. * Mesh side orientation : by default, `FRONTSIDE`
  114984. */
  114985. static readonly DEFAULTSIDE: number;
  114986. /**
  114987. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  114988. */
  114989. positions: Nullable<FloatArray>;
  114990. /**
  114991. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  114992. */
  114993. normals: Nullable<FloatArray>;
  114994. /**
  114995. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  114996. */
  114997. tangents: Nullable<FloatArray>;
  114998. /**
  114999. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115000. */
  115001. uvs: Nullable<FloatArray>;
  115002. /**
  115003. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115004. */
  115005. uvs2: Nullable<FloatArray>;
  115006. /**
  115007. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115008. */
  115009. uvs3: Nullable<FloatArray>;
  115010. /**
  115011. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115012. */
  115013. uvs4: Nullable<FloatArray>;
  115014. /**
  115015. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115016. */
  115017. uvs5: Nullable<FloatArray>;
  115018. /**
  115019. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115020. */
  115021. uvs6: Nullable<FloatArray>;
  115022. /**
  115023. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  115024. */
  115025. colors: Nullable<FloatArray>;
  115026. /**
  115027. * 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).
  115028. */
  115029. matricesIndices: Nullable<FloatArray>;
  115030. /**
  115031. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  115032. */
  115033. matricesWeights: Nullable<FloatArray>;
  115034. /**
  115035. * An array extending the number of possible indices
  115036. */
  115037. matricesIndicesExtra: Nullable<FloatArray>;
  115038. /**
  115039. * An array extending the number of possible weights when the number of indices is extended
  115040. */
  115041. matricesWeightsExtra: Nullable<FloatArray>;
  115042. /**
  115043. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  115044. */
  115045. indices: Nullable<IndicesArray>;
  115046. /**
  115047. * Uses the passed data array to set the set the values for the specified kind of data
  115048. * @param data a linear array of floating numbers
  115049. * @param kind the type of data that is being set, eg positions, colors etc
  115050. */
  115051. set(data: FloatArray, kind: string): void;
  115052. /**
  115053. * Associates the vertexData to the passed Mesh.
  115054. * Sets it as updatable or not (default `false`)
  115055. * @param mesh the mesh the vertexData is applied to
  115056. * @param updatable when used and having the value true allows new data to update the vertexData
  115057. * @returns the VertexData
  115058. */
  115059. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  115060. /**
  115061. * Associates the vertexData to the passed Geometry.
  115062. * Sets it as updatable or not (default `false`)
  115063. * @param geometry the geometry the vertexData is applied to
  115064. * @param updatable when used and having the value true allows new data to update the vertexData
  115065. * @returns VertexData
  115066. */
  115067. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  115068. /**
  115069. * Updates the associated mesh
  115070. * @param mesh the mesh to be updated
  115071. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  115072. * @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
  115073. * @returns VertexData
  115074. */
  115075. updateMesh(mesh: Mesh): VertexData;
  115076. /**
  115077. * Updates the associated geometry
  115078. * @param geometry the geometry to be updated
  115079. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  115080. * @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
  115081. * @returns VertexData.
  115082. */
  115083. updateGeometry(geometry: Geometry): VertexData;
  115084. private _applyTo;
  115085. private _update;
  115086. /**
  115087. * Transforms each position and each normal of the vertexData according to the passed Matrix
  115088. * @param matrix the transforming matrix
  115089. * @returns the VertexData
  115090. */
  115091. transform(matrix: Matrix): VertexData;
  115092. /**
  115093. * Merges the passed VertexData into the current one
  115094. * @param other the VertexData to be merged into the current one
  115095. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  115096. * @returns the modified VertexData
  115097. */
  115098. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  115099. private _mergeElement;
  115100. private _validate;
  115101. /**
  115102. * Serializes the VertexData
  115103. * @returns a serialized object
  115104. */
  115105. serialize(): any;
  115106. /**
  115107. * Extracts the vertexData from a mesh
  115108. * @param mesh the mesh from which to extract the VertexData
  115109. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  115110. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  115111. * @returns the object VertexData associated to the passed mesh
  115112. */
  115113. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  115114. /**
  115115. * Extracts the vertexData from the geometry
  115116. * @param geometry the geometry from which to extract the VertexData
  115117. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  115118. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  115119. * @returns the object VertexData associated to the passed mesh
  115120. */
  115121. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  115122. private static _ExtractFrom;
  115123. /**
  115124. * Creates the VertexData for a Ribbon
  115125. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  115126. * * pathArray array of paths, each of which an array of successive Vector3
  115127. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  115128. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  115129. * * 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
  115130. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115131. * * 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)
  115132. * * 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)
  115133. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  115134. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  115135. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  115136. * @returns the VertexData of the ribbon
  115137. */
  115138. static CreateRibbon(options: {
  115139. pathArray: Vector3[][];
  115140. closeArray?: boolean;
  115141. closePath?: boolean;
  115142. offset?: number;
  115143. sideOrientation?: number;
  115144. frontUVs?: Vector4;
  115145. backUVs?: Vector4;
  115146. invertUV?: boolean;
  115147. uvs?: Vector2[];
  115148. colors?: Color4[];
  115149. }): VertexData;
  115150. /**
  115151. * Creates the VertexData for a box
  115152. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115153. * * size sets the width, height and depth of the box to the value of size, optional default 1
  115154. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  115155. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  115156. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  115157. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  115158. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  115159. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115160. * * 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)
  115161. * * 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)
  115162. * @returns the VertexData of the box
  115163. */
  115164. static CreateBox(options: {
  115165. size?: number;
  115166. width?: number;
  115167. height?: number;
  115168. depth?: number;
  115169. faceUV?: Vector4[];
  115170. faceColors?: Color4[];
  115171. sideOrientation?: number;
  115172. frontUVs?: Vector4;
  115173. backUVs?: Vector4;
  115174. }): VertexData;
  115175. /**
  115176. * Creates the VertexData for a tiled box
  115177. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115178. * * faceTiles sets the pattern, tile size and number of tiles for a face
  115179. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  115180. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  115181. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115182. * @returns the VertexData of the box
  115183. */
  115184. static CreateTiledBox(options: {
  115185. pattern?: number;
  115186. width?: number;
  115187. height?: number;
  115188. depth?: number;
  115189. tileSize?: number;
  115190. tileWidth?: number;
  115191. tileHeight?: number;
  115192. alignHorizontal?: number;
  115193. alignVertical?: number;
  115194. faceUV?: Vector4[];
  115195. faceColors?: Color4[];
  115196. sideOrientation?: number;
  115197. }): VertexData;
  115198. /**
  115199. * Creates the VertexData for a tiled plane
  115200. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115201. * * pattern a limited pattern arrangement depending on the number
  115202. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  115203. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  115204. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  115205. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115206. * * 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)
  115207. * * 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)
  115208. * @returns the VertexData of the tiled plane
  115209. */
  115210. static CreateTiledPlane(options: {
  115211. pattern?: number;
  115212. tileSize?: number;
  115213. tileWidth?: number;
  115214. tileHeight?: number;
  115215. size?: number;
  115216. width?: number;
  115217. height?: number;
  115218. alignHorizontal?: number;
  115219. alignVertical?: number;
  115220. sideOrientation?: number;
  115221. frontUVs?: Vector4;
  115222. backUVs?: Vector4;
  115223. }): VertexData;
  115224. /**
  115225. * Creates the VertexData for an ellipsoid, defaults to a sphere
  115226. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115227. * * segments sets the number of horizontal strips optional, default 32
  115228. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  115229. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  115230. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  115231. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  115232. * * 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
  115233. * * 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
  115234. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115235. * * 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)
  115236. * * 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)
  115237. * @returns the VertexData of the ellipsoid
  115238. */
  115239. static CreateSphere(options: {
  115240. segments?: number;
  115241. diameter?: number;
  115242. diameterX?: number;
  115243. diameterY?: number;
  115244. diameterZ?: number;
  115245. arc?: number;
  115246. slice?: number;
  115247. sideOrientation?: number;
  115248. frontUVs?: Vector4;
  115249. backUVs?: Vector4;
  115250. }): VertexData;
  115251. /**
  115252. * Creates the VertexData for a cylinder, cone or prism
  115253. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115254. * * height sets the height (y direction) of the cylinder, optional, default 2
  115255. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  115256. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  115257. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  115258. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  115259. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  115260. * * 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
  115261. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  115262. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  115263. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  115264. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  115265. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115266. * * 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)
  115267. * * 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)
  115268. * @returns the VertexData of the cylinder, cone or prism
  115269. */
  115270. static CreateCylinder(options: {
  115271. height?: number;
  115272. diameterTop?: number;
  115273. diameterBottom?: number;
  115274. diameter?: number;
  115275. tessellation?: number;
  115276. subdivisions?: number;
  115277. arc?: number;
  115278. faceColors?: Color4[];
  115279. faceUV?: Vector4[];
  115280. hasRings?: boolean;
  115281. enclose?: boolean;
  115282. sideOrientation?: number;
  115283. frontUVs?: Vector4;
  115284. backUVs?: Vector4;
  115285. }): VertexData;
  115286. /**
  115287. * Creates the VertexData for a torus
  115288. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115289. * * diameter the diameter of the torus, optional default 1
  115290. * * thickness the diameter of the tube forming the torus, optional default 0.5
  115291. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  115292. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115293. * * 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)
  115294. * * 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)
  115295. * @returns the VertexData of the torus
  115296. */
  115297. static CreateTorus(options: {
  115298. diameter?: number;
  115299. thickness?: number;
  115300. tessellation?: number;
  115301. sideOrientation?: number;
  115302. frontUVs?: Vector4;
  115303. backUVs?: Vector4;
  115304. }): VertexData;
  115305. /**
  115306. * Creates the VertexData of the LineSystem
  115307. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  115308. * - lines an array of lines, each line being an array of successive Vector3
  115309. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  115310. * @returns the VertexData of the LineSystem
  115311. */
  115312. static CreateLineSystem(options: {
  115313. lines: Vector3[][];
  115314. colors?: Nullable<Color4[][]>;
  115315. }): VertexData;
  115316. /**
  115317. * Create the VertexData for a DashedLines
  115318. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  115319. * - points an array successive Vector3
  115320. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  115321. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  115322. * - dashNb the intended total number of dashes, optional, default 200
  115323. * @returns the VertexData for the DashedLines
  115324. */
  115325. static CreateDashedLines(options: {
  115326. points: Vector3[];
  115327. dashSize?: number;
  115328. gapSize?: number;
  115329. dashNb?: number;
  115330. }): VertexData;
  115331. /**
  115332. * Creates the VertexData for a Ground
  115333. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  115334. * - width the width (x direction) of the ground, optional, default 1
  115335. * - height the height (z direction) of the ground, optional, default 1
  115336. * - subdivisions the number of subdivisions per side, optional, default 1
  115337. * @returns the VertexData of the Ground
  115338. */
  115339. static CreateGround(options: {
  115340. width?: number;
  115341. height?: number;
  115342. subdivisions?: number;
  115343. subdivisionsX?: number;
  115344. subdivisionsY?: number;
  115345. }): VertexData;
  115346. /**
  115347. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  115348. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  115349. * * xmin the ground minimum X coordinate, optional, default -1
  115350. * * zmin the ground minimum Z coordinate, optional, default -1
  115351. * * xmax the ground maximum X coordinate, optional, default 1
  115352. * * zmax the ground maximum Z coordinate, optional, default 1
  115353. * * 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}
  115354. * * 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}
  115355. * @returns the VertexData of the TiledGround
  115356. */
  115357. static CreateTiledGround(options: {
  115358. xmin: number;
  115359. zmin: number;
  115360. xmax: number;
  115361. zmax: number;
  115362. subdivisions?: {
  115363. w: number;
  115364. h: number;
  115365. };
  115366. precision?: {
  115367. w: number;
  115368. h: number;
  115369. };
  115370. }): VertexData;
  115371. /**
  115372. * Creates the VertexData of the Ground designed from a heightmap
  115373. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  115374. * * width the width (x direction) of the ground
  115375. * * height the height (z direction) of the ground
  115376. * * subdivisions the number of subdivisions per side
  115377. * * minHeight the minimum altitude on the ground, optional, default 0
  115378. * * maxHeight the maximum altitude on the ground, optional default 1
  115379. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  115380. * * buffer the array holding the image color data
  115381. * * bufferWidth the width of image
  115382. * * bufferHeight the height of image
  115383. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  115384. * @returns the VertexData of the Ground designed from a heightmap
  115385. */
  115386. static CreateGroundFromHeightMap(options: {
  115387. width: number;
  115388. height: number;
  115389. subdivisions: number;
  115390. minHeight: number;
  115391. maxHeight: number;
  115392. colorFilter: Color3;
  115393. buffer: Uint8Array;
  115394. bufferWidth: number;
  115395. bufferHeight: number;
  115396. alphaFilter: number;
  115397. }): VertexData;
  115398. /**
  115399. * Creates the VertexData for a Plane
  115400. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  115401. * * size sets the width and height of the plane to the value of size, optional default 1
  115402. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  115403. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  115404. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115405. * * 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)
  115406. * * 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)
  115407. * @returns the VertexData of the box
  115408. */
  115409. static CreatePlane(options: {
  115410. size?: number;
  115411. width?: number;
  115412. height?: number;
  115413. sideOrientation?: number;
  115414. frontUVs?: Vector4;
  115415. backUVs?: Vector4;
  115416. }): VertexData;
  115417. /**
  115418. * Creates the VertexData of the Disc or regular Polygon
  115419. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  115420. * * radius the radius of the disc, optional default 0.5
  115421. * * tessellation the number of polygon sides, optional, default 64
  115422. * * 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
  115423. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115424. * * 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)
  115425. * * 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)
  115426. * @returns the VertexData of the box
  115427. */
  115428. static CreateDisc(options: {
  115429. radius?: number;
  115430. tessellation?: number;
  115431. arc?: number;
  115432. sideOrientation?: number;
  115433. frontUVs?: Vector4;
  115434. backUVs?: Vector4;
  115435. }): VertexData;
  115436. /**
  115437. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  115438. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  115439. * @param polygon a mesh built from polygonTriangulation.build()
  115440. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115441. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  115442. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  115443. * @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)
  115444. * @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)
  115445. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  115446. * @returns the VertexData of the Polygon
  115447. */
  115448. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  115449. /**
  115450. * Creates the VertexData of the IcoSphere
  115451. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  115452. * * radius the radius of the IcoSphere, optional default 1
  115453. * * radiusX allows stretching in the x direction, optional, default radius
  115454. * * radiusY allows stretching in the y direction, optional, default radius
  115455. * * radiusZ allows stretching in the z direction, optional, default radius
  115456. * * flat when true creates a flat shaded mesh, optional, default true
  115457. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  115458. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115459. * * 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)
  115460. * * 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)
  115461. * @returns the VertexData of the IcoSphere
  115462. */
  115463. static CreateIcoSphere(options: {
  115464. radius?: number;
  115465. radiusX?: number;
  115466. radiusY?: number;
  115467. radiusZ?: number;
  115468. flat?: boolean;
  115469. subdivisions?: number;
  115470. sideOrientation?: number;
  115471. frontUVs?: Vector4;
  115472. backUVs?: Vector4;
  115473. }): VertexData;
  115474. /**
  115475. * Creates the VertexData for a Polyhedron
  115476. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  115477. * * type provided types are:
  115478. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  115479. * * 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)
  115480. * * size the size of the IcoSphere, optional default 1
  115481. * * sizeX allows stretching in the x direction, optional, default size
  115482. * * sizeY allows stretching in the y direction, optional, default size
  115483. * * sizeZ allows stretching in the z direction, optional, default size
  115484. * * 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
  115485. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  115486. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  115487. * * flat when true creates a flat shaded mesh, optional, default true
  115488. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  115489. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115490. * * 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)
  115491. * * 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)
  115492. * @returns the VertexData of the Polyhedron
  115493. */
  115494. static CreatePolyhedron(options: {
  115495. type?: number;
  115496. size?: number;
  115497. sizeX?: number;
  115498. sizeY?: number;
  115499. sizeZ?: number;
  115500. custom?: any;
  115501. faceUV?: Vector4[];
  115502. faceColors?: Color4[];
  115503. flat?: boolean;
  115504. sideOrientation?: number;
  115505. frontUVs?: Vector4;
  115506. backUVs?: Vector4;
  115507. }): VertexData;
  115508. /**
  115509. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  115510. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  115511. * @returns the VertexData of the Capsule
  115512. */
  115513. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  115514. /**
  115515. * Creates the VertexData for a TorusKnot
  115516. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  115517. * * radius the radius of the torus knot, optional, default 2
  115518. * * tube the thickness of the tube, optional, default 0.5
  115519. * * radialSegments the number of sides on each tube segments, optional, default 32
  115520. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  115521. * * p the number of windings around the z axis, optional, default 2
  115522. * * q the number of windings around the x axis, optional, default 3
  115523. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115524. * * 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)
  115525. * * 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)
  115526. * @returns the VertexData of the Torus Knot
  115527. */
  115528. static CreateTorusKnot(options: {
  115529. radius?: number;
  115530. tube?: number;
  115531. radialSegments?: number;
  115532. tubularSegments?: number;
  115533. p?: number;
  115534. q?: number;
  115535. sideOrientation?: number;
  115536. frontUVs?: Vector4;
  115537. backUVs?: Vector4;
  115538. }): VertexData;
  115539. /**
  115540. * Compute normals for given positions and indices
  115541. * @param positions an array of vertex positions, [...., x, y, z, ......]
  115542. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  115543. * @param normals an array of vertex normals, [...., x, y, z, ......]
  115544. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  115545. * * facetNormals : optional array of facet normals (vector3)
  115546. * * facetPositions : optional array of facet positions (vector3)
  115547. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  115548. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  115549. * * bInfo : optional bounding info, required for facetPartitioning computation
  115550. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  115551. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  115552. * * useRightHandedSystem: optional boolean to for right handed system computation
  115553. * * depthSort : optional boolean to enable the facet depth sort computation
  115554. * * distanceTo : optional Vector3 to compute the facet depth from this location
  115555. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  115556. */
  115557. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  115558. facetNormals?: any;
  115559. facetPositions?: any;
  115560. facetPartitioning?: any;
  115561. ratio?: number;
  115562. bInfo?: any;
  115563. bbSize?: Vector3;
  115564. subDiv?: any;
  115565. useRightHandedSystem?: boolean;
  115566. depthSort?: boolean;
  115567. distanceTo?: Vector3;
  115568. depthSortedFacets?: any;
  115569. }): void;
  115570. /** @hidden */
  115571. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  115572. /**
  115573. * Applies VertexData created from the imported parameters to the geometry
  115574. * @param parsedVertexData the parsed data from an imported file
  115575. * @param geometry the geometry to apply the VertexData to
  115576. */
  115577. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  115578. }
  115579. }
  115580. declare module BABYLON {
  115581. /**
  115582. * Class containing static functions to help procedurally build meshes
  115583. */
  115584. export class DiscBuilder {
  115585. /**
  115586. * Creates a plane polygonal mesh. By default, this is a disc
  115587. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  115588. * * 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
  115589. * * 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
  115590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115591. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115593. * @param name defines the name of the mesh
  115594. * @param options defines the options used to create the mesh
  115595. * @param scene defines the hosting scene
  115596. * @returns the plane polygonal mesh
  115597. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  115598. */
  115599. static CreateDisc(name: string, options: {
  115600. radius?: number;
  115601. tessellation?: number;
  115602. arc?: number;
  115603. updatable?: boolean;
  115604. sideOrientation?: number;
  115605. frontUVs?: Vector4;
  115606. backUVs?: Vector4;
  115607. }, scene?: Nullable<Scene>): Mesh;
  115608. }
  115609. }
  115610. declare module BABYLON {
  115611. /**
  115612. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  115613. *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.
  115614. * The SPS is also a particle system. It provides some methods to manage the particles.
  115615. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  115616. *
  115617. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  115618. */
  115619. export class SolidParticleSystem implements IDisposable {
  115620. /**
  115621. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  115622. * Example : var p = SPS.particles[i];
  115623. */
  115624. particles: SolidParticle[];
  115625. /**
  115626. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  115627. */
  115628. nbParticles: number;
  115629. /**
  115630. * If the particles must ever face the camera (default false). Useful for planar particles.
  115631. */
  115632. billboard: boolean;
  115633. /**
  115634. * Recompute normals when adding a shape
  115635. */
  115636. recomputeNormals: boolean;
  115637. /**
  115638. * This a counter ofr your own usage. It's not set by any SPS functions.
  115639. */
  115640. counter: number;
  115641. /**
  115642. * The SPS name. This name is also given to the underlying mesh.
  115643. */
  115644. name: string;
  115645. /**
  115646. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  115647. */
  115648. mesh: Mesh;
  115649. /**
  115650. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  115651. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  115652. */
  115653. vars: any;
  115654. /**
  115655. * This array is populated when the SPS is set as 'pickable'.
  115656. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  115657. * Each element of this array is an object `{idx: int, faceId: int}`.
  115658. * `idx` is the picked particle index in the `SPS.particles` array
  115659. * `faceId` is the picked face index counted within this particle.
  115660. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  115661. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  115662. * Use the method SPS.pickedParticle(pickingInfo) instead.
  115663. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115664. */
  115665. pickedParticles: {
  115666. idx: number;
  115667. faceId: number;
  115668. }[];
  115669. /**
  115670. * This array is populated when the SPS is set as 'pickable'
  115671. * Each key of this array is a submesh index.
  115672. * Each element of this array is a second array defined like this :
  115673. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  115674. * Each element of this second array is an object `{idx: int, faceId: int}`.
  115675. * `idx` is the picked particle index in the `SPS.particles` array
  115676. * `faceId` is the picked face index counted within this particle.
  115677. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  115678. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115679. */
  115680. pickedBySubMesh: {
  115681. idx: number;
  115682. faceId: number;
  115683. }[][];
  115684. /**
  115685. * This array is populated when `enableDepthSort` is set to true.
  115686. * Each element of this array is an instance of the class DepthSortedParticle.
  115687. */
  115688. depthSortedParticles: DepthSortedParticle[];
  115689. /**
  115690. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  115691. * @hidden
  115692. */
  115693. _bSphereOnly: boolean;
  115694. /**
  115695. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  115696. * @hidden
  115697. */
  115698. _bSphereRadiusFactor: number;
  115699. private _scene;
  115700. private _positions;
  115701. private _indices;
  115702. private _normals;
  115703. private _colors;
  115704. private _uvs;
  115705. private _indices32;
  115706. private _positions32;
  115707. private _normals32;
  115708. private _fixedNormal32;
  115709. private _colors32;
  115710. private _uvs32;
  115711. private _index;
  115712. private _updatable;
  115713. private _pickable;
  115714. private _isVisibilityBoxLocked;
  115715. private _alwaysVisible;
  115716. private _depthSort;
  115717. private _expandable;
  115718. private _shapeCounter;
  115719. private _copy;
  115720. private _color;
  115721. private _computeParticleColor;
  115722. private _computeParticleTexture;
  115723. private _computeParticleRotation;
  115724. private _computeParticleVertex;
  115725. private _computeBoundingBox;
  115726. private _depthSortParticles;
  115727. private _camera;
  115728. private _mustUnrotateFixedNormals;
  115729. private _particlesIntersect;
  115730. private _needs32Bits;
  115731. private _isNotBuilt;
  115732. private _lastParticleId;
  115733. private _idxOfId;
  115734. private _multimaterialEnabled;
  115735. private _useModelMaterial;
  115736. private _indicesByMaterial;
  115737. private _materialIndexes;
  115738. private _depthSortFunction;
  115739. private _materialSortFunction;
  115740. private _materials;
  115741. private _multimaterial;
  115742. private _materialIndexesById;
  115743. private _defaultMaterial;
  115744. private _autoUpdateSubMeshes;
  115745. private _tmpVertex;
  115746. /**
  115747. * Creates a SPS (Solid Particle System) object.
  115748. * @param name (String) is the SPS name, this will be the underlying mesh name.
  115749. * @param scene (Scene) is the scene in which the SPS is added.
  115750. * @param options defines the options of the sps e.g.
  115751. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  115752. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  115753. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  115754. * * 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.
  115755. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  115756. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  115757. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  115758. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  115759. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  115760. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  115761. */
  115762. constructor(name: string, scene: Scene, options?: {
  115763. updatable?: boolean;
  115764. isPickable?: boolean;
  115765. enableDepthSort?: boolean;
  115766. particleIntersection?: boolean;
  115767. boundingSphereOnly?: boolean;
  115768. bSphereRadiusFactor?: number;
  115769. expandable?: boolean;
  115770. useModelMaterial?: boolean;
  115771. enableMultiMaterial?: boolean;
  115772. });
  115773. /**
  115774. * Builds the SPS underlying mesh. Returns a standard Mesh.
  115775. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  115776. * @returns the created mesh
  115777. */
  115778. buildMesh(): Mesh;
  115779. /**
  115780. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  115781. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  115782. * Thus the particles generated from `digest()` have their property `position` set yet.
  115783. * @param mesh ( Mesh ) is the mesh to be digested
  115784. * @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
  115785. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  115786. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  115787. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115788. * @returns the current SPS
  115789. */
  115790. digest(mesh: Mesh, options?: {
  115791. facetNb?: number;
  115792. number?: number;
  115793. delta?: number;
  115794. storage?: [];
  115795. }): SolidParticleSystem;
  115796. /**
  115797. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  115798. * @hidden
  115799. */
  115800. private _unrotateFixedNormals;
  115801. /**
  115802. * Resets the temporary working copy particle
  115803. * @hidden
  115804. */
  115805. private _resetCopy;
  115806. /**
  115807. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  115808. * @param p the current index in the positions array to be updated
  115809. * @param ind the current index in the indices array
  115810. * @param shape a Vector3 array, the shape geometry
  115811. * @param positions the positions array to be updated
  115812. * @param meshInd the shape indices array
  115813. * @param indices the indices array to be updated
  115814. * @param meshUV the shape uv array
  115815. * @param uvs the uv array to be updated
  115816. * @param meshCol the shape color array
  115817. * @param colors the color array to be updated
  115818. * @param meshNor the shape normals array
  115819. * @param normals the normals array to be updated
  115820. * @param idx the particle index
  115821. * @param idxInShape the particle index in its shape
  115822. * @param options the addShape() method passed options
  115823. * @model the particle model
  115824. * @hidden
  115825. */
  115826. private _meshBuilder;
  115827. /**
  115828. * Returns a shape Vector3 array from positions float array
  115829. * @param positions float array
  115830. * @returns a vector3 array
  115831. * @hidden
  115832. */
  115833. private _posToShape;
  115834. /**
  115835. * Returns a shapeUV array from a float uvs (array deep copy)
  115836. * @param uvs as a float array
  115837. * @returns a shapeUV array
  115838. * @hidden
  115839. */
  115840. private _uvsToShapeUV;
  115841. /**
  115842. * Adds a new particle object in the particles array
  115843. * @param idx particle index in particles array
  115844. * @param id particle id
  115845. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  115846. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  115847. * @param model particle ModelShape object
  115848. * @param shapeId model shape identifier
  115849. * @param idxInShape index of the particle in the current model
  115850. * @param bInfo model bounding info object
  115851. * @param storage target storage array, if any
  115852. * @hidden
  115853. */
  115854. private _addParticle;
  115855. /**
  115856. * Adds some particles to the SPS from the model shape. Returns the shape id.
  115857. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  115858. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  115859. * @param nb (positive integer) the number of particles to be created from this model
  115860. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  115861. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  115862. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115863. * @returns the number of shapes in the system
  115864. */
  115865. addShape(mesh: Mesh, nb: number, options?: {
  115866. positionFunction?: any;
  115867. vertexFunction?: any;
  115868. storage?: [];
  115869. }): number;
  115870. /**
  115871. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  115872. * @hidden
  115873. */
  115874. private _rebuildParticle;
  115875. /**
  115876. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  115877. * @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.
  115878. * @returns the SPS.
  115879. */
  115880. rebuildMesh(reset?: boolean): SolidParticleSystem;
  115881. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  115882. * Returns an array with the removed particles.
  115883. * 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.
  115884. * The SPS can't be empty so at least one particle needs to remain in place.
  115885. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  115886. * @param start index of the first particle to remove
  115887. * @param end index of the last particle to remove (included)
  115888. * @returns an array populated with the removed particles
  115889. */
  115890. removeParticles(start: number, end: number): SolidParticle[];
  115891. /**
  115892. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  115893. * @param solidParticleArray an array populated with Solid Particles objects
  115894. * @returns the SPS
  115895. */
  115896. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  115897. /**
  115898. * Creates a new particle and modifies the SPS mesh geometry :
  115899. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  115900. * - calls _addParticle() to populate the particle array
  115901. * factorized code from addShape() and insertParticlesFromArray()
  115902. * @param idx particle index in the particles array
  115903. * @param i particle index in its shape
  115904. * @param modelShape particle ModelShape object
  115905. * @param shape shape vertex array
  115906. * @param meshInd shape indices array
  115907. * @param meshUV shape uv array
  115908. * @param meshCol shape color array
  115909. * @param meshNor shape normals array
  115910. * @param bbInfo shape bounding info
  115911. * @param storage target particle storage
  115912. * @options addShape() passed options
  115913. * @hidden
  115914. */
  115915. private _insertNewParticle;
  115916. /**
  115917. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  115918. * This method calls `updateParticle()` for each particle of the SPS.
  115919. * For an animated SPS, it is usually called within the render loop.
  115920. * 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.
  115921. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  115922. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  115923. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  115924. * @returns the SPS.
  115925. */
  115926. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  115927. /**
  115928. * Disposes the SPS.
  115929. */
  115930. dispose(): void;
  115931. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  115932. * idx is the particle index in the SPS
  115933. * faceId is the picked face index counted within this particle.
  115934. * Returns null if the pickInfo can't identify a picked particle.
  115935. * @param pickingInfo (PickingInfo object)
  115936. * @returns {idx: number, faceId: number} or null
  115937. */
  115938. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  115939. idx: number;
  115940. faceId: number;
  115941. }>;
  115942. /**
  115943. * Returns a SolidParticle object from its identifier : particle.id
  115944. * @param id (integer) the particle Id
  115945. * @returns the searched particle or null if not found in the SPS.
  115946. */
  115947. getParticleById(id: number): Nullable<SolidParticle>;
  115948. /**
  115949. * Returns a new array populated with the particles having the passed shapeId.
  115950. * @param shapeId (integer) the shape identifier
  115951. * @returns a new solid particle array
  115952. */
  115953. getParticlesByShapeId(shapeId: number): SolidParticle[];
  115954. /**
  115955. * Populates the passed array "ref" with the particles having the passed shapeId.
  115956. * @param shapeId the shape identifier
  115957. * @returns the SPS
  115958. * @param ref
  115959. */
  115960. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  115961. /**
  115962. * Computes the required SubMeshes according the materials assigned to the particles.
  115963. * @returns the solid particle system.
  115964. * Does nothing if called before the SPS mesh is built.
  115965. */
  115966. computeSubMeshes(): SolidParticleSystem;
  115967. /**
  115968. * Sorts the solid particles by material when MultiMaterial is enabled.
  115969. * Updates the indices32 array.
  115970. * Updates the indicesByMaterial array.
  115971. * Updates the mesh indices array.
  115972. * @returns the SPS
  115973. * @hidden
  115974. */
  115975. private _sortParticlesByMaterial;
  115976. /**
  115977. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  115978. * @hidden
  115979. */
  115980. private _setMaterialIndexesById;
  115981. /**
  115982. * Returns an array with unique values of Materials from the passed array
  115983. * @param array the material array to be checked and filtered
  115984. * @hidden
  115985. */
  115986. private _filterUniqueMaterialId;
  115987. /**
  115988. * Sets a new Standard Material as _defaultMaterial if not already set.
  115989. * @hidden
  115990. */
  115991. private _setDefaultMaterial;
  115992. /**
  115993. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  115994. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115995. * @returns the SPS.
  115996. */
  115997. refreshVisibleSize(): SolidParticleSystem;
  115998. /**
  115999. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  116000. * @param size the size (float) of the visibility box
  116001. * note : this doesn't lock the SPS mesh bounding box.
  116002. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116003. */
  116004. setVisibilityBox(size: number): void;
  116005. /**
  116006. * Gets whether the SPS as always visible or not
  116007. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116008. */
  116009. get isAlwaysVisible(): boolean;
  116010. /**
  116011. * Sets the SPS as always visible or not
  116012. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116013. */
  116014. set isAlwaysVisible(val: boolean);
  116015. /**
  116016. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  116017. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116018. */
  116019. set isVisibilityBoxLocked(val: boolean);
  116020. /**
  116021. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  116022. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116023. */
  116024. get isVisibilityBoxLocked(): boolean;
  116025. /**
  116026. * Tells to `setParticles()` to compute the particle rotations or not.
  116027. * Default value : true. The SPS is faster when it's set to false.
  116028. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  116029. */
  116030. set computeParticleRotation(val: boolean);
  116031. /**
  116032. * Tells to `setParticles()` to compute the particle colors or not.
  116033. * Default value : true. The SPS is faster when it's set to false.
  116034. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  116035. */
  116036. set computeParticleColor(val: boolean);
  116037. set computeParticleTexture(val: boolean);
  116038. /**
  116039. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  116040. * Default value : false. The SPS is faster when it's set to false.
  116041. * Note : the particle custom vertex positions aren't stored values.
  116042. */
  116043. set computeParticleVertex(val: boolean);
  116044. /**
  116045. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  116046. */
  116047. set computeBoundingBox(val: boolean);
  116048. /**
  116049. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  116050. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  116051. * Default : `true`
  116052. */
  116053. set depthSortParticles(val: boolean);
  116054. /**
  116055. * Gets if `setParticles()` computes the particle rotations or not.
  116056. * Default value : true. The SPS is faster when it's set to false.
  116057. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  116058. */
  116059. get computeParticleRotation(): boolean;
  116060. /**
  116061. * Gets if `setParticles()` computes the particle colors or not.
  116062. * Default value : true. The SPS is faster when it's set to false.
  116063. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  116064. */
  116065. get computeParticleColor(): boolean;
  116066. /**
  116067. * Gets if `setParticles()` computes the particle textures or not.
  116068. * Default value : true. The SPS is faster when it's set to false.
  116069. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  116070. */
  116071. get computeParticleTexture(): boolean;
  116072. /**
  116073. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  116074. * Default value : false. The SPS is faster when it's set to false.
  116075. * Note : the particle custom vertex positions aren't stored values.
  116076. */
  116077. get computeParticleVertex(): boolean;
  116078. /**
  116079. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  116080. */
  116081. get computeBoundingBox(): boolean;
  116082. /**
  116083. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  116084. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  116085. * Default : `true`
  116086. */
  116087. get depthSortParticles(): boolean;
  116088. /**
  116089. * Gets if the SPS is created as expandable at construction time.
  116090. * Default : `false`
  116091. */
  116092. get expandable(): boolean;
  116093. /**
  116094. * Gets if the SPS supports the Multi Materials
  116095. */
  116096. get multimaterialEnabled(): boolean;
  116097. /**
  116098. * Gets if the SPS uses the model materials for its own multimaterial.
  116099. */
  116100. get useModelMaterial(): boolean;
  116101. /**
  116102. * The SPS used material array.
  116103. */
  116104. get materials(): Material[];
  116105. /**
  116106. * Sets the SPS MultiMaterial from the passed materials.
  116107. * Note : the passed array is internally copied and not used then by reference.
  116108. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  116109. */
  116110. setMultiMaterial(materials: Material[]): void;
  116111. /**
  116112. * The SPS computed multimaterial object
  116113. */
  116114. get multimaterial(): MultiMaterial;
  116115. set multimaterial(mm: MultiMaterial);
  116116. /**
  116117. * If the subMeshes must be updated on the next call to setParticles()
  116118. */
  116119. get autoUpdateSubMeshes(): boolean;
  116120. set autoUpdateSubMeshes(val: boolean);
  116121. /**
  116122. * This function does nothing. It may be overwritten to set all the particle first values.
  116123. * The SPS doesn't call this function, you may have to call it by your own.
  116124. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116125. */
  116126. initParticles(): void;
  116127. /**
  116128. * This function does nothing. It may be overwritten to recycle a particle.
  116129. * The SPS doesn't call this function, you may have to call it by your own.
  116130. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116131. * @param particle The particle to recycle
  116132. * @returns the recycled particle
  116133. */
  116134. recycleParticle(particle: SolidParticle): SolidParticle;
  116135. /**
  116136. * Updates a particle : this function should be overwritten by the user.
  116137. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  116138. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116139. * @example : just set a particle position or velocity and recycle conditions
  116140. * @param particle The particle to update
  116141. * @returns the updated particle
  116142. */
  116143. updateParticle(particle: SolidParticle): SolidParticle;
  116144. /**
  116145. * Updates a vertex of a particle : it can be overwritten by the user.
  116146. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  116147. * @param particle the current particle
  116148. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  116149. * @param pt the index of the current vertex in the particle shape
  116150. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  116151. * @example : just set a vertex particle position or color
  116152. * @returns the sps
  116153. */
  116154. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  116155. /**
  116156. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  116157. * This does nothing and may be overwritten by the user.
  116158. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116159. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116160. * @param update the boolean update value actually passed to setParticles()
  116161. */
  116162. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  116163. /**
  116164. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  116165. * This will be passed three parameters.
  116166. * This does nothing and may be overwritten by the user.
  116167. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116168. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116169. * @param update the boolean update value actually passed to setParticles()
  116170. */
  116171. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  116172. }
  116173. }
  116174. declare module BABYLON {
  116175. /**
  116176. * Represents one particle of a solid particle system.
  116177. */
  116178. export class SolidParticle {
  116179. /**
  116180. * particle global index
  116181. */
  116182. idx: number;
  116183. /**
  116184. * particle identifier
  116185. */
  116186. id: number;
  116187. /**
  116188. * The color of the particle
  116189. */
  116190. color: Nullable<Color4>;
  116191. /**
  116192. * The world space position of the particle.
  116193. */
  116194. position: Vector3;
  116195. /**
  116196. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  116197. */
  116198. rotation: Vector3;
  116199. /**
  116200. * The world space rotation quaternion of the particle.
  116201. */
  116202. rotationQuaternion: Nullable<Quaternion>;
  116203. /**
  116204. * The scaling of the particle.
  116205. */
  116206. scaling: Vector3;
  116207. /**
  116208. * The uvs of the particle.
  116209. */
  116210. uvs: Vector4;
  116211. /**
  116212. * The current speed of the particle.
  116213. */
  116214. velocity: Vector3;
  116215. /**
  116216. * The pivot point in the particle local space.
  116217. */
  116218. pivot: Vector3;
  116219. /**
  116220. * Must the particle be translated from its pivot point in its local space ?
  116221. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  116222. * Default : false
  116223. */
  116224. translateFromPivot: boolean;
  116225. /**
  116226. * Is the particle active or not ?
  116227. */
  116228. alive: boolean;
  116229. /**
  116230. * Is the particle visible or not ?
  116231. */
  116232. isVisible: boolean;
  116233. /**
  116234. * Index of this particle in the global "positions" array (Internal use)
  116235. * @hidden
  116236. */
  116237. _pos: number;
  116238. /**
  116239. * @hidden Index of this particle in the global "indices" array (Internal use)
  116240. */
  116241. _ind: number;
  116242. /**
  116243. * @hidden ModelShape of this particle (Internal use)
  116244. */
  116245. _model: ModelShape;
  116246. /**
  116247. * ModelShape id of this particle
  116248. */
  116249. shapeId: number;
  116250. /**
  116251. * Index of the particle in its shape id
  116252. */
  116253. idxInShape: number;
  116254. /**
  116255. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  116256. */
  116257. _modelBoundingInfo: BoundingInfo;
  116258. /**
  116259. * @hidden Particle BoundingInfo object (Internal use)
  116260. */
  116261. _boundingInfo: BoundingInfo;
  116262. /**
  116263. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  116264. */
  116265. _sps: SolidParticleSystem;
  116266. /**
  116267. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  116268. */
  116269. _stillInvisible: boolean;
  116270. /**
  116271. * @hidden Last computed particle rotation matrix
  116272. */
  116273. _rotationMatrix: number[];
  116274. /**
  116275. * Parent particle Id, if any.
  116276. * Default null.
  116277. */
  116278. parentId: Nullable<number>;
  116279. /**
  116280. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  116281. */
  116282. materialIndex: Nullable<number>;
  116283. /**
  116284. * Custom object or properties.
  116285. */
  116286. props: Nullable<any>;
  116287. /**
  116288. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  116289. * The possible values are :
  116290. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  116291. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116292. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  116293. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  116294. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116295. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  116296. * */
  116297. cullingStrategy: number;
  116298. /**
  116299. * @hidden Internal global position in the SPS.
  116300. */
  116301. _globalPosition: Vector3;
  116302. /**
  116303. * Creates a Solid Particle object.
  116304. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  116305. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  116306. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  116307. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  116308. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  116309. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  116310. * @param shapeId (integer) is the model shape identifier in the SPS.
  116311. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  116312. * @param sps defines the sps it is associated to
  116313. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  116314. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  116315. */
  116316. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  116317. /**
  116318. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  116319. * @param target the particle target
  116320. * @returns the current particle
  116321. */
  116322. copyToRef(target: SolidParticle): SolidParticle;
  116323. /**
  116324. * Legacy support, changed scale to scaling
  116325. */
  116326. get scale(): Vector3;
  116327. /**
  116328. * Legacy support, changed scale to scaling
  116329. */
  116330. set scale(scale: Vector3);
  116331. /**
  116332. * Legacy support, changed quaternion to rotationQuaternion
  116333. */
  116334. get quaternion(): Nullable<Quaternion>;
  116335. /**
  116336. * Legacy support, changed quaternion to rotationQuaternion
  116337. */
  116338. set quaternion(q: Nullable<Quaternion>);
  116339. /**
  116340. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  116341. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  116342. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  116343. * @returns true if it intersects
  116344. */
  116345. intersectsMesh(target: Mesh | SolidParticle): boolean;
  116346. /**
  116347. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  116348. * A particle is in the frustum if its bounding box intersects the frustum
  116349. * @param frustumPlanes defines the frustum to test
  116350. * @returns true if the particle is in the frustum planes
  116351. */
  116352. isInFrustum(frustumPlanes: Plane[]): boolean;
  116353. /**
  116354. * get the rotation matrix of the particle
  116355. * @hidden
  116356. */
  116357. getRotationMatrix(m: Matrix): void;
  116358. }
  116359. /**
  116360. * Represents the shape of the model used by one particle of a solid particle system.
  116361. * SPS internal tool, don't use it manually.
  116362. */
  116363. export class ModelShape {
  116364. /**
  116365. * The shape id
  116366. * @hidden
  116367. */
  116368. shapeID: number;
  116369. /**
  116370. * flat array of model positions (internal use)
  116371. * @hidden
  116372. */
  116373. _shape: Vector3[];
  116374. /**
  116375. * flat array of model UVs (internal use)
  116376. * @hidden
  116377. */
  116378. _shapeUV: number[];
  116379. /**
  116380. * color array of the model
  116381. * @hidden
  116382. */
  116383. _shapeColors: number[];
  116384. /**
  116385. * indices array of the model
  116386. * @hidden
  116387. */
  116388. _indices: number[];
  116389. /**
  116390. * normals array of the model
  116391. * @hidden
  116392. */
  116393. _normals: number[];
  116394. /**
  116395. * length of the shape in the model indices array (internal use)
  116396. * @hidden
  116397. */
  116398. _indicesLength: number;
  116399. /**
  116400. * Custom position function (internal use)
  116401. * @hidden
  116402. */
  116403. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  116404. /**
  116405. * Custom vertex function (internal use)
  116406. * @hidden
  116407. */
  116408. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  116409. /**
  116410. * Model material (internal use)
  116411. * @hidden
  116412. */
  116413. _material: Nullable<Material>;
  116414. /**
  116415. * 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.
  116416. * SPS internal tool, don't use it manually.
  116417. * @hidden
  116418. */
  116419. 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>);
  116420. }
  116421. /**
  116422. * Represents a Depth Sorted Particle in the solid particle system.
  116423. * @hidden
  116424. */
  116425. export class DepthSortedParticle {
  116426. /**
  116427. * Particle index
  116428. */
  116429. idx: number;
  116430. /**
  116431. * Index of the particle in the "indices" array
  116432. */
  116433. ind: number;
  116434. /**
  116435. * Length of the particle shape in the "indices" array
  116436. */
  116437. indicesLength: number;
  116438. /**
  116439. * Squared distance from the particle to the camera
  116440. */
  116441. sqDistance: number;
  116442. /**
  116443. * Material index when used with MultiMaterials
  116444. */
  116445. materialIndex: number;
  116446. /**
  116447. * Creates a new sorted particle
  116448. * @param materialIndex
  116449. */
  116450. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  116451. }
  116452. /**
  116453. * Represents a solid particle vertex
  116454. */
  116455. export class SolidParticleVertex {
  116456. /**
  116457. * Vertex position
  116458. */
  116459. position: Vector3;
  116460. /**
  116461. * Vertex color
  116462. */
  116463. color: Color4;
  116464. /**
  116465. * Vertex UV
  116466. */
  116467. uv: Vector2;
  116468. /**
  116469. * Creates a new solid particle vertex
  116470. */
  116471. constructor();
  116472. /** Vertex x coordinate */
  116473. get x(): number;
  116474. set x(val: number);
  116475. /** Vertex y coordinate */
  116476. get y(): number;
  116477. set y(val: number);
  116478. /** Vertex z coordinate */
  116479. get z(): number;
  116480. set z(val: number);
  116481. }
  116482. }
  116483. declare module BABYLON {
  116484. /**
  116485. * @hidden
  116486. */
  116487. export class _MeshCollisionData {
  116488. _checkCollisions: boolean;
  116489. _collisionMask: number;
  116490. _collisionGroup: number;
  116491. _surroundingMeshes: Nullable<AbstractMesh[]>;
  116492. _collider: Nullable<Collider>;
  116493. _oldPositionForCollisions: Vector3;
  116494. _diffPositionForCollisions: Vector3;
  116495. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  116496. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  116497. _collisionResponse: boolean;
  116498. }
  116499. }
  116500. declare module BABYLON {
  116501. /** @hidden */
  116502. class _FacetDataStorage {
  116503. facetPositions: Vector3[];
  116504. facetNormals: Vector3[];
  116505. facetPartitioning: number[][];
  116506. facetNb: number;
  116507. partitioningSubdivisions: number;
  116508. partitioningBBoxRatio: number;
  116509. facetDataEnabled: boolean;
  116510. facetParameters: any;
  116511. bbSize: Vector3;
  116512. subDiv: {
  116513. max: number;
  116514. X: number;
  116515. Y: number;
  116516. Z: number;
  116517. };
  116518. facetDepthSort: boolean;
  116519. facetDepthSortEnabled: boolean;
  116520. depthSortedIndices: IndicesArray;
  116521. depthSortedFacets: {
  116522. ind: number;
  116523. sqDistance: number;
  116524. }[];
  116525. facetDepthSortFunction: (f1: {
  116526. ind: number;
  116527. sqDistance: number;
  116528. }, f2: {
  116529. ind: number;
  116530. sqDistance: number;
  116531. }) => number;
  116532. facetDepthSortFrom: Vector3;
  116533. facetDepthSortOrigin: Vector3;
  116534. invertedMatrix: Matrix;
  116535. }
  116536. /**
  116537. * @hidden
  116538. **/
  116539. class _InternalAbstractMeshDataInfo {
  116540. _hasVertexAlpha: boolean;
  116541. _useVertexColors: boolean;
  116542. _numBoneInfluencers: number;
  116543. _applyFog: boolean;
  116544. _receiveShadows: boolean;
  116545. _facetData: _FacetDataStorage;
  116546. _visibility: number;
  116547. _skeleton: Nullable<Skeleton>;
  116548. _layerMask: number;
  116549. _computeBonesUsingShaders: boolean;
  116550. _isActive: boolean;
  116551. _onlyForInstances: boolean;
  116552. _isActiveIntermediate: boolean;
  116553. _onlyForInstancesIntermediate: boolean;
  116554. _actAsRegularMesh: boolean;
  116555. _currentLOD: Nullable<AbstractMesh>;
  116556. }
  116557. /**
  116558. * Class used to store all common mesh properties
  116559. */
  116560. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  116561. /** No occlusion */
  116562. static OCCLUSION_TYPE_NONE: number;
  116563. /** Occlusion set to optimisitic */
  116564. static OCCLUSION_TYPE_OPTIMISTIC: number;
  116565. /** Occlusion set to strict */
  116566. static OCCLUSION_TYPE_STRICT: number;
  116567. /** Use an accurante occlusion algorithm */
  116568. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  116569. /** Use a conservative occlusion algorithm */
  116570. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  116571. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  116572. * Test order :
  116573. * Is the bounding sphere outside the frustum ?
  116574. * If not, are the bounding box vertices outside the frustum ?
  116575. * It not, then the cullable object is in the frustum.
  116576. */
  116577. static readonly CULLINGSTRATEGY_STANDARD: number;
  116578. /** Culling strategy : Bounding Sphere Only.
  116579. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  116580. * It's also less accurate than the standard because some not visible objects can still be selected.
  116581. * Test : is the bounding sphere outside the frustum ?
  116582. * If not, then the cullable object is in the frustum.
  116583. */
  116584. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  116585. /** Culling strategy : Optimistic Inclusion.
  116586. * This in an inclusion test first, then the standard exclusion test.
  116587. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  116588. * 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.
  116589. * Anyway, it's as accurate as the standard strategy.
  116590. * Test :
  116591. * Is the cullable object bounding sphere center in the frustum ?
  116592. * If not, apply the default culling strategy.
  116593. */
  116594. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  116595. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  116596. * This in an inclusion test first, then the bounding sphere only exclusion test.
  116597. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  116598. * 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.
  116599. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  116600. * Test :
  116601. * Is the cullable object bounding sphere center in the frustum ?
  116602. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  116603. */
  116604. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  116605. /**
  116606. * No billboard
  116607. */
  116608. static get BILLBOARDMODE_NONE(): number;
  116609. /** Billboard on X axis */
  116610. static get BILLBOARDMODE_X(): number;
  116611. /** Billboard on Y axis */
  116612. static get BILLBOARDMODE_Y(): number;
  116613. /** Billboard on Z axis */
  116614. static get BILLBOARDMODE_Z(): number;
  116615. /** Billboard on all axes */
  116616. static get BILLBOARDMODE_ALL(): number;
  116617. /** Billboard on using position instead of orientation */
  116618. static get BILLBOARDMODE_USE_POSITION(): number;
  116619. /** @hidden */
  116620. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  116621. /**
  116622. * The culling strategy to use to check whether the mesh must be rendered or not.
  116623. * This value can be changed at any time and will be used on the next render mesh selection.
  116624. * The possible values are :
  116625. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  116626. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116627. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  116628. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  116629. * Please read each static variable documentation to get details about the culling process.
  116630. * */
  116631. cullingStrategy: number;
  116632. /**
  116633. * Gets the number of facets in the mesh
  116634. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116635. */
  116636. get facetNb(): number;
  116637. /**
  116638. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  116639. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116640. */
  116641. get partitioningSubdivisions(): number;
  116642. set partitioningSubdivisions(nb: number);
  116643. /**
  116644. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  116645. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  116646. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116647. */
  116648. get partitioningBBoxRatio(): number;
  116649. set partitioningBBoxRatio(ratio: number);
  116650. /**
  116651. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  116652. * Works only for updatable meshes.
  116653. * Doesn't work with multi-materials
  116654. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116655. */
  116656. get mustDepthSortFacets(): boolean;
  116657. set mustDepthSortFacets(sort: boolean);
  116658. /**
  116659. * The location (Vector3) where the facet depth sort must be computed from.
  116660. * By default, the active camera position.
  116661. * Used only when facet depth sort is enabled
  116662. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116663. */
  116664. get facetDepthSortFrom(): Vector3;
  116665. set facetDepthSortFrom(location: Vector3);
  116666. /**
  116667. * gets a boolean indicating if facetData is enabled
  116668. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116669. */
  116670. get isFacetDataEnabled(): boolean;
  116671. /** @hidden */
  116672. _updateNonUniformScalingState(value: boolean): boolean;
  116673. /**
  116674. * An event triggered when this mesh collides with another one
  116675. */
  116676. onCollideObservable: Observable<AbstractMesh>;
  116677. /** Set a function to call when this mesh collides with another one */
  116678. set onCollide(callback: () => void);
  116679. /**
  116680. * An event triggered when the collision's position changes
  116681. */
  116682. onCollisionPositionChangeObservable: Observable<Vector3>;
  116683. /** Set a function to call when the collision's position changes */
  116684. set onCollisionPositionChange(callback: () => void);
  116685. /**
  116686. * An event triggered when material is changed
  116687. */
  116688. onMaterialChangedObservable: Observable<AbstractMesh>;
  116689. /**
  116690. * Gets or sets the orientation for POV movement & rotation
  116691. */
  116692. definedFacingForward: boolean;
  116693. /** @hidden */
  116694. _occlusionQuery: Nullable<WebGLQuery>;
  116695. /** @hidden */
  116696. _renderingGroup: Nullable<RenderingGroup>;
  116697. /**
  116698. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116699. */
  116700. get visibility(): number;
  116701. /**
  116702. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116703. */
  116704. set visibility(value: number);
  116705. /** Gets or sets the alpha index used to sort transparent meshes
  116706. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  116707. */
  116708. alphaIndex: number;
  116709. /**
  116710. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  116711. */
  116712. isVisible: boolean;
  116713. /**
  116714. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  116715. */
  116716. isPickable: boolean;
  116717. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  116718. showSubMeshesBoundingBox: boolean;
  116719. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  116720. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116721. */
  116722. isBlocker: boolean;
  116723. /**
  116724. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  116725. */
  116726. enablePointerMoveEvents: boolean;
  116727. private _renderingGroupId;
  116728. /**
  116729. * Specifies the rendering group id for this mesh (0 by default)
  116730. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  116731. */
  116732. get renderingGroupId(): number;
  116733. set renderingGroupId(value: number);
  116734. private _material;
  116735. /** Gets or sets current material */
  116736. get material(): Nullable<Material>;
  116737. set material(value: Nullable<Material>);
  116738. /**
  116739. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  116740. * @see https://doc.babylonjs.com/babylon101/shadows
  116741. */
  116742. get receiveShadows(): boolean;
  116743. set receiveShadows(value: boolean);
  116744. /** Defines color to use when rendering outline */
  116745. outlineColor: Color3;
  116746. /** Define width to use when rendering outline */
  116747. outlineWidth: number;
  116748. /** Defines color to use when rendering overlay */
  116749. overlayColor: Color3;
  116750. /** Defines alpha to use when rendering overlay */
  116751. overlayAlpha: number;
  116752. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  116753. get hasVertexAlpha(): boolean;
  116754. set hasVertexAlpha(value: boolean);
  116755. /** 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) */
  116756. get useVertexColors(): boolean;
  116757. set useVertexColors(value: boolean);
  116758. /**
  116759. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  116760. */
  116761. get computeBonesUsingShaders(): boolean;
  116762. set computeBonesUsingShaders(value: boolean);
  116763. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  116764. get numBoneInfluencers(): number;
  116765. set numBoneInfluencers(value: number);
  116766. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  116767. get applyFog(): boolean;
  116768. set applyFog(value: boolean);
  116769. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  116770. useOctreeForRenderingSelection: boolean;
  116771. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  116772. useOctreeForPicking: boolean;
  116773. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  116774. useOctreeForCollisions: boolean;
  116775. /**
  116776. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  116777. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  116778. */
  116779. get layerMask(): number;
  116780. set layerMask(value: number);
  116781. /**
  116782. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  116783. */
  116784. alwaysSelectAsActiveMesh: boolean;
  116785. /**
  116786. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  116787. */
  116788. doNotSyncBoundingInfo: boolean;
  116789. /**
  116790. * Gets or sets the current action manager
  116791. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116792. */
  116793. actionManager: Nullable<AbstractActionManager>;
  116794. private _meshCollisionData;
  116795. /**
  116796. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  116797. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116798. */
  116799. ellipsoid: Vector3;
  116800. /**
  116801. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  116802. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116803. */
  116804. ellipsoidOffset: Vector3;
  116805. /**
  116806. * Gets or sets a collision mask used to mask collisions (default is -1).
  116807. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116808. */
  116809. get collisionMask(): number;
  116810. set collisionMask(mask: number);
  116811. /**
  116812. * Gets or sets a collision response flag (default is true).
  116813. * when collisionResponse is false, events are still triggered but colliding entity has no response
  116814. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  116815. * to respond to the collision.
  116816. */
  116817. get collisionResponse(): boolean;
  116818. set collisionResponse(response: boolean);
  116819. /**
  116820. * Gets or sets the current collision group mask (-1 by default).
  116821. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116822. */
  116823. get collisionGroup(): number;
  116824. set collisionGroup(mask: number);
  116825. /**
  116826. * Gets or sets current surrounding meshes (null by default).
  116827. *
  116828. * By default collision detection is tested against every mesh in the scene.
  116829. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  116830. * meshes will be tested for the collision.
  116831. *
  116832. * Note: if set to an empty array no collision will happen when this mesh is moved.
  116833. */
  116834. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  116835. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  116836. /**
  116837. * Defines edge width used when edgesRenderer is enabled
  116838. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116839. */
  116840. edgesWidth: number;
  116841. /**
  116842. * Defines edge color used when edgesRenderer is enabled
  116843. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116844. */
  116845. edgesColor: Color4;
  116846. /** @hidden */
  116847. _edgesRenderer: Nullable<IEdgesRenderer>;
  116848. /** @hidden */
  116849. _masterMesh: Nullable<AbstractMesh>;
  116850. /** @hidden */
  116851. _boundingInfo: Nullable<BoundingInfo>;
  116852. /** @hidden */
  116853. _renderId: number;
  116854. /**
  116855. * Gets or sets the list of subMeshes
  116856. * @see https://doc.babylonjs.com/how_to/multi_materials
  116857. */
  116858. subMeshes: SubMesh[];
  116859. /** @hidden */
  116860. _intersectionsInProgress: AbstractMesh[];
  116861. /** @hidden */
  116862. _unIndexed: boolean;
  116863. /** @hidden */
  116864. _lightSources: Light[];
  116865. /** Gets the list of lights affecting that mesh */
  116866. get lightSources(): Light[];
  116867. /** @hidden */
  116868. get _positions(): Nullable<Vector3[]>;
  116869. /** @hidden */
  116870. _waitingData: {
  116871. lods: Nullable<any>;
  116872. actions: Nullable<any>;
  116873. freezeWorldMatrix: Nullable<boolean>;
  116874. };
  116875. /** @hidden */
  116876. _bonesTransformMatrices: Nullable<Float32Array>;
  116877. /** @hidden */
  116878. _transformMatrixTexture: Nullable<RawTexture>;
  116879. /**
  116880. * Gets or sets a skeleton to apply skining transformations
  116881. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  116882. */
  116883. set skeleton(value: Nullable<Skeleton>);
  116884. get skeleton(): Nullable<Skeleton>;
  116885. /**
  116886. * An event triggered when the mesh is rebuilt.
  116887. */
  116888. onRebuildObservable: Observable<AbstractMesh>;
  116889. /**
  116890. * Creates a new AbstractMesh
  116891. * @param name defines the name of the mesh
  116892. * @param scene defines the hosting scene
  116893. */
  116894. constructor(name: string, scene?: Nullable<Scene>);
  116895. /**
  116896. * Returns the string "AbstractMesh"
  116897. * @returns "AbstractMesh"
  116898. */
  116899. getClassName(): string;
  116900. /**
  116901. * Gets a string representation of the current mesh
  116902. * @param fullDetails defines a boolean indicating if full details must be included
  116903. * @returns a string representation of the current mesh
  116904. */
  116905. toString(fullDetails?: boolean): string;
  116906. /**
  116907. * @hidden
  116908. */
  116909. protected _getEffectiveParent(): Nullable<Node>;
  116910. /** @hidden */
  116911. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  116912. /** @hidden */
  116913. _rebuild(): void;
  116914. /** @hidden */
  116915. _resyncLightSources(): void;
  116916. /** @hidden */
  116917. _resyncLightSource(light: Light): void;
  116918. /** @hidden */
  116919. _unBindEffect(): void;
  116920. /** @hidden */
  116921. _removeLightSource(light: Light, dispose: boolean): void;
  116922. private _markSubMeshesAsDirty;
  116923. /** @hidden */
  116924. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  116925. /** @hidden */
  116926. _markSubMeshesAsAttributesDirty(): void;
  116927. /** @hidden */
  116928. _markSubMeshesAsMiscDirty(): void;
  116929. /**
  116930. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  116931. */
  116932. get scaling(): Vector3;
  116933. set scaling(newScaling: Vector3);
  116934. /**
  116935. * Returns true if the mesh is blocked. Implemented by child classes
  116936. */
  116937. get isBlocked(): boolean;
  116938. /**
  116939. * Returns the mesh itself by default. Implemented by child classes
  116940. * @param camera defines the camera to use to pick the right LOD level
  116941. * @returns the currentAbstractMesh
  116942. */
  116943. getLOD(camera: Camera): Nullable<AbstractMesh>;
  116944. /**
  116945. * Returns 0 by default. Implemented by child classes
  116946. * @returns an integer
  116947. */
  116948. getTotalVertices(): number;
  116949. /**
  116950. * Returns a positive integer : the total number of indices in this mesh geometry.
  116951. * @returns the numner of indices or zero if the mesh has no geometry.
  116952. */
  116953. getTotalIndices(): number;
  116954. /**
  116955. * Returns null by default. Implemented by child classes
  116956. * @returns null
  116957. */
  116958. getIndices(): Nullable<IndicesArray>;
  116959. /**
  116960. * Returns the array of the requested vertex data kind. Implemented by child classes
  116961. * @param kind defines the vertex data kind to use
  116962. * @returns null
  116963. */
  116964. getVerticesData(kind: string): Nullable<FloatArray>;
  116965. /**
  116966. * Sets the vertex data of the mesh geometry for the requested `kind`.
  116967. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  116968. * Note that a new underlying VertexBuffer object is created each call.
  116969. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  116970. * @param kind defines vertex data kind:
  116971. * * VertexBuffer.PositionKind
  116972. * * VertexBuffer.UVKind
  116973. * * VertexBuffer.UV2Kind
  116974. * * VertexBuffer.UV3Kind
  116975. * * VertexBuffer.UV4Kind
  116976. * * VertexBuffer.UV5Kind
  116977. * * VertexBuffer.UV6Kind
  116978. * * VertexBuffer.ColorKind
  116979. * * VertexBuffer.MatricesIndicesKind
  116980. * * VertexBuffer.MatricesIndicesExtraKind
  116981. * * VertexBuffer.MatricesWeightsKind
  116982. * * VertexBuffer.MatricesWeightsExtraKind
  116983. * @param data defines the data source
  116984. * @param updatable defines if the data must be flagged as updatable (or static)
  116985. * @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
  116986. * @returns the current mesh
  116987. */
  116988. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  116989. /**
  116990. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  116991. * If the mesh has no geometry, it is simply returned as it is.
  116992. * @param kind defines vertex data kind:
  116993. * * VertexBuffer.PositionKind
  116994. * * VertexBuffer.UVKind
  116995. * * VertexBuffer.UV2Kind
  116996. * * VertexBuffer.UV3Kind
  116997. * * VertexBuffer.UV4Kind
  116998. * * VertexBuffer.UV5Kind
  116999. * * VertexBuffer.UV6Kind
  117000. * * VertexBuffer.ColorKind
  117001. * * VertexBuffer.MatricesIndicesKind
  117002. * * VertexBuffer.MatricesIndicesExtraKind
  117003. * * VertexBuffer.MatricesWeightsKind
  117004. * * VertexBuffer.MatricesWeightsExtraKind
  117005. * @param data defines the data source
  117006. * @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
  117007. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  117008. * @returns the current mesh
  117009. */
  117010. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  117011. /**
  117012. * Sets the mesh indices,
  117013. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  117014. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  117015. * @param totalVertices Defines the total number of vertices
  117016. * @returns the current mesh
  117017. */
  117018. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  117019. /**
  117020. * Gets a boolean indicating if specific vertex data is present
  117021. * @param kind defines the vertex data kind to use
  117022. * @returns true is data kind is present
  117023. */
  117024. isVerticesDataPresent(kind: string): boolean;
  117025. /**
  117026. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  117027. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  117028. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  117029. * @returns a BoundingInfo
  117030. */
  117031. getBoundingInfo(): BoundingInfo;
  117032. /**
  117033. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  117034. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  117035. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  117036. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  117037. * @returns the current mesh
  117038. */
  117039. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  117040. /**
  117041. * Overwrite the current bounding info
  117042. * @param boundingInfo defines the new bounding info
  117043. * @returns the current mesh
  117044. */
  117045. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  117046. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  117047. get useBones(): boolean;
  117048. /** @hidden */
  117049. _preActivate(): void;
  117050. /** @hidden */
  117051. _preActivateForIntermediateRendering(renderId: number): void;
  117052. /** @hidden */
  117053. _activate(renderId: number, intermediateRendering: boolean): boolean;
  117054. /** @hidden */
  117055. _postActivate(): void;
  117056. /** @hidden */
  117057. _freeze(): void;
  117058. /** @hidden */
  117059. _unFreeze(): void;
  117060. /**
  117061. * Gets the current world matrix
  117062. * @returns a Matrix
  117063. */
  117064. getWorldMatrix(): Matrix;
  117065. /** @hidden */
  117066. _getWorldMatrixDeterminant(): number;
  117067. /**
  117068. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  117069. */
  117070. get isAnInstance(): boolean;
  117071. /**
  117072. * Gets a boolean indicating if this mesh has instances
  117073. */
  117074. get hasInstances(): boolean;
  117075. /**
  117076. * Gets a boolean indicating if this mesh has thin instances
  117077. */
  117078. get hasThinInstances(): boolean;
  117079. /**
  117080. * Perform relative position change from the point of view of behind the front of the mesh.
  117081. * This is performed taking into account the meshes current rotation, so you do not have to care.
  117082. * Supports definition of mesh facing forward or backward
  117083. * @param amountRight defines the distance on the right axis
  117084. * @param amountUp defines the distance on the up axis
  117085. * @param amountForward defines the distance on the forward axis
  117086. * @returns the current mesh
  117087. */
  117088. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  117089. /**
  117090. * Calculate relative position change from the point of view of behind the front of the mesh.
  117091. * This is performed taking into account the meshes current rotation, so you do not have to care.
  117092. * Supports definition of mesh facing forward or backward
  117093. * @param amountRight defines the distance on the right axis
  117094. * @param amountUp defines the distance on the up axis
  117095. * @param amountForward defines the distance on the forward axis
  117096. * @returns the new displacement vector
  117097. */
  117098. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  117099. /**
  117100. * Perform relative rotation change from the point of view of behind the front of the mesh.
  117101. * Supports definition of mesh facing forward or backward
  117102. * @param flipBack defines the flip
  117103. * @param twirlClockwise defines the twirl
  117104. * @param tiltRight defines the tilt
  117105. * @returns the current mesh
  117106. */
  117107. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  117108. /**
  117109. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  117110. * Supports definition of mesh facing forward or backward.
  117111. * @param flipBack defines the flip
  117112. * @param twirlClockwise defines the twirl
  117113. * @param tiltRight defines the tilt
  117114. * @returns the new rotation vector
  117115. */
  117116. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  117117. /**
  117118. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  117119. * This means the mesh underlying bounding box and sphere are recomputed.
  117120. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  117121. * @returns the current mesh
  117122. */
  117123. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  117124. /** @hidden */
  117125. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  117126. /** @hidden */
  117127. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  117128. /** @hidden */
  117129. _updateBoundingInfo(): AbstractMesh;
  117130. /** @hidden */
  117131. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  117132. /** @hidden */
  117133. protected _afterComputeWorldMatrix(): void;
  117134. /** @hidden */
  117135. get _effectiveMesh(): AbstractMesh;
  117136. /**
  117137. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  117138. * A mesh is in the frustum if its bounding box intersects the frustum
  117139. * @param frustumPlanes defines the frustum to test
  117140. * @returns true if the mesh is in the frustum planes
  117141. */
  117142. isInFrustum(frustumPlanes: Plane[]): boolean;
  117143. /**
  117144. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  117145. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  117146. * @param frustumPlanes defines the frustum to test
  117147. * @returns true if the mesh is completely in the frustum planes
  117148. */
  117149. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  117150. /**
  117151. * True if the mesh intersects another mesh or a SolidParticle object
  117152. * @param mesh defines a target mesh or SolidParticle to test
  117153. * @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)
  117154. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  117155. * @returns true if there is an intersection
  117156. */
  117157. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  117158. /**
  117159. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  117160. * @param point defines the point to test
  117161. * @returns true if there is an intersection
  117162. */
  117163. intersectsPoint(point: Vector3): boolean;
  117164. /**
  117165. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  117166. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117167. */
  117168. get checkCollisions(): boolean;
  117169. set checkCollisions(collisionEnabled: boolean);
  117170. /**
  117171. * Gets Collider object used to compute collisions (not physics)
  117172. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117173. */
  117174. get collider(): Nullable<Collider>;
  117175. /**
  117176. * Move the mesh using collision engine
  117177. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117178. * @param displacement defines the requested displacement vector
  117179. * @returns the current mesh
  117180. */
  117181. moveWithCollisions(displacement: Vector3): AbstractMesh;
  117182. private _onCollisionPositionChange;
  117183. /** @hidden */
  117184. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  117185. /** @hidden */
  117186. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  117187. /** @hidden */
  117188. _checkCollision(collider: Collider): AbstractMesh;
  117189. /** @hidden */
  117190. _generatePointsArray(): boolean;
  117191. /**
  117192. * Checks if the passed Ray intersects with the mesh
  117193. * @param ray defines the ray to use
  117194. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  117195. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117196. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  117197. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  117198. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  117199. * @returns the picking info
  117200. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  117201. */
  117202. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  117203. /**
  117204. * Clones the current mesh
  117205. * @param name defines the mesh name
  117206. * @param newParent defines the new mesh parent
  117207. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  117208. * @returns the new mesh
  117209. */
  117210. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  117211. /**
  117212. * Disposes all the submeshes of the current meshnp
  117213. * @returns the current mesh
  117214. */
  117215. releaseSubMeshes(): AbstractMesh;
  117216. /**
  117217. * Releases resources associated with this abstract mesh.
  117218. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117219. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117220. */
  117221. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117222. /**
  117223. * Adds the passed mesh as a child to the current mesh
  117224. * @param mesh defines the child mesh
  117225. * @returns the current mesh
  117226. */
  117227. addChild(mesh: AbstractMesh): AbstractMesh;
  117228. /**
  117229. * Removes the passed mesh from the current mesh children list
  117230. * @param mesh defines the child mesh
  117231. * @returns the current mesh
  117232. */
  117233. removeChild(mesh: AbstractMesh): AbstractMesh;
  117234. /** @hidden */
  117235. private _initFacetData;
  117236. /**
  117237. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  117238. * This method can be called within the render loop.
  117239. * 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
  117240. * @returns the current mesh
  117241. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117242. */
  117243. updateFacetData(): AbstractMesh;
  117244. /**
  117245. * Returns the facetLocalNormals array.
  117246. * The normals are expressed in the mesh local spac
  117247. * @returns an array of Vector3
  117248. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117249. */
  117250. getFacetLocalNormals(): Vector3[];
  117251. /**
  117252. * Returns the facetLocalPositions array.
  117253. * The facet positions are expressed in the mesh local space
  117254. * @returns an array of Vector3
  117255. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117256. */
  117257. getFacetLocalPositions(): Vector3[];
  117258. /**
  117259. * Returns the facetLocalPartioning array
  117260. * @returns an array of array of numbers
  117261. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117262. */
  117263. getFacetLocalPartitioning(): number[][];
  117264. /**
  117265. * Returns the i-th facet position in the world system.
  117266. * This method allocates a new Vector3 per call
  117267. * @param i defines the facet index
  117268. * @returns a new Vector3
  117269. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117270. */
  117271. getFacetPosition(i: number): Vector3;
  117272. /**
  117273. * Sets the reference Vector3 with the i-th facet position in the world system
  117274. * @param i defines the facet index
  117275. * @param ref defines the target vector
  117276. * @returns the current mesh
  117277. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117278. */
  117279. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  117280. /**
  117281. * Returns the i-th facet normal in the world system.
  117282. * This method allocates a new Vector3 per call
  117283. * @param i defines the facet index
  117284. * @returns a new Vector3
  117285. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117286. */
  117287. getFacetNormal(i: number): Vector3;
  117288. /**
  117289. * Sets the reference Vector3 with the i-th facet normal in the world system
  117290. * @param i defines the facet index
  117291. * @param ref defines the target vector
  117292. * @returns the current mesh
  117293. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117294. */
  117295. getFacetNormalToRef(i: number, ref: Vector3): this;
  117296. /**
  117297. * 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)
  117298. * @param x defines x coordinate
  117299. * @param y defines y coordinate
  117300. * @param z defines z coordinate
  117301. * @returns the array of facet indexes
  117302. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117303. */
  117304. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  117305. /**
  117306. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  117307. * @param projected sets as the (x,y,z) world projection on the facet
  117308. * @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
  117309. * @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
  117310. * @param x defines x coordinate
  117311. * @param y defines y coordinate
  117312. * @param z defines z coordinate
  117313. * @returns the face index if found (or null instead)
  117314. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117315. */
  117316. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  117317. /**
  117318. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  117319. * @param projected sets as the (x,y,z) local projection on the facet
  117320. * @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
  117321. * @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
  117322. * @param x defines x coordinate
  117323. * @param y defines y coordinate
  117324. * @param z defines z coordinate
  117325. * @returns the face index if found (or null instead)
  117326. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117327. */
  117328. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  117329. /**
  117330. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  117331. * @returns the parameters
  117332. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117333. */
  117334. getFacetDataParameters(): any;
  117335. /**
  117336. * Disables the feature FacetData and frees the related memory
  117337. * @returns the current mesh
  117338. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117339. */
  117340. disableFacetData(): AbstractMesh;
  117341. /**
  117342. * Updates the AbstractMesh indices array
  117343. * @param indices defines the data source
  117344. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  117345. * @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)
  117346. * @returns the current mesh
  117347. */
  117348. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  117349. /**
  117350. * Creates new normals data for the mesh
  117351. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  117352. * @returns the current mesh
  117353. */
  117354. createNormals(updatable: boolean): AbstractMesh;
  117355. /**
  117356. * Align the mesh with a normal
  117357. * @param normal defines the normal to use
  117358. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  117359. * @returns the current mesh
  117360. */
  117361. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  117362. /** @hidden */
  117363. _checkOcclusionQuery(): boolean;
  117364. /**
  117365. * Disables the mesh edge rendering mode
  117366. * @returns the currentAbstractMesh
  117367. */
  117368. disableEdgesRendering(): AbstractMesh;
  117369. /**
  117370. * Enables the edge rendering mode on the mesh.
  117371. * This mode makes the mesh edges visible
  117372. * @param epsilon defines the maximal distance between two angles to detect a face
  117373. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  117374. * @param options options to the edge renderer
  117375. * @returns the currentAbstractMesh
  117376. * @see https://www.babylonjs-playground.com/#19O9TU#0
  117377. */
  117378. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  117379. /**
  117380. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  117381. * @returns an array of particle systems in the scene that use the mesh as an emitter
  117382. */
  117383. getConnectedParticleSystems(): IParticleSystem[];
  117384. }
  117385. }
  117386. declare module BABYLON {
  117387. /**
  117388. * Interface used to define ActionEvent
  117389. */
  117390. export interface IActionEvent {
  117391. /** The mesh or sprite that triggered the action */
  117392. source: any;
  117393. /** The X mouse cursor position at the time of the event */
  117394. pointerX: number;
  117395. /** The Y mouse cursor position at the time of the event */
  117396. pointerY: number;
  117397. /** The mesh that is currently pointed at (can be null) */
  117398. meshUnderPointer: Nullable<AbstractMesh>;
  117399. /** the original (browser) event that triggered the ActionEvent */
  117400. sourceEvent?: any;
  117401. /** additional data for the event */
  117402. additionalData?: any;
  117403. }
  117404. /**
  117405. * ActionEvent is the event being sent when an action is triggered.
  117406. */
  117407. export class ActionEvent implements IActionEvent {
  117408. /** The mesh or sprite that triggered the action */
  117409. source: any;
  117410. /** The X mouse cursor position at the time of the event */
  117411. pointerX: number;
  117412. /** The Y mouse cursor position at the time of the event */
  117413. pointerY: number;
  117414. /** The mesh that is currently pointed at (can be null) */
  117415. meshUnderPointer: Nullable<AbstractMesh>;
  117416. /** the original (browser) event that triggered the ActionEvent */
  117417. sourceEvent?: any;
  117418. /** additional data for the event */
  117419. additionalData?: any;
  117420. /**
  117421. * Creates a new ActionEvent
  117422. * @param source The mesh or sprite that triggered the action
  117423. * @param pointerX The X mouse cursor position at the time of the event
  117424. * @param pointerY The Y mouse cursor position at the time of the event
  117425. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  117426. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  117427. * @param additionalData additional data for the event
  117428. */
  117429. constructor(
  117430. /** The mesh or sprite that triggered the action */
  117431. source: any,
  117432. /** The X mouse cursor position at the time of the event */
  117433. pointerX: number,
  117434. /** The Y mouse cursor position at the time of the event */
  117435. pointerY: number,
  117436. /** The mesh that is currently pointed at (can be null) */
  117437. meshUnderPointer: Nullable<AbstractMesh>,
  117438. /** the original (browser) event that triggered the ActionEvent */
  117439. sourceEvent?: any,
  117440. /** additional data for the event */
  117441. additionalData?: any);
  117442. /**
  117443. * Helper function to auto-create an ActionEvent from a source mesh.
  117444. * @param source The source mesh that triggered the event
  117445. * @param evt The original (browser) event
  117446. * @param additionalData additional data for the event
  117447. * @returns the new ActionEvent
  117448. */
  117449. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  117450. /**
  117451. * Helper function to auto-create an ActionEvent from a source sprite
  117452. * @param source The source sprite that triggered the event
  117453. * @param scene Scene associated with the sprite
  117454. * @param evt The original (browser) event
  117455. * @param additionalData additional data for the event
  117456. * @returns the new ActionEvent
  117457. */
  117458. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  117459. /**
  117460. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  117461. * @param scene the scene where the event occurred
  117462. * @param evt The original (browser) event
  117463. * @returns the new ActionEvent
  117464. */
  117465. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  117466. /**
  117467. * Helper function to auto-create an ActionEvent from a primitive
  117468. * @param prim defines the target primitive
  117469. * @param pointerPos defines the pointer position
  117470. * @param evt The original (browser) event
  117471. * @param additionalData additional data for the event
  117472. * @returns the new ActionEvent
  117473. */
  117474. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  117475. }
  117476. }
  117477. declare module BABYLON {
  117478. /**
  117479. * Abstract class used to decouple action Manager from scene and meshes.
  117480. * Do not instantiate.
  117481. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  117482. */
  117483. export abstract class AbstractActionManager implements IDisposable {
  117484. /** Gets the list of active triggers */
  117485. static Triggers: {
  117486. [key: string]: number;
  117487. };
  117488. /** Gets the cursor to use when hovering items */
  117489. hoverCursor: string;
  117490. /** Gets the list of actions */
  117491. actions: IAction[];
  117492. /**
  117493. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  117494. */
  117495. isRecursive: boolean;
  117496. /**
  117497. * Releases all associated resources
  117498. */
  117499. abstract dispose(): void;
  117500. /**
  117501. * Does this action manager has pointer triggers
  117502. */
  117503. abstract get hasPointerTriggers(): boolean;
  117504. /**
  117505. * Does this action manager has pick triggers
  117506. */
  117507. abstract get hasPickTriggers(): boolean;
  117508. /**
  117509. * Process a specific trigger
  117510. * @param trigger defines the trigger to process
  117511. * @param evt defines the event details to be processed
  117512. */
  117513. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  117514. /**
  117515. * Does this action manager handles actions of any of the given triggers
  117516. * @param triggers defines the triggers to be tested
  117517. * @return a boolean indicating whether one (or more) of the triggers is handled
  117518. */
  117519. abstract hasSpecificTriggers(triggers: number[]): boolean;
  117520. /**
  117521. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  117522. * speed.
  117523. * @param triggerA defines the trigger to be tested
  117524. * @param triggerB defines the trigger to be tested
  117525. * @return a boolean indicating whether one (or more) of the triggers is handled
  117526. */
  117527. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  117528. /**
  117529. * Does this action manager handles actions of a given trigger
  117530. * @param trigger defines the trigger to be tested
  117531. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  117532. * @return whether the trigger is handled
  117533. */
  117534. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  117535. /**
  117536. * Serialize this manager to a JSON object
  117537. * @param name defines the property name to store this manager
  117538. * @returns a JSON representation of this manager
  117539. */
  117540. abstract serialize(name: string): any;
  117541. /**
  117542. * Registers an action to this action manager
  117543. * @param action defines the action to be registered
  117544. * @return the action amended (prepared) after registration
  117545. */
  117546. abstract registerAction(action: IAction): Nullable<IAction>;
  117547. /**
  117548. * Unregisters an action to this action manager
  117549. * @param action defines the action to be unregistered
  117550. * @return a boolean indicating whether the action has been unregistered
  117551. */
  117552. abstract unregisterAction(action: IAction): Boolean;
  117553. /**
  117554. * Does exist one action manager with at least one trigger
  117555. **/
  117556. static get HasTriggers(): boolean;
  117557. /**
  117558. * Does exist one action manager with at least one pick trigger
  117559. **/
  117560. static get HasPickTriggers(): boolean;
  117561. /**
  117562. * Does exist one action manager that handles actions of a given trigger
  117563. * @param trigger defines the trigger to be tested
  117564. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  117565. **/
  117566. static HasSpecificTrigger(trigger: number): boolean;
  117567. }
  117568. }
  117569. declare module BABYLON {
  117570. /**
  117571. * Defines how a node can be built from a string name.
  117572. */
  117573. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  117574. /**
  117575. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  117576. */
  117577. export class Node implements IBehaviorAware<Node> {
  117578. /** @hidden */
  117579. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  117580. private static _NodeConstructors;
  117581. /**
  117582. * Add a new node constructor
  117583. * @param type defines the type name of the node to construct
  117584. * @param constructorFunc defines the constructor function
  117585. */
  117586. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  117587. /**
  117588. * Returns a node constructor based on type name
  117589. * @param type defines the type name
  117590. * @param name defines the new node name
  117591. * @param scene defines the hosting scene
  117592. * @param options defines optional options to transmit to constructors
  117593. * @returns the new constructor or null
  117594. */
  117595. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  117596. /**
  117597. * Gets or sets the name of the node
  117598. */
  117599. name: string;
  117600. /**
  117601. * Gets or sets the id of the node
  117602. */
  117603. id: string;
  117604. /**
  117605. * Gets or sets the unique id of the node
  117606. */
  117607. uniqueId: number;
  117608. /**
  117609. * Gets or sets a string used to store user defined state for the node
  117610. */
  117611. state: string;
  117612. /**
  117613. * Gets or sets an object used to store user defined information for the node
  117614. */
  117615. metadata: any;
  117616. /**
  117617. * For internal use only. Please do not use.
  117618. */
  117619. reservedDataStore: any;
  117620. /**
  117621. * List of inspectable custom properties (used by the Inspector)
  117622. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  117623. */
  117624. inspectableCustomProperties: IInspectable[];
  117625. private _doNotSerialize;
  117626. /**
  117627. * Gets or sets a boolean used to define if the node must be serialized
  117628. */
  117629. get doNotSerialize(): boolean;
  117630. set doNotSerialize(value: boolean);
  117631. /** @hidden */
  117632. _isDisposed: boolean;
  117633. /**
  117634. * Gets a list of Animations associated with the node
  117635. */
  117636. animations: Animation[];
  117637. protected _ranges: {
  117638. [name: string]: Nullable<AnimationRange>;
  117639. };
  117640. /**
  117641. * Callback raised when the node is ready to be used
  117642. */
  117643. onReady: Nullable<(node: Node) => void>;
  117644. private _isEnabled;
  117645. private _isParentEnabled;
  117646. private _isReady;
  117647. /** @hidden */
  117648. _currentRenderId: number;
  117649. private _parentUpdateId;
  117650. /** @hidden */
  117651. _childUpdateId: number;
  117652. /** @hidden */
  117653. _waitingParentId: Nullable<string>;
  117654. /** @hidden */
  117655. _scene: Scene;
  117656. /** @hidden */
  117657. _cache: any;
  117658. private _parentNode;
  117659. private _children;
  117660. /** @hidden */
  117661. _worldMatrix: Matrix;
  117662. /** @hidden */
  117663. _worldMatrixDeterminant: number;
  117664. /** @hidden */
  117665. _worldMatrixDeterminantIsDirty: boolean;
  117666. /** @hidden */
  117667. private _sceneRootNodesIndex;
  117668. /**
  117669. * Gets a boolean indicating if the node has been disposed
  117670. * @returns true if the node was disposed
  117671. */
  117672. isDisposed(): boolean;
  117673. /**
  117674. * Gets or sets the parent of the node (without keeping the current position in the scene)
  117675. * @see https://doc.babylonjs.com/how_to/parenting
  117676. */
  117677. set parent(parent: Nullable<Node>);
  117678. get parent(): Nullable<Node>;
  117679. /** @hidden */
  117680. _addToSceneRootNodes(): void;
  117681. /** @hidden */
  117682. _removeFromSceneRootNodes(): void;
  117683. private _animationPropertiesOverride;
  117684. /**
  117685. * Gets or sets the animation properties override
  117686. */
  117687. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  117688. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  117689. /**
  117690. * Gets a string identifying the name of the class
  117691. * @returns "Node" string
  117692. */
  117693. getClassName(): string;
  117694. /** @hidden */
  117695. readonly _isNode: boolean;
  117696. /**
  117697. * An event triggered when the mesh is disposed
  117698. */
  117699. onDisposeObservable: Observable<Node>;
  117700. private _onDisposeObserver;
  117701. /**
  117702. * Sets a callback that will be raised when the node will be disposed
  117703. */
  117704. set onDispose(callback: () => void);
  117705. /**
  117706. * Creates a new Node
  117707. * @param name the name and id to be given to this node
  117708. * @param scene the scene this node will be added to
  117709. */
  117710. constructor(name: string, scene?: Nullable<Scene>);
  117711. /**
  117712. * Gets the scene of the node
  117713. * @returns a scene
  117714. */
  117715. getScene(): Scene;
  117716. /**
  117717. * Gets the engine of the node
  117718. * @returns a Engine
  117719. */
  117720. getEngine(): Engine;
  117721. private _behaviors;
  117722. /**
  117723. * Attach a behavior to the node
  117724. * @see https://doc.babylonjs.com/features/behaviour
  117725. * @param behavior defines the behavior to attach
  117726. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  117727. * @returns the current Node
  117728. */
  117729. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  117730. /**
  117731. * Remove an attached behavior
  117732. * @see https://doc.babylonjs.com/features/behaviour
  117733. * @param behavior defines the behavior to attach
  117734. * @returns the current Node
  117735. */
  117736. removeBehavior(behavior: Behavior<Node>): Node;
  117737. /**
  117738. * Gets the list of attached behaviors
  117739. * @see https://doc.babylonjs.com/features/behaviour
  117740. */
  117741. get behaviors(): Behavior<Node>[];
  117742. /**
  117743. * Gets an attached behavior by name
  117744. * @param name defines the name of the behavior to look for
  117745. * @see https://doc.babylonjs.com/features/behaviour
  117746. * @returns null if behavior was not found else the requested behavior
  117747. */
  117748. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  117749. /**
  117750. * Returns the latest update of the World matrix
  117751. * @returns a Matrix
  117752. */
  117753. getWorldMatrix(): Matrix;
  117754. /** @hidden */
  117755. _getWorldMatrixDeterminant(): number;
  117756. /**
  117757. * Returns directly the latest state of the mesh World matrix.
  117758. * A Matrix is returned.
  117759. */
  117760. get worldMatrixFromCache(): Matrix;
  117761. /** @hidden */
  117762. _initCache(): void;
  117763. /** @hidden */
  117764. updateCache(force?: boolean): void;
  117765. /** @hidden */
  117766. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  117767. /** @hidden */
  117768. _updateCache(ignoreParentClass?: boolean): void;
  117769. /** @hidden */
  117770. _isSynchronized(): boolean;
  117771. /** @hidden */
  117772. _markSyncedWithParent(): void;
  117773. /** @hidden */
  117774. isSynchronizedWithParent(): boolean;
  117775. /** @hidden */
  117776. isSynchronized(): boolean;
  117777. /**
  117778. * Is this node ready to be used/rendered
  117779. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  117780. * @return true if the node is ready
  117781. */
  117782. isReady(completeCheck?: boolean): boolean;
  117783. /**
  117784. * Is this node enabled?
  117785. * 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
  117786. * @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
  117787. * @return whether this node (and its parent) is enabled
  117788. */
  117789. isEnabled(checkAncestors?: boolean): boolean;
  117790. /** @hidden */
  117791. protected _syncParentEnabledState(): void;
  117792. /**
  117793. * Set the enabled state of this node
  117794. * @param value defines the new enabled state
  117795. */
  117796. setEnabled(value: boolean): void;
  117797. /**
  117798. * Is this node a descendant of the given node?
  117799. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  117800. * @param ancestor defines the parent node to inspect
  117801. * @returns a boolean indicating if this node is a descendant of the given node
  117802. */
  117803. isDescendantOf(ancestor: Node): boolean;
  117804. /** @hidden */
  117805. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  117806. /**
  117807. * Will return all nodes that have this node as ascendant
  117808. * @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
  117809. * @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
  117810. * @return all children nodes of all types
  117811. */
  117812. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  117813. /**
  117814. * Get all child-meshes of this node
  117815. * @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)
  117816. * @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
  117817. * @returns an array of AbstractMesh
  117818. */
  117819. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  117820. /**
  117821. * Get all direct children of this node
  117822. * @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
  117823. * @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)
  117824. * @returns an array of Node
  117825. */
  117826. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  117827. /** @hidden */
  117828. _setReady(state: boolean): void;
  117829. /**
  117830. * Get an animation by name
  117831. * @param name defines the name of the animation to look for
  117832. * @returns null if not found else the requested animation
  117833. */
  117834. getAnimationByName(name: string): Nullable<Animation>;
  117835. /**
  117836. * Creates an animation range for this node
  117837. * @param name defines the name of the range
  117838. * @param from defines the starting key
  117839. * @param to defines the end key
  117840. */
  117841. createAnimationRange(name: string, from: number, to: number): void;
  117842. /**
  117843. * Delete a specific animation range
  117844. * @param name defines the name of the range to delete
  117845. * @param deleteFrames defines if animation frames from the range must be deleted as well
  117846. */
  117847. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  117848. /**
  117849. * Get an animation range by name
  117850. * @param name defines the name of the animation range to look for
  117851. * @returns null if not found else the requested animation range
  117852. */
  117853. getAnimationRange(name: string): Nullable<AnimationRange>;
  117854. /**
  117855. * Gets the list of all animation ranges defined on this node
  117856. * @returns an array
  117857. */
  117858. getAnimationRanges(): Nullable<AnimationRange>[];
  117859. /**
  117860. * Will start the animation sequence
  117861. * @param name defines the range frames for animation sequence
  117862. * @param loop defines if the animation should loop (false by default)
  117863. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  117864. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  117865. * @returns the object created for this animation. If range does not exist, it will return null
  117866. */
  117867. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  117868. /**
  117869. * Serialize animation ranges into a JSON compatible object
  117870. * @returns serialization object
  117871. */
  117872. serializeAnimationRanges(): any;
  117873. /**
  117874. * Computes the world matrix of the node
  117875. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  117876. * @returns the world matrix
  117877. */
  117878. computeWorldMatrix(force?: boolean): Matrix;
  117879. /**
  117880. * Releases resources associated with this node.
  117881. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117882. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117883. */
  117884. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117885. /**
  117886. * Parse animation range data from a serialization object and store them into a given node
  117887. * @param node defines where to store the animation ranges
  117888. * @param parsedNode defines the serialization object to read data from
  117889. * @param scene defines the hosting scene
  117890. */
  117891. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  117892. /**
  117893. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  117894. * @param includeDescendants Include bounding info from descendants as well (true by default)
  117895. * @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
  117896. * @returns the new bounding vectors
  117897. */
  117898. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  117899. min: Vector3;
  117900. max: Vector3;
  117901. };
  117902. }
  117903. }
  117904. declare module BABYLON {
  117905. /**
  117906. * @hidden
  117907. */
  117908. export class _IAnimationState {
  117909. key: number;
  117910. repeatCount: number;
  117911. workValue?: any;
  117912. loopMode?: number;
  117913. offsetValue?: any;
  117914. highLimitValue?: any;
  117915. }
  117916. /**
  117917. * Class used to store any kind of animation
  117918. */
  117919. export class Animation {
  117920. /**Name of the animation */
  117921. name: string;
  117922. /**Property to animate */
  117923. targetProperty: string;
  117924. /**The frames per second of the animation */
  117925. framePerSecond: number;
  117926. /**The data type of the animation */
  117927. dataType: number;
  117928. /**The loop mode of the animation */
  117929. loopMode?: number | undefined;
  117930. /**Specifies if blending should be enabled */
  117931. enableBlending?: boolean | undefined;
  117932. /**
  117933. * Use matrix interpolation instead of using direct key value when animating matrices
  117934. */
  117935. static AllowMatricesInterpolation: boolean;
  117936. /**
  117937. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  117938. */
  117939. static AllowMatrixDecomposeForInterpolation: boolean;
  117940. /** Define the Url to load snippets */
  117941. static SnippetUrl: string;
  117942. /** Snippet ID if the animation was created from the snippet server */
  117943. snippetId: string;
  117944. /**
  117945. * Stores the key frames of the animation
  117946. */
  117947. private _keys;
  117948. /**
  117949. * Stores the easing function of the animation
  117950. */
  117951. private _easingFunction;
  117952. /**
  117953. * @hidden Internal use only
  117954. */
  117955. _runtimeAnimations: RuntimeAnimation[];
  117956. /**
  117957. * The set of event that will be linked to this animation
  117958. */
  117959. private _events;
  117960. /**
  117961. * Stores an array of target property paths
  117962. */
  117963. targetPropertyPath: string[];
  117964. /**
  117965. * Stores the blending speed of the animation
  117966. */
  117967. blendingSpeed: number;
  117968. /**
  117969. * Stores the animation ranges for the animation
  117970. */
  117971. private _ranges;
  117972. /**
  117973. * @hidden Internal use
  117974. */
  117975. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  117976. /**
  117977. * Sets up an animation
  117978. * @param property The property to animate
  117979. * @param animationType The animation type to apply
  117980. * @param framePerSecond The frames per second of the animation
  117981. * @param easingFunction The easing function used in the animation
  117982. * @returns The created animation
  117983. */
  117984. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  117985. /**
  117986. * Create and start an animation on a node
  117987. * @param name defines the name of the global animation that will be run on all nodes
  117988. * @param node defines the root node where the animation will take place
  117989. * @param targetProperty defines property to animate
  117990. * @param framePerSecond defines the number of frame per second yo use
  117991. * @param totalFrame defines the number of frames in total
  117992. * @param from defines the initial value
  117993. * @param to defines the final value
  117994. * @param loopMode defines which loop mode you want to use (off by default)
  117995. * @param easingFunction defines the easing function to use (linear by default)
  117996. * @param onAnimationEnd defines the callback to call when animation end
  117997. * @returns the animatable created for this animation
  117998. */
  117999. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  118000. /**
  118001. * Create and start an animation on a node and its descendants
  118002. * @param name defines the name of the global animation that will be run on all nodes
  118003. * @param node defines the root node where the animation will take place
  118004. * @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
  118005. * @param targetProperty defines property to animate
  118006. * @param framePerSecond defines the number of frame per second to use
  118007. * @param totalFrame defines the number of frames in total
  118008. * @param from defines the initial value
  118009. * @param to defines the final value
  118010. * @param loopMode defines which loop mode you want to use (off by default)
  118011. * @param easingFunction defines the easing function to use (linear by default)
  118012. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  118013. * @returns the list of animatables created for all nodes
  118014. * @example https://www.babylonjs-playground.com/#MH0VLI
  118015. */
  118016. 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[]>;
  118017. /**
  118018. * Creates a new animation, merges it with the existing animations and starts it
  118019. * @param name Name of the animation
  118020. * @param node Node which contains the scene that begins the animations
  118021. * @param targetProperty Specifies which property to animate
  118022. * @param framePerSecond The frames per second of the animation
  118023. * @param totalFrame The total number of frames
  118024. * @param from The frame at the beginning of the animation
  118025. * @param to The frame at the end of the animation
  118026. * @param loopMode Specifies the loop mode of the animation
  118027. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  118028. * @param onAnimationEnd Callback to run once the animation is complete
  118029. * @returns Nullable animation
  118030. */
  118031. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  118032. /**
  118033. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  118034. * @param sourceAnimation defines the Animation containing keyframes to convert
  118035. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  118036. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  118037. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  118038. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  118039. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  118040. */
  118041. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  118042. /**
  118043. * Transition property of an host to the target Value
  118044. * @param property The property to transition
  118045. * @param targetValue The target Value of the property
  118046. * @param host The object where the property to animate belongs
  118047. * @param scene Scene used to run the animation
  118048. * @param frameRate Framerate (in frame/s) to use
  118049. * @param transition The transition type we want to use
  118050. * @param duration The duration of the animation, in milliseconds
  118051. * @param onAnimationEnd Callback trigger at the end of the animation
  118052. * @returns Nullable animation
  118053. */
  118054. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  118055. /**
  118056. * Return the array of runtime animations currently using this animation
  118057. */
  118058. get runtimeAnimations(): RuntimeAnimation[];
  118059. /**
  118060. * Specifies if any of the runtime animations are currently running
  118061. */
  118062. get hasRunningRuntimeAnimations(): boolean;
  118063. /**
  118064. * Initializes the animation
  118065. * @param name Name of the animation
  118066. * @param targetProperty Property to animate
  118067. * @param framePerSecond The frames per second of the animation
  118068. * @param dataType The data type of the animation
  118069. * @param loopMode The loop mode of the animation
  118070. * @param enableBlending Specifies if blending should be enabled
  118071. */
  118072. constructor(
  118073. /**Name of the animation */
  118074. name: string,
  118075. /**Property to animate */
  118076. targetProperty: string,
  118077. /**The frames per second of the animation */
  118078. framePerSecond: number,
  118079. /**The data type of the animation */
  118080. dataType: number,
  118081. /**The loop mode of the animation */
  118082. loopMode?: number | undefined,
  118083. /**Specifies if blending should be enabled */
  118084. enableBlending?: boolean | undefined);
  118085. /**
  118086. * Converts the animation to a string
  118087. * @param fullDetails support for multiple levels of logging within scene loading
  118088. * @returns String form of the animation
  118089. */
  118090. toString(fullDetails?: boolean): string;
  118091. /**
  118092. * Add an event to this animation
  118093. * @param event Event to add
  118094. */
  118095. addEvent(event: AnimationEvent): void;
  118096. /**
  118097. * Remove all events found at the given frame
  118098. * @param frame The frame to remove events from
  118099. */
  118100. removeEvents(frame: number): void;
  118101. /**
  118102. * Retrieves all the events from the animation
  118103. * @returns Events from the animation
  118104. */
  118105. getEvents(): AnimationEvent[];
  118106. /**
  118107. * Creates an animation range
  118108. * @param name Name of the animation range
  118109. * @param from Starting frame of the animation range
  118110. * @param to Ending frame of the animation
  118111. */
  118112. createRange(name: string, from: number, to: number): void;
  118113. /**
  118114. * Deletes an animation range by name
  118115. * @param name Name of the animation range to delete
  118116. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  118117. */
  118118. deleteRange(name: string, deleteFrames?: boolean): void;
  118119. /**
  118120. * Gets the animation range by name, or null if not defined
  118121. * @param name Name of the animation range
  118122. * @returns Nullable animation range
  118123. */
  118124. getRange(name: string): Nullable<AnimationRange>;
  118125. /**
  118126. * Gets the key frames from the animation
  118127. * @returns The key frames of the animation
  118128. */
  118129. getKeys(): Array<IAnimationKey>;
  118130. /**
  118131. * Gets the highest frame rate of the animation
  118132. * @returns Highest frame rate of the animation
  118133. */
  118134. getHighestFrame(): number;
  118135. /**
  118136. * Gets the easing function of the animation
  118137. * @returns Easing function of the animation
  118138. */
  118139. getEasingFunction(): IEasingFunction;
  118140. /**
  118141. * Sets the easing function of the animation
  118142. * @param easingFunction A custom mathematical formula for animation
  118143. */
  118144. setEasingFunction(easingFunction: EasingFunction): void;
  118145. /**
  118146. * Interpolates a scalar linearly
  118147. * @param startValue Start value of the animation curve
  118148. * @param endValue End value of the animation curve
  118149. * @param gradient Scalar amount to interpolate
  118150. * @returns Interpolated scalar value
  118151. */
  118152. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  118153. /**
  118154. * Interpolates a scalar cubically
  118155. * @param startValue Start value of the animation curve
  118156. * @param outTangent End tangent of the animation
  118157. * @param endValue End value of the animation curve
  118158. * @param inTangent Start tangent of the animation curve
  118159. * @param gradient Scalar amount to interpolate
  118160. * @returns Interpolated scalar value
  118161. */
  118162. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  118163. /**
  118164. * Interpolates a quaternion using a spherical linear interpolation
  118165. * @param startValue Start value of the animation curve
  118166. * @param endValue End value of the animation curve
  118167. * @param gradient Scalar amount to interpolate
  118168. * @returns Interpolated quaternion value
  118169. */
  118170. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  118171. /**
  118172. * Interpolates a quaternion cubically
  118173. * @param startValue Start value of the animation curve
  118174. * @param outTangent End tangent of the animation curve
  118175. * @param endValue End value of the animation curve
  118176. * @param inTangent Start tangent of the animation curve
  118177. * @param gradient Scalar amount to interpolate
  118178. * @returns Interpolated quaternion value
  118179. */
  118180. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  118181. /**
  118182. * Interpolates a Vector3 linearl
  118183. * @param startValue Start value of the animation curve
  118184. * @param endValue End value of the animation curve
  118185. * @param gradient Scalar amount to interpolate
  118186. * @returns Interpolated scalar value
  118187. */
  118188. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  118189. /**
  118190. * Interpolates a Vector3 cubically
  118191. * @param startValue Start value of the animation curve
  118192. * @param outTangent End tangent of the animation
  118193. * @param endValue End value of the animation curve
  118194. * @param inTangent Start tangent of the animation curve
  118195. * @param gradient Scalar amount to interpolate
  118196. * @returns InterpolatedVector3 value
  118197. */
  118198. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  118199. /**
  118200. * Interpolates a Vector2 linearly
  118201. * @param startValue Start value of the animation curve
  118202. * @param endValue End value of the animation curve
  118203. * @param gradient Scalar amount to interpolate
  118204. * @returns Interpolated Vector2 value
  118205. */
  118206. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  118207. /**
  118208. * Interpolates a Vector2 cubically
  118209. * @param startValue Start value of the animation curve
  118210. * @param outTangent End tangent of the animation
  118211. * @param endValue End value of the animation curve
  118212. * @param inTangent Start tangent of the animation curve
  118213. * @param gradient Scalar amount to interpolate
  118214. * @returns Interpolated Vector2 value
  118215. */
  118216. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  118217. /**
  118218. * Interpolates a size linearly
  118219. * @param startValue Start value of the animation curve
  118220. * @param endValue End value of the animation curve
  118221. * @param gradient Scalar amount to interpolate
  118222. * @returns Interpolated Size value
  118223. */
  118224. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  118225. /**
  118226. * Interpolates a Color3 linearly
  118227. * @param startValue Start value of the animation curve
  118228. * @param endValue End value of the animation curve
  118229. * @param gradient Scalar amount to interpolate
  118230. * @returns Interpolated Color3 value
  118231. */
  118232. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  118233. /**
  118234. * Interpolates a Color4 linearly
  118235. * @param startValue Start value of the animation curve
  118236. * @param endValue End value of the animation curve
  118237. * @param gradient Scalar amount to interpolate
  118238. * @returns Interpolated Color3 value
  118239. */
  118240. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  118241. /**
  118242. * @hidden Internal use only
  118243. */
  118244. _getKeyValue(value: any): any;
  118245. /**
  118246. * @hidden Internal use only
  118247. */
  118248. _interpolate(currentFrame: number, state: _IAnimationState): any;
  118249. /**
  118250. * Defines the function to use to interpolate matrices
  118251. * @param startValue defines the start matrix
  118252. * @param endValue defines the end matrix
  118253. * @param gradient defines the gradient between both matrices
  118254. * @param result defines an optional target matrix where to store the interpolation
  118255. * @returns the interpolated matrix
  118256. */
  118257. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  118258. /**
  118259. * Makes a copy of the animation
  118260. * @returns Cloned animation
  118261. */
  118262. clone(): Animation;
  118263. /**
  118264. * Sets the key frames of the animation
  118265. * @param values The animation key frames to set
  118266. */
  118267. setKeys(values: Array<IAnimationKey>): void;
  118268. /**
  118269. * Serializes the animation to an object
  118270. * @returns Serialized object
  118271. */
  118272. serialize(): any;
  118273. /**
  118274. * Float animation type
  118275. */
  118276. static readonly ANIMATIONTYPE_FLOAT: number;
  118277. /**
  118278. * Vector3 animation type
  118279. */
  118280. static readonly ANIMATIONTYPE_VECTOR3: number;
  118281. /**
  118282. * Quaternion animation type
  118283. */
  118284. static readonly ANIMATIONTYPE_QUATERNION: number;
  118285. /**
  118286. * Matrix animation type
  118287. */
  118288. static readonly ANIMATIONTYPE_MATRIX: number;
  118289. /**
  118290. * Color3 animation type
  118291. */
  118292. static readonly ANIMATIONTYPE_COLOR3: number;
  118293. /**
  118294. * Color3 animation type
  118295. */
  118296. static readonly ANIMATIONTYPE_COLOR4: number;
  118297. /**
  118298. * Vector2 animation type
  118299. */
  118300. static readonly ANIMATIONTYPE_VECTOR2: number;
  118301. /**
  118302. * Size animation type
  118303. */
  118304. static readonly ANIMATIONTYPE_SIZE: number;
  118305. /**
  118306. * Relative Loop Mode
  118307. */
  118308. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  118309. /**
  118310. * Cycle Loop Mode
  118311. */
  118312. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  118313. /**
  118314. * Constant Loop Mode
  118315. */
  118316. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  118317. /** @hidden */
  118318. static _UniversalLerp(left: any, right: any, amount: number): any;
  118319. /**
  118320. * Parses an animation object and creates an animation
  118321. * @param parsedAnimation Parsed animation object
  118322. * @returns Animation object
  118323. */
  118324. static Parse(parsedAnimation: any): Animation;
  118325. /**
  118326. * Appends the serialized animations from the source animations
  118327. * @param source Source containing the animations
  118328. * @param destination Target to store the animations
  118329. */
  118330. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  118331. /**
  118332. * Creates a new animation or an array of animations from a snippet saved in a remote file
  118333. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  118334. * @param url defines the url to load from
  118335. * @returns a promise that will resolve to the new animation or an array of animations
  118336. */
  118337. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  118338. /**
  118339. * Creates an animation or an array of animations from a snippet saved by the Inspector
  118340. * @param snippetId defines the snippet to load
  118341. * @returns a promise that will resolve to the new animation or a new array of animations
  118342. */
  118343. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  118344. }
  118345. }
  118346. declare module BABYLON {
  118347. /**
  118348. * Interface containing an array of animations
  118349. */
  118350. export interface IAnimatable {
  118351. /**
  118352. * Array of animations
  118353. */
  118354. animations: Nullable<Array<Animation>>;
  118355. }
  118356. }
  118357. declare module BABYLON {
  118358. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  118359. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118360. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118361. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118362. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118363. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118364. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118365. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118366. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118367. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118368. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118369. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118370. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118371. /**
  118372. * Decorator used to define property that can be serialized as reference to a camera
  118373. * @param sourceName defines the name of the property to decorate
  118374. */
  118375. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118376. /**
  118377. * Class used to help serialization objects
  118378. */
  118379. export class SerializationHelper {
  118380. /** @hidden */
  118381. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  118382. /** @hidden */
  118383. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  118384. /** @hidden */
  118385. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  118386. /** @hidden */
  118387. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  118388. /**
  118389. * Appends the serialized animations from the source animations
  118390. * @param source Source containing the animations
  118391. * @param destination Target to store the animations
  118392. */
  118393. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  118394. /**
  118395. * Static function used to serialized a specific entity
  118396. * @param entity defines the entity to serialize
  118397. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  118398. * @returns a JSON compatible object representing the serialization of the entity
  118399. */
  118400. static Serialize<T>(entity: T, serializationObject?: any): any;
  118401. /**
  118402. * Creates a new entity from a serialization data object
  118403. * @param creationFunction defines a function used to instanciated the new entity
  118404. * @param source defines the source serialization data
  118405. * @param scene defines the hosting scene
  118406. * @param rootUrl defines the root url for resources
  118407. * @returns a new entity
  118408. */
  118409. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  118410. /**
  118411. * Clones an object
  118412. * @param creationFunction defines the function used to instanciate the new object
  118413. * @param source defines the source object
  118414. * @returns the cloned object
  118415. */
  118416. static Clone<T>(creationFunction: () => T, source: T): T;
  118417. /**
  118418. * Instanciates a new object based on a source one (some data will be shared between both object)
  118419. * @param creationFunction defines the function used to instanciate the new object
  118420. * @param source defines the source object
  118421. * @returns the new object
  118422. */
  118423. static Instanciate<T>(creationFunction: () => T, source: T): T;
  118424. }
  118425. }
  118426. declare module BABYLON {
  118427. /**
  118428. * This is the base class of all the camera used in the application.
  118429. * @see https://doc.babylonjs.com/features/cameras
  118430. */
  118431. export class Camera extends Node {
  118432. /** @hidden */
  118433. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  118434. /**
  118435. * This is the default projection mode used by the cameras.
  118436. * It helps recreating a feeling of perspective and better appreciate depth.
  118437. * This is the best way to simulate real life cameras.
  118438. */
  118439. static readonly PERSPECTIVE_CAMERA: number;
  118440. /**
  118441. * This helps creating camera with an orthographic mode.
  118442. * 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.
  118443. */
  118444. static readonly ORTHOGRAPHIC_CAMERA: number;
  118445. /**
  118446. * This is the default FOV mode for perspective cameras.
  118447. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  118448. */
  118449. static readonly FOVMODE_VERTICAL_FIXED: number;
  118450. /**
  118451. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  118452. */
  118453. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  118454. /**
  118455. * This specifies ther is no need for a camera rig.
  118456. * Basically only one eye is rendered corresponding to the camera.
  118457. */
  118458. static readonly RIG_MODE_NONE: number;
  118459. /**
  118460. * Simulates a camera Rig with one blue eye and one red eye.
  118461. * This can be use with 3d blue and red glasses.
  118462. */
  118463. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  118464. /**
  118465. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  118466. */
  118467. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  118468. /**
  118469. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  118470. */
  118471. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  118472. /**
  118473. * Defines that both eyes of the camera will be rendered over under each other.
  118474. */
  118475. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  118476. /**
  118477. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  118478. */
  118479. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  118480. /**
  118481. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  118482. */
  118483. static readonly RIG_MODE_VR: number;
  118484. /**
  118485. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  118486. */
  118487. static readonly RIG_MODE_WEBVR: number;
  118488. /**
  118489. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  118490. */
  118491. static readonly RIG_MODE_CUSTOM: number;
  118492. /**
  118493. * Defines if by default attaching controls should prevent the default javascript event to continue.
  118494. */
  118495. static ForceAttachControlToAlwaysPreventDefault: boolean;
  118496. /**
  118497. * Define the input manager associated with the camera.
  118498. */
  118499. inputs: CameraInputsManager<Camera>;
  118500. /** @hidden */
  118501. _position: Vector3;
  118502. /**
  118503. * Define the current local position of the camera in the scene
  118504. */
  118505. get position(): Vector3;
  118506. set position(newPosition: Vector3);
  118507. protected _upVector: Vector3;
  118508. /**
  118509. * The vector the camera should consider as up.
  118510. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  118511. */
  118512. set upVector(vec: Vector3);
  118513. get upVector(): Vector3;
  118514. /**
  118515. * Define the current limit on the left side for an orthographic camera
  118516. * In scene unit
  118517. */
  118518. orthoLeft: Nullable<number>;
  118519. /**
  118520. * Define the current limit on the right side for an orthographic camera
  118521. * In scene unit
  118522. */
  118523. orthoRight: Nullable<number>;
  118524. /**
  118525. * Define the current limit on the bottom side for an orthographic camera
  118526. * In scene unit
  118527. */
  118528. orthoBottom: Nullable<number>;
  118529. /**
  118530. * Define the current limit on the top side for an orthographic camera
  118531. * In scene unit
  118532. */
  118533. orthoTop: Nullable<number>;
  118534. /**
  118535. * Field Of View is set in Radians. (default is 0.8)
  118536. */
  118537. fov: number;
  118538. /**
  118539. * Define the minimum distance the camera can see from.
  118540. * This is important to note that the depth buffer are not infinite and the closer it starts
  118541. * the more your scene might encounter depth fighting issue.
  118542. */
  118543. minZ: number;
  118544. /**
  118545. * Define the maximum distance the camera can see to.
  118546. * This is important to note that the depth buffer are not infinite and the further it end
  118547. * the more your scene might encounter depth fighting issue.
  118548. */
  118549. maxZ: number;
  118550. /**
  118551. * Define the default inertia of the camera.
  118552. * This helps giving a smooth feeling to the camera movement.
  118553. */
  118554. inertia: number;
  118555. /**
  118556. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  118557. */
  118558. mode: number;
  118559. /**
  118560. * Define whether the camera is intermediate.
  118561. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  118562. */
  118563. isIntermediate: boolean;
  118564. /**
  118565. * Define the viewport of the camera.
  118566. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  118567. */
  118568. viewport: Viewport;
  118569. /**
  118570. * Restricts the camera to viewing objects with the same layerMask.
  118571. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  118572. */
  118573. layerMask: number;
  118574. /**
  118575. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  118576. */
  118577. fovMode: number;
  118578. /**
  118579. * Rig mode of the camera.
  118580. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  118581. * This is normally controlled byt the camera themselves as internal use.
  118582. */
  118583. cameraRigMode: number;
  118584. /**
  118585. * Defines the distance between both "eyes" in case of a RIG
  118586. */
  118587. interaxialDistance: number;
  118588. /**
  118589. * Defines if stereoscopic rendering is done side by side or over under.
  118590. */
  118591. isStereoscopicSideBySide: boolean;
  118592. /**
  118593. * 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
  118594. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  118595. * else in the scene. (Eg. security camera)
  118596. *
  118597. * 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)
  118598. */
  118599. customRenderTargets: RenderTargetTexture[];
  118600. /**
  118601. * When set, the camera will render to this render target instead of the default canvas
  118602. *
  118603. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  118604. */
  118605. outputRenderTarget: Nullable<RenderTargetTexture>;
  118606. /**
  118607. * Observable triggered when the camera view matrix has changed.
  118608. */
  118609. onViewMatrixChangedObservable: Observable<Camera>;
  118610. /**
  118611. * Observable triggered when the camera Projection matrix has changed.
  118612. */
  118613. onProjectionMatrixChangedObservable: Observable<Camera>;
  118614. /**
  118615. * Observable triggered when the inputs have been processed.
  118616. */
  118617. onAfterCheckInputsObservable: Observable<Camera>;
  118618. /**
  118619. * Observable triggered when reset has been called and applied to the camera.
  118620. */
  118621. onRestoreStateObservable: Observable<Camera>;
  118622. /**
  118623. * Is this camera a part of a rig system?
  118624. */
  118625. isRigCamera: boolean;
  118626. /**
  118627. * If isRigCamera set to true this will be set with the parent camera.
  118628. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  118629. */
  118630. rigParent?: Camera;
  118631. /** @hidden */
  118632. _cameraRigParams: any;
  118633. /** @hidden */
  118634. _rigCameras: Camera[];
  118635. /** @hidden */
  118636. _rigPostProcess: Nullable<PostProcess>;
  118637. protected _webvrViewMatrix: Matrix;
  118638. /** @hidden */
  118639. _skipRendering: boolean;
  118640. /** @hidden */
  118641. _projectionMatrix: Matrix;
  118642. /** @hidden */
  118643. _postProcesses: Nullable<PostProcess>[];
  118644. /** @hidden */
  118645. _activeMeshes: SmartArray<AbstractMesh>;
  118646. protected _globalPosition: Vector3;
  118647. /** @hidden */
  118648. _computedViewMatrix: Matrix;
  118649. private _doNotComputeProjectionMatrix;
  118650. private _transformMatrix;
  118651. private _frustumPlanes;
  118652. private _refreshFrustumPlanes;
  118653. private _storedFov;
  118654. private _stateStored;
  118655. /**
  118656. * Instantiates a new camera object.
  118657. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  118658. * @see https://doc.babylonjs.com/features/cameras
  118659. * @param name Defines the name of the camera in the scene
  118660. * @param position Defines the position of the camera
  118661. * @param scene Defines the scene the camera belongs too
  118662. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  118663. */
  118664. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  118665. /**
  118666. * Store current camera state (fov, position, etc..)
  118667. * @returns the camera
  118668. */
  118669. storeState(): Camera;
  118670. /**
  118671. * Restores the camera state values if it has been stored. You must call storeState() first
  118672. */
  118673. protected _restoreStateValues(): boolean;
  118674. /**
  118675. * Restored camera state. You must call storeState() first.
  118676. * @returns true if restored and false otherwise
  118677. */
  118678. restoreState(): boolean;
  118679. /**
  118680. * Gets the class name of the camera.
  118681. * @returns the class name
  118682. */
  118683. getClassName(): string;
  118684. /** @hidden */
  118685. readonly _isCamera: boolean;
  118686. /**
  118687. * Gets a string representation of the camera useful for debug purpose.
  118688. * @param fullDetails Defines that a more verboe level of logging is required
  118689. * @returns the string representation
  118690. */
  118691. toString(fullDetails?: boolean): string;
  118692. /**
  118693. * Gets the current world space position of the camera.
  118694. */
  118695. get globalPosition(): Vector3;
  118696. /**
  118697. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  118698. * @returns the active meshe list
  118699. */
  118700. getActiveMeshes(): SmartArray<AbstractMesh>;
  118701. /**
  118702. * Check whether a mesh is part of the current active mesh list of the camera
  118703. * @param mesh Defines the mesh to check
  118704. * @returns true if active, false otherwise
  118705. */
  118706. isActiveMesh(mesh: Mesh): boolean;
  118707. /**
  118708. * Is this camera ready to be used/rendered
  118709. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  118710. * @return true if the camera is ready
  118711. */
  118712. isReady(completeCheck?: boolean): boolean;
  118713. /** @hidden */
  118714. _initCache(): void;
  118715. /** @hidden */
  118716. _updateCache(ignoreParentClass?: boolean): void;
  118717. /** @hidden */
  118718. _isSynchronized(): boolean;
  118719. /** @hidden */
  118720. _isSynchronizedViewMatrix(): boolean;
  118721. /** @hidden */
  118722. _isSynchronizedProjectionMatrix(): boolean;
  118723. /**
  118724. * Attach the input controls to a specific dom element to get the input from.
  118725. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118726. */
  118727. attachControl(noPreventDefault?: boolean): void;
  118728. /**
  118729. * Attach the input controls to a specific dom element to get the input from.
  118730. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  118731. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118732. * BACK COMPAT SIGNATURE ONLY.
  118733. */
  118734. attachControl(ignored: any, noPreventDefault?: boolean): void;
  118735. /**
  118736. * Detach the current controls from the specified dom element.
  118737. */
  118738. detachControl(): void;
  118739. /**
  118740. * Detach the current controls from the specified dom element.
  118741. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  118742. */
  118743. detachControl(ignored: any): void;
  118744. /**
  118745. * Update the camera state according to the different inputs gathered during the frame.
  118746. */
  118747. update(): void;
  118748. /** @hidden */
  118749. _checkInputs(): void;
  118750. /** @hidden */
  118751. get rigCameras(): Camera[];
  118752. /**
  118753. * Gets the post process used by the rig cameras
  118754. */
  118755. get rigPostProcess(): Nullable<PostProcess>;
  118756. /**
  118757. * Internal, gets the first post proces.
  118758. * @returns the first post process to be run on this camera.
  118759. */
  118760. _getFirstPostProcess(): Nullable<PostProcess>;
  118761. private _cascadePostProcessesToRigCams;
  118762. /**
  118763. * Attach a post process to the camera.
  118764. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  118765. * @param postProcess The post process to attach to the camera
  118766. * @param insertAt The position of the post process in case several of them are in use in the scene
  118767. * @returns the position the post process has been inserted at
  118768. */
  118769. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  118770. /**
  118771. * Detach a post process to the camera.
  118772. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  118773. * @param postProcess The post process to detach from the camera
  118774. */
  118775. detachPostProcess(postProcess: PostProcess): void;
  118776. /**
  118777. * Gets the current world matrix of the camera
  118778. */
  118779. getWorldMatrix(): Matrix;
  118780. /** @hidden */
  118781. _getViewMatrix(): Matrix;
  118782. /**
  118783. * Gets the current view matrix of the camera.
  118784. * @param force forces the camera to recompute the matrix without looking at the cached state
  118785. * @returns the view matrix
  118786. */
  118787. getViewMatrix(force?: boolean): Matrix;
  118788. /**
  118789. * Freeze the projection matrix.
  118790. * It will prevent the cache check of the camera projection compute and can speed up perf
  118791. * if no parameter of the camera are meant to change
  118792. * @param projection Defines manually a projection if necessary
  118793. */
  118794. freezeProjectionMatrix(projection?: Matrix): void;
  118795. /**
  118796. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  118797. */
  118798. unfreezeProjectionMatrix(): void;
  118799. /**
  118800. * Gets the current projection matrix of the camera.
  118801. * @param force forces the camera to recompute the matrix without looking at the cached state
  118802. * @returns the projection matrix
  118803. */
  118804. getProjectionMatrix(force?: boolean): Matrix;
  118805. /**
  118806. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  118807. * @returns a Matrix
  118808. */
  118809. getTransformationMatrix(): Matrix;
  118810. private _updateFrustumPlanes;
  118811. /**
  118812. * Checks if a cullable object (mesh...) is in the camera frustum
  118813. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  118814. * @param target The object to check
  118815. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  118816. * @returns true if the object is in frustum otherwise false
  118817. */
  118818. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  118819. /**
  118820. * Checks if a cullable object (mesh...) is in the camera frustum
  118821. * Unlike isInFrustum this cheks the full bounding box
  118822. * @param target The object to check
  118823. * @returns true if the object is in frustum otherwise false
  118824. */
  118825. isCompletelyInFrustum(target: ICullable): boolean;
  118826. /**
  118827. * Gets a ray in the forward direction from the camera.
  118828. * @param length Defines the length of the ray to create
  118829. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  118830. * @param origin Defines the start point of the ray which defaults to the camera position
  118831. * @returns the forward ray
  118832. */
  118833. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  118834. /**
  118835. * Gets a ray in the forward direction from the camera.
  118836. * @param refRay the ray to (re)use when setting the values
  118837. * @param length Defines the length of the ray to create
  118838. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  118839. * @param origin Defines the start point of the ray which defaults to the camera position
  118840. * @returns the forward ray
  118841. */
  118842. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  118843. /**
  118844. * Releases resources associated with this node.
  118845. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  118846. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  118847. */
  118848. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  118849. /** @hidden */
  118850. _isLeftCamera: boolean;
  118851. /**
  118852. * Gets the left camera of a rig setup in case of Rigged Camera
  118853. */
  118854. get isLeftCamera(): boolean;
  118855. /** @hidden */
  118856. _isRightCamera: boolean;
  118857. /**
  118858. * Gets the right camera of a rig setup in case of Rigged Camera
  118859. */
  118860. get isRightCamera(): boolean;
  118861. /**
  118862. * Gets the left camera of a rig setup in case of Rigged Camera
  118863. */
  118864. get leftCamera(): Nullable<FreeCamera>;
  118865. /**
  118866. * Gets the right camera of a rig setup in case of Rigged Camera
  118867. */
  118868. get rightCamera(): Nullable<FreeCamera>;
  118869. /**
  118870. * Gets the left camera target of a rig setup in case of Rigged Camera
  118871. * @returns the target position
  118872. */
  118873. getLeftTarget(): Nullable<Vector3>;
  118874. /**
  118875. * Gets the right camera target of a rig setup in case of Rigged Camera
  118876. * @returns the target position
  118877. */
  118878. getRightTarget(): Nullable<Vector3>;
  118879. /**
  118880. * @hidden
  118881. */
  118882. setCameraRigMode(mode: number, rigParams: any): void;
  118883. /** @hidden */
  118884. static _setStereoscopicRigMode(camera: Camera): void;
  118885. /** @hidden */
  118886. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  118887. /** @hidden */
  118888. static _setVRRigMode(camera: Camera, rigParams: any): void;
  118889. /** @hidden */
  118890. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  118891. /** @hidden */
  118892. _getVRProjectionMatrix(): Matrix;
  118893. protected _updateCameraRotationMatrix(): void;
  118894. protected _updateWebVRCameraRotationMatrix(): void;
  118895. /**
  118896. * This function MUST be overwritten by the different WebVR cameras available.
  118897. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  118898. * @hidden
  118899. */
  118900. _getWebVRProjectionMatrix(): Matrix;
  118901. /**
  118902. * This function MUST be overwritten by the different WebVR cameras available.
  118903. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  118904. * @hidden
  118905. */
  118906. _getWebVRViewMatrix(): Matrix;
  118907. /** @hidden */
  118908. setCameraRigParameter(name: string, value: any): void;
  118909. /**
  118910. * needs to be overridden by children so sub has required properties to be copied
  118911. * @hidden
  118912. */
  118913. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  118914. /**
  118915. * May need to be overridden by children
  118916. * @hidden
  118917. */
  118918. _updateRigCameras(): void;
  118919. /** @hidden */
  118920. _setupInputs(): void;
  118921. /**
  118922. * Serialiaze the camera setup to a json represention
  118923. * @returns the JSON representation
  118924. */
  118925. serialize(): any;
  118926. /**
  118927. * Clones the current camera.
  118928. * @param name The cloned camera name
  118929. * @returns the cloned camera
  118930. */
  118931. clone(name: string): Camera;
  118932. /**
  118933. * Gets the direction of the camera relative to a given local axis.
  118934. * @param localAxis Defines the reference axis to provide a relative direction.
  118935. * @return the direction
  118936. */
  118937. getDirection(localAxis: Vector3): Vector3;
  118938. /**
  118939. * Returns the current camera absolute rotation
  118940. */
  118941. get absoluteRotation(): Quaternion;
  118942. /**
  118943. * Gets the direction of the camera relative to a given local axis into a passed vector.
  118944. * @param localAxis Defines the reference axis to provide a relative direction.
  118945. * @param result Defines the vector to store the result in
  118946. */
  118947. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  118948. /**
  118949. * Gets a camera constructor for a given camera type
  118950. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  118951. * @param name The name of the camera the result will be able to instantiate
  118952. * @param scene The scene the result will construct the camera in
  118953. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  118954. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  118955. * @returns a factory method to construc the camera
  118956. */
  118957. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  118958. /**
  118959. * Compute the world matrix of the camera.
  118960. * @returns the camera world matrix
  118961. */
  118962. computeWorldMatrix(): Matrix;
  118963. /**
  118964. * Parse a JSON and creates the camera from the parsed information
  118965. * @param parsedCamera The JSON to parse
  118966. * @param scene The scene to instantiate the camera in
  118967. * @returns the newly constructed camera
  118968. */
  118969. static Parse(parsedCamera: any, scene: Scene): Camera;
  118970. }
  118971. }
  118972. declare module BABYLON {
  118973. /**
  118974. * PostProcessManager is used to manage one or more post processes or post process pipelines
  118975. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118976. */
  118977. export class PostProcessManager {
  118978. private _scene;
  118979. private _indexBuffer;
  118980. private _vertexBuffers;
  118981. /**
  118982. * Creates a new instance PostProcess
  118983. * @param scene The scene that the post process is associated with.
  118984. */
  118985. constructor(scene: Scene);
  118986. private _prepareBuffers;
  118987. private _buildIndexBuffer;
  118988. /**
  118989. * Rebuilds the vertex buffers of the manager.
  118990. * @hidden
  118991. */
  118992. _rebuild(): void;
  118993. /**
  118994. * Prepares a frame to be run through a post process.
  118995. * @param sourceTexture The input texture to the post procesess. (default: null)
  118996. * @param postProcesses An array of post processes to be run. (default: null)
  118997. * @returns True if the post processes were able to be run.
  118998. * @hidden
  118999. */
  119000. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  119001. /**
  119002. * Manually render a set of post processes to a texture.
  119003. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  119004. * @param postProcesses An array of post processes to be run.
  119005. * @param targetTexture The target texture to render to.
  119006. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  119007. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  119008. * @param lodLevel defines which lod of the texture to render to
  119009. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  119010. */
  119011. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  119012. /**
  119013. * Finalize the result of the output of the postprocesses.
  119014. * @param doNotPresent If true the result will not be displayed to the screen.
  119015. * @param targetTexture The target texture to render to.
  119016. * @param faceIndex The index of the face to bind the target texture to.
  119017. * @param postProcesses The array of post processes to render.
  119018. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  119019. * @hidden
  119020. */
  119021. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  119022. /**
  119023. * Disposes of the post process manager.
  119024. */
  119025. dispose(): void;
  119026. }
  119027. }
  119028. declare module BABYLON {
  119029. /**
  119030. * This Helps creating a texture that will be created from a camera in your scene.
  119031. * It is basically a dynamic texture that could be used to create special effects for instance.
  119032. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  119033. */
  119034. export class RenderTargetTexture extends Texture {
  119035. /**
  119036. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  119037. */
  119038. static readonly REFRESHRATE_RENDER_ONCE: number;
  119039. /**
  119040. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  119041. */
  119042. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  119043. /**
  119044. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  119045. * the central point of your effect and can save a lot of performances.
  119046. */
  119047. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  119048. /**
  119049. * Use this predicate to dynamically define the list of mesh you want to render.
  119050. * If set, the renderList property will be overwritten.
  119051. */
  119052. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  119053. private _renderList;
  119054. /**
  119055. * Use this list to define the list of mesh you want to render.
  119056. */
  119057. get renderList(): Nullable<Array<AbstractMesh>>;
  119058. set renderList(value: Nullable<Array<AbstractMesh>>);
  119059. /**
  119060. * Use this function to overload the renderList array at rendering time.
  119061. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  119062. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  119063. * the cube (if the RTT is a cube, else layerOrFace=0).
  119064. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  119065. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  119066. * hold dummy elements!
  119067. */
  119068. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  119069. private _hookArray;
  119070. /**
  119071. * Define if particles should be rendered in your texture.
  119072. */
  119073. renderParticles: boolean;
  119074. /**
  119075. * Define if sprites should be rendered in your texture.
  119076. */
  119077. renderSprites: boolean;
  119078. /**
  119079. * Define the camera used to render the texture.
  119080. */
  119081. activeCamera: Nullable<Camera>;
  119082. /**
  119083. * Override the mesh isReady function with your own one.
  119084. */
  119085. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  119086. /**
  119087. * Override the render function of the texture with your own one.
  119088. */
  119089. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  119090. /**
  119091. * Define if camera post processes should be use while rendering the texture.
  119092. */
  119093. useCameraPostProcesses: boolean;
  119094. /**
  119095. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  119096. */
  119097. ignoreCameraViewport: boolean;
  119098. private _postProcessManager;
  119099. private _postProcesses;
  119100. private _resizeObserver;
  119101. /**
  119102. * An event triggered when the texture is unbind.
  119103. */
  119104. onBeforeBindObservable: Observable<RenderTargetTexture>;
  119105. /**
  119106. * An event triggered when the texture is unbind.
  119107. */
  119108. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  119109. private _onAfterUnbindObserver;
  119110. /**
  119111. * Set a after unbind callback in the texture.
  119112. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  119113. */
  119114. set onAfterUnbind(callback: () => void);
  119115. /**
  119116. * An event triggered before rendering the texture
  119117. */
  119118. onBeforeRenderObservable: Observable<number>;
  119119. private _onBeforeRenderObserver;
  119120. /**
  119121. * Set a before render callback in the texture.
  119122. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  119123. */
  119124. set onBeforeRender(callback: (faceIndex: number) => void);
  119125. /**
  119126. * An event triggered after rendering the texture
  119127. */
  119128. onAfterRenderObservable: Observable<number>;
  119129. private _onAfterRenderObserver;
  119130. /**
  119131. * Set a after render callback in the texture.
  119132. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  119133. */
  119134. set onAfterRender(callback: (faceIndex: number) => void);
  119135. /**
  119136. * An event triggered after the texture clear
  119137. */
  119138. onClearObservable: Observable<Engine>;
  119139. private _onClearObserver;
  119140. /**
  119141. * Set a clear callback in the texture.
  119142. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  119143. */
  119144. set onClear(callback: (Engine: Engine) => void);
  119145. /**
  119146. * An event triggered when the texture is resized.
  119147. */
  119148. onResizeObservable: Observable<RenderTargetTexture>;
  119149. /**
  119150. * Define the clear color of the Render Target if it should be different from the scene.
  119151. */
  119152. clearColor: Color4;
  119153. protected _size: number | {
  119154. width: number;
  119155. height: number;
  119156. layers?: number;
  119157. };
  119158. protected _initialSizeParameter: number | {
  119159. width: number;
  119160. height: number;
  119161. } | {
  119162. ratio: number;
  119163. };
  119164. protected _sizeRatio: Nullable<number>;
  119165. /** @hidden */
  119166. _generateMipMaps: boolean;
  119167. protected _renderingManager: RenderingManager;
  119168. /** @hidden */
  119169. _waitingRenderList?: string[];
  119170. protected _doNotChangeAspectRatio: boolean;
  119171. protected _currentRefreshId: number;
  119172. protected _refreshRate: number;
  119173. protected _textureMatrix: Matrix;
  119174. protected _samples: number;
  119175. protected _renderTargetOptions: RenderTargetCreationOptions;
  119176. /**
  119177. * Gets render target creation options that were used.
  119178. */
  119179. get renderTargetOptions(): RenderTargetCreationOptions;
  119180. protected _onRatioRescale(): void;
  119181. /**
  119182. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  119183. * It must define where the camera used to render the texture is set
  119184. */
  119185. boundingBoxPosition: Vector3;
  119186. private _boundingBoxSize;
  119187. /**
  119188. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  119189. * When defined, the cubemap will switch to local mode
  119190. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  119191. * @example https://www.babylonjs-playground.com/#RNASML
  119192. */
  119193. set boundingBoxSize(value: Vector3);
  119194. get boundingBoxSize(): Vector3;
  119195. /**
  119196. * In case the RTT has been created with a depth texture, get the associated
  119197. * depth texture.
  119198. * Otherwise, return null.
  119199. */
  119200. get depthStencilTexture(): Nullable<InternalTexture>;
  119201. /**
  119202. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  119203. * or used a shadow, depth texture...
  119204. * @param name The friendly name of the texture
  119205. * @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)
  119206. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  119207. * @param generateMipMaps True if mip maps need to be generated after render.
  119208. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  119209. * @param type The type of the buffer in the RTT (int, half float, float...)
  119210. * @param isCube True if a cube texture needs to be created
  119211. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  119212. * @param generateDepthBuffer True to generate a depth buffer
  119213. * @param generateStencilBuffer True to generate a stencil buffer
  119214. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  119215. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  119216. * @param delayAllocation if the texture allocation should be delayed (default: false)
  119217. */
  119218. constructor(name: string, size: number | {
  119219. width: number;
  119220. height: number;
  119221. layers?: number;
  119222. } | {
  119223. ratio: number;
  119224. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  119225. /**
  119226. * Creates a depth stencil texture.
  119227. * This is only available in WebGL 2 or with the depth texture extension available.
  119228. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  119229. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  119230. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  119231. */
  119232. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  119233. private _processSizeParameter;
  119234. /**
  119235. * Define the number of samples to use in case of MSAA.
  119236. * It defaults to one meaning no MSAA has been enabled.
  119237. */
  119238. get samples(): number;
  119239. set samples(value: number);
  119240. /**
  119241. * Resets the refresh counter of the texture and start bak from scratch.
  119242. * Could be useful to regenerate the texture if it is setup to render only once.
  119243. */
  119244. resetRefreshCounter(): void;
  119245. /**
  119246. * Define the refresh rate of the texture or the rendering frequency.
  119247. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  119248. */
  119249. get refreshRate(): number;
  119250. set refreshRate(value: number);
  119251. /**
  119252. * Adds a post process to the render target rendering passes.
  119253. * @param postProcess define the post process to add
  119254. */
  119255. addPostProcess(postProcess: PostProcess): void;
  119256. /**
  119257. * Clear all the post processes attached to the render target
  119258. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  119259. */
  119260. clearPostProcesses(dispose?: boolean): void;
  119261. /**
  119262. * Remove one of the post process from the list of attached post processes to the texture
  119263. * @param postProcess define the post process to remove from the list
  119264. */
  119265. removePostProcess(postProcess: PostProcess): void;
  119266. /** @hidden */
  119267. _shouldRender(): boolean;
  119268. /**
  119269. * Gets the actual render size of the texture.
  119270. * @returns the width of the render size
  119271. */
  119272. getRenderSize(): number;
  119273. /**
  119274. * Gets the actual render width of the texture.
  119275. * @returns the width of the render size
  119276. */
  119277. getRenderWidth(): number;
  119278. /**
  119279. * Gets the actual render height of the texture.
  119280. * @returns the height of the render size
  119281. */
  119282. getRenderHeight(): number;
  119283. /**
  119284. * Gets the actual number of layers of the texture.
  119285. * @returns the number of layers
  119286. */
  119287. getRenderLayers(): number;
  119288. /**
  119289. * Get if the texture can be rescaled or not.
  119290. */
  119291. get canRescale(): boolean;
  119292. /**
  119293. * Resize the texture using a ratio.
  119294. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  119295. */
  119296. scale(ratio: number): void;
  119297. /**
  119298. * Get the texture reflection matrix used to rotate/transform the reflection.
  119299. * @returns the reflection matrix
  119300. */
  119301. getReflectionTextureMatrix(): Matrix;
  119302. /**
  119303. * Resize the texture to a new desired size.
  119304. * Be carrefull as it will recreate all the data in the new texture.
  119305. * @param size Define the new size. It can be:
  119306. * - a number for squared texture,
  119307. * - an object containing { width: number, height: number }
  119308. * - or an object containing a ratio { ratio: number }
  119309. */
  119310. resize(size: number | {
  119311. width: number;
  119312. height: number;
  119313. } | {
  119314. ratio: number;
  119315. }): void;
  119316. private _defaultRenderListPrepared;
  119317. /**
  119318. * Renders all the objects from the render list into the texture.
  119319. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  119320. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  119321. */
  119322. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  119323. private _bestReflectionRenderTargetDimension;
  119324. private _prepareRenderingManager;
  119325. /**
  119326. * @hidden
  119327. * @param faceIndex face index to bind to if this is a cubetexture
  119328. * @param layer defines the index of the texture to bind in the array
  119329. */
  119330. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  119331. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  119332. private renderToTarget;
  119333. /**
  119334. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  119335. * This allowed control for front to back rendering or reversly depending of the special needs.
  119336. *
  119337. * @param renderingGroupId The rendering group id corresponding to its index
  119338. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  119339. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  119340. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  119341. */
  119342. 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;
  119343. /**
  119344. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  119345. *
  119346. * @param renderingGroupId The rendering group id corresponding to its index
  119347. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  119348. */
  119349. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  119350. /**
  119351. * Clones the texture.
  119352. * @returns the cloned texture
  119353. */
  119354. clone(): RenderTargetTexture;
  119355. /**
  119356. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  119357. * @returns The JSON representation of the texture
  119358. */
  119359. serialize(): any;
  119360. /**
  119361. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  119362. */
  119363. disposeFramebufferObjects(): void;
  119364. /**
  119365. * Dispose the texture and release its associated resources.
  119366. */
  119367. dispose(): void;
  119368. /** @hidden */
  119369. _rebuild(): void;
  119370. /**
  119371. * Clear the info related to rendering groups preventing retention point in material dispose.
  119372. */
  119373. freeRenderingGroups(): void;
  119374. /**
  119375. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  119376. * @returns the view count
  119377. */
  119378. getViewCount(): number;
  119379. }
  119380. }
  119381. declare module BABYLON {
  119382. /**
  119383. * Options to be used when creating an effect.
  119384. */
  119385. export interface IEffectCreationOptions {
  119386. /**
  119387. * Atrributes that will be used in the shader.
  119388. */
  119389. attributes: string[];
  119390. /**
  119391. * Uniform varible names that will be set in the shader.
  119392. */
  119393. uniformsNames: string[];
  119394. /**
  119395. * Uniform buffer variable names that will be set in the shader.
  119396. */
  119397. uniformBuffersNames: string[];
  119398. /**
  119399. * Sampler texture variable names that will be set in the shader.
  119400. */
  119401. samplers: string[];
  119402. /**
  119403. * Define statements that will be set in the shader.
  119404. */
  119405. defines: any;
  119406. /**
  119407. * Possible fallbacks for this effect to improve performance when needed.
  119408. */
  119409. fallbacks: Nullable<IEffectFallbacks>;
  119410. /**
  119411. * Callback that will be called when the shader is compiled.
  119412. */
  119413. onCompiled: Nullable<(effect: Effect) => void>;
  119414. /**
  119415. * Callback that will be called if an error occurs during shader compilation.
  119416. */
  119417. onError: Nullable<(effect: Effect, errors: string) => void>;
  119418. /**
  119419. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  119420. */
  119421. indexParameters?: any;
  119422. /**
  119423. * Max number of lights that can be used in the shader.
  119424. */
  119425. maxSimultaneousLights?: number;
  119426. /**
  119427. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  119428. */
  119429. transformFeedbackVaryings?: Nullable<string[]>;
  119430. /**
  119431. * 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
  119432. */
  119433. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  119434. /**
  119435. * Is this effect rendering to several color attachments ?
  119436. */
  119437. multiTarget?: boolean;
  119438. }
  119439. /**
  119440. * Effect containing vertex and fragment shader that can be executed on an object.
  119441. */
  119442. export class Effect implements IDisposable {
  119443. /**
  119444. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  119445. */
  119446. static ShadersRepository: string;
  119447. /**
  119448. * Enable logging of the shader code when a compilation error occurs
  119449. */
  119450. static LogShaderCodeOnCompilationError: boolean;
  119451. /**
  119452. * Name of the effect.
  119453. */
  119454. name: any;
  119455. /**
  119456. * String container all the define statements that should be set on the shader.
  119457. */
  119458. defines: string;
  119459. /**
  119460. * Callback that will be called when the shader is compiled.
  119461. */
  119462. onCompiled: Nullable<(effect: Effect) => void>;
  119463. /**
  119464. * Callback that will be called if an error occurs during shader compilation.
  119465. */
  119466. onError: Nullable<(effect: Effect, errors: string) => void>;
  119467. /**
  119468. * Callback that will be called when effect is bound.
  119469. */
  119470. onBind: Nullable<(effect: Effect) => void>;
  119471. /**
  119472. * Unique ID of the effect.
  119473. */
  119474. uniqueId: number;
  119475. /**
  119476. * Observable that will be called when the shader is compiled.
  119477. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  119478. */
  119479. onCompileObservable: Observable<Effect>;
  119480. /**
  119481. * Observable that will be called if an error occurs during shader compilation.
  119482. */
  119483. onErrorObservable: Observable<Effect>;
  119484. /** @hidden */
  119485. _onBindObservable: Nullable<Observable<Effect>>;
  119486. /**
  119487. * @hidden
  119488. * Specifies if the effect was previously ready
  119489. */
  119490. _wasPreviouslyReady: boolean;
  119491. /**
  119492. * Observable that will be called when effect is bound.
  119493. */
  119494. get onBindObservable(): Observable<Effect>;
  119495. /** @hidden */
  119496. _bonesComputationForcedToCPU: boolean;
  119497. /** @hidden */
  119498. _multiTarget: boolean;
  119499. private static _uniqueIdSeed;
  119500. private _engine;
  119501. private _uniformBuffersNames;
  119502. private _uniformBuffersNamesList;
  119503. private _uniformsNames;
  119504. private _samplerList;
  119505. private _samplers;
  119506. private _isReady;
  119507. private _compilationError;
  119508. private _allFallbacksProcessed;
  119509. private _attributesNames;
  119510. private _attributes;
  119511. private _attributeLocationByName;
  119512. private _uniforms;
  119513. /**
  119514. * Key for the effect.
  119515. * @hidden
  119516. */
  119517. _key: string;
  119518. private _indexParameters;
  119519. private _fallbacks;
  119520. private _vertexSourceCode;
  119521. private _fragmentSourceCode;
  119522. private _vertexSourceCodeOverride;
  119523. private _fragmentSourceCodeOverride;
  119524. private _transformFeedbackVaryings;
  119525. private _rawVertexSourceCode;
  119526. private _rawFragmentSourceCode;
  119527. /**
  119528. * Compiled shader to webGL program.
  119529. * @hidden
  119530. */
  119531. _pipelineContext: Nullable<IPipelineContext>;
  119532. private _valueCache;
  119533. private static _baseCache;
  119534. /**
  119535. * Instantiates an effect.
  119536. * An effect can be used to create/manage/execute vertex and fragment shaders.
  119537. * @param baseName Name of the effect.
  119538. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  119539. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  119540. * @param samplers List of sampler variables that will be passed to the shader.
  119541. * @param engine Engine to be used to render the effect
  119542. * @param defines Define statements to be added to the shader.
  119543. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  119544. * @param onCompiled Callback that will be called when the shader is compiled.
  119545. * @param onError Callback that will be called if an error occurs during shader compilation.
  119546. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  119547. */
  119548. 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);
  119549. private _useFinalCode;
  119550. /**
  119551. * Unique key for this effect
  119552. */
  119553. get key(): string;
  119554. /**
  119555. * If the effect has been compiled and prepared.
  119556. * @returns if the effect is compiled and prepared.
  119557. */
  119558. isReady(): boolean;
  119559. private _isReadyInternal;
  119560. /**
  119561. * The engine the effect was initialized with.
  119562. * @returns the engine.
  119563. */
  119564. getEngine(): Engine;
  119565. /**
  119566. * The pipeline context for this effect
  119567. * @returns the associated pipeline context
  119568. */
  119569. getPipelineContext(): Nullable<IPipelineContext>;
  119570. /**
  119571. * The set of names of attribute variables for the shader.
  119572. * @returns An array of attribute names.
  119573. */
  119574. getAttributesNames(): string[];
  119575. /**
  119576. * Returns the attribute at the given index.
  119577. * @param index The index of the attribute.
  119578. * @returns The location of the attribute.
  119579. */
  119580. getAttributeLocation(index: number): number;
  119581. /**
  119582. * Returns the attribute based on the name of the variable.
  119583. * @param name of the attribute to look up.
  119584. * @returns the attribute location.
  119585. */
  119586. getAttributeLocationByName(name: string): number;
  119587. /**
  119588. * The number of attributes.
  119589. * @returns the numnber of attributes.
  119590. */
  119591. getAttributesCount(): number;
  119592. /**
  119593. * Gets the index of a uniform variable.
  119594. * @param uniformName of the uniform to look up.
  119595. * @returns the index.
  119596. */
  119597. getUniformIndex(uniformName: string): number;
  119598. /**
  119599. * Returns the attribute based on the name of the variable.
  119600. * @param uniformName of the uniform to look up.
  119601. * @returns the location of the uniform.
  119602. */
  119603. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  119604. /**
  119605. * Returns an array of sampler variable names
  119606. * @returns The array of sampler variable names.
  119607. */
  119608. getSamplers(): string[];
  119609. /**
  119610. * Returns an array of uniform variable names
  119611. * @returns The array of uniform variable names.
  119612. */
  119613. getUniformNames(): string[];
  119614. /**
  119615. * Returns an array of uniform buffer variable names
  119616. * @returns The array of uniform buffer variable names.
  119617. */
  119618. getUniformBuffersNames(): string[];
  119619. /**
  119620. * Returns the index parameters used to create the effect
  119621. * @returns The index parameters object
  119622. */
  119623. getIndexParameters(): any;
  119624. /**
  119625. * The error from the last compilation.
  119626. * @returns the error string.
  119627. */
  119628. getCompilationError(): string;
  119629. /**
  119630. * Gets a boolean indicating that all fallbacks were used during compilation
  119631. * @returns true if all fallbacks were used
  119632. */
  119633. allFallbacksProcessed(): boolean;
  119634. /**
  119635. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  119636. * @param func The callback to be used.
  119637. */
  119638. executeWhenCompiled(func: (effect: Effect) => void): void;
  119639. private _checkIsReady;
  119640. private _loadShader;
  119641. /**
  119642. * Gets the vertex shader source code of this effect
  119643. */
  119644. get vertexSourceCode(): string;
  119645. /**
  119646. * Gets the fragment shader source code of this effect
  119647. */
  119648. get fragmentSourceCode(): string;
  119649. /**
  119650. * Gets the vertex shader source code before it has been processed by the preprocessor
  119651. */
  119652. get rawVertexSourceCode(): string;
  119653. /**
  119654. * Gets the fragment shader source code before it has been processed by the preprocessor
  119655. */
  119656. get rawFragmentSourceCode(): string;
  119657. /**
  119658. * Recompiles the webGL program
  119659. * @param vertexSourceCode The source code for the vertex shader.
  119660. * @param fragmentSourceCode The source code for the fragment shader.
  119661. * @param onCompiled Callback called when completed.
  119662. * @param onError Callback called on error.
  119663. * @hidden
  119664. */
  119665. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  119666. /**
  119667. * Prepares the effect
  119668. * @hidden
  119669. */
  119670. _prepareEffect(): void;
  119671. private _getShaderCodeAndErrorLine;
  119672. private _processCompilationErrors;
  119673. /**
  119674. * Checks if the effect is supported. (Must be called after compilation)
  119675. */
  119676. get isSupported(): boolean;
  119677. /**
  119678. * Binds a texture to the engine to be used as output of the shader.
  119679. * @param channel Name of the output variable.
  119680. * @param texture Texture to bind.
  119681. * @hidden
  119682. */
  119683. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  119684. /**
  119685. * Sets a texture on the engine to be used in the shader.
  119686. * @param channel Name of the sampler variable.
  119687. * @param texture Texture to set.
  119688. */
  119689. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  119690. /**
  119691. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  119692. * @param channel Name of the sampler variable.
  119693. * @param texture Texture to set.
  119694. */
  119695. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  119696. /**
  119697. * Sets an array of textures on the engine to be used in the shader.
  119698. * @param channel Name of the variable.
  119699. * @param textures Textures to set.
  119700. */
  119701. setTextureArray(channel: string, textures: ThinTexture[]): void;
  119702. /**
  119703. * 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)
  119704. * @param channel Name of the sampler variable.
  119705. * @param postProcess Post process to get the input texture from.
  119706. */
  119707. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  119708. /**
  119709. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  119710. * 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)
  119711. * @param channel Name of the sampler variable.
  119712. * @param postProcess Post process to get the output texture from.
  119713. */
  119714. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  119715. /** @hidden */
  119716. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  119717. /** @hidden */
  119718. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  119719. /** @hidden */
  119720. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  119721. /** @hidden */
  119722. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  119723. /**
  119724. * Binds a buffer to a uniform.
  119725. * @param buffer Buffer to bind.
  119726. * @param name Name of the uniform variable to bind to.
  119727. */
  119728. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  119729. /**
  119730. * Binds block to a uniform.
  119731. * @param blockName Name of the block to bind.
  119732. * @param index Index to bind.
  119733. */
  119734. bindUniformBlock(blockName: string, index: number): void;
  119735. /**
  119736. * Sets an interger value on a uniform variable.
  119737. * @param uniformName Name of the variable.
  119738. * @param value Value to be set.
  119739. * @returns this effect.
  119740. */
  119741. setInt(uniformName: string, value: number): Effect;
  119742. /**
  119743. * Sets an int array on a uniform variable.
  119744. * @param uniformName Name of the variable.
  119745. * @param array array to be set.
  119746. * @returns this effect.
  119747. */
  119748. setIntArray(uniformName: string, array: Int32Array): Effect;
  119749. /**
  119750. * 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)
  119751. * @param uniformName Name of the variable.
  119752. * @param array array to be set.
  119753. * @returns this effect.
  119754. */
  119755. setIntArray2(uniformName: string, array: Int32Array): Effect;
  119756. /**
  119757. * 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)
  119758. * @param uniformName Name of the variable.
  119759. * @param array array to be set.
  119760. * @returns this effect.
  119761. */
  119762. setIntArray3(uniformName: string, array: Int32Array): Effect;
  119763. /**
  119764. * 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)
  119765. * @param uniformName Name of the variable.
  119766. * @param array array to be set.
  119767. * @returns this effect.
  119768. */
  119769. setIntArray4(uniformName: string, array: Int32Array): Effect;
  119770. /**
  119771. * Sets an float array on a uniform variable.
  119772. * @param uniformName Name of the variable.
  119773. * @param array array to be set.
  119774. * @returns this effect.
  119775. */
  119776. setFloatArray(uniformName: string, array: Float32Array): Effect;
  119777. /**
  119778. * 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)
  119779. * @param uniformName Name of the variable.
  119780. * @param array array to be set.
  119781. * @returns this effect.
  119782. */
  119783. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  119784. /**
  119785. * 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)
  119786. * @param uniformName Name of the variable.
  119787. * @param array array to be set.
  119788. * @returns this effect.
  119789. */
  119790. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  119791. /**
  119792. * 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)
  119793. * @param uniformName Name of the variable.
  119794. * @param array array to be set.
  119795. * @returns this effect.
  119796. */
  119797. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  119798. /**
  119799. * Sets an array on a uniform variable.
  119800. * @param uniformName Name of the variable.
  119801. * @param array array to be set.
  119802. * @returns this effect.
  119803. */
  119804. setArray(uniformName: string, array: number[]): Effect;
  119805. /**
  119806. * 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)
  119807. * @param uniformName Name of the variable.
  119808. * @param array array to be set.
  119809. * @returns this effect.
  119810. */
  119811. setArray2(uniformName: string, array: number[]): Effect;
  119812. /**
  119813. * 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)
  119814. * @param uniformName Name of the variable.
  119815. * @param array array to be set.
  119816. * @returns this effect.
  119817. */
  119818. setArray3(uniformName: string, array: number[]): Effect;
  119819. /**
  119820. * 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)
  119821. * @param uniformName Name of the variable.
  119822. * @param array array to be set.
  119823. * @returns this effect.
  119824. */
  119825. setArray4(uniformName: string, array: number[]): Effect;
  119826. /**
  119827. * Sets matrices on a uniform variable.
  119828. * @param uniformName Name of the variable.
  119829. * @param matrices matrices to be set.
  119830. * @returns this effect.
  119831. */
  119832. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  119833. /**
  119834. * Sets matrix on a uniform variable.
  119835. * @param uniformName Name of the variable.
  119836. * @param matrix matrix to be set.
  119837. * @returns this effect.
  119838. */
  119839. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  119840. /**
  119841. * 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)
  119842. * @param uniformName Name of the variable.
  119843. * @param matrix matrix to be set.
  119844. * @returns this effect.
  119845. */
  119846. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  119847. /**
  119848. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  119849. * @param uniformName Name of the variable.
  119850. * @param matrix matrix to be set.
  119851. * @returns this effect.
  119852. */
  119853. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  119854. /**
  119855. * Sets a float on a uniform variable.
  119856. * @param uniformName Name of the variable.
  119857. * @param value value to be set.
  119858. * @returns this effect.
  119859. */
  119860. setFloat(uniformName: string, value: number): Effect;
  119861. /**
  119862. * Sets a boolean on a uniform variable.
  119863. * @param uniformName Name of the variable.
  119864. * @param bool value to be set.
  119865. * @returns this effect.
  119866. */
  119867. setBool(uniformName: string, bool: boolean): Effect;
  119868. /**
  119869. * Sets a Vector2 on a uniform variable.
  119870. * @param uniformName Name of the variable.
  119871. * @param vector2 vector2 to be set.
  119872. * @returns this effect.
  119873. */
  119874. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  119875. /**
  119876. * Sets a float2 on a uniform variable.
  119877. * @param uniformName Name of the variable.
  119878. * @param x First float in float2.
  119879. * @param y Second float in float2.
  119880. * @returns this effect.
  119881. */
  119882. setFloat2(uniformName: string, x: number, y: number): Effect;
  119883. /**
  119884. * Sets a Vector3 on a uniform variable.
  119885. * @param uniformName Name of the variable.
  119886. * @param vector3 Value to be set.
  119887. * @returns this effect.
  119888. */
  119889. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  119890. /**
  119891. * Sets a float3 on a uniform variable.
  119892. * @param uniformName Name of the variable.
  119893. * @param x First float in float3.
  119894. * @param y Second float in float3.
  119895. * @param z Third float in float3.
  119896. * @returns this effect.
  119897. */
  119898. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  119899. /**
  119900. * Sets a Vector4 on a uniform variable.
  119901. * @param uniformName Name of the variable.
  119902. * @param vector4 Value to be set.
  119903. * @returns this effect.
  119904. */
  119905. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  119906. /**
  119907. * Sets a float4 on a uniform variable.
  119908. * @param uniformName Name of the variable.
  119909. * @param x First float in float4.
  119910. * @param y Second float in float4.
  119911. * @param z Third float in float4.
  119912. * @param w Fourth float in float4.
  119913. * @returns this effect.
  119914. */
  119915. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  119916. /**
  119917. * Sets a Color3 on a uniform variable.
  119918. * @param uniformName Name of the variable.
  119919. * @param color3 Value to be set.
  119920. * @returns this effect.
  119921. */
  119922. setColor3(uniformName: string, color3: IColor3Like): Effect;
  119923. /**
  119924. * Sets a Color4 on a uniform variable.
  119925. * @param uniformName Name of the variable.
  119926. * @param color3 Value to be set.
  119927. * @param alpha Alpha value to be set.
  119928. * @returns this effect.
  119929. */
  119930. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  119931. /**
  119932. * Sets a Color4 on a uniform variable
  119933. * @param uniformName defines the name of the variable
  119934. * @param color4 defines the value to be set
  119935. * @returns this effect.
  119936. */
  119937. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  119938. /** Release all associated resources */
  119939. dispose(): void;
  119940. /**
  119941. * This function will add a new shader to the shader store
  119942. * @param name the name of the shader
  119943. * @param pixelShader optional pixel shader content
  119944. * @param vertexShader optional vertex shader content
  119945. */
  119946. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  119947. /**
  119948. * Store of each shader (The can be looked up using effect.key)
  119949. */
  119950. static ShadersStore: {
  119951. [key: string]: string;
  119952. };
  119953. /**
  119954. * Store of each included file for a shader (The can be looked up using effect.key)
  119955. */
  119956. static IncludesShadersStore: {
  119957. [key: string]: string;
  119958. };
  119959. /**
  119960. * Resets the cache of effects.
  119961. */
  119962. static ResetCache(): void;
  119963. }
  119964. }
  119965. declare module BABYLON {
  119966. /**
  119967. * Interface used to describe the capabilities of the engine relatively to the current browser
  119968. */
  119969. export interface EngineCapabilities {
  119970. /** Maximum textures units per fragment shader */
  119971. maxTexturesImageUnits: number;
  119972. /** Maximum texture units per vertex shader */
  119973. maxVertexTextureImageUnits: number;
  119974. /** Maximum textures units in the entire pipeline */
  119975. maxCombinedTexturesImageUnits: number;
  119976. /** Maximum texture size */
  119977. maxTextureSize: number;
  119978. /** Maximum texture samples */
  119979. maxSamples?: number;
  119980. /** Maximum cube texture size */
  119981. maxCubemapTextureSize: number;
  119982. /** Maximum render texture size */
  119983. maxRenderTextureSize: number;
  119984. /** Maximum number of vertex attributes */
  119985. maxVertexAttribs: number;
  119986. /** Maximum number of varyings */
  119987. maxVaryingVectors: number;
  119988. /** Maximum number of uniforms per vertex shader */
  119989. maxVertexUniformVectors: number;
  119990. /** Maximum number of uniforms per fragment shader */
  119991. maxFragmentUniformVectors: number;
  119992. /** Defines if standard derivates (dx/dy) are supported */
  119993. standardDerivatives: boolean;
  119994. /** Defines if s3tc texture compression is supported */
  119995. s3tc?: WEBGL_compressed_texture_s3tc;
  119996. /** Defines if pvrtc texture compression is supported */
  119997. pvrtc: any;
  119998. /** Defines if etc1 texture compression is supported */
  119999. etc1: any;
  120000. /** Defines if etc2 texture compression is supported */
  120001. etc2: any;
  120002. /** Defines if astc texture compression is supported */
  120003. astc: any;
  120004. /** Defines if bptc texture compression is supported */
  120005. bptc: any;
  120006. /** Defines if float textures are supported */
  120007. textureFloat: boolean;
  120008. /** Defines if vertex array objects are supported */
  120009. vertexArrayObject: boolean;
  120010. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  120011. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  120012. /** Gets the maximum level of anisotropy supported */
  120013. maxAnisotropy: number;
  120014. /** Defines if instancing is supported */
  120015. instancedArrays: boolean;
  120016. /** Defines if 32 bits indices are supported */
  120017. uintIndices: boolean;
  120018. /** Defines if high precision shaders are supported */
  120019. highPrecisionShaderSupported: boolean;
  120020. /** Defines if depth reading in the fragment shader is supported */
  120021. fragmentDepthSupported: boolean;
  120022. /** Defines if float texture linear filtering is supported*/
  120023. textureFloatLinearFiltering: boolean;
  120024. /** Defines if rendering to float textures is supported */
  120025. textureFloatRender: boolean;
  120026. /** Defines if half float textures are supported*/
  120027. textureHalfFloat: boolean;
  120028. /** Defines if half float texture linear filtering is supported*/
  120029. textureHalfFloatLinearFiltering: boolean;
  120030. /** Defines if rendering to half float textures is supported */
  120031. textureHalfFloatRender: boolean;
  120032. /** Defines if textureLOD shader command is supported */
  120033. textureLOD: boolean;
  120034. /** Defines if draw buffers extension is supported */
  120035. drawBuffersExtension: boolean;
  120036. /** Defines if depth textures are supported */
  120037. depthTextureExtension: boolean;
  120038. /** Defines if float color buffer are supported */
  120039. colorBufferFloat: boolean;
  120040. /** Gets disjoint timer query extension (null if not supported) */
  120041. timerQuery?: EXT_disjoint_timer_query;
  120042. /** Defines if timestamp can be used with timer query */
  120043. canUseTimestampForTimerQuery: boolean;
  120044. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  120045. multiview?: any;
  120046. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  120047. oculusMultiview?: any;
  120048. /** Function used to let the system compiles shaders in background */
  120049. parallelShaderCompile?: {
  120050. COMPLETION_STATUS_KHR: number;
  120051. };
  120052. /** Max number of texture samples for MSAA */
  120053. maxMSAASamples: number;
  120054. /** Defines if the blend min max extension is supported */
  120055. blendMinMax: boolean;
  120056. }
  120057. }
  120058. declare module BABYLON {
  120059. /**
  120060. * @hidden
  120061. **/
  120062. export class DepthCullingState {
  120063. private _isDepthTestDirty;
  120064. private _isDepthMaskDirty;
  120065. private _isDepthFuncDirty;
  120066. private _isCullFaceDirty;
  120067. private _isCullDirty;
  120068. private _isZOffsetDirty;
  120069. private _isFrontFaceDirty;
  120070. private _depthTest;
  120071. private _depthMask;
  120072. private _depthFunc;
  120073. private _cull;
  120074. private _cullFace;
  120075. private _zOffset;
  120076. private _frontFace;
  120077. /**
  120078. * Initializes the state.
  120079. */
  120080. constructor();
  120081. get isDirty(): boolean;
  120082. get zOffset(): number;
  120083. set zOffset(value: number);
  120084. get cullFace(): Nullable<number>;
  120085. set cullFace(value: Nullable<number>);
  120086. get cull(): Nullable<boolean>;
  120087. set cull(value: Nullable<boolean>);
  120088. get depthFunc(): Nullable<number>;
  120089. set depthFunc(value: Nullable<number>);
  120090. get depthMask(): boolean;
  120091. set depthMask(value: boolean);
  120092. get depthTest(): boolean;
  120093. set depthTest(value: boolean);
  120094. get frontFace(): Nullable<number>;
  120095. set frontFace(value: Nullable<number>);
  120096. reset(): void;
  120097. apply(gl: WebGLRenderingContext): void;
  120098. }
  120099. }
  120100. declare module BABYLON {
  120101. /**
  120102. * @hidden
  120103. **/
  120104. export class StencilState {
  120105. /** 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 */
  120106. static readonly ALWAYS: number;
  120107. /** Passed to stencilOperation to specify that stencil value must be kept */
  120108. static readonly KEEP: number;
  120109. /** Passed to stencilOperation to specify that stencil value must be replaced */
  120110. static readonly REPLACE: number;
  120111. private _isStencilTestDirty;
  120112. private _isStencilMaskDirty;
  120113. private _isStencilFuncDirty;
  120114. private _isStencilOpDirty;
  120115. private _stencilTest;
  120116. private _stencilMask;
  120117. private _stencilFunc;
  120118. private _stencilFuncRef;
  120119. private _stencilFuncMask;
  120120. private _stencilOpStencilFail;
  120121. private _stencilOpDepthFail;
  120122. private _stencilOpStencilDepthPass;
  120123. get isDirty(): boolean;
  120124. get stencilFunc(): number;
  120125. set stencilFunc(value: number);
  120126. get stencilFuncRef(): number;
  120127. set stencilFuncRef(value: number);
  120128. get stencilFuncMask(): number;
  120129. set stencilFuncMask(value: number);
  120130. get stencilOpStencilFail(): number;
  120131. set stencilOpStencilFail(value: number);
  120132. get stencilOpDepthFail(): number;
  120133. set stencilOpDepthFail(value: number);
  120134. get stencilOpStencilDepthPass(): number;
  120135. set stencilOpStencilDepthPass(value: number);
  120136. get stencilMask(): number;
  120137. set stencilMask(value: number);
  120138. get stencilTest(): boolean;
  120139. set stencilTest(value: boolean);
  120140. constructor();
  120141. reset(): void;
  120142. apply(gl: WebGLRenderingContext): void;
  120143. }
  120144. }
  120145. declare module BABYLON {
  120146. /**
  120147. * @hidden
  120148. **/
  120149. export class AlphaState {
  120150. private _isAlphaBlendDirty;
  120151. private _isBlendFunctionParametersDirty;
  120152. private _isBlendEquationParametersDirty;
  120153. private _isBlendConstantsDirty;
  120154. private _alphaBlend;
  120155. private _blendFunctionParameters;
  120156. private _blendEquationParameters;
  120157. private _blendConstants;
  120158. /**
  120159. * Initializes the state.
  120160. */
  120161. constructor();
  120162. get isDirty(): boolean;
  120163. get alphaBlend(): boolean;
  120164. set alphaBlend(value: boolean);
  120165. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  120166. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  120167. setAlphaEquationParameters(rgb: number, alpha: number): void;
  120168. reset(): void;
  120169. apply(gl: WebGLRenderingContext): void;
  120170. }
  120171. }
  120172. declare module BABYLON {
  120173. /** @hidden */
  120174. export class WebGLShaderProcessor implements IShaderProcessor {
  120175. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  120176. }
  120177. }
  120178. declare module BABYLON {
  120179. /** @hidden */
  120180. export class WebGL2ShaderProcessor implements IShaderProcessor {
  120181. attributeProcessor(attribute: string): string;
  120182. varyingProcessor(varying: string, isFragment: boolean): string;
  120183. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120184. }
  120185. }
  120186. declare module BABYLON {
  120187. /**
  120188. * Interface for attribute information associated with buffer instanciation
  120189. */
  120190. export interface InstancingAttributeInfo {
  120191. /**
  120192. * Name of the GLSL attribute
  120193. * if attribute index is not specified, this is used to retrieve the index from the effect
  120194. */
  120195. attributeName: string;
  120196. /**
  120197. * Index/offset of the attribute in the vertex shader
  120198. * if not specified, this will be computes from the name.
  120199. */
  120200. index?: number;
  120201. /**
  120202. * size of the attribute, 1, 2, 3 or 4
  120203. */
  120204. attributeSize: number;
  120205. /**
  120206. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  120207. */
  120208. offset: number;
  120209. /**
  120210. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  120211. * default to 1
  120212. */
  120213. divisor?: number;
  120214. /**
  120215. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  120216. * default is FLOAT
  120217. */
  120218. attributeType?: number;
  120219. /**
  120220. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  120221. */
  120222. normalized?: boolean;
  120223. }
  120224. }
  120225. declare module BABYLON {
  120226. interface ThinEngine {
  120227. /**
  120228. * Update a video texture
  120229. * @param texture defines the texture to update
  120230. * @param video defines the video element to use
  120231. * @param invertY defines if data must be stored with Y axis inverted
  120232. */
  120233. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  120234. }
  120235. }
  120236. declare module BABYLON {
  120237. interface ThinEngine {
  120238. /**
  120239. * Creates a dynamic texture
  120240. * @param width defines the width of the texture
  120241. * @param height defines the height of the texture
  120242. * @param generateMipMaps defines if the engine should generate the mip levels
  120243. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  120244. * @returns the dynamic texture inside an InternalTexture
  120245. */
  120246. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  120247. /**
  120248. * Update the content of a dynamic texture
  120249. * @param texture defines the texture to update
  120250. * @param source defines the source containing the data
  120251. * @param invertY defines if data must be stored with Y axis inverted
  120252. * @param premulAlpha defines if alpha is stored as premultiplied
  120253. * @param format defines the format of the data
  120254. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  120255. */
  120256. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  120257. }
  120258. }
  120259. declare module BABYLON {
  120260. /**
  120261. * Settings for finer control over video usage
  120262. */
  120263. export interface VideoTextureSettings {
  120264. /**
  120265. * Applies `autoplay` to video, if specified
  120266. */
  120267. autoPlay?: boolean;
  120268. /**
  120269. * Applies `muted` to video, if specified
  120270. */
  120271. muted?: boolean;
  120272. /**
  120273. * Applies `loop` to video, if specified
  120274. */
  120275. loop?: boolean;
  120276. /**
  120277. * Automatically updates internal texture from video at every frame in the render loop
  120278. */
  120279. autoUpdateTexture: boolean;
  120280. /**
  120281. * Image src displayed during the video loading or until the user interacts with the video.
  120282. */
  120283. poster?: string;
  120284. }
  120285. /**
  120286. * If you want to display a video in your scene, this is the special texture for that.
  120287. * This special texture works similar to other textures, with the exception of a few parameters.
  120288. * @see https://doc.babylonjs.com/how_to/video_texture
  120289. */
  120290. export class VideoTexture extends Texture {
  120291. /**
  120292. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  120293. */
  120294. readonly autoUpdateTexture: boolean;
  120295. /**
  120296. * The video instance used by the texture internally
  120297. */
  120298. readonly video: HTMLVideoElement;
  120299. private _onUserActionRequestedObservable;
  120300. /**
  120301. * Event triggerd when a dom action is required by the user to play the video.
  120302. * This happens due to recent changes in browser policies preventing video to auto start.
  120303. */
  120304. get onUserActionRequestedObservable(): Observable<Texture>;
  120305. private _generateMipMaps;
  120306. private _stillImageCaptured;
  120307. private _displayingPosterTexture;
  120308. private _settings;
  120309. private _createInternalTextureOnEvent;
  120310. private _frameId;
  120311. private _currentSrc;
  120312. /**
  120313. * Creates a video texture.
  120314. * If you want to display a video in your scene, this is the special texture for that.
  120315. * This special texture works similar to other textures, with the exception of a few parameters.
  120316. * @see https://doc.babylonjs.com/how_to/video_texture
  120317. * @param name optional name, will detect from video source, if not defined
  120318. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  120319. * @param scene is obviously the current scene.
  120320. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  120321. * @param invertY is false by default but can be used to invert video on Y axis
  120322. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  120323. * @param settings allows finer control over video usage
  120324. */
  120325. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  120326. private _getName;
  120327. private _getVideo;
  120328. private _createInternalTexture;
  120329. private reset;
  120330. /**
  120331. * @hidden Internal method to initiate `update`.
  120332. */
  120333. _rebuild(): void;
  120334. /**
  120335. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  120336. */
  120337. update(): void;
  120338. /**
  120339. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  120340. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  120341. */
  120342. updateTexture(isVisible: boolean): void;
  120343. protected _updateInternalTexture: () => void;
  120344. /**
  120345. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  120346. * @param url New url.
  120347. */
  120348. updateURL(url: string): void;
  120349. /**
  120350. * Clones the texture.
  120351. * @returns the cloned texture
  120352. */
  120353. clone(): VideoTexture;
  120354. /**
  120355. * Dispose the texture and release its associated resources.
  120356. */
  120357. dispose(): void;
  120358. /**
  120359. * Creates a video texture straight from a stream.
  120360. * @param scene Define the scene the texture should be created in
  120361. * @param stream Define the stream the texture should be created from
  120362. * @returns The created video texture as a promise
  120363. */
  120364. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  120365. /**
  120366. * Creates a video texture straight from your WebCam video feed.
  120367. * @param scene Define the scene the texture should be created in
  120368. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  120369. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  120370. * @returns The created video texture as a promise
  120371. */
  120372. static CreateFromWebCamAsync(scene: Scene, constraints: {
  120373. minWidth: number;
  120374. maxWidth: number;
  120375. minHeight: number;
  120376. maxHeight: number;
  120377. deviceId: string;
  120378. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  120379. /**
  120380. * Creates a video texture straight from your WebCam video feed.
  120381. * @param scene Define the scene the texture should be created in
  120382. * @param onReady Define a callback to triggered once the texture will be ready
  120383. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  120384. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  120385. */
  120386. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  120387. minWidth: number;
  120388. maxWidth: number;
  120389. minHeight: number;
  120390. maxHeight: number;
  120391. deviceId: string;
  120392. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  120393. }
  120394. }
  120395. declare module BABYLON {
  120396. /**
  120397. * Defines the interface used by objects working like Scene
  120398. * @hidden
  120399. */
  120400. export interface ISceneLike {
  120401. _addPendingData(data: any): void;
  120402. _removePendingData(data: any): void;
  120403. offlineProvider: IOfflineProvider;
  120404. }
  120405. /**
  120406. * Information about the current host
  120407. */
  120408. export interface HostInformation {
  120409. /**
  120410. * Defines if the current host is a mobile
  120411. */
  120412. isMobile: boolean;
  120413. }
  120414. /** Interface defining initialization parameters for Engine class */
  120415. export interface EngineOptions extends WebGLContextAttributes {
  120416. /**
  120417. * Defines if the engine should no exceed a specified device ratio
  120418. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  120419. */
  120420. limitDeviceRatio?: number;
  120421. /**
  120422. * Defines if webvr should be enabled automatically
  120423. * @see https://doc.babylonjs.com/how_to/webvr_camera
  120424. */
  120425. autoEnableWebVR?: boolean;
  120426. /**
  120427. * Defines if webgl2 should be turned off even if supported
  120428. * @see https://doc.babylonjs.com/features/webgl2
  120429. */
  120430. disableWebGL2Support?: boolean;
  120431. /**
  120432. * Defines if webaudio should be initialized as well
  120433. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120434. */
  120435. audioEngine?: boolean;
  120436. /**
  120437. * Defines if animations should run using a deterministic lock step
  120438. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120439. */
  120440. deterministicLockstep?: boolean;
  120441. /** Defines the maximum steps to use with deterministic lock step mode */
  120442. lockstepMaxSteps?: number;
  120443. /** Defines the seconds between each deterministic lock step */
  120444. timeStep?: number;
  120445. /**
  120446. * Defines that engine should ignore context lost events
  120447. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  120448. */
  120449. doNotHandleContextLost?: boolean;
  120450. /**
  120451. * Defines that engine should ignore modifying touch action attribute and style
  120452. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  120453. */
  120454. doNotHandleTouchAction?: boolean;
  120455. /**
  120456. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  120457. */
  120458. useHighPrecisionFloats?: boolean;
  120459. /**
  120460. * Make the canvas XR Compatible for XR sessions
  120461. */
  120462. xrCompatible?: boolean;
  120463. /**
  120464. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  120465. */
  120466. useHighPrecisionMatrix?: boolean;
  120467. /**
  120468. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  120469. */
  120470. failIfMajorPerformanceCaveat?: boolean;
  120471. }
  120472. /**
  120473. * The base engine class (root of all engines)
  120474. */
  120475. export class ThinEngine {
  120476. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  120477. static ExceptionList: ({
  120478. key: string;
  120479. capture: string;
  120480. captureConstraint: number;
  120481. targets: string[];
  120482. } | {
  120483. key: string;
  120484. capture: null;
  120485. captureConstraint: null;
  120486. targets: string[];
  120487. })[];
  120488. /** @hidden */
  120489. static _TextureLoaders: IInternalTextureLoader[];
  120490. /**
  120491. * Returns the current npm package of the sdk
  120492. */
  120493. static get NpmPackage(): string;
  120494. /**
  120495. * Returns the current version of the framework
  120496. */
  120497. static get Version(): string;
  120498. /**
  120499. * Returns a string describing the current engine
  120500. */
  120501. get description(): string;
  120502. /**
  120503. * Gets or sets the epsilon value used by collision engine
  120504. */
  120505. static CollisionsEpsilon: number;
  120506. /**
  120507. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  120508. */
  120509. static get ShadersRepository(): string;
  120510. static set ShadersRepository(value: string);
  120511. /** @hidden */
  120512. _shaderProcessor: IShaderProcessor;
  120513. /**
  120514. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  120515. */
  120516. forcePOTTextures: boolean;
  120517. /**
  120518. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  120519. */
  120520. isFullscreen: boolean;
  120521. /**
  120522. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  120523. */
  120524. cullBackFaces: boolean;
  120525. /**
  120526. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  120527. */
  120528. renderEvenInBackground: boolean;
  120529. /**
  120530. * Gets or sets a boolean indicating that cache can be kept between frames
  120531. */
  120532. preventCacheWipeBetweenFrames: boolean;
  120533. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  120534. validateShaderPrograms: boolean;
  120535. /**
  120536. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  120537. * This can provide greater z depth for distant objects.
  120538. */
  120539. useReverseDepthBuffer: boolean;
  120540. /**
  120541. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  120542. */
  120543. disableUniformBuffers: boolean;
  120544. /** @hidden */
  120545. _uniformBuffers: UniformBuffer[];
  120546. /**
  120547. * Gets a boolean indicating that the engine supports uniform buffers
  120548. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  120549. */
  120550. get supportsUniformBuffers(): boolean;
  120551. /** @hidden */
  120552. _gl: WebGLRenderingContext;
  120553. /** @hidden */
  120554. _webGLVersion: number;
  120555. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  120556. protected _windowIsBackground: boolean;
  120557. protected _creationOptions: EngineOptions;
  120558. protected _highPrecisionShadersAllowed: boolean;
  120559. /** @hidden */
  120560. get _shouldUseHighPrecisionShader(): boolean;
  120561. /**
  120562. * Gets a boolean indicating that only power of 2 textures are supported
  120563. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  120564. */
  120565. get needPOTTextures(): boolean;
  120566. /** @hidden */
  120567. _badOS: boolean;
  120568. /** @hidden */
  120569. _badDesktopOS: boolean;
  120570. private _hardwareScalingLevel;
  120571. /** @hidden */
  120572. _caps: EngineCapabilities;
  120573. private _isStencilEnable;
  120574. private _glVersion;
  120575. private _glRenderer;
  120576. private _glVendor;
  120577. /** @hidden */
  120578. _videoTextureSupported: boolean;
  120579. protected _renderingQueueLaunched: boolean;
  120580. protected _activeRenderLoops: (() => void)[];
  120581. /**
  120582. * Observable signaled when a context lost event is raised
  120583. */
  120584. onContextLostObservable: Observable<ThinEngine>;
  120585. /**
  120586. * Observable signaled when a context restored event is raised
  120587. */
  120588. onContextRestoredObservable: Observable<ThinEngine>;
  120589. private _onContextLost;
  120590. private _onContextRestored;
  120591. protected _contextWasLost: boolean;
  120592. /** @hidden */
  120593. _doNotHandleContextLost: boolean;
  120594. /**
  120595. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  120596. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  120597. */
  120598. get doNotHandleContextLost(): boolean;
  120599. set doNotHandleContextLost(value: boolean);
  120600. /**
  120601. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  120602. */
  120603. disableVertexArrayObjects: boolean;
  120604. /** @hidden */
  120605. protected _colorWrite: boolean;
  120606. /** @hidden */
  120607. protected _colorWriteChanged: boolean;
  120608. /** @hidden */
  120609. protected _depthCullingState: DepthCullingState;
  120610. /** @hidden */
  120611. protected _stencilState: StencilState;
  120612. /** @hidden */
  120613. _alphaState: AlphaState;
  120614. /** @hidden */
  120615. _alphaMode: number;
  120616. /** @hidden */
  120617. _alphaEquation: number;
  120618. /** @hidden */
  120619. _internalTexturesCache: InternalTexture[];
  120620. /** @hidden */
  120621. protected _activeChannel: number;
  120622. private _currentTextureChannel;
  120623. /** @hidden */
  120624. protected _boundTexturesCache: {
  120625. [key: string]: Nullable<InternalTexture>;
  120626. };
  120627. /** @hidden */
  120628. protected _currentEffect: Nullable<Effect>;
  120629. /** @hidden */
  120630. protected _currentProgram: Nullable<WebGLProgram>;
  120631. private _compiledEffects;
  120632. private _vertexAttribArraysEnabled;
  120633. /** @hidden */
  120634. protected _cachedViewport: Nullable<IViewportLike>;
  120635. private _cachedVertexArrayObject;
  120636. /** @hidden */
  120637. protected _cachedVertexBuffers: any;
  120638. /** @hidden */
  120639. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  120640. /** @hidden */
  120641. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  120642. /** @hidden */
  120643. _currentRenderTarget: Nullable<InternalTexture>;
  120644. private _uintIndicesCurrentlySet;
  120645. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  120646. /** @hidden */
  120647. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  120648. /** @hidden */
  120649. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  120650. private _currentBufferPointers;
  120651. private _currentInstanceLocations;
  120652. private _currentInstanceBuffers;
  120653. private _textureUnits;
  120654. /** @hidden */
  120655. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  120656. /** @hidden */
  120657. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  120658. /** @hidden */
  120659. _boundRenderFunction: any;
  120660. private _vaoRecordInProgress;
  120661. private _mustWipeVertexAttributes;
  120662. private _emptyTexture;
  120663. private _emptyCubeTexture;
  120664. private _emptyTexture3D;
  120665. private _emptyTexture2DArray;
  120666. /** @hidden */
  120667. _frameHandler: number;
  120668. private _nextFreeTextureSlots;
  120669. private _maxSimultaneousTextures;
  120670. private _activeRequests;
  120671. /** @hidden */
  120672. _transformTextureUrl: Nullable<(url: string) => string>;
  120673. /**
  120674. * Gets information about the current host
  120675. */
  120676. hostInformation: HostInformation;
  120677. protected get _supportsHardwareTextureRescaling(): boolean;
  120678. private _framebufferDimensionsObject;
  120679. /**
  120680. * sets the object from which width and height will be taken from when getting render width and height
  120681. * Will fallback to the gl object
  120682. * @param dimensions the framebuffer width and height that will be used.
  120683. */
  120684. set framebufferDimensionsObject(dimensions: Nullable<{
  120685. framebufferWidth: number;
  120686. framebufferHeight: number;
  120687. }>);
  120688. /**
  120689. * Gets the current viewport
  120690. */
  120691. get currentViewport(): Nullable<IViewportLike>;
  120692. /**
  120693. * Gets the default empty texture
  120694. */
  120695. get emptyTexture(): InternalTexture;
  120696. /**
  120697. * Gets the default empty 3D texture
  120698. */
  120699. get emptyTexture3D(): InternalTexture;
  120700. /**
  120701. * Gets the default empty 2D array texture
  120702. */
  120703. get emptyTexture2DArray(): InternalTexture;
  120704. /**
  120705. * Gets the default empty cube texture
  120706. */
  120707. get emptyCubeTexture(): InternalTexture;
  120708. /**
  120709. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  120710. */
  120711. readonly premultipliedAlpha: boolean;
  120712. /**
  120713. * Observable event triggered before each texture is initialized
  120714. */
  120715. onBeforeTextureInitObservable: Observable<Texture>;
  120716. /**
  120717. * Creates a new engine
  120718. * @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
  120719. * @param antialias defines enable antialiasing (default: false)
  120720. * @param options defines further options to be sent to the getContext() function
  120721. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  120722. */
  120723. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  120724. private _rebuildInternalTextures;
  120725. private _rebuildEffects;
  120726. /**
  120727. * Gets a boolean indicating if all created effects are ready
  120728. * @returns true if all effects are ready
  120729. */
  120730. areAllEffectsReady(): boolean;
  120731. protected _rebuildBuffers(): void;
  120732. protected _initGLContext(): void;
  120733. /**
  120734. * Gets version of the current webGL context
  120735. */
  120736. get webGLVersion(): number;
  120737. /**
  120738. * Gets a string identifying the name of the class
  120739. * @returns "Engine" string
  120740. */
  120741. getClassName(): string;
  120742. /**
  120743. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  120744. */
  120745. get isStencilEnable(): boolean;
  120746. /** @hidden */
  120747. _prepareWorkingCanvas(): void;
  120748. /**
  120749. * Reset the texture cache to empty state
  120750. */
  120751. resetTextureCache(): void;
  120752. /**
  120753. * Gets an object containing information about the current webGL context
  120754. * @returns an object containing the vender, the renderer and the version of the current webGL context
  120755. */
  120756. getGlInfo(): {
  120757. vendor: string;
  120758. renderer: string;
  120759. version: string;
  120760. };
  120761. /**
  120762. * Defines the hardware scaling level.
  120763. * By default the hardware scaling level is computed from the window device ratio.
  120764. * 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.
  120765. * @param level defines the level to use
  120766. */
  120767. setHardwareScalingLevel(level: number): void;
  120768. /**
  120769. * Gets the current hardware scaling level.
  120770. * By default the hardware scaling level is computed from the window device ratio.
  120771. * 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.
  120772. * @returns a number indicating the current hardware scaling level
  120773. */
  120774. getHardwareScalingLevel(): number;
  120775. /**
  120776. * Gets the list of loaded textures
  120777. * @returns an array containing all loaded textures
  120778. */
  120779. getLoadedTexturesCache(): InternalTexture[];
  120780. /**
  120781. * Gets the object containing all engine capabilities
  120782. * @returns the EngineCapabilities object
  120783. */
  120784. getCaps(): EngineCapabilities;
  120785. /**
  120786. * stop executing a render loop function and remove it from the execution array
  120787. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  120788. */
  120789. stopRenderLoop(renderFunction?: () => void): void;
  120790. /** @hidden */
  120791. _renderLoop(): void;
  120792. /**
  120793. * Gets the HTML canvas attached with the current webGL context
  120794. * @returns a HTML canvas
  120795. */
  120796. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  120797. /**
  120798. * Gets host window
  120799. * @returns the host window object
  120800. */
  120801. getHostWindow(): Nullable<Window>;
  120802. /**
  120803. * Gets the current render width
  120804. * @param useScreen defines if screen size must be used (or the current render target if any)
  120805. * @returns a number defining the current render width
  120806. */
  120807. getRenderWidth(useScreen?: boolean): number;
  120808. /**
  120809. * Gets the current render height
  120810. * @param useScreen defines if screen size must be used (or the current render target if any)
  120811. * @returns a number defining the current render height
  120812. */
  120813. getRenderHeight(useScreen?: boolean): number;
  120814. /**
  120815. * Can be used to override the current requestAnimationFrame requester.
  120816. * @hidden
  120817. */
  120818. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120819. /**
  120820. * Register and execute a render loop. The engine can have more than one render function
  120821. * @param renderFunction defines the function to continuously execute
  120822. */
  120823. runRenderLoop(renderFunction: () => void): void;
  120824. /**
  120825. * Clear the current render buffer or the current render target (if any is set up)
  120826. * @param color defines the color to use
  120827. * @param backBuffer defines if the back buffer must be cleared
  120828. * @param depth defines if the depth buffer must be cleared
  120829. * @param stencil defines if the stencil buffer must be cleared
  120830. */
  120831. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120832. private _viewportCached;
  120833. /** @hidden */
  120834. _viewport(x: number, y: number, width: number, height: number): void;
  120835. /**
  120836. * Set the WebGL's viewport
  120837. * @param viewport defines the viewport element to be used
  120838. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  120839. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  120840. */
  120841. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  120842. /**
  120843. * Begin a new frame
  120844. */
  120845. beginFrame(): void;
  120846. /**
  120847. * Enf the current frame
  120848. */
  120849. endFrame(): void;
  120850. /**
  120851. * Resize the view according to the canvas' size
  120852. */
  120853. resize(): void;
  120854. /**
  120855. * Force a specific size of the canvas
  120856. * @param width defines the new canvas' width
  120857. * @param height defines the new canvas' height
  120858. * @returns true if the size was changed
  120859. */
  120860. setSize(width: number, height: number): boolean;
  120861. /**
  120862. * Binds the frame buffer to the specified texture.
  120863. * @param texture The texture to render to or null for the default canvas
  120864. * @param faceIndex The face of the texture to render to in case of cube texture
  120865. * @param requiredWidth The width of the target to render to
  120866. * @param requiredHeight The height of the target to render to
  120867. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  120868. * @param lodLevel defines the lod level to bind to the frame buffer
  120869. * @param layer defines the 2d array index to bind to frame buffer to
  120870. */
  120871. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  120872. /** @hidden */
  120873. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120874. /**
  120875. * Unbind the current render target texture from the webGL context
  120876. * @param texture defines the render target texture to unbind
  120877. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120878. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120879. */
  120880. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120881. /**
  120882. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  120883. */
  120884. flushFramebuffer(): void;
  120885. /**
  120886. * Unbind the current render target and bind the default framebuffer
  120887. */
  120888. restoreDefaultFramebuffer(): void;
  120889. /** @hidden */
  120890. protected _resetVertexBufferBinding(): void;
  120891. /**
  120892. * Creates a vertex buffer
  120893. * @param data the data for the vertex buffer
  120894. * @returns the new WebGL static buffer
  120895. */
  120896. createVertexBuffer(data: DataArray): DataBuffer;
  120897. private _createVertexBuffer;
  120898. /**
  120899. * Creates a dynamic vertex buffer
  120900. * @param data the data for the dynamic vertex buffer
  120901. * @returns the new WebGL dynamic buffer
  120902. */
  120903. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  120904. protected _resetIndexBufferBinding(): void;
  120905. /**
  120906. * Creates a new index buffer
  120907. * @param indices defines the content of the index buffer
  120908. * @param updatable defines if the index buffer must be updatable
  120909. * @returns a new webGL buffer
  120910. */
  120911. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  120912. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  120913. /**
  120914. * Bind a webGL buffer to the webGL context
  120915. * @param buffer defines the buffer to bind
  120916. */
  120917. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  120918. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  120919. private bindBuffer;
  120920. /**
  120921. * update the bound buffer with the given data
  120922. * @param data defines the data to update
  120923. */
  120924. updateArrayBuffer(data: Float32Array): void;
  120925. private _vertexAttribPointer;
  120926. /** @hidden */
  120927. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  120928. private _bindVertexBuffersAttributes;
  120929. /**
  120930. * Records a vertex array object
  120931. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  120932. * @param vertexBuffers defines the list of vertex buffers to store
  120933. * @param indexBuffer defines the index buffer to store
  120934. * @param effect defines the effect to store
  120935. * @returns the new vertex array object
  120936. */
  120937. recordVertexArrayObject(vertexBuffers: {
  120938. [key: string]: VertexBuffer;
  120939. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120940. /**
  120941. * Bind a specific vertex array object
  120942. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  120943. * @param vertexArrayObject defines the vertex array object to bind
  120944. * @param indexBuffer defines the index buffer to bind
  120945. */
  120946. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  120947. /**
  120948. * Bind webGl buffers directly to the webGL context
  120949. * @param vertexBuffer defines the vertex buffer to bind
  120950. * @param indexBuffer defines the index buffer to bind
  120951. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  120952. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  120953. * @param effect defines the effect associated with the vertex buffer
  120954. */
  120955. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  120956. private _unbindVertexArrayObject;
  120957. /**
  120958. * Bind a list of vertex buffers to the webGL context
  120959. * @param vertexBuffers defines the list of vertex buffers to bind
  120960. * @param indexBuffer defines the index buffer to bind
  120961. * @param effect defines the effect associated with the vertex buffers
  120962. */
  120963. bindBuffers(vertexBuffers: {
  120964. [key: string]: Nullable<VertexBuffer>;
  120965. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  120966. /**
  120967. * Unbind all instance attributes
  120968. */
  120969. unbindInstanceAttributes(): void;
  120970. /**
  120971. * Release and free the memory of a vertex array object
  120972. * @param vao defines the vertex array object to delete
  120973. */
  120974. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  120975. /** @hidden */
  120976. _releaseBuffer(buffer: DataBuffer): boolean;
  120977. protected _deleteBuffer(buffer: DataBuffer): void;
  120978. /**
  120979. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  120980. * @param instancesBuffer defines the webGL buffer to update and bind
  120981. * @param data defines the data to store in the buffer
  120982. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  120983. */
  120984. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  120985. /**
  120986. * Bind the content of a webGL buffer used with instantiation
  120987. * @param instancesBuffer defines the webGL buffer to bind
  120988. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  120989. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  120990. */
  120991. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  120992. /**
  120993. * Disable the instance attribute corresponding to the name in parameter
  120994. * @param name defines the name of the attribute to disable
  120995. */
  120996. disableInstanceAttributeByName(name: string): void;
  120997. /**
  120998. * Disable the instance attribute corresponding to the location in parameter
  120999. * @param attributeLocation defines the attribute location of the attribute to disable
  121000. */
  121001. disableInstanceAttribute(attributeLocation: number): void;
  121002. /**
  121003. * Disable the attribute corresponding to the location in parameter
  121004. * @param attributeLocation defines the attribute location of the attribute to disable
  121005. */
  121006. disableAttributeByIndex(attributeLocation: number): void;
  121007. /**
  121008. * Send a draw order
  121009. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  121010. * @param indexStart defines the starting index
  121011. * @param indexCount defines the number of index to draw
  121012. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121013. */
  121014. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  121015. /**
  121016. * Draw a list of points
  121017. * @param verticesStart defines the index of first vertex to draw
  121018. * @param verticesCount defines the count of vertices to draw
  121019. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121020. */
  121021. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121022. /**
  121023. * Draw a list of unindexed primitives
  121024. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  121025. * @param verticesStart defines the index of first vertex to draw
  121026. * @param verticesCount defines the count of vertices to draw
  121027. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121028. */
  121029. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121030. /**
  121031. * Draw a list of indexed primitives
  121032. * @param fillMode defines the primitive to use
  121033. * @param indexStart defines the starting index
  121034. * @param indexCount defines the number of index to draw
  121035. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121036. */
  121037. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  121038. /**
  121039. * Draw a list of unindexed primitives
  121040. * @param fillMode defines the primitive to use
  121041. * @param verticesStart defines the index of first vertex to draw
  121042. * @param verticesCount defines the count of vertices to draw
  121043. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121044. */
  121045. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121046. private _drawMode;
  121047. /** @hidden */
  121048. protected _reportDrawCall(): void;
  121049. /** @hidden */
  121050. _releaseEffect(effect: Effect): void;
  121051. /** @hidden */
  121052. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  121053. /**
  121054. * Create a new effect (used to store vertex/fragment shaders)
  121055. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  121056. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  121057. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  121058. * @param samplers defines an array of string used to represent textures
  121059. * @param defines defines the string containing the defines to use to compile the shaders
  121060. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  121061. * @param onCompiled defines a function to call when the effect creation is successful
  121062. * @param onError defines a function to call when the effect creation has failed
  121063. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  121064. * @returns the new Effect
  121065. */
  121066. 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;
  121067. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  121068. private _compileShader;
  121069. private _compileRawShader;
  121070. /** @hidden */
  121071. _getShaderSource(shader: WebGLShader): Nullable<string>;
  121072. /**
  121073. * Directly creates a webGL program
  121074. * @param pipelineContext defines the pipeline context to attach to
  121075. * @param vertexCode defines the vertex shader code to use
  121076. * @param fragmentCode defines the fragment shader code to use
  121077. * @param context defines the webGL context to use (if not set, the current one will be used)
  121078. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  121079. * @returns the new webGL program
  121080. */
  121081. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121082. /**
  121083. * Creates a webGL program
  121084. * @param pipelineContext defines the pipeline context to attach to
  121085. * @param vertexCode defines the vertex shader code to use
  121086. * @param fragmentCode defines the fragment shader code to use
  121087. * @param defines defines the string containing the defines to use to compile the shaders
  121088. * @param context defines the webGL context to use (if not set, the current one will be used)
  121089. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  121090. * @returns the new webGL program
  121091. */
  121092. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121093. /**
  121094. * Creates a new pipeline context
  121095. * @returns the new pipeline
  121096. */
  121097. createPipelineContext(): IPipelineContext;
  121098. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121099. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  121100. /** @hidden */
  121101. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  121102. /** @hidden */
  121103. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  121104. /** @hidden */
  121105. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  121106. /**
  121107. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  121108. * @param pipelineContext defines the pipeline context to use
  121109. * @param uniformsNames defines the list of uniform names
  121110. * @returns an array of webGL uniform locations
  121111. */
  121112. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  121113. /**
  121114. * Gets the lsit of active attributes for a given webGL program
  121115. * @param pipelineContext defines the pipeline context to use
  121116. * @param attributesNames defines the list of attribute names to get
  121117. * @returns an array of indices indicating the offset of each attribute
  121118. */
  121119. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  121120. /**
  121121. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  121122. * @param effect defines the effect to activate
  121123. */
  121124. enableEffect(effect: Nullable<Effect>): void;
  121125. /**
  121126. * Set the value of an uniform to a number (int)
  121127. * @param uniform defines the webGL uniform location where to store the value
  121128. * @param value defines the int number to store
  121129. * @returns true if the value was set
  121130. */
  121131. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  121132. /**
  121133. * Set the value of an uniform to an array of int32
  121134. * @param uniform defines the webGL uniform location where to store the value
  121135. * @param array defines the array of int32 to store
  121136. * @returns true if the value was set
  121137. */
  121138. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121139. /**
  121140. * Set the value of an uniform to an array of int32 (stored as vec2)
  121141. * @param uniform defines the webGL uniform location where to store the value
  121142. * @param array defines the array of int32 to store
  121143. * @returns true if the value was set
  121144. */
  121145. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121146. /**
  121147. * Set the value of an uniform to an array of int32 (stored as vec3)
  121148. * @param uniform defines the webGL uniform location where to store the value
  121149. * @param array defines the array of int32 to store
  121150. * @returns true if the value was set
  121151. */
  121152. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121153. /**
  121154. * Set the value of an uniform to an array of int32 (stored as vec4)
  121155. * @param uniform defines the webGL uniform location where to store the value
  121156. * @param array defines the array of int32 to store
  121157. * @returns true if the value was set
  121158. */
  121159. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121160. /**
  121161. * Set the value of an uniform to an array of number
  121162. * @param uniform defines the webGL uniform location where to store the value
  121163. * @param array defines the array of number to store
  121164. * @returns true if the value was set
  121165. */
  121166. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121167. /**
  121168. * Set the value of an uniform to an array of number (stored as vec2)
  121169. * @param uniform defines the webGL uniform location where to store the value
  121170. * @param array defines the array of number to store
  121171. * @returns true if the value was set
  121172. */
  121173. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121174. /**
  121175. * Set the value of an uniform to an array of number (stored as vec3)
  121176. * @param uniform defines the webGL uniform location where to store the value
  121177. * @param array defines the array of number to store
  121178. * @returns true if the value was set
  121179. */
  121180. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121181. /**
  121182. * Set the value of an uniform to an array of number (stored as vec4)
  121183. * @param uniform defines the webGL uniform location where to store the value
  121184. * @param array defines the array of number to store
  121185. * @returns true if the value was set
  121186. */
  121187. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121188. /**
  121189. * Set the value of an uniform to an array of float32 (stored as matrices)
  121190. * @param uniform defines the webGL uniform location where to store the value
  121191. * @param matrices defines the array of float32 to store
  121192. * @returns true if the value was set
  121193. */
  121194. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  121195. /**
  121196. * Set the value of an uniform to a matrix (3x3)
  121197. * @param uniform defines the webGL uniform location where to store the value
  121198. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  121199. * @returns true if the value was set
  121200. */
  121201. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  121202. /**
  121203. * Set the value of an uniform to a matrix (2x2)
  121204. * @param uniform defines the webGL uniform location where to store the value
  121205. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  121206. * @returns true if the value was set
  121207. */
  121208. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  121209. /**
  121210. * Set the value of an uniform to a number (float)
  121211. * @param uniform defines the webGL uniform location where to store the value
  121212. * @param value defines the float number to store
  121213. * @returns true if the value was transfered
  121214. */
  121215. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  121216. /**
  121217. * Set the value of an uniform to a vec2
  121218. * @param uniform defines the webGL uniform location where to store the value
  121219. * @param x defines the 1st component of the value
  121220. * @param y defines the 2nd component of the value
  121221. * @returns true if the value was set
  121222. */
  121223. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  121224. /**
  121225. * Set the value of an uniform to a vec3
  121226. * @param uniform defines the webGL uniform location where to store the value
  121227. * @param x defines the 1st component of the value
  121228. * @param y defines the 2nd component of the value
  121229. * @param z defines the 3rd component of the value
  121230. * @returns true if the value was set
  121231. */
  121232. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  121233. /**
  121234. * Set the value of an uniform to a vec4
  121235. * @param uniform defines the webGL uniform location where to store the value
  121236. * @param x defines the 1st component of the value
  121237. * @param y defines the 2nd component of the value
  121238. * @param z defines the 3rd component of the value
  121239. * @param w defines the 4th component of the value
  121240. * @returns true if the value was set
  121241. */
  121242. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  121243. /**
  121244. * Apply all cached states (depth, culling, stencil and alpha)
  121245. */
  121246. applyStates(): void;
  121247. /**
  121248. * Enable or disable color writing
  121249. * @param enable defines the state to set
  121250. */
  121251. setColorWrite(enable: boolean): void;
  121252. /**
  121253. * Gets a boolean indicating if color writing is enabled
  121254. * @returns the current color writing state
  121255. */
  121256. getColorWrite(): boolean;
  121257. /**
  121258. * Gets the depth culling state manager
  121259. */
  121260. get depthCullingState(): DepthCullingState;
  121261. /**
  121262. * Gets the alpha state manager
  121263. */
  121264. get alphaState(): AlphaState;
  121265. /**
  121266. * Gets the stencil state manager
  121267. */
  121268. get stencilState(): StencilState;
  121269. /**
  121270. * Clears the list of texture accessible through engine.
  121271. * This can help preventing texture load conflict due to name collision.
  121272. */
  121273. clearInternalTexturesCache(): void;
  121274. /**
  121275. * Force the entire cache to be cleared
  121276. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  121277. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  121278. */
  121279. wipeCaches(bruteForce?: boolean): void;
  121280. /** @hidden */
  121281. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  121282. min: number;
  121283. mag: number;
  121284. };
  121285. /** @hidden */
  121286. _createTexture(): WebGLTexture;
  121287. /**
  121288. * Usually called from Texture.ts.
  121289. * Passed information to create a WebGLTexture
  121290. * @param url defines a value which contains one of the following:
  121291. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121292. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121293. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121294. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121295. * @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)
  121296. * @param scene needed for loading to the correct scene
  121297. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  121298. * @param onLoad optional callback to be called upon successful completion
  121299. * @param onError optional callback to be called upon failure
  121300. * @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
  121301. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121302. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121303. * @param forcedExtension defines the extension to use to pick the right loader
  121304. * @param mimeType defines an optional mime type
  121305. * @param loaderOptions options to be passed to the loader
  121306. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121307. */
  121308. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  121309. /**
  121310. * Loads an image as an HTMLImageElement.
  121311. * @param input url string, ArrayBuffer, or Blob to load
  121312. * @param onLoad callback called when the image successfully loads
  121313. * @param onError callback called when the image fails to load
  121314. * @param offlineProvider offline provider for caching
  121315. * @param mimeType optional mime type
  121316. * @returns the HTMLImageElement of the loaded image
  121317. * @hidden
  121318. */
  121319. 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>;
  121320. /**
  121321. * @hidden
  121322. */
  121323. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  121324. private _unpackFlipYCached;
  121325. /**
  121326. * In case you are sharing the context with other applications, it might
  121327. * be interested to not cache the unpack flip y state to ensure a consistent
  121328. * value would be set.
  121329. */
  121330. enableUnpackFlipYCached: boolean;
  121331. /** @hidden */
  121332. _unpackFlipY(value: boolean): void;
  121333. /** @hidden */
  121334. _getUnpackAlignement(): number;
  121335. private _getTextureTarget;
  121336. /**
  121337. * Update the sampling mode of a given texture
  121338. * @param samplingMode defines the required sampling mode
  121339. * @param texture defines the texture to update
  121340. * @param generateMipMaps defines whether to generate mipmaps for the texture
  121341. */
  121342. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  121343. /**
  121344. * Update the sampling mode of a given texture
  121345. * @param texture defines the texture to update
  121346. * @param wrapU defines the texture wrap mode of the u coordinates
  121347. * @param wrapV defines the texture wrap mode of the v coordinates
  121348. * @param wrapR defines the texture wrap mode of the r coordinates
  121349. */
  121350. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  121351. /** @hidden */
  121352. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  121353. width: number;
  121354. height: number;
  121355. layers?: number;
  121356. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  121357. /** @hidden */
  121358. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121359. /** @hidden */
  121360. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  121361. /**
  121362. * Update a portion of an internal texture
  121363. * @param texture defines the texture to update
  121364. * @param imageData defines the data to store into the texture
  121365. * @param xOffset defines the x coordinates of the update rectangle
  121366. * @param yOffset defines the y coordinates of the update rectangle
  121367. * @param width defines the width of the update rectangle
  121368. * @param height defines the height of the update rectangle
  121369. * @param faceIndex defines the face index if texture is a cube (0 by default)
  121370. * @param lod defines the lod level to update (0 by default)
  121371. */
  121372. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  121373. /** @hidden */
  121374. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121375. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  121376. private _prepareWebGLTexture;
  121377. /** @hidden */
  121378. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  121379. private _getDepthStencilBuffer;
  121380. /** @hidden */
  121381. _releaseFramebufferObjects(texture: InternalTexture): void;
  121382. /** @hidden */
  121383. _releaseTexture(texture: InternalTexture): void;
  121384. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  121385. protected _setProgram(program: WebGLProgram): void;
  121386. protected _boundUniforms: {
  121387. [key: number]: WebGLUniformLocation;
  121388. };
  121389. /**
  121390. * Binds an effect to the webGL context
  121391. * @param effect defines the effect to bind
  121392. */
  121393. bindSamplers(effect: Effect): void;
  121394. private _activateCurrentTexture;
  121395. /** @hidden */
  121396. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  121397. /** @hidden */
  121398. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  121399. /**
  121400. * Unbind all textures from the webGL context
  121401. */
  121402. unbindAllTextures(): void;
  121403. /**
  121404. * Sets a texture to the according uniform.
  121405. * @param channel The texture channel
  121406. * @param uniform The uniform to set
  121407. * @param texture The texture to apply
  121408. */
  121409. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>): void;
  121410. private _bindSamplerUniformToChannel;
  121411. private _getTextureWrapMode;
  121412. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  121413. /**
  121414. * Sets an array of texture to the webGL context
  121415. * @param channel defines the channel where the texture array must be set
  121416. * @param uniform defines the associated uniform location
  121417. * @param textures defines the array of textures to bind
  121418. */
  121419. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[]): void;
  121420. /** @hidden */
  121421. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  121422. private _setTextureParameterFloat;
  121423. private _setTextureParameterInteger;
  121424. /**
  121425. * Unbind all vertex attributes from the webGL context
  121426. */
  121427. unbindAllAttributes(): void;
  121428. /**
  121429. * 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
  121430. */
  121431. releaseEffects(): void;
  121432. /**
  121433. * Dispose and release all associated resources
  121434. */
  121435. dispose(): void;
  121436. /**
  121437. * Attach a new callback raised when context lost event is fired
  121438. * @param callback defines the callback to call
  121439. */
  121440. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  121441. /**
  121442. * Attach a new callback raised when context restored event is fired
  121443. * @param callback defines the callback to call
  121444. */
  121445. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  121446. /**
  121447. * Get the current error code of the webGL context
  121448. * @returns the error code
  121449. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  121450. */
  121451. getError(): number;
  121452. private _canRenderToFloatFramebuffer;
  121453. private _canRenderToHalfFloatFramebuffer;
  121454. private _canRenderToFramebuffer;
  121455. /** @hidden */
  121456. _getWebGLTextureType(type: number): number;
  121457. /** @hidden */
  121458. _getInternalFormat(format: number): number;
  121459. /** @hidden */
  121460. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  121461. /** @hidden */
  121462. _getRGBAMultiSampleBufferFormat(type: number): number;
  121463. /** @hidden */
  121464. _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;
  121465. /**
  121466. * Loads a file from a url
  121467. * @param url url to load
  121468. * @param onSuccess callback called when the file successfully loads
  121469. * @param onProgress callback called while file is loading (if the server supports this mode)
  121470. * @param offlineProvider defines the offline provider for caching
  121471. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  121472. * @param onError callback called when the file fails to load
  121473. * @returns a file request object
  121474. * @hidden
  121475. */
  121476. 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;
  121477. /**
  121478. * Reads pixels from the current frame buffer. Please note that this function can be slow
  121479. * @param x defines the x coordinate of the rectangle where pixels must be read
  121480. * @param y defines the y coordinate of the rectangle where pixels must be read
  121481. * @param width defines the width of the rectangle where pixels must be read
  121482. * @param height defines the height of the rectangle where pixels must be read
  121483. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  121484. * @returns a Uint8Array containing RGBA colors
  121485. */
  121486. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  121487. private static _IsSupported;
  121488. private static _HasMajorPerformanceCaveat;
  121489. /**
  121490. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  121491. */
  121492. static get IsSupported(): boolean;
  121493. /**
  121494. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  121495. * @returns true if the engine can be created
  121496. * @ignorenaming
  121497. */
  121498. static isSupported(): boolean;
  121499. /**
  121500. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  121501. */
  121502. static get HasMajorPerformanceCaveat(): boolean;
  121503. /**
  121504. * Find the next highest power of two.
  121505. * @param x Number to start search from.
  121506. * @return Next highest power of two.
  121507. */
  121508. static CeilingPOT(x: number): number;
  121509. /**
  121510. * Find the next lowest power of two.
  121511. * @param x Number to start search from.
  121512. * @return Next lowest power of two.
  121513. */
  121514. static FloorPOT(x: number): number;
  121515. /**
  121516. * Find the nearest power of two.
  121517. * @param x Number to start search from.
  121518. * @return Next nearest power of two.
  121519. */
  121520. static NearestPOT(x: number): number;
  121521. /**
  121522. * Get the closest exponent of two
  121523. * @param value defines the value to approximate
  121524. * @param max defines the maximum value to return
  121525. * @param mode defines how to define the closest value
  121526. * @returns closest exponent of two of the given value
  121527. */
  121528. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  121529. /**
  121530. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  121531. * @param func - the function to be called
  121532. * @param requester - the object that will request the next frame. Falls back to window.
  121533. * @returns frame number
  121534. */
  121535. static QueueNewFrame(func: () => void, requester?: any): number;
  121536. /**
  121537. * Gets host document
  121538. * @returns the host document object
  121539. */
  121540. getHostDocument(): Nullable<Document>;
  121541. }
  121542. }
  121543. declare module BABYLON {
  121544. /**
  121545. * Defines the source of the internal texture
  121546. */
  121547. export enum InternalTextureSource {
  121548. /**
  121549. * The source of the texture data is unknown
  121550. */
  121551. Unknown = 0,
  121552. /**
  121553. * Texture data comes from an URL
  121554. */
  121555. Url = 1,
  121556. /**
  121557. * Texture data is only used for temporary storage
  121558. */
  121559. Temp = 2,
  121560. /**
  121561. * Texture data comes from raw data (ArrayBuffer)
  121562. */
  121563. Raw = 3,
  121564. /**
  121565. * Texture content is dynamic (video or dynamic texture)
  121566. */
  121567. Dynamic = 4,
  121568. /**
  121569. * Texture content is generated by rendering to it
  121570. */
  121571. RenderTarget = 5,
  121572. /**
  121573. * Texture content is part of a multi render target process
  121574. */
  121575. MultiRenderTarget = 6,
  121576. /**
  121577. * Texture data comes from a cube data file
  121578. */
  121579. Cube = 7,
  121580. /**
  121581. * Texture data comes from a raw cube data
  121582. */
  121583. CubeRaw = 8,
  121584. /**
  121585. * Texture data come from a prefiltered cube data file
  121586. */
  121587. CubePrefiltered = 9,
  121588. /**
  121589. * Texture content is raw 3D data
  121590. */
  121591. Raw3D = 10,
  121592. /**
  121593. * Texture content is raw 2D array data
  121594. */
  121595. Raw2DArray = 11,
  121596. /**
  121597. * Texture content is a depth texture
  121598. */
  121599. Depth = 12,
  121600. /**
  121601. * Texture data comes from a raw cube data encoded with RGBD
  121602. */
  121603. CubeRawRGBD = 13
  121604. }
  121605. /**
  121606. * Class used to store data associated with WebGL texture data for the engine
  121607. * This class should not be used directly
  121608. */
  121609. export class InternalTexture {
  121610. /** @hidden */
  121611. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  121612. /**
  121613. * Defines if the texture is ready
  121614. */
  121615. isReady: boolean;
  121616. /**
  121617. * Defines if the texture is a cube texture
  121618. */
  121619. isCube: boolean;
  121620. /**
  121621. * Defines if the texture contains 3D data
  121622. */
  121623. is3D: boolean;
  121624. /**
  121625. * Defines if the texture contains 2D array data
  121626. */
  121627. is2DArray: boolean;
  121628. /**
  121629. * Defines if the texture contains multiview data
  121630. */
  121631. isMultiview: boolean;
  121632. /**
  121633. * Gets the URL used to load this texture
  121634. */
  121635. url: string;
  121636. /** @hidden */
  121637. _originalUrl: string;
  121638. /**
  121639. * Gets the sampling mode of the texture
  121640. */
  121641. samplingMode: number;
  121642. /**
  121643. * Gets a boolean indicating if the texture needs mipmaps generation
  121644. */
  121645. generateMipMaps: boolean;
  121646. /**
  121647. * Gets the number of samples used by the texture (WebGL2+ only)
  121648. */
  121649. samples: number;
  121650. /**
  121651. * Gets the type of the texture (int, float...)
  121652. */
  121653. type: number;
  121654. /**
  121655. * Gets the format of the texture (RGB, RGBA...)
  121656. */
  121657. format: number;
  121658. /**
  121659. * Observable called when the texture is loaded
  121660. */
  121661. onLoadedObservable: Observable<InternalTexture>;
  121662. /**
  121663. * Gets the width of the texture
  121664. */
  121665. width: number;
  121666. /**
  121667. * Gets the height of the texture
  121668. */
  121669. height: number;
  121670. /**
  121671. * Gets the depth of the texture
  121672. */
  121673. depth: number;
  121674. /**
  121675. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  121676. */
  121677. baseWidth: number;
  121678. /**
  121679. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  121680. */
  121681. baseHeight: number;
  121682. /**
  121683. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  121684. */
  121685. baseDepth: number;
  121686. /**
  121687. * Gets a boolean indicating if the texture is inverted on Y axis
  121688. */
  121689. invertY: boolean;
  121690. /** @hidden */
  121691. _invertVScale: boolean;
  121692. /** @hidden */
  121693. _associatedChannel: number;
  121694. /** @hidden */
  121695. _source: InternalTextureSource;
  121696. /** @hidden */
  121697. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  121698. /** @hidden */
  121699. _bufferView: Nullable<ArrayBufferView>;
  121700. /** @hidden */
  121701. _bufferViewArray: Nullable<ArrayBufferView[]>;
  121702. /** @hidden */
  121703. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  121704. /** @hidden */
  121705. _size: number;
  121706. /** @hidden */
  121707. _extension: string;
  121708. /** @hidden */
  121709. _files: Nullable<string[]>;
  121710. /** @hidden */
  121711. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  121712. /** @hidden */
  121713. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  121714. /** @hidden */
  121715. _framebuffer: Nullable<WebGLFramebuffer>;
  121716. /** @hidden */
  121717. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  121718. /** @hidden */
  121719. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  121720. /** @hidden */
  121721. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  121722. /** @hidden */
  121723. _attachments: Nullable<number[]>;
  121724. /** @hidden */
  121725. _textureArray: Nullable<InternalTexture[]>;
  121726. /** @hidden */
  121727. _cachedCoordinatesMode: Nullable<number>;
  121728. /** @hidden */
  121729. _cachedWrapU: Nullable<number>;
  121730. /** @hidden */
  121731. _cachedWrapV: Nullable<number>;
  121732. /** @hidden */
  121733. _cachedWrapR: Nullable<number>;
  121734. /** @hidden */
  121735. _cachedAnisotropicFilteringLevel: Nullable<number>;
  121736. /** @hidden */
  121737. _isDisabled: boolean;
  121738. /** @hidden */
  121739. _compression: Nullable<string>;
  121740. /** @hidden */
  121741. _generateStencilBuffer: boolean;
  121742. /** @hidden */
  121743. _generateDepthBuffer: boolean;
  121744. /** @hidden */
  121745. _comparisonFunction: number;
  121746. /** @hidden */
  121747. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  121748. /** @hidden */
  121749. _lodGenerationScale: number;
  121750. /** @hidden */
  121751. _lodGenerationOffset: number;
  121752. /** @hidden */
  121753. _depthStencilTexture: Nullable<InternalTexture>;
  121754. /** @hidden */
  121755. _colorTextureArray: Nullable<WebGLTexture>;
  121756. /** @hidden */
  121757. _depthStencilTextureArray: Nullable<WebGLTexture>;
  121758. /** @hidden */
  121759. _lodTextureHigh: Nullable<BaseTexture>;
  121760. /** @hidden */
  121761. _lodTextureMid: Nullable<BaseTexture>;
  121762. /** @hidden */
  121763. _lodTextureLow: Nullable<BaseTexture>;
  121764. /** @hidden */
  121765. _isRGBD: boolean;
  121766. /** @hidden */
  121767. _linearSpecularLOD: boolean;
  121768. /** @hidden */
  121769. _irradianceTexture: Nullable<BaseTexture>;
  121770. /** @hidden */
  121771. _webGLTexture: Nullable<WebGLTexture>;
  121772. /** @hidden */
  121773. _references: number;
  121774. /** @hidden */
  121775. _gammaSpace: Nullable<boolean>;
  121776. private _engine;
  121777. /**
  121778. * Gets the Engine the texture belongs to.
  121779. * @returns The babylon engine
  121780. */
  121781. getEngine(): ThinEngine;
  121782. /**
  121783. * Gets the data source type of the texture
  121784. */
  121785. get source(): InternalTextureSource;
  121786. /**
  121787. * Creates a new InternalTexture
  121788. * @param engine defines the engine to use
  121789. * @param source defines the type of data that will be used
  121790. * @param delayAllocation if the texture allocation should be delayed (default: false)
  121791. */
  121792. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  121793. /**
  121794. * Increments the number of references (ie. the number of Texture that point to it)
  121795. */
  121796. incrementReferences(): void;
  121797. /**
  121798. * Change the size of the texture (not the size of the content)
  121799. * @param width defines the new width
  121800. * @param height defines the new height
  121801. * @param depth defines the new depth (1 by default)
  121802. */
  121803. updateSize(width: int, height: int, depth?: int): void;
  121804. /** @hidden */
  121805. _rebuild(): void;
  121806. /** @hidden */
  121807. _swapAndDie(target: InternalTexture): void;
  121808. /**
  121809. * Dispose the current allocated resources
  121810. */
  121811. dispose(): void;
  121812. }
  121813. }
  121814. declare module BABYLON {
  121815. /**
  121816. * Interface used to present a loading screen while loading a scene
  121817. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121818. */
  121819. export interface ILoadingScreen {
  121820. /**
  121821. * Function called to display the loading screen
  121822. */
  121823. displayLoadingUI: () => void;
  121824. /**
  121825. * Function called to hide the loading screen
  121826. */
  121827. hideLoadingUI: () => void;
  121828. /**
  121829. * Gets or sets the color to use for the background
  121830. */
  121831. loadingUIBackgroundColor: string;
  121832. /**
  121833. * Gets or sets the text to display while loading
  121834. */
  121835. loadingUIText: string;
  121836. }
  121837. /**
  121838. * Class used for the default loading screen
  121839. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121840. */
  121841. export class DefaultLoadingScreen implements ILoadingScreen {
  121842. private _renderingCanvas;
  121843. private _loadingText;
  121844. private _loadingDivBackgroundColor;
  121845. private _loadingDiv;
  121846. private _loadingTextDiv;
  121847. /** Gets or sets the logo url to use for the default loading screen */
  121848. static DefaultLogoUrl: string;
  121849. /** Gets or sets the spinner url to use for the default loading screen */
  121850. static DefaultSpinnerUrl: string;
  121851. /**
  121852. * Creates a new default loading screen
  121853. * @param _renderingCanvas defines the canvas used to render the scene
  121854. * @param _loadingText defines the default text to display
  121855. * @param _loadingDivBackgroundColor defines the default background color
  121856. */
  121857. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  121858. /**
  121859. * Function called to display the loading screen
  121860. */
  121861. displayLoadingUI(): void;
  121862. /**
  121863. * Function called to hide the loading screen
  121864. */
  121865. hideLoadingUI(): void;
  121866. /**
  121867. * Gets or sets the text to display while loading
  121868. */
  121869. set loadingUIText(text: string);
  121870. get loadingUIText(): string;
  121871. /**
  121872. * Gets or sets the color to use for the background
  121873. */
  121874. get loadingUIBackgroundColor(): string;
  121875. set loadingUIBackgroundColor(color: string);
  121876. private _resizeLoadingUI;
  121877. }
  121878. }
  121879. declare module BABYLON {
  121880. /**
  121881. * Interface for any object that can request an animation frame
  121882. */
  121883. export interface ICustomAnimationFrameRequester {
  121884. /**
  121885. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  121886. */
  121887. renderFunction?: Function;
  121888. /**
  121889. * Called to request the next frame to render to
  121890. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  121891. */
  121892. requestAnimationFrame: Function;
  121893. /**
  121894. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  121895. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  121896. */
  121897. requestID?: number;
  121898. }
  121899. }
  121900. declare module BABYLON {
  121901. /**
  121902. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  121903. */
  121904. export class PerformanceMonitor {
  121905. private _enabled;
  121906. private _rollingFrameTime;
  121907. private _lastFrameTimeMs;
  121908. /**
  121909. * constructor
  121910. * @param frameSampleSize The number of samples required to saturate the sliding window
  121911. */
  121912. constructor(frameSampleSize?: number);
  121913. /**
  121914. * Samples current frame
  121915. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  121916. */
  121917. sampleFrame(timeMs?: number): void;
  121918. /**
  121919. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  121920. */
  121921. get averageFrameTime(): number;
  121922. /**
  121923. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  121924. */
  121925. get averageFrameTimeVariance(): number;
  121926. /**
  121927. * Returns the frame time of the most recent frame
  121928. */
  121929. get instantaneousFrameTime(): number;
  121930. /**
  121931. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  121932. */
  121933. get averageFPS(): number;
  121934. /**
  121935. * Returns the average framerate in frames per second using the most recent frame time
  121936. */
  121937. get instantaneousFPS(): number;
  121938. /**
  121939. * Returns true if enough samples have been taken to completely fill the sliding window
  121940. */
  121941. get isSaturated(): boolean;
  121942. /**
  121943. * Enables contributions to the sliding window sample set
  121944. */
  121945. enable(): void;
  121946. /**
  121947. * Disables contributions to the sliding window sample set
  121948. * Samples will not be interpolated over the disabled period
  121949. */
  121950. disable(): void;
  121951. /**
  121952. * Returns true if sampling is enabled
  121953. */
  121954. get isEnabled(): boolean;
  121955. /**
  121956. * Resets performance monitor
  121957. */
  121958. reset(): void;
  121959. }
  121960. /**
  121961. * RollingAverage
  121962. *
  121963. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  121964. */
  121965. export class RollingAverage {
  121966. /**
  121967. * Current average
  121968. */
  121969. average: number;
  121970. /**
  121971. * Current variance
  121972. */
  121973. variance: number;
  121974. protected _samples: Array<number>;
  121975. protected _sampleCount: number;
  121976. protected _pos: number;
  121977. protected _m2: number;
  121978. /**
  121979. * constructor
  121980. * @param length The number of samples required to saturate the sliding window
  121981. */
  121982. constructor(length: number);
  121983. /**
  121984. * Adds a sample to the sample set
  121985. * @param v The sample value
  121986. */
  121987. add(v: number): void;
  121988. /**
  121989. * Returns previously added values or null if outside of history or outside the sliding window domain
  121990. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  121991. * @return Value previously recorded with add() or null if outside of range
  121992. */
  121993. history(i: number): number;
  121994. /**
  121995. * Returns true if enough samples have been taken to completely fill the sliding window
  121996. * @return true if sample-set saturated
  121997. */
  121998. isSaturated(): boolean;
  121999. /**
  122000. * Resets the rolling average (equivalent to 0 samples taken so far)
  122001. */
  122002. reset(): void;
  122003. /**
  122004. * Wraps a value around the sample range boundaries
  122005. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  122006. * @return Wrapped position in sample range
  122007. */
  122008. protected _wrapPosition(i: number): number;
  122009. }
  122010. }
  122011. declare module BABYLON {
  122012. /**
  122013. * This class is used to track a performance counter which is number based.
  122014. * The user has access to many properties which give statistics of different nature.
  122015. *
  122016. * The implementer can track two kinds of Performance Counter: time and count.
  122017. * 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.
  122018. * 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.
  122019. */
  122020. export class PerfCounter {
  122021. /**
  122022. * Gets or sets a global boolean to turn on and off all the counters
  122023. */
  122024. static Enabled: boolean;
  122025. /**
  122026. * Returns the smallest value ever
  122027. */
  122028. get min(): number;
  122029. /**
  122030. * Returns the biggest value ever
  122031. */
  122032. get max(): number;
  122033. /**
  122034. * Returns the average value since the performance counter is running
  122035. */
  122036. get average(): number;
  122037. /**
  122038. * Returns the average value of the last second the counter was monitored
  122039. */
  122040. get lastSecAverage(): number;
  122041. /**
  122042. * Returns the current value
  122043. */
  122044. get current(): number;
  122045. /**
  122046. * Gets the accumulated total
  122047. */
  122048. get total(): number;
  122049. /**
  122050. * Gets the total value count
  122051. */
  122052. get count(): number;
  122053. /**
  122054. * Creates a new counter
  122055. */
  122056. constructor();
  122057. /**
  122058. * Call this method to start monitoring a new frame.
  122059. * 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.
  122060. */
  122061. fetchNewFrame(): void;
  122062. /**
  122063. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  122064. * @param newCount the count value to add to the monitored count
  122065. * @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.
  122066. */
  122067. addCount(newCount: number, fetchResult: boolean): void;
  122068. /**
  122069. * Start monitoring this performance counter
  122070. */
  122071. beginMonitoring(): void;
  122072. /**
  122073. * Compute the time lapsed since the previous beginMonitoring() call.
  122074. * @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
  122075. */
  122076. endMonitoring(newFrame?: boolean): void;
  122077. private _fetchResult;
  122078. private _startMonitoringTime;
  122079. private _min;
  122080. private _max;
  122081. private _average;
  122082. private _current;
  122083. private _totalValueCount;
  122084. private _totalAccumulated;
  122085. private _lastSecAverage;
  122086. private _lastSecAccumulated;
  122087. private _lastSecTime;
  122088. private _lastSecValueCount;
  122089. }
  122090. }
  122091. declare module BABYLON {
  122092. interface ThinEngine {
  122093. /** @hidden */
  122094. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  122095. }
  122096. }
  122097. declare module BABYLON {
  122098. /**
  122099. * Class used to work with sound analyzer using fast fourier transform (FFT)
  122100. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122101. */
  122102. export class Analyser {
  122103. /**
  122104. * Gets or sets the smoothing
  122105. * @ignorenaming
  122106. */
  122107. SMOOTHING: number;
  122108. /**
  122109. * Gets or sets the FFT table size
  122110. * @ignorenaming
  122111. */
  122112. FFT_SIZE: number;
  122113. /**
  122114. * Gets or sets the bar graph amplitude
  122115. * @ignorenaming
  122116. */
  122117. BARGRAPHAMPLITUDE: number;
  122118. /**
  122119. * Gets or sets the position of the debug canvas
  122120. * @ignorenaming
  122121. */
  122122. DEBUGCANVASPOS: {
  122123. x: number;
  122124. y: number;
  122125. };
  122126. /**
  122127. * Gets or sets the debug canvas size
  122128. * @ignorenaming
  122129. */
  122130. DEBUGCANVASSIZE: {
  122131. width: number;
  122132. height: number;
  122133. };
  122134. private _byteFreqs;
  122135. private _byteTime;
  122136. private _floatFreqs;
  122137. private _webAudioAnalyser;
  122138. private _debugCanvas;
  122139. private _debugCanvasContext;
  122140. private _scene;
  122141. private _registerFunc;
  122142. private _audioEngine;
  122143. /**
  122144. * Creates a new analyser
  122145. * @param scene defines hosting scene
  122146. */
  122147. constructor(scene: Scene);
  122148. /**
  122149. * Get the number of data values you will have to play with for the visualization
  122150. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  122151. * @returns a number
  122152. */
  122153. getFrequencyBinCount(): number;
  122154. /**
  122155. * Gets the current frequency data as a byte array
  122156. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  122157. * @returns a Uint8Array
  122158. */
  122159. getByteFrequencyData(): Uint8Array;
  122160. /**
  122161. * Gets the current waveform as a byte array
  122162. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  122163. * @returns a Uint8Array
  122164. */
  122165. getByteTimeDomainData(): Uint8Array;
  122166. /**
  122167. * Gets the current frequency data as a float array
  122168. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  122169. * @returns a Float32Array
  122170. */
  122171. getFloatFrequencyData(): Float32Array;
  122172. /**
  122173. * Renders the debug canvas
  122174. */
  122175. drawDebugCanvas(): void;
  122176. /**
  122177. * Stops rendering the debug canvas and removes it
  122178. */
  122179. stopDebugCanvas(): void;
  122180. /**
  122181. * Connects two audio nodes
  122182. * @param inputAudioNode defines first node to connect
  122183. * @param outputAudioNode defines second node to connect
  122184. */
  122185. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  122186. /**
  122187. * Releases all associated resources
  122188. */
  122189. dispose(): void;
  122190. }
  122191. }
  122192. declare module BABYLON {
  122193. /**
  122194. * This represents an audio engine and it is responsible
  122195. * to play, synchronize and analyse sounds throughout the application.
  122196. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122197. */
  122198. export interface IAudioEngine extends IDisposable {
  122199. /**
  122200. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  122201. */
  122202. readonly canUseWebAudio: boolean;
  122203. /**
  122204. * Gets the current AudioContext if available.
  122205. */
  122206. readonly audioContext: Nullable<AudioContext>;
  122207. /**
  122208. * The master gain node defines the global audio volume of your audio engine.
  122209. */
  122210. readonly masterGain: GainNode;
  122211. /**
  122212. * Gets whether or not mp3 are supported by your browser.
  122213. */
  122214. readonly isMP3supported: boolean;
  122215. /**
  122216. * Gets whether or not ogg are supported by your browser.
  122217. */
  122218. readonly isOGGsupported: boolean;
  122219. /**
  122220. * Defines if Babylon should emit a warning if WebAudio is not supported.
  122221. * @ignoreNaming
  122222. */
  122223. WarnedWebAudioUnsupported: boolean;
  122224. /**
  122225. * Defines if the audio engine relies on a custom unlocked button.
  122226. * In this case, the embedded button will not be displayed.
  122227. */
  122228. useCustomUnlockedButton: boolean;
  122229. /**
  122230. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  122231. */
  122232. readonly unlocked: boolean;
  122233. /**
  122234. * Event raised when audio has been unlocked on the browser.
  122235. */
  122236. onAudioUnlockedObservable: Observable<IAudioEngine>;
  122237. /**
  122238. * Event raised when audio has been locked on the browser.
  122239. */
  122240. onAudioLockedObservable: Observable<IAudioEngine>;
  122241. /**
  122242. * Flags the audio engine in Locked state.
  122243. * This happens due to new browser policies preventing audio to autoplay.
  122244. */
  122245. lock(): void;
  122246. /**
  122247. * Unlocks the audio engine once a user action has been done on the dom.
  122248. * This is helpful to resume play once browser policies have been satisfied.
  122249. */
  122250. unlock(): void;
  122251. /**
  122252. * Gets the global volume sets on the master gain.
  122253. * @returns the global volume if set or -1 otherwise
  122254. */
  122255. getGlobalVolume(): number;
  122256. /**
  122257. * Sets the global volume of your experience (sets on the master gain).
  122258. * @param newVolume Defines the new global volume of the application
  122259. */
  122260. setGlobalVolume(newVolume: number): void;
  122261. /**
  122262. * Connect the audio engine to an audio analyser allowing some amazing
  122263. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  122264. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  122265. * @param analyser The analyser to connect to the engine
  122266. */
  122267. connectToAnalyser(analyser: Analyser): void;
  122268. }
  122269. }
  122270. declare module BABYLON {
  122271. /**
  122272. * Defines the interface used by display changed events
  122273. */
  122274. export interface IDisplayChangedEventArgs {
  122275. /** Gets the vrDisplay object (if any) */
  122276. vrDisplay: Nullable<any>;
  122277. /** Gets a boolean indicating if webVR is supported */
  122278. vrSupported: boolean;
  122279. }
  122280. /**
  122281. * Defines the interface used by objects containing a viewport (like a camera)
  122282. */
  122283. interface IViewportOwnerLike {
  122284. /**
  122285. * Gets or sets the viewport
  122286. */
  122287. viewport: IViewportLike;
  122288. }
  122289. /**
  122290. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  122291. */
  122292. export class Engine extends ThinEngine {
  122293. /** Defines that alpha blending is disabled */
  122294. static readonly ALPHA_DISABLE: number;
  122295. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  122296. static readonly ALPHA_ADD: number;
  122297. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  122298. static readonly ALPHA_COMBINE: number;
  122299. /** Defines that alpha blending to DEST - SRC * DEST */
  122300. static readonly ALPHA_SUBTRACT: number;
  122301. /** Defines that alpha blending to SRC * DEST */
  122302. static readonly ALPHA_MULTIPLY: number;
  122303. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  122304. static readonly ALPHA_MAXIMIZED: number;
  122305. /** Defines that alpha blending to SRC + DEST */
  122306. static readonly ALPHA_ONEONE: number;
  122307. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  122308. static readonly ALPHA_PREMULTIPLIED: number;
  122309. /**
  122310. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  122311. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  122312. */
  122313. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  122314. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  122315. static readonly ALPHA_INTERPOLATE: number;
  122316. /**
  122317. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  122318. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  122319. */
  122320. static readonly ALPHA_SCREENMODE: number;
  122321. /** Defines that the ressource is not delayed*/
  122322. static readonly DELAYLOADSTATE_NONE: number;
  122323. /** Defines that the ressource was successfully delay loaded */
  122324. static readonly DELAYLOADSTATE_LOADED: number;
  122325. /** Defines that the ressource is currently delay loading */
  122326. static readonly DELAYLOADSTATE_LOADING: number;
  122327. /** Defines that the ressource is delayed and has not started loading */
  122328. static readonly DELAYLOADSTATE_NOTLOADED: number;
  122329. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  122330. static readonly NEVER: number;
  122331. /** 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 */
  122332. static readonly ALWAYS: number;
  122333. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  122334. static readonly LESS: number;
  122335. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  122336. static readonly EQUAL: number;
  122337. /** 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 */
  122338. static readonly LEQUAL: number;
  122339. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  122340. static readonly GREATER: number;
  122341. /** 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 */
  122342. static readonly GEQUAL: number;
  122343. /** 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 */
  122344. static readonly NOTEQUAL: number;
  122345. /** Passed to stencilOperation to specify that stencil value must be kept */
  122346. static readonly KEEP: number;
  122347. /** Passed to stencilOperation to specify that stencil value must be replaced */
  122348. static readonly REPLACE: number;
  122349. /** Passed to stencilOperation to specify that stencil value must be incremented */
  122350. static readonly INCR: number;
  122351. /** Passed to stencilOperation to specify that stencil value must be decremented */
  122352. static readonly DECR: number;
  122353. /** Passed to stencilOperation to specify that stencil value must be inverted */
  122354. static readonly INVERT: number;
  122355. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  122356. static readonly INCR_WRAP: number;
  122357. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  122358. static readonly DECR_WRAP: number;
  122359. /** Texture is not repeating outside of 0..1 UVs */
  122360. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  122361. /** Texture is repeating outside of 0..1 UVs */
  122362. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  122363. /** Texture is repeating and mirrored */
  122364. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  122365. /** ALPHA */
  122366. static readonly TEXTUREFORMAT_ALPHA: number;
  122367. /** LUMINANCE */
  122368. static readonly TEXTUREFORMAT_LUMINANCE: number;
  122369. /** LUMINANCE_ALPHA */
  122370. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  122371. /** RGB */
  122372. static readonly TEXTUREFORMAT_RGB: number;
  122373. /** RGBA */
  122374. static readonly TEXTUREFORMAT_RGBA: number;
  122375. /** RED */
  122376. static readonly TEXTUREFORMAT_RED: number;
  122377. /** RED (2nd reference) */
  122378. static readonly TEXTUREFORMAT_R: number;
  122379. /** RG */
  122380. static readonly TEXTUREFORMAT_RG: number;
  122381. /** RED_INTEGER */
  122382. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  122383. /** RED_INTEGER (2nd reference) */
  122384. static readonly TEXTUREFORMAT_R_INTEGER: number;
  122385. /** RG_INTEGER */
  122386. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  122387. /** RGB_INTEGER */
  122388. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  122389. /** RGBA_INTEGER */
  122390. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  122391. /** UNSIGNED_BYTE */
  122392. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  122393. /** UNSIGNED_BYTE (2nd reference) */
  122394. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  122395. /** FLOAT */
  122396. static readonly TEXTURETYPE_FLOAT: number;
  122397. /** HALF_FLOAT */
  122398. static readonly TEXTURETYPE_HALF_FLOAT: number;
  122399. /** BYTE */
  122400. static readonly TEXTURETYPE_BYTE: number;
  122401. /** SHORT */
  122402. static readonly TEXTURETYPE_SHORT: number;
  122403. /** UNSIGNED_SHORT */
  122404. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  122405. /** INT */
  122406. static readonly TEXTURETYPE_INT: number;
  122407. /** UNSIGNED_INT */
  122408. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  122409. /** UNSIGNED_SHORT_4_4_4_4 */
  122410. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  122411. /** UNSIGNED_SHORT_5_5_5_1 */
  122412. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  122413. /** UNSIGNED_SHORT_5_6_5 */
  122414. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  122415. /** UNSIGNED_INT_2_10_10_10_REV */
  122416. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  122417. /** UNSIGNED_INT_24_8 */
  122418. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  122419. /** UNSIGNED_INT_10F_11F_11F_REV */
  122420. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  122421. /** UNSIGNED_INT_5_9_9_9_REV */
  122422. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  122423. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  122424. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  122425. /** nearest is mag = nearest and min = nearest and mip = linear */
  122426. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  122427. /** Bilinear is mag = linear and min = linear and mip = nearest */
  122428. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  122429. /** Trilinear is mag = linear and min = linear and mip = linear */
  122430. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  122431. /** nearest is mag = nearest and min = nearest and mip = linear */
  122432. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  122433. /** Bilinear is mag = linear and min = linear and mip = nearest */
  122434. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  122435. /** Trilinear is mag = linear and min = linear and mip = linear */
  122436. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  122437. /** mag = nearest and min = nearest and mip = nearest */
  122438. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  122439. /** mag = nearest and min = linear and mip = nearest */
  122440. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  122441. /** mag = nearest and min = linear and mip = linear */
  122442. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  122443. /** mag = nearest and min = linear and mip = none */
  122444. static readonly TEXTURE_NEAREST_LINEAR: number;
  122445. /** mag = nearest and min = nearest and mip = none */
  122446. static readonly TEXTURE_NEAREST_NEAREST: number;
  122447. /** mag = linear and min = nearest and mip = nearest */
  122448. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  122449. /** mag = linear and min = nearest and mip = linear */
  122450. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  122451. /** mag = linear and min = linear and mip = none */
  122452. static readonly TEXTURE_LINEAR_LINEAR: number;
  122453. /** mag = linear and min = nearest and mip = none */
  122454. static readonly TEXTURE_LINEAR_NEAREST: number;
  122455. /** Explicit coordinates mode */
  122456. static readonly TEXTURE_EXPLICIT_MODE: number;
  122457. /** Spherical coordinates mode */
  122458. static readonly TEXTURE_SPHERICAL_MODE: number;
  122459. /** Planar coordinates mode */
  122460. static readonly TEXTURE_PLANAR_MODE: number;
  122461. /** Cubic coordinates mode */
  122462. static readonly TEXTURE_CUBIC_MODE: number;
  122463. /** Projection coordinates mode */
  122464. static readonly TEXTURE_PROJECTION_MODE: number;
  122465. /** Skybox coordinates mode */
  122466. static readonly TEXTURE_SKYBOX_MODE: number;
  122467. /** Inverse Cubic coordinates mode */
  122468. static readonly TEXTURE_INVCUBIC_MODE: number;
  122469. /** Equirectangular coordinates mode */
  122470. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  122471. /** Equirectangular Fixed coordinates mode */
  122472. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  122473. /** Equirectangular Fixed Mirrored coordinates mode */
  122474. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  122475. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  122476. static readonly SCALEMODE_FLOOR: number;
  122477. /** Defines that texture rescaling will look for the nearest power of 2 size */
  122478. static readonly SCALEMODE_NEAREST: number;
  122479. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  122480. static readonly SCALEMODE_CEILING: number;
  122481. /**
  122482. * Returns the current npm package of the sdk
  122483. */
  122484. static get NpmPackage(): string;
  122485. /**
  122486. * Returns the current version of the framework
  122487. */
  122488. static get Version(): string;
  122489. /** Gets the list of created engines */
  122490. static get Instances(): Engine[];
  122491. /**
  122492. * Gets the latest created engine
  122493. */
  122494. static get LastCreatedEngine(): Nullable<Engine>;
  122495. /**
  122496. * Gets the latest created scene
  122497. */
  122498. static get LastCreatedScene(): Nullable<Scene>;
  122499. /**
  122500. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  122501. * @param flag defines which part of the materials must be marked as dirty
  122502. * @param predicate defines a predicate used to filter which materials should be affected
  122503. */
  122504. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  122505. /**
  122506. * Method called to create the default loading screen.
  122507. * This can be overriden in your own app.
  122508. * @param canvas The rendering canvas element
  122509. * @returns The loading screen
  122510. */
  122511. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  122512. /**
  122513. * Method called to create the default rescale post process on each engine.
  122514. */
  122515. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  122516. /**
  122517. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  122518. **/
  122519. enableOfflineSupport: boolean;
  122520. /**
  122521. * 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)
  122522. **/
  122523. disableManifestCheck: boolean;
  122524. /**
  122525. * Gets the list of created scenes
  122526. */
  122527. scenes: Scene[];
  122528. /**
  122529. * Event raised when a new scene is created
  122530. */
  122531. onNewSceneAddedObservable: Observable<Scene>;
  122532. /**
  122533. * Gets the list of created postprocesses
  122534. */
  122535. postProcesses: PostProcess[];
  122536. /**
  122537. * Gets a boolean indicating if the pointer is currently locked
  122538. */
  122539. isPointerLock: boolean;
  122540. /**
  122541. * Observable event triggered each time the rendering canvas is resized
  122542. */
  122543. onResizeObservable: Observable<Engine>;
  122544. /**
  122545. * Observable event triggered each time the canvas loses focus
  122546. */
  122547. onCanvasBlurObservable: Observable<Engine>;
  122548. /**
  122549. * Observable event triggered each time the canvas gains focus
  122550. */
  122551. onCanvasFocusObservable: Observable<Engine>;
  122552. /**
  122553. * Observable event triggered each time the canvas receives pointerout event
  122554. */
  122555. onCanvasPointerOutObservable: Observable<PointerEvent>;
  122556. /**
  122557. * Observable raised when the engine begins a new frame
  122558. */
  122559. onBeginFrameObservable: Observable<Engine>;
  122560. /**
  122561. * If set, will be used to request the next animation frame for the render loop
  122562. */
  122563. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  122564. /**
  122565. * Observable raised when the engine ends the current frame
  122566. */
  122567. onEndFrameObservable: Observable<Engine>;
  122568. /**
  122569. * Observable raised when the engine is about to compile a shader
  122570. */
  122571. onBeforeShaderCompilationObservable: Observable<Engine>;
  122572. /**
  122573. * Observable raised when the engine has jsut compiled a shader
  122574. */
  122575. onAfterShaderCompilationObservable: Observable<Engine>;
  122576. /**
  122577. * Gets the audio engine
  122578. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122579. * @ignorenaming
  122580. */
  122581. static audioEngine: IAudioEngine;
  122582. /**
  122583. * Default AudioEngine factory responsible of creating the Audio Engine.
  122584. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  122585. */
  122586. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  122587. /**
  122588. * Default offline support factory responsible of creating a tool used to store data locally.
  122589. * By default, this will create a Database object if the workload has been embedded.
  122590. */
  122591. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  122592. private _loadingScreen;
  122593. private _pointerLockRequested;
  122594. private _rescalePostProcess;
  122595. private _deterministicLockstep;
  122596. private _lockstepMaxSteps;
  122597. private _timeStep;
  122598. protected get _supportsHardwareTextureRescaling(): boolean;
  122599. private _fps;
  122600. private _deltaTime;
  122601. /** @hidden */
  122602. _drawCalls: PerfCounter;
  122603. /** 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 */
  122604. canvasTabIndex: number;
  122605. /**
  122606. * Turn this value on if you want to pause FPS computation when in background
  122607. */
  122608. disablePerformanceMonitorInBackground: boolean;
  122609. private _performanceMonitor;
  122610. /**
  122611. * Gets the performance monitor attached to this engine
  122612. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  122613. */
  122614. get performanceMonitor(): PerformanceMonitor;
  122615. private _onFocus;
  122616. private _onBlur;
  122617. private _onCanvasPointerOut;
  122618. private _onCanvasBlur;
  122619. private _onCanvasFocus;
  122620. private _onFullscreenChange;
  122621. private _onPointerLockChange;
  122622. /**
  122623. * Gets the HTML element used to attach event listeners
  122624. * @returns a HTML element
  122625. */
  122626. getInputElement(): Nullable<HTMLElement>;
  122627. /**
  122628. * Creates a new engine
  122629. * @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
  122630. * @param antialias defines enable antialiasing (default: false)
  122631. * @param options defines further options to be sent to the getContext() function
  122632. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  122633. */
  122634. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  122635. /**
  122636. * Gets current aspect ratio
  122637. * @param viewportOwner defines the camera to use to get the aspect ratio
  122638. * @param useScreen defines if screen size must be used (or the current render target if any)
  122639. * @returns a number defining the aspect ratio
  122640. */
  122641. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  122642. /**
  122643. * Gets current screen aspect ratio
  122644. * @returns a number defining the aspect ratio
  122645. */
  122646. getScreenAspectRatio(): number;
  122647. /**
  122648. * Gets the client rect of the HTML canvas attached with the current webGL context
  122649. * @returns a client rectanglee
  122650. */
  122651. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  122652. /**
  122653. * Gets the client rect of the HTML element used for events
  122654. * @returns a client rectanglee
  122655. */
  122656. getInputElementClientRect(): Nullable<ClientRect>;
  122657. /**
  122658. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  122659. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122660. * @returns true if engine is in deterministic lock step mode
  122661. */
  122662. isDeterministicLockStep(): boolean;
  122663. /**
  122664. * Gets the max steps when engine is running in deterministic lock step
  122665. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122666. * @returns the max steps
  122667. */
  122668. getLockstepMaxSteps(): number;
  122669. /**
  122670. * Returns the time in ms between steps when using deterministic lock step.
  122671. * @returns time step in (ms)
  122672. */
  122673. getTimeStep(): number;
  122674. /**
  122675. * Force the mipmap generation for the given render target texture
  122676. * @param texture defines the render target texture to use
  122677. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  122678. */
  122679. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  122680. /** States */
  122681. /**
  122682. * Set various states to the webGL context
  122683. * @param culling defines backface culling state
  122684. * @param zOffset defines the value to apply to zOffset (0 by default)
  122685. * @param force defines if states must be applied even if cache is up to date
  122686. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  122687. */
  122688. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  122689. /**
  122690. * Set the z offset to apply to current rendering
  122691. * @param value defines the offset to apply
  122692. */
  122693. setZOffset(value: number): void;
  122694. /**
  122695. * Gets the current value of the zOffset
  122696. * @returns the current zOffset state
  122697. */
  122698. getZOffset(): number;
  122699. /**
  122700. * Enable or disable depth buffering
  122701. * @param enable defines the state to set
  122702. */
  122703. setDepthBuffer(enable: boolean): void;
  122704. /**
  122705. * Gets a boolean indicating if depth writing is enabled
  122706. * @returns the current depth writing state
  122707. */
  122708. getDepthWrite(): boolean;
  122709. /**
  122710. * Enable or disable depth writing
  122711. * @param enable defines the state to set
  122712. */
  122713. setDepthWrite(enable: boolean): void;
  122714. /**
  122715. * Gets a boolean indicating if stencil buffer is enabled
  122716. * @returns the current stencil buffer state
  122717. */
  122718. getStencilBuffer(): boolean;
  122719. /**
  122720. * Enable or disable the stencil buffer
  122721. * @param enable defines if the stencil buffer must be enabled or disabled
  122722. */
  122723. setStencilBuffer(enable: boolean): void;
  122724. /**
  122725. * Gets the current stencil mask
  122726. * @returns a number defining the new stencil mask to use
  122727. */
  122728. getStencilMask(): number;
  122729. /**
  122730. * Sets the current stencil mask
  122731. * @param mask defines the new stencil mask to use
  122732. */
  122733. setStencilMask(mask: number): void;
  122734. /**
  122735. * Gets the current stencil function
  122736. * @returns a number defining the stencil function to use
  122737. */
  122738. getStencilFunction(): number;
  122739. /**
  122740. * Gets the current stencil reference value
  122741. * @returns a number defining the stencil reference value to use
  122742. */
  122743. getStencilFunctionReference(): number;
  122744. /**
  122745. * Gets the current stencil mask
  122746. * @returns a number defining the stencil mask to use
  122747. */
  122748. getStencilFunctionMask(): number;
  122749. /**
  122750. * Sets the current stencil function
  122751. * @param stencilFunc defines the new stencil function to use
  122752. */
  122753. setStencilFunction(stencilFunc: number): void;
  122754. /**
  122755. * Sets the current stencil reference
  122756. * @param reference defines the new stencil reference to use
  122757. */
  122758. setStencilFunctionReference(reference: number): void;
  122759. /**
  122760. * Sets the current stencil mask
  122761. * @param mask defines the new stencil mask to use
  122762. */
  122763. setStencilFunctionMask(mask: number): void;
  122764. /**
  122765. * Gets the current stencil operation when stencil fails
  122766. * @returns a number defining stencil operation to use when stencil fails
  122767. */
  122768. getStencilOperationFail(): number;
  122769. /**
  122770. * Gets the current stencil operation when depth fails
  122771. * @returns a number defining stencil operation to use when depth fails
  122772. */
  122773. getStencilOperationDepthFail(): number;
  122774. /**
  122775. * Gets the current stencil operation when stencil passes
  122776. * @returns a number defining stencil operation to use when stencil passes
  122777. */
  122778. getStencilOperationPass(): number;
  122779. /**
  122780. * Sets the stencil operation to use when stencil fails
  122781. * @param operation defines the stencil operation to use when stencil fails
  122782. */
  122783. setStencilOperationFail(operation: number): void;
  122784. /**
  122785. * Sets the stencil operation to use when depth fails
  122786. * @param operation defines the stencil operation to use when depth fails
  122787. */
  122788. setStencilOperationDepthFail(operation: number): void;
  122789. /**
  122790. * Sets the stencil operation to use when stencil passes
  122791. * @param operation defines the stencil operation to use when stencil passes
  122792. */
  122793. setStencilOperationPass(operation: number): void;
  122794. /**
  122795. * Sets a boolean indicating if the dithering state is enabled or disabled
  122796. * @param value defines the dithering state
  122797. */
  122798. setDitheringState(value: boolean): void;
  122799. /**
  122800. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  122801. * @param value defines the rasterizer state
  122802. */
  122803. setRasterizerState(value: boolean): void;
  122804. /**
  122805. * Gets the current depth function
  122806. * @returns a number defining the depth function
  122807. */
  122808. getDepthFunction(): Nullable<number>;
  122809. /**
  122810. * Sets the current depth function
  122811. * @param depthFunc defines the function to use
  122812. */
  122813. setDepthFunction(depthFunc: number): void;
  122814. /**
  122815. * Sets the current depth function to GREATER
  122816. */
  122817. setDepthFunctionToGreater(): void;
  122818. /**
  122819. * Sets the current depth function to GEQUAL
  122820. */
  122821. setDepthFunctionToGreaterOrEqual(): void;
  122822. /**
  122823. * Sets the current depth function to LESS
  122824. */
  122825. setDepthFunctionToLess(): void;
  122826. /**
  122827. * Sets the current depth function to LEQUAL
  122828. */
  122829. setDepthFunctionToLessOrEqual(): void;
  122830. private _cachedStencilBuffer;
  122831. private _cachedStencilFunction;
  122832. private _cachedStencilMask;
  122833. private _cachedStencilOperationPass;
  122834. private _cachedStencilOperationFail;
  122835. private _cachedStencilOperationDepthFail;
  122836. private _cachedStencilReference;
  122837. /**
  122838. * Caches the the state of the stencil buffer
  122839. */
  122840. cacheStencilState(): void;
  122841. /**
  122842. * Restores the state of the stencil buffer
  122843. */
  122844. restoreStencilState(): void;
  122845. /**
  122846. * Directly set the WebGL Viewport
  122847. * @param x defines the x coordinate of the viewport (in screen space)
  122848. * @param y defines the y coordinate of the viewport (in screen space)
  122849. * @param width defines the width of the viewport (in screen space)
  122850. * @param height defines the height of the viewport (in screen space)
  122851. * @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
  122852. */
  122853. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  122854. /**
  122855. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  122856. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  122857. * @param y defines the y-coordinate of the corner of the clear rectangle
  122858. * @param width defines the width of the clear rectangle
  122859. * @param height defines the height of the clear rectangle
  122860. * @param clearColor defines the clear color
  122861. */
  122862. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  122863. /**
  122864. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  122865. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  122866. * @param y defines the y-coordinate of the corner of the clear rectangle
  122867. * @param width defines the width of the clear rectangle
  122868. * @param height defines the height of the clear rectangle
  122869. */
  122870. enableScissor(x: number, y: number, width: number, height: number): void;
  122871. /**
  122872. * Disable previously set scissor test rectangle
  122873. */
  122874. disableScissor(): void;
  122875. protected _reportDrawCall(): void;
  122876. /**
  122877. * Initializes a webVR display and starts listening to display change events
  122878. * The onVRDisplayChangedObservable will be notified upon these changes
  122879. * @returns The onVRDisplayChangedObservable
  122880. */
  122881. initWebVR(): Observable<IDisplayChangedEventArgs>;
  122882. /** @hidden */
  122883. _prepareVRComponent(): void;
  122884. /** @hidden */
  122885. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  122886. /** @hidden */
  122887. _submitVRFrame(): void;
  122888. /**
  122889. * Call this function to leave webVR mode
  122890. * Will do nothing if webVR is not supported or if there is no webVR device
  122891. * @see https://doc.babylonjs.com/how_to/webvr_camera
  122892. */
  122893. disableVR(): void;
  122894. /**
  122895. * Gets a boolean indicating that the system is in VR mode and is presenting
  122896. * @returns true if VR mode is engaged
  122897. */
  122898. isVRPresenting(): boolean;
  122899. /** @hidden */
  122900. _requestVRFrame(): void;
  122901. /** @hidden */
  122902. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  122903. /**
  122904. * Gets the source code of the vertex shader associated with a specific webGL program
  122905. * @param program defines the program to use
  122906. * @returns a string containing the source code of the vertex shader associated with the program
  122907. */
  122908. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  122909. /**
  122910. * Gets the source code of the fragment shader associated with a specific webGL program
  122911. * @param program defines the program to use
  122912. * @returns a string containing the source code of the fragment shader associated with the program
  122913. */
  122914. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  122915. /**
  122916. * Sets a depth stencil texture from a render target to the according uniform.
  122917. * @param channel The texture channel
  122918. * @param uniform The uniform to set
  122919. * @param texture The render target texture containing the depth stencil texture to apply
  122920. */
  122921. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  122922. /**
  122923. * Sets a texture to the webGL context from a postprocess
  122924. * @param channel defines the channel to use
  122925. * @param postProcess defines the source postprocess
  122926. */
  122927. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  122928. /**
  122929. * Binds the output of the passed in post process to the texture channel specified
  122930. * @param channel The channel the texture should be bound to
  122931. * @param postProcess The post process which's output should be bound
  122932. */
  122933. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  122934. protected _rebuildBuffers(): void;
  122935. /** @hidden */
  122936. _renderFrame(): void;
  122937. _renderLoop(): void;
  122938. /** @hidden */
  122939. _renderViews(): boolean;
  122940. /**
  122941. * Toggle full screen mode
  122942. * @param requestPointerLock defines if a pointer lock should be requested from the user
  122943. */
  122944. switchFullscreen(requestPointerLock: boolean): void;
  122945. /**
  122946. * Enters full screen mode
  122947. * @param requestPointerLock defines if a pointer lock should be requested from the user
  122948. */
  122949. enterFullscreen(requestPointerLock: boolean): void;
  122950. /**
  122951. * Exits full screen mode
  122952. */
  122953. exitFullscreen(): void;
  122954. /**
  122955. * Enters Pointerlock mode
  122956. */
  122957. enterPointerlock(): void;
  122958. /**
  122959. * Exits Pointerlock mode
  122960. */
  122961. exitPointerlock(): void;
  122962. /**
  122963. * Begin a new frame
  122964. */
  122965. beginFrame(): void;
  122966. /**
  122967. * Enf the current frame
  122968. */
  122969. endFrame(): void;
  122970. resize(): void;
  122971. /**
  122972. * Force a specific size of the canvas
  122973. * @param width defines the new canvas' width
  122974. * @param height defines the new canvas' height
  122975. * @returns true if the size was changed
  122976. */
  122977. setSize(width: number, height: number): boolean;
  122978. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  122979. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  122980. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  122981. _releaseTexture(texture: InternalTexture): void;
  122982. /**
  122983. * @hidden
  122984. * Rescales a texture
  122985. * @param source input texutre
  122986. * @param destination destination texture
  122987. * @param scene scene to use to render the resize
  122988. * @param internalFormat format to use when resizing
  122989. * @param onComplete callback to be called when resize has completed
  122990. */
  122991. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  122992. /**
  122993. * Gets the current framerate
  122994. * @returns a number representing the framerate
  122995. */
  122996. getFps(): number;
  122997. /**
  122998. * Gets the time spent between current and previous frame
  122999. * @returns a number representing the delta time in ms
  123000. */
  123001. getDeltaTime(): number;
  123002. private _measureFps;
  123003. /** @hidden */
  123004. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  123005. /**
  123006. * Updates the sample count of a render target texture
  123007. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  123008. * @param texture defines the texture to update
  123009. * @param samples defines the sample count to set
  123010. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  123011. */
  123012. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  123013. /**
  123014. * Updates a depth texture Comparison Mode and Function.
  123015. * If the comparison Function is equal to 0, the mode will be set to none.
  123016. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  123017. * @param texture The texture to set the comparison function for
  123018. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  123019. */
  123020. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  123021. /**
  123022. * Creates a webGL buffer to use with instanciation
  123023. * @param capacity defines the size of the buffer
  123024. * @returns the webGL buffer
  123025. */
  123026. createInstancesBuffer(capacity: number): DataBuffer;
  123027. /**
  123028. * Delete a webGL buffer used with instanciation
  123029. * @param buffer defines the webGL buffer to delete
  123030. */
  123031. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  123032. private _clientWaitAsync;
  123033. /** @hidden */
  123034. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  123035. dispose(): void;
  123036. private _disableTouchAction;
  123037. /**
  123038. * Display the loading screen
  123039. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123040. */
  123041. displayLoadingUI(): void;
  123042. /**
  123043. * Hide the loading screen
  123044. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123045. */
  123046. hideLoadingUI(): void;
  123047. /**
  123048. * Gets the current loading screen object
  123049. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123050. */
  123051. get loadingScreen(): ILoadingScreen;
  123052. /**
  123053. * Sets the current loading screen object
  123054. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123055. */
  123056. set loadingScreen(loadingScreen: ILoadingScreen);
  123057. /**
  123058. * Sets the current loading screen text
  123059. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123060. */
  123061. set loadingUIText(text: string);
  123062. /**
  123063. * Sets the current loading screen background color
  123064. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123065. */
  123066. set loadingUIBackgroundColor(color: string);
  123067. /** Pointerlock and fullscreen */
  123068. /**
  123069. * Ask the browser to promote the current element to pointerlock mode
  123070. * @param element defines the DOM element to promote
  123071. */
  123072. static _RequestPointerlock(element: HTMLElement): void;
  123073. /**
  123074. * Asks the browser to exit pointerlock mode
  123075. */
  123076. static _ExitPointerlock(): void;
  123077. /**
  123078. * Ask the browser to promote the current element to fullscreen rendering mode
  123079. * @param element defines the DOM element to promote
  123080. */
  123081. static _RequestFullscreen(element: HTMLElement): void;
  123082. /**
  123083. * Asks the browser to exit fullscreen mode
  123084. */
  123085. static _ExitFullscreen(): void;
  123086. }
  123087. }
  123088. declare module BABYLON {
  123089. /**
  123090. * The engine store class is responsible to hold all the instances of Engine and Scene created
  123091. * during the life time of the application.
  123092. */
  123093. export class EngineStore {
  123094. /** Gets the list of created engines */
  123095. static Instances: Engine[];
  123096. /** @hidden */
  123097. static _LastCreatedScene: Nullable<Scene>;
  123098. /**
  123099. * Gets the latest created engine
  123100. */
  123101. static get LastCreatedEngine(): Nullable<Engine>;
  123102. /**
  123103. * Gets the latest created scene
  123104. */
  123105. static get LastCreatedScene(): Nullable<Scene>;
  123106. /**
  123107. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  123108. * @ignorenaming
  123109. */
  123110. static UseFallbackTexture: boolean;
  123111. /**
  123112. * Texture content used if a texture cannot loaded
  123113. * @ignorenaming
  123114. */
  123115. static FallbackTexture: string;
  123116. }
  123117. }
  123118. declare module BABYLON {
  123119. /**
  123120. * Helper class that provides a small promise polyfill
  123121. */
  123122. export class PromisePolyfill {
  123123. /**
  123124. * Static function used to check if the polyfill is required
  123125. * If this is the case then the function will inject the polyfill to window.Promise
  123126. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  123127. */
  123128. static Apply(force?: boolean): void;
  123129. }
  123130. }
  123131. declare module BABYLON {
  123132. /**
  123133. * Interface for screenshot methods with describe argument called `size` as object with options
  123134. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  123135. */
  123136. export interface IScreenshotSize {
  123137. /**
  123138. * number in pixels for canvas height
  123139. */
  123140. height?: number;
  123141. /**
  123142. * multiplier allowing render at a higher or lower resolution
  123143. * If value is defined then height and width will be ignored and taken from camera
  123144. */
  123145. precision?: number;
  123146. /**
  123147. * number in pixels for canvas width
  123148. */
  123149. width?: number;
  123150. }
  123151. }
  123152. declare module BABYLON {
  123153. interface IColor4Like {
  123154. r: float;
  123155. g: float;
  123156. b: float;
  123157. a: float;
  123158. }
  123159. /**
  123160. * Class containing a set of static utilities functions
  123161. */
  123162. export class Tools {
  123163. /**
  123164. * Gets or sets the base URL to use to load assets
  123165. */
  123166. static get BaseUrl(): string;
  123167. static set BaseUrl(value: string);
  123168. /**
  123169. * Enable/Disable Custom HTTP Request Headers globally.
  123170. * default = false
  123171. * @see CustomRequestHeaders
  123172. */
  123173. static UseCustomRequestHeaders: boolean;
  123174. /**
  123175. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  123176. * i.e. when loading files, where the server/service expects an Authorization header
  123177. */
  123178. static CustomRequestHeaders: {
  123179. [key: string]: string;
  123180. };
  123181. /**
  123182. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  123183. */
  123184. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  123185. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  123186. /**
  123187. * Default behaviour for cors in the application.
  123188. * It can be a string if the expected behavior is identical in the entire app.
  123189. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  123190. */
  123191. static get CorsBehavior(): string | ((url: string | string[]) => string);
  123192. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  123193. /**
  123194. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  123195. * @ignorenaming
  123196. */
  123197. static get UseFallbackTexture(): boolean;
  123198. static set UseFallbackTexture(value: boolean);
  123199. /**
  123200. * Use this object to register external classes like custom textures or material
  123201. * to allow the laoders to instantiate them
  123202. */
  123203. static get RegisteredExternalClasses(): {
  123204. [key: string]: Object;
  123205. };
  123206. static set RegisteredExternalClasses(classes: {
  123207. [key: string]: Object;
  123208. });
  123209. /**
  123210. * Texture content used if a texture cannot loaded
  123211. * @ignorenaming
  123212. */
  123213. static get fallbackTexture(): string;
  123214. static set fallbackTexture(value: string);
  123215. /**
  123216. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  123217. * @param u defines the coordinate on X axis
  123218. * @param v defines the coordinate on Y axis
  123219. * @param width defines the width of the source data
  123220. * @param height defines the height of the source data
  123221. * @param pixels defines the source byte array
  123222. * @param color defines the output color
  123223. */
  123224. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  123225. /**
  123226. * Interpolates between a and b via alpha
  123227. * @param a The lower value (returned when alpha = 0)
  123228. * @param b The upper value (returned when alpha = 1)
  123229. * @param alpha The interpolation-factor
  123230. * @return The mixed value
  123231. */
  123232. static Mix(a: number, b: number, alpha: number): number;
  123233. /**
  123234. * Tries to instantiate a new object from a given class name
  123235. * @param className defines the class name to instantiate
  123236. * @returns the new object or null if the system was not able to do the instantiation
  123237. */
  123238. static Instantiate(className: string): any;
  123239. /**
  123240. * Provides a slice function that will work even on IE
  123241. * @param data defines the array to slice
  123242. * @param start defines the start of the data (optional)
  123243. * @param end defines the end of the data (optional)
  123244. * @returns the new sliced array
  123245. */
  123246. static Slice<T>(data: T, start?: number, end?: number): T;
  123247. /**
  123248. * Provides a slice function that will work even on IE
  123249. * The difference between this and Slice is that this will force-convert to array
  123250. * @param data defines the array to slice
  123251. * @param start defines the start of the data (optional)
  123252. * @param end defines the end of the data (optional)
  123253. * @returns the new sliced array
  123254. */
  123255. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  123256. /**
  123257. * Polyfill for setImmediate
  123258. * @param action defines the action to execute after the current execution block
  123259. */
  123260. static SetImmediate(action: () => void): void;
  123261. /**
  123262. * Function indicating if a number is an exponent of 2
  123263. * @param value defines the value to test
  123264. * @returns true if the value is an exponent of 2
  123265. */
  123266. static IsExponentOfTwo(value: number): boolean;
  123267. private static _tmpFloatArray;
  123268. /**
  123269. * Returns the nearest 32-bit single precision float representation of a Number
  123270. * @param value A Number. If the parameter is of a different type, it will get converted
  123271. * to a number or to NaN if it cannot be converted
  123272. * @returns number
  123273. */
  123274. static FloatRound(value: number): number;
  123275. /**
  123276. * Extracts the filename from a path
  123277. * @param path defines the path to use
  123278. * @returns the filename
  123279. */
  123280. static GetFilename(path: string): string;
  123281. /**
  123282. * Extracts the "folder" part of a path (everything before the filename).
  123283. * @param uri The URI to extract the info from
  123284. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  123285. * @returns The "folder" part of the path
  123286. */
  123287. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  123288. /**
  123289. * Extracts text content from a DOM element hierarchy
  123290. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  123291. */
  123292. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  123293. /**
  123294. * Convert an angle in radians to degrees
  123295. * @param angle defines the angle to convert
  123296. * @returns the angle in degrees
  123297. */
  123298. static ToDegrees(angle: number): number;
  123299. /**
  123300. * Convert an angle in degrees to radians
  123301. * @param angle defines the angle to convert
  123302. * @returns the angle in radians
  123303. */
  123304. static ToRadians(angle: number): number;
  123305. /**
  123306. * Returns an array if obj is not an array
  123307. * @param obj defines the object to evaluate as an array
  123308. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  123309. * @returns either obj directly if obj is an array or a new array containing obj
  123310. */
  123311. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  123312. /**
  123313. * Gets the pointer prefix to use
  123314. * @param engine defines the engine we are finding the prefix for
  123315. * @returns "pointer" if touch is enabled. Else returns "mouse"
  123316. */
  123317. static GetPointerPrefix(engine: Engine): string;
  123318. /**
  123319. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  123320. * @param url define the url we are trying
  123321. * @param element define the dom element where to configure the cors policy
  123322. */
  123323. static SetCorsBehavior(url: string | string[], element: {
  123324. crossOrigin: string | null;
  123325. }): void;
  123326. /**
  123327. * Removes unwanted characters from an url
  123328. * @param url defines the url to clean
  123329. * @returns the cleaned url
  123330. */
  123331. static CleanUrl(url: string): string;
  123332. /**
  123333. * Gets or sets a function used to pre-process url before using them to load assets
  123334. */
  123335. static get PreprocessUrl(): (url: string) => string;
  123336. static set PreprocessUrl(processor: (url: string) => string);
  123337. /**
  123338. * Loads an image as an HTMLImageElement.
  123339. * @param input url string, ArrayBuffer, or Blob to load
  123340. * @param onLoad callback called when the image successfully loads
  123341. * @param onError callback called when the image fails to load
  123342. * @param offlineProvider offline provider for caching
  123343. * @param mimeType optional mime type
  123344. * @returns the HTMLImageElement of the loaded image
  123345. */
  123346. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  123347. /**
  123348. * Loads a file from a url
  123349. * @param url url string, ArrayBuffer, or Blob to load
  123350. * @param onSuccess callback called when the file successfully loads
  123351. * @param onProgress callback called while file is loading (if the server supports this mode)
  123352. * @param offlineProvider defines the offline provider for caching
  123353. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  123354. * @param onError callback called when the file fails to load
  123355. * @returns a file request object
  123356. */
  123357. 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;
  123358. /**
  123359. * Loads a file from a url
  123360. * @param url the file url to load
  123361. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  123362. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  123363. */
  123364. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  123365. /**
  123366. * Load a script (identified by an url). When the url returns, the
  123367. * content of this file is added into a new script element, attached to the DOM (body element)
  123368. * @param scriptUrl defines the url of the script to laod
  123369. * @param onSuccess defines the callback called when the script is loaded
  123370. * @param onError defines the callback to call if an error occurs
  123371. * @param scriptId defines the id of the script element
  123372. */
  123373. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  123374. /**
  123375. * Load an asynchronous script (identified by an url). When the url returns, the
  123376. * content of this file is added into a new script element, attached to the DOM (body element)
  123377. * @param scriptUrl defines the url of the script to laod
  123378. * @param scriptId defines the id of the script element
  123379. * @returns a promise request object
  123380. */
  123381. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  123382. /**
  123383. * Loads a file from a blob
  123384. * @param fileToLoad defines the blob to use
  123385. * @param callback defines the callback to call when data is loaded
  123386. * @param progressCallback defines the callback to call during loading process
  123387. * @returns a file request object
  123388. */
  123389. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  123390. /**
  123391. * Reads a file from a File object
  123392. * @param file defines the file to load
  123393. * @param onSuccess defines the callback to call when data is loaded
  123394. * @param onProgress defines the callback to call during loading process
  123395. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  123396. * @param onError defines the callback to call when an error occurs
  123397. * @returns a file request object
  123398. */
  123399. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  123400. /**
  123401. * Creates a data url from a given string content
  123402. * @param content defines the content to convert
  123403. * @returns the new data url link
  123404. */
  123405. static FileAsURL(content: string): string;
  123406. /**
  123407. * Format the given number to a specific decimal format
  123408. * @param value defines the number to format
  123409. * @param decimals defines the number of decimals to use
  123410. * @returns the formatted string
  123411. */
  123412. static Format(value: number, decimals?: number): string;
  123413. /**
  123414. * Tries to copy an object by duplicating every property
  123415. * @param source defines the source object
  123416. * @param destination defines the target object
  123417. * @param doNotCopyList defines a list of properties to avoid
  123418. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  123419. */
  123420. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  123421. /**
  123422. * Gets a boolean indicating if the given object has no own property
  123423. * @param obj defines the object to test
  123424. * @returns true if object has no own property
  123425. */
  123426. static IsEmpty(obj: any): boolean;
  123427. /**
  123428. * Function used to register events at window level
  123429. * @param windowElement defines the Window object to use
  123430. * @param events defines the events to register
  123431. */
  123432. static RegisterTopRootEvents(windowElement: Window, events: {
  123433. name: string;
  123434. handler: Nullable<(e: FocusEvent) => any>;
  123435. }[]): void;
  123436. /**
  123437. * Function used to unregister events from window level
  123438. * @param windowElement defines the Window object to use
  123439. * @param events defines the events to unregister
  123440. */
  123441. static UnregisterTopRootEvents(windowElement: Window, events: {
  123442. name: string;
  123443. handler: Nullable<(e: FocusEvent) => any>;
  123444. }[]): void;
  123445. /**
  123446. * @ignore
  123447. */
  123448. static _ScreenshotCanvas: HTMLCanvasElement;
  123449. /**
  123450. * Dumps the current bound framebuffer
  123451. * @param width defines the rendering width
  123452. * @param height defines the rendering height
  123453. * @param engine defines the hosting engine
  123454. * @param successCallback defines the callback triggered once the data are available
  123455. * @param mimeType defines the mime type of the result
  123456. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  123457. */
  123458. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  123459. /**
  123460. * Converts the canvas data to blob.
  123461. * This acts as a polyfill for browsers not supporting the to blob function.
  123462. * @param canvas Defines the canvas to extract the data from
  123463. * @param successCallback Defines the callback triggered once the data are available
  123464. * @param mimeType Defines the mime type of the result
  123465. */
  123466. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  123467. /**
  123468. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  123469. * @param successCallback defines the callback triggered once the data are available
  123470. * @param mimeType defines the mime type of the result
  123471. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  123472. */
  123473. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  123474. /**
  123475. * Downloads a blob in the browser
  123476. * @param blob defines the blob to download
  123477. * @param fileName defines the name of the downloaded file
  123478. */
  123479. static Download(blob: Blob, fileName: string): void;
  123480. /**
  123481. * Will return the right value of the noPreventDefault variable
  123482. * Needed to keep backwards compatibility to the old API.
  123483. *
  123484. * @param args arguments passed to the attachControl function
  123485. * @returns the correct value for noPreventDefault
  123486. */
  123487. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  123488. /**
  123489. * Captures a screenshot of the current rendering
  123490. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123491. * @param engine defines the rendering engine
  123492. * @param camera defines the source camera
  123493. * @param size This parameter can be set to a single number or to an object with the
  123494. * following (optional) properties: precision, width, height. If a single number is passed,
  123495. * it will be used for both width and height. If an object is passed, the screenshot size
  123496. * will be derived from the parameters. The precision property is a multiplier allowing
  123497. * rendering at a higher or lower resolution
  123498. * @param successCallback defines the callback receives a single parameter which contains the
  123499. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  123500. * src parameter of an <img> to display it
  123501. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  123502. * Check your browser for supported MIME types
  123503. */
  123504. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  123505. /**
  123506. * Captures a screenshot of the current rendering
  123507. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123508. * @param engine defines the rendering engine
  123509. * @param camera defines the source camera
  123510. * @param size This parameter can be set to a single number or to an object with the
  123511. * following (optional) properties: precision, width, height. If a single number is passed,
  123512. * it will be used for both width and height. If an object is passed, the screenshot size
  123513. * will be derived from the parameters. The precision property is a multiplier allowing
  123514. * rendering at a higher or lower resolution
  123515. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  123516. * Check your browser for supported MIME types
  123517. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  123518. * to the src parameter of an <img> to display it
  123519. */
  123520. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  123521. /**
  123522. * Generates an image screenshot from the specified camera.
  123523. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123524. * @param engine The engine to use for rendering
  123525. * @param camera The camera to use for rendering
  123526. * @param size This parameter can be set to a single number or to an object with the
  123527. * following (optional) properties: precision, width, height. If a single number is passed,
  123528. * it will be used for both width and height. If an object is passed, the screenshot size
  123529. * will be derived from the parameters. The precision property is a multiplier allowing
  123530. * rendering at a higher or lower resolution
  123531. * @param successCallback The callback receives a single parameter which contains the
  123532. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  123533. * src parameter of an <img> to display it
  123534. * @param mimeType The MIME type of the screenshot image (default: image/png).
  123535. * Check your browser for supported MIME types
  123536. * @param samples Texture samples (default: 1)
  123537. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  123538. * @param fileName A name for for the downloaded file.
  123539. */
  123540. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  123541. /**
  123542. * Generates an image screenshot from the specified camera.
  123543. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123544. * @param engine The engine to use for rendering
  123545. * @param camera The camera to use for rendering
  123546. * @param size This parameter can be set to a single number or to an object with the
  123547. * following (optional) properties: precision, width, height. If a single number is passed,
  123548. * it will be used for both width and height. If an object is passed, the screenshot size
  123549. * will be derived from the parameters. The precision property is a multiplier allowing
  123550. * rendering at a higher or lower resolution
  123551. * @param mimeType The MIME type of the screenshot image (default: image/png).
  123552. * Check your browser for supported MIME types
  123553. * @param samples Texture samples (default: 1)
  123554. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  123555. * @param fileName A name for for the downloaded file.
  123556. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  123557. * to the src parameter of an <img> to display it
  123558. */
  123559. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  123560. /**
  123561. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  123562. * Be aware Math.random() could cause collisions, but:
  123563. * "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"
  123564. * @returns a pseudo random id
  123565. */
  123566. static RandomId(): string;
  123567. /**
  123568. * Test if the given uri is a base64 string
  123569. * @param uri The uri to test
  123570. * @return True if the uri is a base64 string or false otherwise
  123571. */
  123572. static IsBase64(uri: string): boolean;
  123573. /**
  123574. * Decode the given base64 uri.
  123575. * @param uri The uri to decode
  123576. * @return The decoded base64 data.
  123577. */
  123578. static DecodeBase64(uri: string): ArrayBuffer;
  123579. /**
  123580. * Gets the absolute url.
  123581. * @param url the input url
  123582. * @return the absolute url
  123583. */
  123584. static GetAbsoluteUrl(url: string): string;
  123585. /**
  123586. * No log
  123587. */
  123588. static readonly NoneLogLevel: number;
  123589. /**
  123590. * Only message logs
  123591. */
  123592. static readonly MessageLogLevel: number;
  123593. /**
  123594. * Only warning logs
  123595. */
  123596. static readonly WarningLogLevel: number;
  123597. /**
  123598. * Only error logs
  123599. */
  123600. static readonly ErrorLogLevel: number;
  123601. /**
  123602. * All logs
  123603. */
  123604. static readonly AllLogLevel: number;
  123605. /**
  123606. * Gets a value indicating the number of loading errors
  123607. * @ignorenaming
  123608. */
  123609. static get errorsCount(): number;
  123610. /**
  123611. * Callback called when a new log is added
  123612. */
  123613. static OnNewCacheEntry: (entry: string) => void;
  123614. /**
  123615. * Log a message to the console
  123616. * @param message defines the message to log
  123617. */
  123618. static Log(message: string): void;
  123619. /**
  123620. * Write a warning message to the console
  123621. * @param message defines the message to log
  123622. */
  123623. static Warn(message: string): void;
  123624. /**
  123625. * Write an error message to the console
  123626. * @param message defines the message to log
  123627. */
  123628. static Error(message: string): void;
  123629. /**
  123630. * Gets current log cache (list of logs)
  123631. */
  123632. static get LogCache(): string;
  123633. /**
  123634. * Clears the log cache
  123635. */
  123636. static ClearLogCache(): void;
  123637. /**
  123638. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  123639. */
  123640. static set LogLevels(level: number);
  123641. /**
  123642. * Checks if the window object exists
  123643. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  123644. */
  123645. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  123646. /**
  123647. * No performance log
  123648. */
  123649. static readonly PerformanceNoneLogLevel: number;
  123650. /**
  123651. * Use user marks to log performance
  123652. */
  123653. static readonly PerformanceUserMarkLogLevel: number;
  123654. /**
  123655. * Log performance to the console
  123656. */
  123657. static readonly PerformanceConsoleLogLevel: number;
  123658. private static _performance;
  123659. /**
  123660. * Sets the current performance log level
  123661. */
  123662. static set PerformanceLogLevel(level: number);
  123663. private static _StartPerformanceCounterDisabled;
  123664. private static _EndPerformanceCounterDisabled;
  123665. private static _StartUserMark;
  123666. private static _EndUserMark;
  123667. private static _StartPerformanceConsole;
  123668. private static _EndPerformanceConsole;
  123669. /**
  123670. * Starts a performance counter
  123671. */
  123672. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  123673. /**
  123674. * Ends a specific performance coutner
  123675. */
  123676. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  123677. /**
  123678. * Gets either window.performance.now() if supported or Date.now() else
  123679. */
  123680. static get Now(): number;
  123681. /**
  123682. * This method will return the name of the class used to create the instance of the given object.
  123683. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  123684. * @param object the object to get the class name from
  123685. * @param isType defines if the object is actually a type
  123686. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  123687. */
  123688. static GetClassName(object: any, isType?: boolean): string;
  123689. /**
  123690. * Gets the first element of an array satisfying a given predicate
  123691. * @param array defines the array to browse
  123692. * @param predicate defines the predicate to use
  123693. * @returns null if not found or the element
  123694. */
  123695. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  123696. /**
  123697. * This method will return the name of the full name of the class, including its owning module (if any).
  123698. * 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).
  123699. * @param object the object to get the class name from
  123700. * @param isType defines if the object is actually a type
  123701. * @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.
  123702. * @ignorenaming
  123703. */
  123704. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  123705. /**
  123706. * Returns a promise that resolves after the given amount of time.
  123707. * @param delay Number of milliseconds to delay
  123708. * @returns Promise that resolves after the given amount of time
  123709. */
  123710. static DelayAsync(delay: number): Promise<void>;
  123711. /**
  123712. * Utility function to detect if the current user agent is Safari
  123713. * @returns whether or not the current user agent is safari
  123714. */
  123715. static IsSafari(): boolean;
  123716. }
  123717. /**
  123718. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  123719. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  123720. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  123721. * @param name The name of the class, case should be preserved
  123722. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  123723. */
  123724. export function className(name: string, module?: string): (target: Object) => void;
  123725. /**
  123726. * An implementation of a loop for asynchronous functions.
  123727. */
  123728. export class AsyncLoop {
  123729. /**
  123730. * Defines the number of iterations for the loop
  123731. */
  123732. iterations: number;
  123733. /**
  123734. * Defines the current index of the loop.
  123735. */
  123736. index: number;
  123737. private _done;
  123738. private _fn;
  123739. private _successCallback;
  123740. /**
  123741. * Constructor.
  123742. * @param iterations the number of iterations.
  123743. * @param func the function to run each iteration
  123744. * @param successCallback the callback that will be called upon succesful execution
  123745. * @param offset starting offset.
  123746. */
  123747. constructor(
  123748. /**
  123749. * Defines the number of iterations for the loop
  123750. */
  123751. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  123752. /**
  123753. * Execute the next iteration. Must be called after the last iteration was finished.
  123754. */
  123755. executeNext(): void;
  123756. /**
  123757. * Break the loop and run the success callback.
  123758. */
  123759. breakLoop(): void;
  123760. /**
  123761. * Create and run an async loop.
  123762. * @param iterations the number of iterations.
  123763. * @param fn the function to run each iteration
  123764. * @param successCallback the callback that will be called upon succesful execution
  123765. * @param offset starting offset.
  123766. * @returns the created async loop object
  123767. */
  123768. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  123769. /**
  123770. * A for-loop that will run a given number of iterations synchronous and the rest async.
  123771. * @param iterations total number of iterations
  123772. * @param syncedIterations number of synchronous iterations in each async iteration.
  123773. * @param fn the function to call each iteration.
  123774. * @param callback a success call back that will be called when iterating stops.
  123775. * @param breakFunction a break condition (optional)
  123776. * @param timeout timeout settings for the setTimeout function. default - 0.
  123777. * @returns the created async loop object
  123778. */
  123779. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  123780. }
  123781. }
  123782. declare module BABYLON {
  123783. /**
  123784. * This class implement a typical dictionary using a string as key and the generic type T as value.
  123785. * The underlying implementation relies on an associative array to ensure the best performances.
  123786. * The value can be anything including 'null' but except 'undefined'
  123787. */
  123788. export class StringDictionary<T> {
  123789. /**
  123790. * This will clear this dictionary and copy the content from the 'source' one.
  123791. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  123792. * @param source the dictionary to take the content from and copy to this dictionary
  123793. */
  123794. copyFrom(source: StringDictionary<T>): void;
  123795. /**
  123796. * Get a value based from its key
  123797. * @param key the given key to get the matching value from
  123798. * @return the value if found, otherwise undefined is returned
  123799. */
  123800. get(key: string): T | undefined;
  123801. /**
  123802. * Get a value from its key or add it if it doesn't exist.
  123803. * This method will ensure you that a given key/data will be present in the dictionary.
  123804. * @param key the given key to get the matching value from
  123805. * @param factory the factory that will create the value if the key is not present in the dictionary.
  123806. * The factory will only be invoked if there's no data for the given key.
  123807. * @return the value corresponding to the key.
  123808. */
  123809. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  123810. /**
  123811. * Get a value from its key if present in the dictionary otherwise add it
  123812. * @param key the key to get the value from
  123813. * @param val if there's no such key/value pair in the dictionary add it with this value
  123814. * @return the value corresponding to the key
  123815. */
  123816. getOrAdd(key: string, val: T): T;
  123817. /**
  123818. * Check if there's a given key in the dictionary
  123819. * @param key the key to check for
  123820. * @return true if the key is present, false otherwise
  123821. */
  123822. contains(key: string): boolean;
  123823. /**
  123824. * Add a new key and its corresponding value
  123825. * @param key the key to add
  123826. * @param value the value corresponding to the key
  123827. * @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
  123828. */
  123829. add(key: string, value: T): boolean;
  123830. /**
  123831. * Update a specific value associated to a key
  123832. * @param key defines the key to use
  123833. * @param value defines the value to store
  123834. * @returns true if the value was updated (or false if the key was not found)
  123835. */
  123836. set(key: string, value: T): boolean;
  123837. /**
  123838. * Get the element of the given key and remove it from the dictionary
  123839. * @param key defines the key to search
  123840. * @returns the value associated with the key or null if not found
  123841. */
  123842. getAndRemove(key: string): Nullable<T>;
  123843. /**
  123844. * Remove a key/value from the dictionary.
  123845. * @param key the key to remove
  123846. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  123847. */
  123848. remove(key: string): boolean;
  123849. /**
  123850. * Clear the whole content of the dictionary
  123851. */
  123852. clear(): void;
  123853. /**
  123854. * Gets the current count
  123855. */
  123856. get count(): number;
  123857. /**
  123858. * Execute a callback on each key/val of the dictionary.
  123859. * Note that you can remove any element in this dictionary in the callback implementation
  123860. * @param callback the callback to execute on a given key/value pair
  123861. */
  123862. forEach(callback: (key: string, val: T) => void): void;
  123863. /**
  123864. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  123865. * If the callback returns null or undefined the method will iterate to the next key/value pair
  123866. * Note that you can remove any element in this dictionary in the callback implementation
  123867. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  123868. * @returns the first item
  123869. */
  123870. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  123871. private _count;
  123872. private _data;
  123873. }
  123874. }
  123875. declare module BABYLON {
  123876. /** @hidden */
  123877. export interface ICollisionCoordinator {
  123878. createCollider(): Collider;
  123879. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  123880. init(scene: Scene): void;
  123881. }
  123882. /** @hidden */
  123883. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  123884. private _scene;
  123885. private _scaledPosition;
  123886. private _scaledVelocity;
  123887. private _finalPosition;
  123888. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  123889. createCollider(): Collider;
  123890. init(scene: Scene): void;
  123891. private _collideWithWorld;
  123892. }
  123893. }
  123894. declare module BABYLON {
  123895. /**
  123896. * Class used to manage all inputs for the scene.
  123897. */
  123898. export class InputManager {
  123899. /** The distance in pixel that you have to move to prevent some events */
  123900. static DragMovementThreshold: number;
  123901. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  123902. static LongPressDelay: number;
  123903. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  123904. static DoubleClickDelay: number;
  123905. /** If you need to check double click without raising a single click at first click, enable this flag */
  123906. static ExclusiveDoubleClickMode: boolean;
  123907. /** 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. */
  123908. private _alreadyAttached;
  123909. private _alreadyAttachedTo;
  123910. private _wheelEventName;
  123911. private _onPointerMove;
  123912. private _onPointerDown;
  123913. private _onPointerUp;
  123914. private _initClickEvent;
  123915. private _initActionManager;
  123916. private _delayedSimpleClick;
  123917. private _delayedSimpleClickTimeout;
  123918. private _previousDelayedSimpleClickTimeout;
  123919. private _meshPickProceed;
  123920. private _previousButtonPressed;
  123921. private _currentPickResult;
  123922. private _previousPickResult;
  123923. private _totalPointersPressed;
  123924. private _doubleClickOccured;
  123925. private _pointerOverMesh;
  123926. private _pickedDownMesh;
  123927. private _pickedUpMesh;
  123928. private _pointerX;
  123929. private _pointerY;
  123930. private _unTranslatedPointerX;
  123931. private _unTranslatedPointerY;
  123932. private _startingPointerPosition;
  123933. private _previousStartingPointerPosition;
  123934. private _startingPointerTime;
  123935. private _previousStartingPointerTime;
  123936. private _pointerCaptures;
  123937. private _meshUnderPointerId;
  123938. private _onKeyDown;
  123939. private _onKeyUp;
  123940. private _keyboardIsAttached;
  123941. private _onCanvasFocusObserver;
  123942. private _onCanvasBlurObserver;
  123943. private _scene;
  123944. /**
  123945. * Creates a new InputManager
  123946. * @param scene defines the hosting scene
  123947. */
  123948. constructor(scene: Scene);
  123949. /**
  123950. * Gets the mesh that is currently under the pointer
  123951. */
  123952. get meshUnderPointer(): Nullable<AbstractMesh>;
  123953. /**
  123954. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  123955. * @param pointerId the pointer id to use
  123956. * @returns The mesh under this pointer id or null if not found
  123957. */
  123958. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  123959. /**
  123960. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  123961. */
  123962. get unTranslatedPointer(): Vector2;
  123963. /**
  123964. * Gets or sets the current on-screen X position of the pointer
  123965. */
  123966. get pointerX(): number;
  123967. set pointerX(value: number);
  123968. /**
  123969. * Gets or sets the current on-screen Y position of the pointer
  123970. */
  123971. get pointerY(): number;
  123972. set pointerY(value: number);
  123973. private _updatePointerPosition;
  123974. private _processPointerMove;
  123975. private _setRayOnPointerInfo;
  123976. private _checkPrePointerObservable;
  123977. /**
  123978. * Use this method to simulate a pointer move on a mesh
  123979. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123980. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123981. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123982. */
  123983. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  123984. /**
  123985. * Use this method to simulate a pointer down on a mesh
  123986. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123987. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123988. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123989. */
  123990. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  123991. private _processPointerDown;
  123992. /** @hidden */
  123993. _isPointerSwiping(): boolean;
  123994. /**
  123995. * Use this method to simulate a pointer up on a mesh
  123996. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123997. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123998. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123999. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  124000. */
  124001. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  124002. private _processPointerUp;
  124003. /**
  124004. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  124005. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  124006. * @returns true if the pointer was captured
  124007. */
  124008. isPointerCaptured(pointerId?: number): boolean;
  124009. /**
  124010. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  124011. * @param attachUp defines if you want to attach events to pointerup
  124012. * @param attachDown defines if you want to attach events to pointerdown
  124013. * @param attachMove defines if you want to attach events to pointermove
  124014. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  124015. */
  124016. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  124017. /**
  124018. * Detaches all event handlers
  124019. */
  124020. detachControl(): void;
  124021. /**
  124022. * Force the value of meshUnderPointer
  124023. * @param mesh defines the mesh to use
  124024. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  124025. */
  124026. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  124027. /**
  124028. * Gets the mesh under the pointer
  124029. * @returns a Mesh or null if no mesh is under the pointer
  124030. */
  124031. getPointerOverMesh(): Nullable<AbstractMesh>;
  124032. }
  124033. }
  124034. declare module BABYLON {
  124035. /**
  124036. * This class defines the direct association between an animation and a target
  124037. */
  124038. export class TargetedAnimation {
  124039. /**
  124040. * Animation to perform
  124041. */
  124042. animation: Animation;
  124043. /**
  124044. * Target to animate
  124045. */
  124046. target: any;
  124047. /**
  124048. * Returns the string "TargetedAnimation"
  124049. * @returns "TargetedAnimation"
  124050. */
  124051. getClassName(): string;
  124052. /**
  124053. * Serialize the object
  124054. * @returns the JSON object representing the current entity
  124055. */
  124056. serialize(): any;
  124057. }
  124058. /**
  124059. * Use this class to create coordinated animations on multiple targets
  124060. */
  124061. export class AnimationGroup implements IDisposable {
  124062. /** The name of the animation group */
  124063. name: string;
  124064. private _scene;
  124065. private _targetedAnimations;
  124066. private _animatables;
  124067. private _from;
  124068. private _to;
  124069. private _isStarted;
  124070. private _isPaused;
  124071. private _speedRatio;
  124072. private _loopAnimation;
  124073. private _isAdditive;
  124074. /**
  124075. * Gets or sets the unique id of the node
  124076. */
  124077. uniqueId: number;
  124078. /**
  124079. * This observable will notify when one animation have ended
  124080. */
  124081. onAnimationEndObservable: Observable<TargetedAnimation>;
  124082. /**
  124083. * Observer raised when one animation loops
  124084. */
  124085. onAnimationLoopObservable: Observable<TargetedAnimation>;
  124086. /**
  124087. * Observer raised when all animations have looped
  124088. */
  124089. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  124090. /**
  124091. * This observable will notify when all animations have ended.
  124092. */
  124093. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  124094. /**
  124095. * This observable will notify when all animations have paused.
  124096. */
  124097. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  124098. /**
  124099. * This observable will notify when all animations are playing.
  124100. */
  124101. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  124102. /**
  124103. * Gets the first frame
  124104. */
  124105. get from(): number;
  124106. /**
  124107. * Gets the last frame
  124108. */
  124109. get to(): number;
  124110. /**
  124111. * Define if the animations are started
  124112. */
  124113. get isStarted(): boolean;
  124114. /**
  124115. * Gets a value indicating that the current group is playing
  124116. */
  124117. get isPlaying(): boolean;
  124118. /**
  124119. * Gets or sets the speed ratio to use for all animations
  124120. */
  124121. get speedRatio(): number;
  124122. /**
  124123. * Gets or sets the speed ratio to use for all animations
  124124. */
  124125. set speedRatio(value: number);
  124126. /**
  124127. * Gets or sets if all animations should loop or not
  124128. */
  124129. get loopAnimation(): boolean;
  124130. set loopAnimation(value: boolean);
  124131. /**
  124132. * Gets or sets if all animations should be evaluated additively
  124133. */
  124134. get isAdditive(): boolean;
  124135. set isAdditive(value: boolean);
  124136. /**
  124137. * Gets the targeted animations for this animation group
  124138. */
  124139. get targetedAnimations(): Array<TargetedAnimation>;
  124140. /**
  124141. * returning the list of animatables controlled by this animation group.
  124142. */
  124143. get animatables(): Array<Animatable>;
  124144. /**
  124145. * Gets the list of target animations
  124146. */
  124147. get children(): TargetedAnimation[];
  124148. /**
  124149. * Instantiates a new Animation Group.
  124150. * This helps managing several animations at once.
  124151. * @see https://doc.babylonjs.com/how_to/group
  124152. * @param name Defines the name of the group
  124153. * @param scene Defines the scene the group belongs to
  124154. */
  124155. constructor(
  124156. /** The name of the animation group */
  124157. name: string, scene?: Nullable<Scene>);
  124158. /**
  124159. * Add an animation (with its target) in the group
  124160. * @param animation defines the animation we want to add
  124161. * @param target defines the target of the animation
  124162. * @returns the TargetedAnimation object
  124163. */
  124164. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  124165. /**
  124166. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  124167. * It can add constant keys at begin or end
  124168. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  124169. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  124170. * @returns the animation group
  124171. */
  124172. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  124173. private _animationLoopCount;
  124174. private _animationLoopFlags;
  124175. private _processLoop;
  124176. /**
  124177. * Start all animations on given targets
  124178. * @param loop defines if animations must loop
  124179. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  124180. * @param from defines the from key (optional)
  124181. * @param to defines the to key (optional)
  124182. * @param isAdditive defines the additive state for the resulting animatables (optional)
  124183. * @returns the current animation group
  124184. */
  124185. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  124186. /**
  124187. * Pause all animations
  124188. * @returns the animation group
  124189. */
  124190. pause(): AnimationGroup;
  124191. /**
  124192. * Play all animations to initial state
  124193. * This function will start() the animations if they were not started or will restart() them if they were paused
  124194. * @param loop defines if animations must loop
  124195. * @returns the animation group
  124196. */
  124197. play(loop?: boolean): AnimationGroup;
  124198. /**
  124199. * Reset all animations to initial state
  124200. * @returns the animation group
  124201. */
  124202. reset(): AnimationGroup;
  124203. /**
  124204. * Restart animations from key 0
  124205. * @returns the animation group
  124206. */
  124207. restart(): AnimationGroup;
  124208. /**
  124209. * Stop all animations
  124210. * @returns the animation group
  124211. */
  124212. stop(): AnimationGroup;
  124213. /**
  124214. * Set animation weight for all animatables
  124215. * @param weight defines the weight to use
  124216. * @return the animationGroup
  124217. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  124218. */
  124219. setWeightForAllAnimatables(weight: number): AnimationGroup;
  124220. /**
  124221. * Synchronize and normalize all animatables with a source animatable
  124222. * @param root defines the root animatable to synchronize with
  124223. * @return the animationGroup
  124224. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  124225. */
  124226. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  124227. /**
  124228. * Goes to a specific frame in this animation group
  124229. * @param frame the frame number to go to
  124230. * @return the animationGroup
  124231. */
  124232. goToFrame(frame: number): AnimationGroup;
  124233. /**
  124234. * Dispose all associated resources
  124235. */
  124236. dispose(): void;
  124237. private _checkAnimationGroupEnded;
  124238. /**
  124239. * Clone the current animation group and returns a copy
  124240. * @param newName defines the name of the new group
  124241. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  124242. * @returns the new aniamtion group
  124243. */
  124244. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  124245. /**
  124246. * Serializes the animationGroup to an object
  124247. * @returns Serialized object
  124248. */
  124249. serialize(): any;
  124250. /**
  124251. * Returns a new AnimationGroup object parsed from the source provided.
  124252. * @param parsedAnimationGroup defines the source
  124253. * @param scene defines the scene that will receive the animationGroup
  124254. * @returns a new AnimationGroup
  124255. */
  124256. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  124257. /**
  124258. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  124259. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  124260. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  124261. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  124262. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  124263. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  124264. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  124265. */
  124266. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  124267. /**
  124268. * Returns the string "AnimationGroup"
  124269. * @returns "AnimationGroup"
  124270. */
  124271. getClassName(): string;
  124272. /**
  124273. * Creates a detailled string about the object
  124274. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  124275. * @returns a string representing the object
  124276. */
  124277. toString(fullDetails?: boolean): string;
  124278. }
  124279. }
  124280. declare module BABYLON {
  124281. /**
  124282. * Define an interface for all classes that will hold resources
  124283. */
  124284. export interface IDisposable {
  124285. /**
  124286. * Releases all held resources
  124287. */
  124288. dispose(): void;
  124289. }
  124290. /** Interface defining initialization parameters for Scene class */
  124291. export interface SceneOptions {
  124292. /**
  124293. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  124294. * It will improve performance when the number of geometries becomes important.
  124295. */
  124296. useGeometryUniqueIdsMap?: boolean;
  124297. /**
  124298. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  124299. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  124300. */
  124301. useMaterialMeshMap?: boolean;
  124302. /**
  124303. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  124304. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  124305. */
  124306. useClonedMeshMap?: boolean;
  124307. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  124308. virtual?: boolean;
  124309. }
  124310. /**
  124311. * Represents a scene to be rendered by the engine.
  124312. * @see https://doc.babylonjs.com/features/scene
  124313. */
  124314. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  124315. /** The fog is deactivated */
  124316. static readonly FOGMODE_NONE: number;
  124317. /** The fog density is following an exponential function */
  124318. static readonly FOGMODE_EXP: number;
  124319. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  124320. static readonly FOGMODE_EXP2: number;
  124321. /** The fog density is following a linear function. */
  124322. static readonly FOGMODE_LINEAR: number;
  124323. /**
  124324. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  124325. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124326. */
  124327. static MinDeltaTime: number;
  124328. /**
  124329. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  124330. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124331. */
  124332. static MaxDeltaTime: number;
  124333. /**
  124334. * Factory used to create the default material.
  124335. * @param name The name of the material to create
  124336. * @param scene The scene to create the material for
  124337. * @returns The default material
  124338. */
  124339. static DefaultMaterialFactory(scene: Scene): Material;
  124340. /**
  124341. * Factory used to create the a collision coordinator.
  124342. * @returns The collision coordinator
  124343. */
  124344. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  124345. /** @hidden */
  124346. _inputManager: InputManager;
  124347. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  124348. cameraToUseForPointers: Nullable<Camera>;
  124349. /** @hidden */
  124350. readonly _isScene: boolean;
  124351. /** @hidden */
  124352. _blockEntityCollection: boolean;
  124353. /**
  124354. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  124355. */
  124356. autoClear: boolean;
  124357. /**
  124358. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  124359. */
  124360. autoClearDepthAndStencil: boolean;
  124361. /**
  124362. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  124363. */
  124364. clearColor: Color4;
  124365. /**
  124366. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  124367. */
  124368. ambientColor: Color3;
  124369. /**
  124370. * This is use to store the default BRDF lookup for PBR materials in your scene.
  124371. * It should only be one of the following (if not the default embedded one):
  124372. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  124373. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  124374. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  124375. * The material properties need to be setup according to the type of texture in use.
  124376. */
  124377. environmentBRDFTexture: BaseTexture;
  124378. /**
  124379. * Texture used in all pbr material as the reflection texture.
  124380. * As in the majority of the scene they are the same (exception for multi room and so on),
  124381. * this is easier to reference from here than from all the materials.
  124382. */
  124383. get environmentTexture(): Nullable<BaseTexture>;
  124384. /**
  124385. * Texture used in all pbr material as the reflection texture.
  124386. * As in the majority of the scene they are the same (exception for multi room and so on),
  124387. * this is easier to set here than in all the materials.
  124388. */
  124389. set environmentTexture(value: Nullable<BaseTexture>);
  124390. /** @hidden */
  124391. protected _environmentIntensity: number;
  124392. /**
  124393. * Intensity of the environment in all pbr material.
  124394. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  124395. * As in the majority of the scene they are the same (exception for multi room and so on),
  124396. * this is easier to reference from here than from all the materials.
  124397. */
  124398. get environmentIntensity(): number;
  124399. /**
  124400. * Intensity of the environment in all pbr material.
  124401. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  124402. * As in the majority of the scene they are the same (exception for multi room and so on),
  124403. * this is easier to set here than in all the materials.
  124404. */
  124405. set environmentIntensity(value: number);
  124406. /** @hidden */
  124407. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124408. /**
  124409. * Default image processing configuration used either in the rendering
  124410. * Forward main pass or through the imageProcessingPostProcess if present.
  124411. * As in the majority of the scene they are the same (exception for multi camera),
  124412. * this is easier to reference from here than from all the materials and post process.
  124413. *
  124414. * No setter as we it is a shared configuration, you can set the values instead.
  124415. */
  124416. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  124417. private _forceWireframe;
  124418. /**
  124419. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  124420. */
  124421. set forceWireframe(value: boolean);
  124422. get forceWireframe(): boolean;
  124423. private _skipFrustumClipping;
  124424. /**
  124425. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  124426. */
  124427. set skipFrustumClipping(value: boolean);
  124428. get skipFrustumClipping(): boolean;
  124429. private _forcePointsCloud;
  124430. /**
  124431. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  124432. */
  124433. set forcePointsCloud(value: boolean);
  124434. get forcePointsCloud(): boolean;
  124435. /**
  124436. * Gets or sets the active clipplane 1
  124437. */
  124438. clipPlane: Nullable<Plane>;
  124439. /**
  124440. * Gets or sets the active clipplane 2
  124441. */
  124442. clipPlane2: Nullable<Plane>;
  124443. /**
  124444. * Gets or sets the active clipplane 3
  124445. */
  124446. clipPlane3: Nullable<Plane>;
  124447. /**
  124448. * Gets or sets the active clipplane 4
  124449. */
  124450. clipPlane4: Nullable<Plane>;
  124451. /**
  124452. * Gets or sets the active clipplane 5
  124453. */
  124454. clipPlane5: Nullable<Plane>;
  124455. /**
  124456. * Gets or sets the active clipplane 6
  124457. */
  124458. clipPlane6: Nullable<Plane>;
  124459. /**
  124460. * Gets or sets a boolean indicating if animations are enabled
  124461. */
  124462. animationsEnabled: boolean;
  124463. private _animationPropertiesOverride;
  124464. /**
  124465. * Gets or sets the animation properties override
  124466. */
  124467. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  124468. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  124469. /**
  124470. * Gets or sets a boolean indicating if a constant deltatime has to be used
  124471. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  124472. */
  124473. useConstantAnimationDeltaTime: boolean;
  124474. /**
  124475. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  124476. * Please note that it requires to run a ray cast through the scene on every frame
  124477. */
  124478. constantlyUpdateMeshUnderPointer: boolean;
  124479. /**
  124480. * Defines the HTML cursor to use when hovering over interactive elements
  124481. */
  124482. hoverCursor: string;
  124483. /**
  124484. * Defines the HTML default cursor to use (empty by default)
  124485. */
  124486. defaultCursor: string;
  124487. /**
  124488. * Defines whether cursors are handled by the scene.
  124489. */
  124490. doNotHandleCursors: boolean;
  124491. /**
  124492. * This is used to call preventDefault() on pointer down
  124493. * in order to block unwanted artifacts like system double clicks
  124494. */
  124495. preventDefaultOnPointerDown: boolean;
  124496. /**
  124497. * This is used to call preventDefault() on pointer up
  124498. * in order to block unwanted artifacts like system double clicks
  124499. */
  124500. preventDefaultOnPointerUp: boolean;
  124501. /**
  124502. * Gets or sets user defined metadata
  124503. */
  124504. metadata: any;
  124505. /**
  124506. * For internal use only. Please do not use.
  124507. */
  124508. reservedDataStore: any;
  124509. /**
  124510. * Gets the name of the plugin used to load this scene (null by default)
  124511. */
  124512. loadingPluginName: string;
  124513. /**
  124514. * Use this array to add regular expressions used to disable offline support for specific urls
  124515. */
  124516. disableOfflineSupportExceptionRules: RegExp[];
  124517. /**
  124518. * An event triggered when the scene is disposed.
  124519. */
  124520. onDisposeObservable: Observable<Scene>;
  124521. private _onDisposeObserver;
  124522. /** Sets a function to be executed when this scene is disposed. */
  124523. set onDispose(callback: () => void);
  124524. /**
  124525. * An event triggered before rendering the scene (right after animations and physics)
  124526. */
  124527. onBeforeRenderObservable: Observable<Scene>;
  124528. private _onBeforeRenderObserver;
  124529. /** Sets a function to be executed before rendering this scene */
  124530. set beforeRender(callback: Nullable<() => void>);
  124531. /**
  124532. * An event triggered after rendering the scene
  124533. */
  124534. onAfterRenderObservable: Observable<Scene>;
  124535. /**
  124536. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  124537. */
  124538. onAfterRenderCameraObservable: Observable<Camera>;
  124539. private _onAfterRenderObserver;
  124540. /** Sets a function to be executed after rendering this scene */
  124541. set afterRender(callback: Nullable<() => void>);
  124542. /**
  124543. * An event triggered before animating the scene
  124544. */
  124545. onBeforeAnimationsObservable: Observable<Scene>;
  124546. /**
  124547. * An event triggered after animations processing
  124548. */
  124549. onAfterAnimationsObservable: Observable<Scene>;
  124550. /**
  124551. * An event triggered before draw calls are ready to be sent
  124552. */
  124553. onBeforeDrawPhaseObservable: Observable<Scene>;
  124554. /**
  124555. * An event triggered after draw calls have been sent
  124556. */
  124557. onAfterDrawPhaseObservable: Observable<Scene>;
  124558. /**
  124559. * An event triggered when the scene is ready
  124560. */
  124561. onReadyObservable: Observable<Scene>;
  124562. /**
  124563. * An event triggered before rendering a camera
  124564. */
  124565. onBeforeCameraRenderObservable: Observable<Camera>;
  124566. private _onBeforeCameraRenderObserver;
  124567. /** Sets a function to be executed before rendering a camera*/
  124568. set beforeCameraRender(callback: () => void);
  124569. /**
  124570. * An event triggered after rendering a camera
  124571. */
  124572. onAfterCameraRenderObservable: Observable<Camera>;
  124573. private _onAfterCameraRenderObserver;
  124574. /** Sets a function to be executed after rendering a camera*/
  124575. set afterCameraRender(callback: () => void);
  124576. /**
  124577. * An event triggered when active meshes evaluation is about to start
  124578. */
  124579. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  124580. /**
  124581. * An event triggered when active meshes evaluation is done
  124582. */
  124583. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  124584. /**
  124585. * An event triggered when particles rendering is about to start
  124586. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  124587. */
  124588. onBeforeParticlesRenderingObservable: Observable<Scene>;
  124589. /**
  124590. * An event triggered when particles rendering is done
  124591. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  124592. */
  124593. onAfterParticlesRenderingObservable: Observable<Scene>;
  124594. /**
  124595. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  124596. */
  124597. onDataLoadedObservable: Observable<Scene>;
  124598. /**
  124599. * An event triggered when a camera is created
  124600. */
  124601. onNewCameraAddedObservable: Observable<Camera>;
  124602. /**
  124603. * An event triggered when a camera is removed
  124604. */
  124605. onCameraRemovedObservable: Observable<Camera>;
  124606. /**
  124607. * An event triggered when a light is created
  124608. */
  124609. onNewLightAddedObservable: Observable<Light>;
  124610. /**
  124611. * An event triggered when a light is removed
  124612. */
  124613. onLightRemovedObservable: Observable<Light>;
  124614. /**
  124615. * An event triggered when a geometry is created
  124616. */
  124617. onNewGeometryAddedObservable: Observable<Geometry>;
  124618. /**
  124619. * An event triggered when a geometry is removed
  124620. */
  124621. onGeometryRemovedObservable: Observable<Geometry>;
  124622. /**
  124623. * An event triggered when a transform node is created
  124624. */
  124625. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  124626. /**
  124627. * An event triggered when a transform node is removed
  124628. */
  124629. onTransformNodeRemovedObservable: Observable<TransformNode>;
  124630. /**
  124631. * An event triggered when a mesh is created
  124632. */
  124633. onNewMeshAddedObservable: Observable<AbstractMesh>;
  124634. /**
  124635. * An event triggered when a mesh is removed
  124636. */
  124637. onMeshRemovedObservable: Observable<AbstractMesh>;
  124638. /**
  124639. * An event triggered when a skeleton is created
  124640. */
  124641. onNewSkeletonAddedObservable: Observable<Skeleton>;
  124642. /**
  124643. * An event triggered when a skeleton is removed
  124644. */
  124645. onSkeletonRemovedObservable: Observable<Skeleton>;
  124646. /**
  124647. * An event triggered when a material is created
  124648. */
  124649. onNewMaterialAddedObservable: Observable<Material>;
  124650. /**
  124651. * An event triggered when a multi material is created
  124652. */
  124653. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  124654. /**
  124655. * An event triggered when a material is removed
  124656. */
  124657. onMaterialRemovedObservable: Observable<Material>;
  124658. /**
  124659. * An event triggered when a multi material is removed
  124660. */
  124661. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  124662. /**
  124663. * An event triggered when a texture is created
  124664. */
  124665. onNewTextureAddedObservable: Observable<BaseTexture>;
  124666. /**
  124667. * An event triggered when a texture is removed
  124668. */
  124669. onTextureRemovedObservable: Observable<BaseTexture>;
  124670. /**
  124671. * An event triggered when render targets are about to be rendered
  124672. * Can happen multiple times per frame.
  124673. */
  124674. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  124675. /**
  124676. * An event triggered when render targets were rendered.
  124677. * Can happen multiple times per frame.
  124678. */
  124679. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  124680. /**
  124681. * An event triggered before calculating deterministic simulation step
  124682. */
  124683. onBeforeStepObservable: Observable<Scene>;
  124684. /**
  124685. * An event triggered after calculating deterministic simulation step
  124686. */
  124687. onAfterStepObservable: Observable<Scene>;
  124688. /**
  124689. * An event triggered when the activeCamera property is updated
  124690. */
  124691. onActiveCameraChanged: Observable<Scene>;
  124692. /**
  124693. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  124694. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  124695. * 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)
  124696. */
  124697. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  124698. /**
  124699. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  124700. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  124701. * 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)
  124702. */
  124703. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  124704. /**
  124705. * This Observable will when a mesh has been imported into the scene.
  124706. */
  124707. onMeshImportedObservable: Observable<AbstractMesh>;
  124708. /**
  124709. * This Observable will when an animation file has been imported into the scene.
  124710. */
  124711. onAnimationFileImportedObservable: Observable<Scene>;
  124712. /**
  124713. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  124714. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  124715. */
  124716. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  124717. /** @hidden */
  124718. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  124719. /**
  124720. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  124721. */
  124722. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  124723. /**
  124724. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  124725. */
  124726. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  124727. /**
  124728. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  124729. */
  124730. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  124731. /** Callback called when a pointer move is detected */
  124732. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  124733. /** Callback called when a pointer down is detected */
  124734. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  124735. /** Callback called when a pointer up is detected */
  124736. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  124737. /** Callback called when a pointer pick is detected */
  124738. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  124739. /**
  124740. * 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).
  124741. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  124742. */
  124743. onPrePointerObservable: Observable<PointerInfoPre>;
  124744. /**
  124745. * Observable event triggered each time an input event is received from the rendering canvas
  124746. */
  124747. onPointerObservable: Observable<PointerInfo>;
  124748. /**
  124749. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  124750. */
  124751. get unTranslatedPointer(): Vector2;
  124752. /**
  124753. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  124754. */
  124755. static get DragMovementThreshold(): number;
  124756. static set DragMovementThreshold(value: number);
  124757. /**
  124758. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  124759. */
  124760. static get LongPressDelay(): number;
  124761. static set LongPressDelay(value: number);
  124762. /**
  124763. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  124764. */
  124765. static get DoubleClickDelay(): number;
  124766. static set DoubleClickDelay(value: number);
  124767. /** If you need to check double click without raising a single click at first click, enable this flag */
  124768. static get ExclusiveDoubleClickMode(): boolean;
  124769. static set ExclusiveDoubleClickMode(value: boolean);
  124770. /** @hidden */
  124771. _mirroredCameraPosition: Nullable<Vector3>;
  124772. /**
  124773. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  124774. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  124775. */
  124776. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  124777. /**
  124778. * Observable event triggered each time an keyboard event is received from the hosting window
  124779. */
  124780. onKeyboardObservable: Observable<KeyboardInfo>;
  124781. private _useRightHandedSystem;
  124782. /**
  124783. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  124784. */
  124785. set useRightHandedSystem(value: boolean);
  124786. get useRightHandedSystem(): boolean;
  124787. private _timeAccumulator;
  124788. private _currentStepId;
  124789. private _currentInternalStep;
  124790. /**
  124791. * Sets the step Id used by deterministic lock step
  124792. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124793. * @param newStepId defines the step Id
  124794. */
  124795. setStepId(newStepId: number): void;
  124796. /**
  124797. * Gets the step Id used by deterministic lock step
  124798. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124799. * @returns the step Id
  124800. */
  124801. getStepId(): number;
  124802. /**
  124803. * Gets the internal step used by deterministic lock step
  124804. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124805. * @returns the internal step
  124806. */
  124807. getInternalStep(): number;
  124808. private _fogEnabled;
  124809. /**
  124810. * Gets or sets a boolean indicating if fog is enabled on this scene
  124811. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124812. * (Default is true)
  124813. */
  124814. set fogEnabled(value: boolean);
  124815. get fogEnabled(): boolean;
  124816. private _fogMode;
  124817. /**
  124818. * Gets or sets the fog mode to use
  124819. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124820. * | mode | value |
  124821. * | --- | --- |
  124822. * | FOGMODE_NONE | 0 |
  124823. * | FOGMODE_EXP | 1 |
  124824. * | FOGMODE_EXP2 | 2 |
  124825. * | FOGMODE_LINEAR | 3 |
  124826. */
  124827. set fogMode(value: number);
  124828. get fogMode(): number;
  124829. /**
  124830. * Gets or sets the fog color to use
  124831. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124832. * (Default is Color3(0.2, 0.2, 0.3))
  124833. */
  124834. fogColor: Color3;
  124835. /**
  124836. * Gets or sets the fog density to use
  124837. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124838. * (Default is 0.1)
  124839. */
  124840. fogDensity: number;
  124841. /**
  124842. * Gets or sets the fog start distance to use
  124843. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124844. * (Default is 0)
  124845. */
  124846. fogStart: number;
  124847. /**
  124848. * Gets or sets the fog end distance to use
  124849. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124850. * (Default is 1000)
  124851. */
  124852. fogEnd: number;
  124853. /**
  124854. * Flag indicating that the frame buffer binding is handled by another component
  124855. */
  124856. prePass: boolean;
  124857. private _shadowsEnabled;
  124858. /**
  124859. * Gets or sets a boolean indicating if shadows are enabled on this scene
  124860. */
  124861. set shadowsEnabled(value: boolean);
  124862. get shadowsEnabled(): boolean;
  124863. private _lightsEnabled;
  124864. /**
  124865. * Gets or sets a boolean indicating if lights are enabled on this scene
  124866. */
  124867. set lightsEnabled(value: boolean);
  124868. get lightsEnabled(): boolean;
  124869. /** All of the active cameras added to this scene. */
  124870. activeCameras: Camera[];
  124871. /** @hidden */
  124872. _activeCamera: Nullable<Camera>;
  124873. /** Gets or sets the current active camera */
  124874. get activeCamera(): Nullable<Camera>;
  124875. set activeCamera(value: Nullable<Camera>);
  124876. private _defaultMaterial;
  124877. /** The default material used on meshes when no material is affected */
  124878. get defaultMaterial(): Material;
  124879. /** The default material used on meshes when no material is affected */
  124880. set defaultMaterial(value: Material);
  124881. private _texturesEnabled;
  124882. /**
  124883. * Gets or sets a boolean indicating if textures are enabled on this scene
  124884. */
  124885. set texturesEnabled(value: boolean);
  124886. get texturesEnabled(): boolean;
  124887. /**
  124888. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  124889. */
  124890. physicsEnabled: boolean;
  124891. /**
  124892. * Gets or sets a boolean indicating if particles are enabled on this scene
  124893. */
  124894. particlesEnabled: boolean;
  124895. /**
  124896. * Gets or sets a boolean indicating if sprites are enabled on this scene
  124897. */
  124898. spritesEnabled: boolean;
  124899. private _skeletonsEnabled;
  124900. /**
  124901. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  124902. */
  124903. set skeletonsEnabled(value: boolean);
  124904. get skeletonsEnabled(): boolean;
  124905. /**
  124906. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  124907. */
  124908. lensFlaresEnabled: boolean;
  124909. /**
  124910. * Gets or sets a boolean indicating if collisions are enabled on this scene
  124911. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  124912. */
  124913. collisionsEnabled: boolean;
  124914. private _collisionCoordinator;
  124915. /** @hidden */
  124916. get collisionCoordinator(): ICollisionCoordinator;
  124917. /**
  124918. * Defines the gravity applied to this scene (used only for collisions)
  124919. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  124920. */
  124921. gravity: Vector3;
  124922. /**
  124923. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  124924. */
  124925. postProcessesEnabled: boolean;
  124926. /**
  124927. * Gets the current postprocess manager
  124928. */
  124929. postProcessManager: PostProcessManager;
  124930. /**
  124931. * Gets or sets a boolean indicating if render targets are enabled on this scene
  124932. */
  124933. renderTargetsEnabled: boolean;
  124934. /**
  124935. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  124936. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  124937. */
  124938. dumpNextRenderTargets: boolean;
  124939. /**
  124940. * The list of user defined render targets added to the scene
  124941. */
  124942. customRenderTargets: RenderTargetTexture[];
  124943. /**
  124944. * Defines if texture loading must be delayed
  124945. * If true, textures will only be loaded when they need to be rendered
  124946. */
  124947. useDelayedTextureLoading: boolean;
  124948. /**
  124949. * Gets the list of meshes imported to the scene through SceneLoader
  124950. */
  124951. importedMeshesFiles: String[];
  124952. /**
  124953. * Gets or sets a boolean indicating if probes are enabled on this scene
  124954. */
  124955. probesEnabled: boolean;
  124956. /**
  124957. * Gets or sets the current offline provider to use to store scene data
  124958. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  124959. */
  124960. offlineProvider: IOfflineProvider;
  124961. /**
  124962. * Gets or sets the action manager associated with the scene
  124963. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  124964. */
  124965. actionManager: AbstractActionManager;
  124966. private _meshesForIntersections;
  124967. /**
  124968. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  124969. */
  124970. proceduralTexturesEnabled: boolean;
  124971. private _engine;
  124972. private _totalVertices;
  124973. /** @hidden */
  124974. _activeIndices: PerfCounter;
  124975. /** @hidden */
  124976. _activeParticles: PerfCounter;
  124977. /** @hidden */
  124978. _activeBones: PerfCounter;
  124979. private _animationRatio;
  124980. /** @hidden */
  124981. _animationTimeLast: number;
  124982. /** @hidden */
  124983. _animationTime: number;
  124984. /**
  124985. * Gets or sets a general scale for animation speed
  124986. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  124987. */
  124988. animationTimeScale: number;
  124989. /** @hidden */
  124990. _cachedMaterial: Nullable<Material>;
  124991. /** @hidden */
  124992. _cachedEffect: Nullable<Effect>;
  124993. /** @hidden */
  124994. _cachedVisibility: Nullable<number>;
  124995. private _renderId;
  124996. private _frameId;
  124997. private _executeWhenReadyTimeoutId;
  124998. private _intermediateRendering;
  124999. private _viewUpdateFlag;
  125000. private _projectionUpdateFlag;
  125001. /** @hidden */
  125002. _toBeDisposed: Nullable<IDisposable>[];
  125003. private _activeRequests;
  125004. /** @hidden */
  125005. _pendingData: any[];
  125006. private _isDisposed;
  125007. /**
  125008. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  125009. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  125010. */
  125011. dispatchAllSubMeshesOfActiveMeshes: boolean;
  125012. private _activeMeshes;
  125013. private _processedMaterials;
  125014. private _renderTargets;
  125015. /** @hidden */
  125016. _activeParticleSystems: SmartArray<IParticleSystem>;
  125017. private _activeSkeletons;
  125018. private _softwareSkinnedMeshes;
  125019. private _renderingManager;
  125020. /** @hidden */
  125021. _activeAnimatables: Animatable[];
  125022. private _transformMatrix;
  125023. private _sceneUbo;
  125024. /** @hidden */
  125025. _viewMatrix: Matrix;
  125026. private _projectionMatrix;
  125027. /** @hidden */
  125028. _forcedViewPosition: Nullable<Vector3>;
  125029. /** @hidden */
  125030. _frustumPlanes: Plane[];
  125031. /**
  125032. * Gets the list of frustum planes (built from the active camera)
  125033. */
  125034. get frustumPlanes(): Plane[];
  125035. /**
  125036. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  125037. * This is useful if there are more lights that the maximum simulteanous authorized
  125038. */
  125039. requireLightSorting: boolean;
  125040. /** @hidden */
  125041. readonly useMaterialMeshMap: boolean;
  125042. /** @hidden */
  125043. readonly useClonedMeshMap: boolean;
  125044. private _externalData;
  125045. private _uid;
  125046. /**
  125047. * @hidden
  125048. * Backing store of defined scene components.
  125049. */
  125050. _components: ISceneComponent[];
  125051. /**
  125052. * @hidden
  125053. * Backing store of defined scene components.
  125054. */
  125055. _serializableComponents: ISceneSerializableComponent[];
  125056. /**
  125057. * List of components to register on the next registration step.
  125058. */
  125059. private _transientComponents;
  125060. /**
  125061. * Registers the transient components if needed.
  125062. */
  125063. private _registerTransientComponents;
  125064. /**
  125065. * @hidden
  125066. * Add a component to the scene.
  125067. * Note that the ccomponent could be registered on th next frame if this is called after
  125068. * the register component stage.
  125069. * @param component Defines the component to add to the scene
  125070. */
  125071. _addComponent(component: ISceneComponent): void;
  125072. /**
  125073. * @hidden
  125074. * Gets a component from the scene.
  125075. * @param name defines the name of the component to retrieve
  125076. * @returns the component or null if not present
  125077. */
  125078. _getComponent(name: string): Nullable<ISceneComponent>;
  125079. /**
  125080. * @hidden
  125081. * Defines the actions happening before camera updates.
  125082. */
  125083. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  125084. /**
  125085. * @hidden
  125086. * Defines the actions happening before clear the canvas.
  125087. */
  125088. _beforeClearStage: Stage<SimpleStageAction>;
  125089. /**
  125090. * @hidden
  125091. * Defines the actions when collecting render targets for the frame.
  125092. */
  125093. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  125094. /**
  125095. * @hidden
  125096. * Defines the actions happening for one camera in the frame.
  125097. */
  125098. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  125099. /**
  125100. * @hidden
  125101. * Defines the actions happening during the per mesh ready checks.
  125102. */
  125103. _isReadyForMeshStage: Stage<MeshStageAction>;
  125104. /**
  125105. * @hidden
  125106. * Defines the actions happening before evaluate active mesh checks.
  125107. */
  125108. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  125109. /**
  125110. * @hidden
  125111. * Defines the actions happening during the evaluate sub mesh checks.
  125112. */
  125113. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  125114. /**
  125115. * @hidden
  125116. * Defines the actions happening during the active mesh stage.
  125117. */
  125118. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  125119. /**
  125120. * @hidden
  125121. * Defines the actions happening during the per camera render target step.
  125122. */
  125123. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  125124. /**
  125125. * @hidden
  125126. * Defines the actions happening just before the active camera is drawing.
  125127. */
  125128. _beforeCameraDrawStage: Stage<CameraStageAction>;
  125129. /**
  125130. * @hidden
  125131. * Defines the actions happening just before a render target is drawing.
  125132. */
  125133. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  125134. /**
  125135. * @hidden
  125136. * Defines the actions happening just before a rendering group is drawing.
  125137. */
  125138. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  125139. /**
  125140. * @hidden
  125141. * Defines the actions happening just before a mesh is drawing.
  125142. */
  125143. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  125144. /**
  125145. * @hidden
  125146. * Defines the actions happening just after a mesh has been drawn.
  125147. */
  125148. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  125149. /**
  125150. * @hidden
  125151. * Defines the actions happening just after a rendering group has been drawn.
  125152. */
  125153. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  125154. /**
  125155. * @hidden
  125156. * Defines the actions happening just after the active camera has been drawn.
  125157. */
  125158. _afterCameraDrawStage: Stage<CameraStageAction>;
  125159. /**
  125160. * @hidden
  125161. * Defines the actions happening just after a render target has been drawn.
  125162. */
  125163. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  125164. /**
  125165. * @hidden
  125166. * Defines the actions happening just after rendering all cameras and computing intersections.
  125167. */
  125168. _afterRenderStage: Stage<SimpleStageAction>;
  125169. /**
  125170. * @hidden
  125171. * Defines the actions happening when a pointer move event happens.
  125172. */
  125173. _pointerMoveStage: Stage<PointerMoveStageAction>;
  125174. /**
  125175. * @hidden
  125176. * Defines the actions happening when a pointer down event happens.
  125177. */
  125178. _pointerDownStage: Stage<PointerUpDownStageAction>;
  125179. /**
  125180. * @hidden
  125181. * Defines the actions happening when a pointer up event happens.
  125182. */
  125183. _pointerUpStage: Stage<PointerUpDownStageAction>;
  125184. /**
  125185. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  125186. */
  125187. private geometriesByUniqueId;
  125188. /**
  125189. * Creates a new Scene
  125190. * @param engine defines the engine to use to render this scene
  125191. * @param options defines the scene options
  125192. */
  125193. constructor(engine: Engine, options?: SceneOptions);
  125194. /**
  125195. * Gets a string identifying the name of the class
  125196. * @returns "Scene" string
  125197. */
  125198. getClassName(): string;
  125199. private _defaultMeshCandidates;
  125200. /**
  125201. * @hidden
  125202. */
  125203. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  125204. private _defaultSubMeshCandidates;
  125205. /**
  125206. * @hidden
  125207. */
  125208. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  125209. /**
  125210. * Sets the default candidate providers for the scene.
  125211. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  125212. * and getCollidingSubMeshCandidates to their default function
  125213. */
  125214. setDefaultCandidateProviders(): void;
  125215. /**
  125216. * Gets the mesh that is currently under the pointer
  125217. */
  125218. get meshUnderPointer(): Nullable<AbstractMesh>;
  125219. /**
  125220. * Gets or sets the current on-screen X position of the pointer
  125221. */
  125222. get pointerX(): number;
  125223. set pointerX(value: number);
  125224. /**
  125225. * Gets or sets the current on-screen Y position of the pointer
  125226. */
  125227. get pointerY(): number;
  125228. set pointerY(value: number);
  125229. /**
  125230. * Gets the cached material (ie. the latest rendered one)
  125231. * @returns the cached material
  125232. */
  125233. getCachedMaterial(): Nullable<Material>;
  125234. /**
  125235. * Gets the cached effect (ie. the latest rendered one)
  125236. * @returns the cached effect
  125237. */
  125238. getCachedEffect(): Nullable<Effect>;
  125239. /**
  125240. * Gets the cached visibility state (ie. the latest rendered one)
  125241. * @returns the cached visibility state
  125242. */
  125243. getCachedVisibility(): Nullable<number>;
  125244. /**
  125245. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  125246. * @param material defines the current material
  125247. * @param effect defines the current effect
  125248. * @param visibility defines the current visibility state
  125249. * @returns true if one parameter is not cached
  125250. */
  125251. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  125252. /**
  125253. * Gets the engine associated with the scene
  125254. * @returns an Engine
  125255. */
  125256. getEngine(): Engine;
  125257. /**
  125258. * Gets the total number of vertices rendered per frame
  125259. * @returns the total number of vertices rendered per frame
  125260. */
  125261. getTotalVertices(): number;
  125262. /**
  125263. * Gets the performance counter for total vertices
  125264. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125265. */
  125266. get totalVerticesPerfCounter(): PerfCounter;
  125267. /**
  125268. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  125269. * @returns the total number of active indices rendered per frame
  125270. */
  125271. getActiveIndices(): number;
  125272. /**
  125273. * Gets the performance counter for active indices
  125274. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125275. */
  125276. get totalActiveIndicesPerfCounter(): PerfCounter;
  125277. /**
  125278. * Gets the total number of active particles rendered per frame
  125279. * @returns the total number of active particles rendered per frame
  125280. */
  125281. getActiveParticles(): number;
  125282. /**
  125283. * Gets the performance counter for active particles
  125284. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125285. */
  125286. get activeParticlesPerfCounter(): PerfCounter;
  125287. /**
  125288. * Gets the total number of active bones rendered per frame
  125289. * @returns the total number of active bones rendered per frame
  125290. */
  125291. getActiveBones(): number;
  125292. /**
  125293. * Gets the performance counter for active bones
  125294. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125295. */
  125296. get activeBonesPerfCounter(): PerfCounter;
  125297. /**
  125298. * Gets the array of active meshes
  125299. * @returns an array of AbstractMesh
  125300. */
  125301. getActiveMeshes(): SmartArray<AbstractMesh>;
  125302. /**
  125303. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  125304. * @returns a number
  125305. */
  125306. getAnimationRatio(): number;
  125307. /**
  125308. * Gets an unique Id for the current render phase
  125309. * @returns a number
  125310. */
  125311. getRenderId(): number;
  125312. /**
  125313. * Gets an unique Id for the current frame
  125314. * @returns a number
  125315. */
  125316. getFrameId(): number;
  125317. /** Call this function if you want to manually increment the render Id*/
  125318. incrementRenderId(): void;
  125319. private _createUbo;
  125320. /**
  125321. * Use this method to simulate a pointer move on a mesh
  125322. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  125323. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  125324. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  125325. * @returns the current scene
  125326. */
  125327. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  125328. /**
  125329. * Use this method to simulate a pointer down on a mesh
  125330. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  125331. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  125332. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  125333. * @returns the current scene
  125334. */
  125335. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  125336. /**
  125337. * Use this method to simulate a pointer up on a mesh
  125338. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  125339. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  125340. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  125341. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  125342. * @returns the current scene
  125343. */
  125344. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  125345. /**
  125346. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  125347. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  125348. * @returns true if the pointer was captured
  125349. */
  125350. isPointerCaptured(pointerId?: number): boolean;
  125351. /**
  125352. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  125353. * @param attachUp defines if you want to attach events to pointerup
  125354. * @param attachDown defines if you want to attach events to pointerdown
  125355. * @param attachMove defines if you want to attach events to pointermove
  125356. */
  125357. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  125358. /** Detaches all event handlers*/
  125359. detachControl(): void;
  125360. /**
  125361. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  125362. * Delay loaded resources are not taking in account
  125363. * @return true if all required resources are ready
  125364. */
  125365. isReady(): boolean;
  125366. /** Resets all cached information relative to material (including effect and visibility) */
  125367. resetCachedMaterial(): void;
  125368. /**
  125369. * Registers a function to be called before every frame render
  125370. * @param func defines the function to register
  125371. */
  125372. registerBeforeRender(func: () => void): void;
  125373. /**
  125374. * Unregisters a function called before every frame render
  125375. * @param func defines the function to unregister
  125376. */
  125377. unregisterBeforeRender(func: () => void): void;
  125378. /**
  125379. * Registers a function to be called after every frame render
  125380. * @param func defines the function to register
  125381. */
  125382. registerAfterRender(func: () => void): void;
  125383. /**
  125384. * Unregisters a function called after every frame render
  125385. * @param func defines the function to unregister
  125386. */
  125387. unregisterAfterRender(func: () => void): void;
  125388. private _executeOnceBeforeRender;
  125389. /**
  125390. * The provided function will run before render once and will be disposed afterwards.
  125391. * A timeout delay can be provided so that the function will be executed in N ms.
  125392. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  125393. * @param func The function to be executed.
  125394. * @param timeout optional delay in ms
  125395. */
  125396. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  125397. /** @hidden */
  125398. _addPendingData(data: any): void;
  125399. /** @hidden */
  125400. _removePendingData(data: any): void;
  125401. /**
  125402. * Returns the number of items waiting to be loaded
  125403. * @returns the number of items waiting to be loaded
  125404. */
  125405. getWaitingItemsCount(): number;
  125406. /**
  125407. * Returns a boolean indicating if the scene is still loading data
  125408. */
  125409. get isLoading(): boolean;
  125410. /**
  125411. * Registers a function to be executed when the scene is ready
  125412. * @param {Function} func - the function to be executed
  125413. */
  125414. executeWhenReady(func: () => void): void;
  125415. /**
  125416. * Returns a promise that resolves when the scene is ready
  125417. * @returns A promise that resolves when the scene is ready
  125418. */
  125419. whenReadyAsync(): Promise<void>;
  125420. /** @hidden */
  125421. _checkIsReady(): void;
  125422. /**
  125423. * Gets all animatable attached to the scene
  125424. */
  125425. get animatables(): Animatable[];
  125426. /**
  125427. * Resets the last animation time frame.
  125428. * Useful to override when animations start running when loading a scene for the first time.
  125429. */
  125430. resetLastAnimationTimeFrame(): void;
  125431. /**
  125432. * Gets the current view matrix
  125433. * @returns a Matrix
  125434. */
  125435. getViewMatrix(): Matrix;
  125436. /**
  125437. * Gets the current projection matrix
  125438. * @returns a Matrix
  125439. */
  125440. getProjectionMatrix(): Matrix;
  125441. /**
  125442. * Gets the current transform matrix
  125443. * @returns a Matrix made of View * Projection
  125444. */
  125445. getTransformMatrix(): Matrix;
  125446. /**
  125447. * Sets the current transform matrix
  125448. * @param viewL defines the View matrix to use
  125449. * @param projectionL defines the Projection matrix to use
  125450. * @param viewR defines the right View matrix to use (if provided)
  125451. * @param projectionR defines the right Projection matrix to use (if provided)
  125452. */
  125453. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  125454. /**
  125455. * Gets the uniform buffer used to store scene data
  125456. * @returns a UniformBuffer
  125457. */
  125458. getSceneUniformBuffer(): UniformBuffer;
  125459. /**
  125460. * Gets an unique (relatively to the current scene) Id
  125461. * @returns an unique number for the scene
  125462. */
  125463. getUniqueId(): number;
  125464. /**
  125465. * Add a mesh to the list of scene's meshes
  125466. * @param newMesh defines the mesh to add
  125467. * @param recursive if all child meshes should also be added to the scene
  125468. */
  125469. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  125470. /**
  125471. * Remove a mesh for the list of scene's meshes
  125472. * @param toRemove defines the mesh to remove
  125473. * @param recursive if all child meshes should also be removed from the scene
  125474. * @returns the index where the mesh was in the mesh list
  125475. */
  125476. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  125477. /**
  125478. * Add a transform node to the list of scene's transform nodes
  125479. * @param newTransformNode defines the transform node to add
  125480. */
  125481. addTransformNode(newTransformNode: TransformNode): void;
  125482. /**
  125483. * Remove a transform node for the list of scene's transform nodes
  125484. * @param toRemove defines the transform node to remove
  125485. * @returns the index where the transform node was in the transform node list
  125486. */
  125487. removeTransformNode(toRemove: TransformNode): number;
  125488. /**
  125489. * Remove a skeleton for the list of scene's skeletons
  125490. * @param toRemove defines the skeleton to remove
  125491. * @returns the index where the skeleton was in the skeleton list
  125492. */
  125493. removeSkeleton(toRemove: Skeleton): number;
  125494. /**
  125495. * Remove a morph target for the list of scene's morph targets
  125496. * @param toRemove defines the morph target to remove
  125497. * @returns the index where the morph target was in the morph target list
  125498. */
  125499. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  125500. /**
  125501. * Remove a light for the list of scene's lights
  125502. * @param toRemove defines the light to remove
  125503. * @returns the index where the light was in the light list
  125504. */
  125505. removeLight(toRemove: Light): number;
  125506. /**
  125507. * Remove a camera for the list of scene's cameras
  125508. * @param toRemove defines the camera to remove
  125509. * @returns the index where the camera was in the camera list
  125510. */
  125511. removeCamera(toRemove: Camera): number;
  125512. /**
  125513. * Remove a particle system for the list of scene's particle systems
  125514. * @param toRemove defines the particle system to remove
  125515. * @returns the index where the particle system was in the particle system list
  125516. */
  125517. removeParticleSystem(toRemove: IParticleSystem): number;
  125518. /**
  125519. * Remove a animation for the list of scene's animations
  125520. * @param toRemove defines the animation to remove
  125521. * @returns the index where the animation was in the animation list
  125522. */
  125523. removeAnimation(toRemove: Animation): number;
  125524. /**
  125525. * Will stop the animation of the given target
  125526. * @param target - the target
  125527. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  125528. * @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)
  125529. */
  125530. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  125531. /**
  125532. * Removes the given animation group from this scene.
  125533. * @param toRemove The animation group to remove
  125534. * @returns The index of the removed animation group
  125535. */
  125536. removeAnimationGroup(toRemove: AnimationGroup): number;
  125537. /**
  125538. * Removes the given multi-material from this scene.
  125539. * @param toRemove The multi-material to remove
  125540. * @returns The index of the removed multi-material
  125541. */
  125542. removeMultiMaterial(toRemove: MultiMaterial): number;
  125543. /**
  125544. * Removes the given material from this scene.
  125545. * @param toRemove The material to remove
  125546. * @returns The index of the removed material
  125547. */
  125548. removeMaterial(toRemove: Material): number;
  125549. /**
  125550. * Removes the given action manager from this scene.
  125551. * @param toRemove The action manager to remove
  125552. * @returns The index of the removed action manager
  125553. */
  125554. removeActionManager(toRemove: AbstractActionManager): number;
  125555. /**
  125556. * Removes the given texture from this scene.
  125557. * @param toRemove The texture to remove
  125558. * @returns The index of the removed texture
  125559. */
  125560. removeTexture(toRemove: BaseTexture): number;
  125561. /**
  125562. * Adds the given light to this scene
  125563. * @param newLight The light to add
  125564. */
  125565. addLight(newLight: Light): void;
  125566. /**
  125567. * Sorts the list list based on light priorities
  125568. */
  125569. sortLightsByPriority(): void;
  125570. /**
  125571. * Adds the given camera to this scene
  125572. * @param newCamera The camera to add
  125573. */
  125574. addCamera(newCamera: Camera): void;
  125575. /**
  125576. * Adds the given skeleton to this scene
  125577. * @param newSkeleton The skeleton to add
  125578. */
  125579. addSkeleton(newSkeleton: Skeleton): void;
  125580. /**
  125581. * Adds the given particle system to this scene
  125582. * @param newParticleSystem The particle system to add
  125583. */
  125584. addParticleSystem(newParticleSystem: IParticleSystem): void;
  125585. /**
  125586. * Adds the given animation to this scene
  125587. * @param newAnimation The animation to add
  125588. */
  125589. addAnimation(newAnimation: Animation): void;
  125590. /**
  125591. * Adds the given animation group to this scene.
  125592. * @param newAnimationGroup The animation group to add
  125593. */
  125594. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  125595. /**
  125596. * Adds the given multi-material to this scene
  125597. * @param newMultiMaterial The multi-material to add
  125598. */
  125599. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  125600. /**
  125601. * Adds the given material to this scene
  125602. * @param newMaterial The material to add
  125603. */
  125604. addMaterial(newMaterial: Material): void;
  125605. /**
  125606. * Adds the given morph target to this scene
  125607. * @param newMorphTargetManager The morph target to add
  125608. */
  125609. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  125610. /**
  125611. * Adds the given geometry to this scene
  125612. * @param newGeometry The geometry to add
  125613. */
  125614. addGeometry(newGeometry: Geometry): void;
  125615. /**
  125616. * Adds the given action manager to this scene
  125617. * @param newActionManager The action manager to add
  125618. */
  125619. addActionManager(newActionManager: AbstractActionManager): void;
  125620. /**
  125621. * Adds the given texture to this scene.
  125622. * @param newTexture The texture to add
  125623. */
  125624. addTexture(newTexture: BaseTexture): void;
  125625. /**
  125626. * Switch active camera
  125627. * @param newCamera defines the new active camera
  125628. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  125629. */
  125630. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  125631. /**
  125632. * sets the active camera of the scene using its ID
  125633. * @param id defines the camera's ID
  125634. * @return the new active camera or null if none found.
  125635. */
  125636. setActiveCameraByID(id: string): Nullable<Camera>;
  125637. /**
  125638. * sets the active camera of the scene using its name
  125639. * @param name defines the camera's name
  125640. * @returns the new active camera or null if none found.
  125641. */
  125642. setActiveCameraByName(name: string): Nullable<Camera>;
  125643. /**
  125644. * get an animation group using its name
  125645. * @param name defines the material's name
  125646. * @return the animation group or null if none found.
  125647. */
  125648. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  125649. /**
  125650. * Get a material using its unique id
  125651. * @param uniqueId defines the material's unique id
  125652. * @return the material or null if none found.
  125653. */
  125654. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  125655. /**
  125656. * get a material using its id
  125657. * @param id defines the material's ID
  125658. * @return the material or null if none found.
  125659. */
  125660. getMaterialByID(id: string): Nullable<Material>;
  125661. /**
  125662. * Gets a the last added material using a given id
  125663. * @param id defines the material's ID
  125664. * @return the last material with the given id or null if none found.
  125665. */
  125666. getLastMaterialByID(id: string): Nullable<Material>;
  125667. /**
  125668. * Gets a material using its name
  125669. * @param name defines the material's name
  125670. * @return the material or null if none found.
  125671. */
  125672. getMaterialByName(name: string): Nullable<Material>;
  125673. /**
  125674. * Get a texture using its unique id
  125675. * @param uniqueId defines the texture's unique id
  125676. * @return the texture or null if none found.
  125677. */
  125678. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  125679. /**
  125680. * Gets a camera using its id
  125681. * @param id defines the id to look for
  125682. * @returns the camera or null if not found
  125683. */
  125684. getCameraByID(id: string): Nullable<Camera>;
  125685. /**
  125686. * Gets a camera using its unique id
  125687. * @param uniqueId defines the unique id to look for
  125688. * @returns the camera or null if not found
  125689. */
  125690. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  125691. /**
  125692. * Gets a camera using its name
  125693. * @param name defines the camera's name
  125694. * @return the camera or null if none found.
  125695. */
  125696. getCameraByName(name: string): Nullable<Camera>;
  125697. /**
  125698. * Gets a bone using its id
  125699. * @param id defines the bone's id
  125700. * @return the bone or null if not found
  125701. */
  125702. getBoneByID(id: string): Nullable<Bone>;
  125703. /**
  125704. * Gets a bone using its id
  125705. * @param name defines the bone's name
  125706. * @return the bone or null if not found
  125707. */
  125708. getBoneByName(name: string): Nullable<Bone>;
  125709. /**
  125710. * Gets a light node using its name
  125711. * @param name defines the the light's name
  125712. * @return the light or null if none found.
  125713. */
  125714. getLightByName(name: string): Nullable<Light>;
  125715. /**
  125716. * Gets a light node using its id
  125717. * @param id defines the light's id
  125718. * @return the light or null if none found.
  125719. */
  125720. getLightByID(id: string): Nullable<Light>;
  125721. /**
  125722. * Gets a light node using its scene-generated unique ID
  125723. * @param uniqueId defines the light's unique id
  125724. * @return the light or null if none found.
  125725. */
  125726. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  125727. /**
  125728. * Gets a particle system by id
  125729. * @param id defines the particle system id
  125730. * @return the corresponding system or null if none found
  125731. */
  125732. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  125733. /**
  125734. * Gets a geometry using its ID
  125735. * @param id defines the geometry's id
  125736. * @return the geometry or null if none found.
  125737. */
  125738. getGeometryByID(id: string): Nullable<Geometry>;
  125739. private _getGeometryByUniqueID;
  125740. /**
  125741. * Add a new geometry to this scene
  125742. * @param geometry defines the geometry to be added to the scene.
  125743. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  125744. * @return a boolean defining if the geometry was added or not
  125745. */
  125746. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  125747. /**
  125748. * Removes an existing geometry
  125749. * @param geometry defines the geometry to be removed from the scene
  125750. * @return a boolean defining if the geometry was removed or not
  125751. */
  125752. removeGeometry(geometry: Geometry): boolean;
  125753. /**
  125754. * Gets the list of geometries attached to the scene
  125755. * @returns an array of Geometry
  125756. */
  125757. getGeometries(): Geometry[];
  125758. /**
  125759. * Gets the first added mesh found of a given ID
  125760. * @param id defines the id to search for
  125761. * @return the mesh found or null if not found at all
  125762. */
  125763. getMeshByID(id: string): Nullable<AbstractMesh>;
  125764. /**
  125765. * Gets a list of meshes using their id
  125766. * @param id defines the id to search for
  125767. * @returns a list of meshes
  125768. */
  125769. getMeshesByID(id: string): Array<AbstractMesh>;
  125770. /**
  125771. * Gets the first added transform node found of a given ID
  125772. * @param id defines the id to search for
  125773. * @return the found transform node or null if not found at all.
  125774. */
  125775. getTransformNodeByID(id: string): Nullable<TransformNode>;
  125776. /**
  125777. * Gets a transform node with its auto-generated unique id
  125778. * @param uniqueId efines the unique id to search for
  125779. * @return the found transform node or null if not found at all.
  125780. */
  125781. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  125782. /**
  125783. * Gets a list of transform nodes using their id
  125784. * @param id defines the id to search for
  125785. * @returns a list of transform nodes
  125786. */
  125787. getTransformNodesByID(id: string): Array<TransformNode>;
  125788. /**
  125789. * Gets a mesh with its auto-generated unique id
  125790. * @param uniqueId defines the unique id to search for
  125791. * @return the found mesh or null if not found at all.
  125792. */
  125793. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  125794. /**
  125795. * Gets a the last added mesh using a given id
  125796. * @param id defines the id to search for
  125797. * @return the found mesh or null if not found at all.
  125798. */
  125799. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  125800. /**
  125801. * Gets a the last added node (Mesh, Camera, Light) using a given id
  125802. * @param id defines the id to search for
  125803. * @return the found node or null if not found at all
  125804. */
  125805. getLastEntryByID(id: string): Nullable<Node>;
  125806. /**
  125807. * Gets a node (Mesh, Camera, Light) using a given id
  125808. * @param id defines the id to search for
  125809. * @return the found node or null if not found at all
  125810. */
  125811. getNodeByID(id: string): Nullable<Node>;
  125812. /**
  125813. * Gets a node (Mesh, Camera, Light) using a given name
  125814. * @param name defines the name to search for
  125815. * @return the found node or null if not found at all.
  125816. */
  125817. getNodeByName(name: string): Nullable<Node>;
  125818. /**
  125819. * Gets a mesh using a given name
  125820. * @param name defines the name to search for
  125821. * @return the found mesh or null if not found at all.
  125822. */
  125823. getMeshByName(name: string): Nullable<AbstractMesh>;
  125824. /**
  125825. * Gets a transform node using a given name
  125826. * @param name defines the name to search for
  125827. * @return the found transform node or null if not found at all.
  125828. */
  125829. getTransformNodeByName(name: string): Nullable<TransformNode>;
  125830. /**
  125831. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  125832. * @param id defines the id to search for
  125833. * @return the found skeleton or null if not found at all.
  125834. */
  125835. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  125836. /**
  125837. * Gets a skeleton using a given auto generated unique id
  125838. * @param uniqueId defines the unique id to search for
  125839. * @return the found skeleton or null if not found at all.
  125840. */
  125841. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  125842. /**
  125843. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  125844. * @param id defines the id to search for
  125845. * @return the found skeleton or null if not found at all.
  125846. */
  125847. getSkeletonById(id: string): Nullable<Skeleton>;
  125848. /**
  125849. * Gets a skeleton using a given name
  125850. * @param name defines the name to search for
  125851. * @return the found skeleton or null if not found at all.
  125852. */
  125853. getSkeletonByName(name: string): Nullable<Skeleton>;
  125854. /**
  125855. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  125856. * @param id defines the id to search for
  125857. * @return the found morph target manager or null if not found at all.
  125858. */
  125859. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  125860. /**
  125861. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  125862. * @param id defines the id to search for
  125863. * @return the found morph target or null if not found at all.
  125864. */
  125865. getMorphTargetById(id: string): Nullable<MorphTarget>;
  125866. /**
  125867. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  125868. * @param name defines the name to search for
  125869. * @return the found morph target or null if not found at all.
  125870. */
  125871. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  125872. /**
  125873. * Gets a post process using a given name (if many are found, this function will pick the first one)
  125874. * @param name defines the name to search for
  125875. * @return the found post process or null if not found at all.
  125876. */
  125877. getPostProcessByName(name: string): Nullable<PostProcess>;
  125878. /**
  125879. * Gets a boolean indicating if the given mesh is active
  125880. * @param mesh defines the mesh to look for
  125881. * @returns true if the mesh is in the active list
  125882. */
  125883. isActiveMesh(mesh: AbstractMesh): boolean;
  125884. /**
  125885. * Return a unique id as a string which can serve as an identifier for the scene
  125886. */
  125887. get uid(): string;
  125888. /**
  125889. * Add an externaly attached data from its key.
  125890. * This method call will fail and return false, if such key already exists.
  125891. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  125892. * @param key the unique key that identifies the data
  125893. * @param data the data object to associate to the key for this Engine instance
  125894. * @return true if no such key were already present and the data was added successfully, false otherwise
  125895. */
  125896. addExternalData<T>(key: string, data: T): boolean;
  125897. /**
  125898. * Get an externaly attached data from its key
  125899. * @param key the unique key that identifies the data
  125900. * @return the associated data, if present (can be null), or undefined if not present
  125901. */
  125902. getExternalData<T>(key: string): Nullable<T>;
  125903. /**
  125904. * Get an externaly attached data from its key, create it using a factory if it's not already present
  125905. * @param key the unique key that identifies the data
  125906. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  125907. * @return the associated data, can be null if the factory returned null.
  125908. */
  125909. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  125910. /**
  125911. * Remove an externaly attached data from the Engine instance
  125912. * @param key the unique key that identifies the data
  125913. * @return true if the data was successfully removed, false if it doesn't exist
  125914. */
  125915. removeExternalData(key: string): boolean;
  125916. private _evaluateSubMesh;
  125917. /**
  125918. * Clear the processed materials smart array preventing retention point in material dispose.
  125919. */
  125920. freeProcessedMaterials(): void;
  125921. private _preventFreeActiveMeshesAndRenderingGroups;
  125922. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  125923. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  125924. * when disposing several meshes in a row or a hierarchy of meshes.
  125925. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  125926. */
  125927. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  125928. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  125929. /**
  125930. * Clear the active meshes smart array preventing retention point in mesh dispose.
  125931. */
  125932. freeActiveMeshes(): void;
  125933. /**
  125934. * Clear the info related to rendering groups preventing retention points during dispose.
  125935. */
  125936. freeRenderingGroups(): void;
  125937. /** @hidden */
  125938. _isInIntermediateRendering(): boolean;
  125939. /**
  125940. * Lambda returning the list of potentially active meshes.
  125941. */
  125942. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  125943. /**
  125944. * Lambda returning the list of potentially active sub meshes.
  125945. */
  125946. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  125947. /**
  125948. * Lambda returning the list of potentially intersecting sub meshes.
  125949. */
  125950. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  125951. /**
  125952. * Lambda returning the list of potentially colliding sub meshes.
  125953. */
  125954. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  125955. private _activeMeshesFrozen;
  125956. private _skipEvaluateActiveMeshesCompletely;
  125957. /**
  125958. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  125959. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  125960. * @param onSuccess optional success callback
  125961. * @param onError optional error callback
  125962. * @returns the current scene
  125963. */
  125964. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  125965. /**
  125966. * Use this function to restart evaluating active meshes on every frame
  125967. * @returns the current scene
  125968. */
  125969. unfreezeActiveMeshes(): Scene;
  125970. private _evaluateActiveMeshes;
  125971. private _activeMesh;
  125972. /**
  125973. * Update the transform matrix to update from the current active camera
  125974. * @param force defines a boolean used to force the update even if cache is up to date
  125975. */
  125976. updateTransformMatrix(force?: boolean): void;
  125977. private _bindFrameBuffer;
  125978. /** @hidden */
  125979. _allowPostProcessClearColor: boolean;
  125980. /** @hidden */
  125981. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  125982. private _processSubCameras;
  125983. private _checkIntersections;
  125984. /** @hidden */
  125985. _advancePhysicsEngineStep(step: number): void;
  125986. /**
  125987. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  125988. */
  125989. getDeterministicFrameTime: () => number;
  125990. /** @hidden */
  125991. _animate(): void;
  125992. /** Execute all animations (for a frame) */
  125993. animate(): void;
  125994. /**
  125995. * Render the scene
  125996. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  125997. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  125998. */
  125999. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  126000. /**
  126001. * Freeze all materials
  126002. * A frozen material will not be updatable but should be faster to render
  126003. */
  126004. freezeMaterials(): void;
  126005. /**
  126006. * Unfreeze all materials
  126007. * A frozen material will not be updatable but should be faster to render
  126008. */
  126009. unfreezeMaterials(): void;
  126010. /**
  126011. * Releases all held ressources
  126012. */
  126013. dispose(): void;
  126014. /**
  126015. * Gets if the scene is already disposed
  126016. */
  126017. get isDisposed(): boolean;
  126018. /**
  126019. * Call this function to reduce memory footprint of the scene.
  126020. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  126021. */
  126022. clearCachedVertexData(): void;
  126023. /**
  126024. * This function will remove the local cached buffer data from texture.
  126025. * It will save memory but will prevent the texture from being rebuilt
  126026. */
  126027. cleanCachedTextureBuffer(): void;
  126028. /**
  126029. * Get the world extend vectors with an optional filter
  126030. *
  126031. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  126032. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  126033. */
  126034. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  126035. min: Vector3;
  126036. max: Vector3;
  126037. };
  126038. /**
  126039. * Creates a ray that can be used to pick in the scene
  126040. * @param x defines the x coordinate of the origin (on-screen)
  126041. * @param y defines the y coordinate of the origin (on-screen)
  126042. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  126043. * @param camera defines the camera to use for the picking
  126044. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  126045. * @returns a Ray
  126046. */
  126047. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  126048. /**
  126049. * Creates a ray that can be used to pick in the scene
  126050. * @param x defines the x coordinate of the origin (on-screen)
  126051. * @param y defines the y coordinate of the origin (on-screen)
  126052. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  126053. * @param result defines the ray where to store the picking ray
  126054. * @param camera defines the camera to use for the picking
  126055. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  126056. * @returns the current scene
  126057. */
  126058. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  126059. /**
  126060. * Creates a ray that can be used to pick in the scene
  126061. * @param x defines the x coordinate of the origin (on-screen)
  126062. * @param y defines the y coordinate of the origin (on-screen)
  126063. * @param camera defines the camera to use for the picking
  126064. * @returns a Ray
  126065. */
  126066. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  126067. /**
  126068. * Creates a ray that can be used to pick in the scene
  126069. * @param x defines the x coordinate of the origin (on-screen)
  126070. * @param y defines the y coordinate of the origin (on-screen)
  126071. * @param result defines the ray where to store the picking ray
  126072. * @param camera defines the camera to use for the picking
  126073. * @returns the current scene
  126074. */
  126075. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  126076. /** Launch a ray to try to pick a mesh in the scene
  126077. * @param x position on screen
  126078. * @param y position on screen
  126079. * @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
  126080. * @param fastCheck defines if the first intersection will be used (and not the closest)
  126081. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  126082. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126083. * @returns a PickingInfo
  126084. */
  126085. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  126086. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  126087. * @param x position on screen
  126088. * @param y position on screen
  126089. * @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
  126090. * @param fastCheck defines if the first intersection will be used (and not the closest)
  126091. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  126092. * @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)
  126093. */
  126094. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  126095. /** Use the given ray to pick a mesh in the scene
  126096. * @param ray The ray to use to pick meshes
  126097. * @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
  126098. * @param fastCheck defines if the first intersection will be used (and not the closest)
  126099. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126100. * @returns a PickingInfo
  126101. */
  126102. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  126103. /**
  126104. * Launch a ray to try to pick a mesh in the scene
  126105. * @param x X position on screen
  126106. * @param y Y position on screen
  126107. * @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
  126108. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  126109. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126110. * @returns an array of PickingInfo
  126111. */
  126112. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  126113. /**
  126114. * Launch a ray to try to pick a mesh in the scene
  126115. * @param ray Ray to use
  126116. * @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
  126117. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126118. * @returns an array of PickingInfo
  126119. */
  126120. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  126121. /**
  126122. * Force the value of meshUnderPointer
  126123. * @param mesh defines the mesh to use
  126124. * @param pointerId optional pointer id when using more than one pointer
  126125. */
  126126. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  126127. /**
  126128. * Gets the mesh under the pointer
  126129. * @returns a Mesh or null if no mesh is under the pointer
  126130. */
  126131. getPointerOverMesh(): Nullable<AbstractMesh>;
  126132. /** @hidden */
  126133. _rebuildGeometries(): void;
  126134. /** @hidden */
  126135. _rebuildTextures(): void;
  126136. private _getByTags;
  126137. /**
  126138. * Get a list of meshes by tags
  126139. * @param tagsQuery defines the tags query to use
  126140. * @param forEach defines a predicate used to filter results
  126141. * @returns an array of Mesh
  126142. */
  126143. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  126144. /**
  126145. * Get a list of cameras by tags
  126146. * @param tagsQuery defines the tags query to use
  126147. * @param forEach defines a predicate used to filter results
  126148. * @returns an array of Camera
  126149. */
  126150. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  126151. /**
  126152. * Get a list of lights by tags
  126153. * @param tagsQuery defines the tags query to use
  126154. * @param forEach defines a predicate used to filter results
  126155. * @returns an array of Light
  126156. */
  126157. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  126158. /**
  126159. * Get a list of materials by tags
  126160. * @param tagsQuery defines the tags query to use
  126161. * @param forEach defines a predicate used to filter results
  126162. * @returns an array of Material
  126163. */
  126164. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  126165. /**
  126166. * Get a list of transform nodes by tags
  126167. * @param tagsQuery defines the tags query to use
  126168. * @param forEach defines a predicate used to filter results
  126169. * @returns an array of TransformNode
  126170. */
  126171. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  126172. /**
  126173. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  126174. * This allowed control for front to back rendering or reversly depending of the special needs.
  126175. *
  126176. * @param renderingGroupId The rendering group id corresponding to its index
  126177. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  126178. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  126179. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  126180. */
  126181. 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;
  126182. /**
  126183. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  126184. *
  126185. * @param renderingGroupId The rendering group id corresponding to its index
  126186. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  126187. * @param depth Automatically clears depth between groups if true and autoClear is true.
  126188. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  126189. */
  126190. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  126191. /**
  126192. * Gets the current auto clear configuration for one rendering group of the rendering
  126193. * manager.
  126194. * @param index the rendering group index to get the information for
  126195. * @returns The auto clear setup for the requested rendering group
  126196. */
  126197. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  126198. private _blockMaterialDirtyMechanism;
  126199. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  126200. get blockMaterialDirtyMechanism(): boolean;
  126201. set blockMaterialDirtyMechanism(value: boolean);
  126202. /**
  126203. * Will flag all materials as dirty to trigger new shader compilation
  126204. * @param flag defines the flag used to specify which material part must be marked as dirty
  126205. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  126206. */
  126207. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  126208. /** @hidden */
  126209. _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;
  126210. /** @hidden */
  126211. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  126212. /** @hidden */
  126213. _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;
  126214. /** @hidden */
  126215. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  126216. /** @hidden */
  126217. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  126218. /** @hidden */
  126219. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  126220. }
  126221. }
  126222. declare module BABYLON {
  126223. /**
  126224. * Set of assets to keep when moving a scene into an asset container.
  126225. */
  126226. export class KeepAssets extends AbstractScene {
  126227. }
  126228. /**
  126229. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  126230. */
  126231. export class InstantiatedEntries {
  126232. /**
  126233. * List of new root nodes (eg. nodes with no parent)
  126234. */
  126235. rootNodes: TransformNode[];
  126236. /**
  126237. * List of new skeletons
  126238. */
  126239. skeletons: Skeleton[];
  126240. /**
  126241. * List of new animation groups
  126242. */
  126243. animationGroups: AnimationGroup[];
  126244. }
  126245. /**
  126246. * Container with a set of assets that can be added or removed from a scene.
  126247. */
  126248. export class AssetContainer extends AbstractScene {
  126249. private _wasAddedToScene;
  126250. /**
  126251. * The scene the AssetContainer belongs to.
  126252. */
  126253. scene: Scene;
  126254. /**
  126255. * Instantiates an AssetContainer.
  126256. * @param scene The scene the AssetContainer belongs to.
  126257. */
  126258. constructor(scene: Scene);
  126259. /**
  126260. * Instantiate or clone all meshes and add the new ones to the scene.
  126261. * Skeletons and animation groups will all be cloned
  126262. * @param nameFunction defines an optional function used to get new names for clones
  126263. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  126264. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  126265. */
  126266. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  126267. /**
  126268. * Adds all the assets from the container to the scene.
  126269. */
  126270. addAllToScene(): void;
  126271. /**
  126272. * Removes all the assets in the container from the scene
  126273. */
  126274. removeAllFromScene(): void;
  126275. /**
  126276. * Disposes all the assets in the container
  126277. */
  126278. dispose(): void;
  126279. private _moveAssets;
  126280. /**
  126281. * Removes all the assets contained in the scene and adds them to the container.
  126282. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  126283. */
  126284. moveAllFromScene(keepAssets?: KeepAssets): void;
  126285. /**
  126286. * 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.
  126287. * @returns the root mesh
  126288. */
  126289. createRootMesh(): Mesh;
  126290. /**
  126291. * Merge animations (direct and animation groups) from this asset container into a scene
  126292. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126293. * @param animatables set of animatables to retarget to a node from the scene
  126294. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  126295. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  126296. */
  126297. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  126298. }
  126299. }
  126300. declare module BABYLON {
  126301. /**
  126302. * Defines how the parser contract is defined.
  126303. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  126304. */
  126305. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  126306. /**
  126307. * Defines how the individual parser contract is defined.
  126308. * These parser can parse an individual asset
  126309. */
  126310. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  126311. /**
  126312. * Base class of the scene acting as a container for the different elements composing a scene.
  126313. * This class is dynamically extended by the different components of the scene increasing
  126314. * flexibility and reducing coupling
  126315. */
  126316. export abstract class AbstractScene {
  126317. /**
  126318. * Stores the list of available parsers in the application.
  126319. */
  126320. private static _BabylonFileParsers;
  126321. /**
  126322. * Stores the list of available individual parsers in the application.
  126323. */
  126324. private static _IndividualBabylonFileParsers;
  126325. /**
  126326. * Adds a parser in the list of available ones
  126327. * @param name Defines the name of the parser
  126328. * @param parser Defines the parser to add
  126329. */
  126330. static AddParser(name: string, parser: BabylonFileParser): void;
  126331. /**
  126332. * Gets a general parser from the list of avaialble ones
  126333. * @param name Defines the name of the parser
  126334. * @returns the requested parser or null
  126335. */
  126336. static GetParser(name: string): Nullable<BabylonFileParser>;
  126337. /**
  126338. * Adds n individual parser in the list of available ones
  126339. * @param name Defines the name of the parser
  126340. * @param parser Defines the parser to add
  126341. */
  126342. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  126343. /**
  126344. * Gets an individual parser from the list of avaialble ones
  126345. * @param name Defines the name of the parser
  126346. * @returns the requested parser or null
  126347. */
  126348. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  126349. /**
  126350. * Parser json data and populate both a scene and its associated container object
  126351. * @param jsonData Defines the data to parse
  126352. * @param scene Defines the scene to parse the data for
  126353. * @param container Defines the container attached to the parsing sequence
  126354. * @param rootUrl Defines the root url of the data
  126355. */
  126356. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  126357. /**
  126358. * Gets the list of root nodes (ie. nodes with no parent)
  126359. */
  126360. rootNodes: Node[];
  126361. /** All of the cameras added to this scene
  126362. * @see https://doc.babylonjs.com/babylon101/cameras
  126363. */
  126364. cameras: Camera[];
  126365. /**
  126366. * All of the lights added to this scene
  126367. * @see https://doc.babylonjs.com/babylon101/lights
  126368. */
  126369. lights: Light[];
  126370. /**
  126371. * All of the (abstract) meshes added to this scene
  126372. */
  126373. meshes: AbstractMesh[];
  126374. /**
  126375. * The list of skeletons added to the scene
  126376. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  126377. */
  126378. skeletons: Skeleton[];
  126379. /**
  126380. * All of the particle systems added to this scene
  126381. * @see https://doc.babylonjs.com/babylon101/particles
  126382. */
  126383. particleSystems: IParticleSystem[];
  126384. /**
  126385. * Gets a list of Animations associated with the scene
  126386. */
  126387. animations: Animation[];
  126388. /**
  126389. * All of the animation groups added to this scene
  126390. * @see https://doc.babylonjs.com/how_to/group
  126391. */
  126392. animationGroups: AnimationGroup[];
  126393. /**
  126394. * All of the multi-materials added to this scene
  126395. * @see https://doc.babylonjs.com/how_to/multi_materials
  126396. */
  126397. multiMaterials: MultiMaterial[];
  126398. /**
  126399. * All of the materials added to this scene
  126400. * In the context of a Scene, it is not supposed to be modified manually.
  126401. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  126402. * Note also that the order of the Material within the array is not significant and might change.
  126403. * @see https://doc.babylonjs.com/babylon101/materials
  126404. */
  126405. materials: Material[];
  126406. /**
  126407. * The list of morph target managers added to the scene
  126408. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  126409. */
  126410. morphTargetManagers: MorphTargetManager[];
  126411. /**
  126412. * The list of geometries used in the scene.
  126413. */
  126414. geometries: Geometry[];
  126415. /**
  126416. * All of the tranform nodes added to this scene
  126417. * In the context of a Scene, it is not supposed to be modified manually.
  126418. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  126419. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  126420. * @see https://doc.babylonjs.com/how_to/transformnode
  126421. */
  126422. transformNodes: TransformNode[];
  126423. /**
  126424. * ActionManagers available on the scene.
  126425. */
  126426. actionManagers: AbstractActionManager[];
  126427. /**
  126428. * Textures to keep.
  126429. */
  126430. textures: BaseTexture[];
  126431. /** @hidden */
  126432. protected _environmentTexture: Nullable<BaseTexture>;
  126433. /**
  126434. * Texture used in all pbr material as the reflection texture.
  126435. * As in the majority of the scene they are the same (exception for multi room and so on),
  126436. * this is easier to reference from here than from all the materials.
  126437. */
  126438. get environmentTexture(): Nullable<BaseTexture>;
  126439. set environmentTexture(value: Nullable<BaseTexture>);
  126440. /**
  126441. * The list of postprocesses added to the scene
  126442. */
  126443. postProcesses: PostProcess[];
  126444. /**
  126445. * @returns all meshes, lights, cameras, transformNodes and bones
  126446. */
  126447. getNodes(): Array<Node>;
  126448. }
  126449. }
  126450. declare module BABYLON {
  126451. /**
  126452. * Interface used to define options for Sound class
  126453. */
  126454. export interface ISoundOptions {
  126455. /**
  126456. * Does the sound autoplay once loaded.
  126457. */
  126458. autoplay?: boolean;
  126459. /**
  126460. * Does the sound loop after it finishes playing once.
  126461. */
  126462. loop?: boolean;
  126463. /**
  126464. * Sound's volume
  126465. */
  126466. volume?: number;
  126467. /**
  126468. * Is it a spatial sound?
  126469. */
  126470. spatialSound?: boolean;
  126471. /**
  126472. * Maximum distance to hear that sound
  126473. */
  126474. maxDistance?: number;
  126475. /**
  126476. * Uses user defined attenuation function
  126477. */
  126478. useCustomAttenuation?: boolean;
  126479. /**
  126480. * Define the roll off factor of spatial sounds.
  126481. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126482. */
  126483. rolloffFactor?: number;
  126484. /**
  126485. * Define the reference distance the sound should be heard perfectly.
  126486. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126487. */
  126488. refDistance?: number;
  126489. /**
  126490. * Define the distance attenuation model the sound will follow.
  126491. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126492. */
  126493. distanceModel?: string;
  126494. /**
  126495. * Defines the playback speed (1 by default)
  126496. */
  126497. playbackRate?: number;
  126498. /**
  126499. * Defines if the sound is from a streaming source
  126500. */
  126501. streaming?: boolean;
  126502. /**
  126503. * Defines an optional length (in seconds) inside the sound file
  126504. */
  126505. length?: number;
  126506. /**
  126507. * Defines an optional offset (in seconds) inside the sound file
  126508. */
  126509. offset?: number;
  126510. /**
  126511. * If true, URLs will not be required to state the audio file codec to use.
  126512. */
  126513. skipCodecCheck?: boolean;
  126514. }
  126515. }
  126516. declare module BABYLON {
  126517. /**
  126518. * Defines a sound that can be played in the application.
  126519. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  126520. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126521. */
  126522. export class Sound {
  126523. /**
  126524. * The name of the sound in the scene.
  126525. */
  126526. name: string;
  126527. /**
  126528. * Does the sound autoplay once loaded.
  126529. */
  126530. autoplay: boolean;
  126531. /**
  126532. * Does the sound loop after it finishes playing once.
  126533. */
  126534. loop: boolean;
  126535. /**
  126536. * Does the sound use a custom attenuation curve to simulate the falloff
  126537. * happening when the source gets further away from the camera.
  126538. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  126539. */
  126540. useCustomAttenuation: boolean;
  126541. /**
  126542. * The sound track id this sound belongs to.
  126543. */
  126544. soundTrackId: number;
  126545. /**
  126546. * Is this sound currently played.
  126547. */
  126548. isPlaying: boolean;
  126549. /**
  126550. * Is this sound currently paused.
  126551. */
  126552. isPaused: boolean;
  126553. /**
  126554. * Does this sound enables spatial sound.
  126555. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126556. */
  126557. spatialSound: boolean;
  126558. /**
  126559. * Define the reference distance the sound should be heard perfectly.
  126560. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126561. */
  126562. refDistance: number;
  126563. /**
  126564. * Define the roll off factor of spatial sounds.
  126565. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126566. */
  126567. rolloffFactor: number;
  126568. /**
  126569. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  126570. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126571. */
  126572. maxDistance: number;
  126573. /**
  126574. * Define the distance attenuation model the sound will follow.
  126575. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126576. */
  126577. distanceModel: string;
  126578. /**
  126579. * @hidden
  126580. * Back Compat
  126581. **/
  126582. onended: () => any;
  126583. /**
  126584. * Gets or sets an object used to store user defined information for the sound.
  126585. */
  126586. metadata: any;
  126587. /**
  126588. * Observable event when the current playing sound finishes.
  126589. */
  126590. onEndedObservable: Observable<Sound>;
  126591. /**
  126592. * Gets the current time for the sound.
  126593. */
  126594. get currentTime(): number;
  126595. private _panningModel;
  126596. private _playbackRate;
  126597. private _streaming;
  126598. private _startTime;
  126599. private _startOffset;
  126600. private _position;
  126601. /** @hidden */
  126602. _positionInEmitterSpace: boolean;
  126603. private _localDirection;
  126604. private _volume;
  126605. private _isReadyToPlay;
  126606. private _isDirectional;
  126607. private _readyToPlayCallback;
  126608. private _audioBuffer;
  126609. private _soundSource;
  126610. private _streamingSource;
  126611. private _soundPanner;
  126612. private _soundGain;
  126613. private _inputAudioNode;
  126614. private _outputAudioNode;
  126615. private _coneInnerAngle;
  126616. private _coneOuterAngle;
  126617. private _coneOuterGain;
  126618. private _scene;
  126619. private _connectedTransformNode;
  126620. private _customAttenuationFunction;
  126621. private _registerFunc;
  126622. private _isOutputConnected;
  126623. private _htmlAudioElement;
  126624. private _urlType;
  126625. private _length?;
  126626. private _offset?;
  126627. /** @hidden */
  126628. static _SceneComponentInitialization: (scene: Scene) => void;
  126629. /**
  126630. * Create a sound and attach it to a scene
  126631. * @param name Name of your sound
  126632. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  126633. * @param scene defines the scene the sound belongs to
  126634. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  126635. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  126636. */
  126637. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  126638. /**
  126639. * Release the sound and its associated resources
  126640. */
  126641. dispose(): void;
  126642. /**
  126643. * Gets if the sounds is ready to be played or not.
  126644. * @returns true if ready, otherwise false
  126645. */
  126646. isReady(): boolean;
  126647. private _soundLoaded;
  126648. /**
  126649. * Sets the data of the sound from an audiobuffer
  126650. * @param audioBuffer The audioBuffer containing the data
  126651. */
  126652. setAudioBuffer(audioBuffer: AudioBuffer): void;
  126653. /**
  126654. * Updates the current sounds options such as maxdistance, loop...
  126655. * @param options A JSON object containing values named as the object properties
  126656. */
  126657. updateOptions(options: ISoundOptions): void;
  126658. private _createSpatialParameters;
  126659. private _updateSpatialParameters;
  126660. /**
  126661. * Switch the panning model to HRTF:
  126662. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  126663. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126664. */
  126665. switchPanningModelToHRTF(): void;
  126666. /**
  126667. * Switch the panning model to Equal Power:
  126668. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  126669. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126670. */
  126671. switchPanningModelToEqualPower(): void;
  126672. private _switchPanningModel;
  126673. /**
  126674. * Connect this sound to a sound track audio node like gain...
  126675. * @param soundTrackAudioNode the sound track audio node to connect to
  126676. */
  126677. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  126678. /**
  126679. * Transform this sound into a directional source
  126680. * @param coneInnerAngle Size of the inner cone in degree
  126681. * @param coneOuterAngle Size of the outer cone in degree
  126682. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  126683. */
  126684. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  126685. /**
  126686. * Gets or sets the inner angle for the directional cone.
  126687. */
  126688. get directionalConeInnerAngle(): number;
  126689. /**
  126690. * Gets or sets the inner angle for the directional cone.
  126691. */
  126692. set directionalConeInnerAngle(value: number);
  126693. /**
  126694. * Gets or sets the outer angle for the directional cone.
  126695. */
  126696. get directionalConeOuterAngle(): number;
  126697. /**
  126698. * Gets or sets the outer angle for the directional cone.
  126699. */
  126700. set directionalConeOuterAngle(value: number);
  126701. /**
  126702. * Sets the position of the emitter if spatial sound is enabled
  126703. * @param newPosition Defines the new posisiton
  126704. */
  126705. setPosition(newPosition: Vector3): void;
  126706. /**
  126707. * Sets the local direction of the emitter if spatial sound is enabled
  126708. * @param newLocalDirection Defines the new local direction
  126709. */
  126710. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  126711. private _updateDirection;
  126712. /** @hidden */
  126713. updateDistanceFromListener(): void;
  126714. /**
  126715. * Sets a new custom attenuation function for the sound.
  126716. * @param callback Defines the function used for the attenuation
  126717. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  126718. */
  126719. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  126720. /**
  126721. * Play the sound
  126722. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  126723. * @param offset (optional) Start the sound at a specific time in seconds
  126724. * @param length (optional) Sound duration (in seconds)
  126725. */
  126726. play(time?: number, offset?: number, length?: number): void;
  126727. private _onended;
  126728. /**
  126729. * Stop the sound
  126730. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  126731. */
  126732. stop(time?: number): void;
  126733. /**
  126734. * Put the sound in pause
  126735. */
  126736. pause(): void;
  126737. /**
  126738. * Sets a dedicated volume for this sounds
  126739. * @param newVolume Define the new volume of the sound
  126740. * @param time Define time for gradual change to new volume
  126741. */
  126742. setVolume(newVolume: number, time?: number): void;
  126743. /**
  126744. * Set the sound play back rate
  126745. * @param newPlaybackRate Define the playback rate the sound should be played at
  126746. */
  126747. setPlaybackRate(newPlaybackRate: number): void;
  126748. /**
  126749. * Gets the volume of the sound.
  126750. * @returns the volume of the sound
  126751. */
  126752. getVolume(): number;
  126753. /**
  126754. * Attach the sound to a dedicated mesh
  126755. * @param transformNode The transform node to connect the sound with
  126756. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  126757. */
  126758. attachToMesh(transformNode: TransformNode): void;
  126759. /**
  126760. * Detach the sound from the previously attached mesh
  126761. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  126762. */
  126763. detachFromMesh(): void;
  126764. private _onRegisterAfterWorldMatrixUpdate;
  126765. /**
  126766. * Clone the current sound in the scene.
  126767. * @returns the new sound clone
  126768. */
  126769. clone(): Nullable<Sound>;
  126770. /**
  126771. * Gets the current underlying audio buffer containing the data
  126772. * @returns the audio buffer
  126773. */
  126774. getAudioBuffer(): Nullable<AudioBuffer>;
  126775. /**
  126776. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  126777. * @returns the source node
  126778. */
  126779. getSoundSource(): Nullable<AudioBufferSourceNode>;
  126780. /**
  126781. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  126782. * @returns the gain node
  126783. */
  126784. getSoundGain(): Nullable<GainNode>;
  126785. /**
  126786. * Serializes the Sound in a JSON representation
  126787. * @returns the JSON representation of the sound
  126788. */
  126789. serialize(): any;
  126790. /**
  126791. * Parse a JSON representation of a sound to innstantiate in a given scene
  126792. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  126793. * @param scene Define the scene the new parsed sound should be created in
  126794. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  126795. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  126796. * @returns the newly parsed sound
  126797. */
  126798. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  126799. }
  126800. }
  126801. declare module BABYLON {
  126802. /**
  126803. * This defines an action helpful to play a defined sound on a triggered action.
  126804. */
  126805. export class PlaySoundAction extends Action {
  126806. private _sound;
  126807. /**
  126808. * Instantiate the action
  126809. * @param triggerOptions defines the trigger options
  126810. * @param sound defines the sound to play
  126811. * @param condition defines the trigger related conditions
  126812. */
  126813. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  126814. /** @hidden */
  126815. _prepare(): void;
  126816. /**
  126817. * Execute the action and play the sound.
  126818. */
  126819. execute(): void;
  126820. /**
  126821. * Serializes the actions and its related information.
  126822. * @param parent defines the object to serialize in
  126823. * @returns the serialized object
  126824. */
  126825. serialize(parent: any): any;
  126826. }
  126827. /**
  126828. * This defines an action helpful to stop a defined sound on a triggered action.
  126829. */
  126830. export class StopSoundAction extends Action {
  126831. private _sound;
  126832. /**
  126833. * Instantiate the action
  126834. * @param triggerOptions defines the trigger options
  126835. * @param sound defines the sound to stop
  126836. * @param condition defines the trigger related conditions
  126837. */
  126838. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  126839. /** @hidden */
  126840. _prepare(): void;
  126841. /**
  126842. * Execute the action and stop the sound.
  126843. */
  126844. execute(): void;
  126845. /**
  126846. * Serializes the actions and its related information.
  126847. * @param parent defines the object to serialize in
  126848. * @returns the serialized object
  126849. */
  126850. serialize(parent: any): any;
  126851. }
  126852. }
  126853. declare module BABYLON {
  126854. /**
  126855. * This defines an action responsible to change the value of a property
  126856. * by interpolating between its current value and the newly set one once triggered.
  126857. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  126858. */
  126859. export class InterpolateValueAction extends Action {
  126860. /**
  126861. * Defines the path of the property where the value should be interpolated
  126862. */
  126863. propertyPath: string;
  126864. /**
  126865. * Defines the target value at the end of the interpolation.
  126866. */
  126867. value: any;
  126868. /**
  126869. * Defines the time it will take for the property to interpolate to the value.
  126870. */
  126871. duration: number;
  126872. /**
  126873. * Defines if the other scene animations should be stopped when the action has been triggered
  126874. */
  126875. stopOtherAnimations?: boolean;
  126876. /**
  126877. * Defines a callback raised once the interpolation animation has been done.
  126878. */
  126879. onInterpolationDone?: () => void;
  126880. /**
  126881. * Observable triggered once the interpolation animation has been done.
  126882. */
  126883. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  126884. private _target;
  126885. private _effectiveTarget;
  126886. private _property;
  126887. /**
  126888. * Instantiate the action
  126889. * @param triggerOptions defines the trigger options
  126890. * @param target defines the object containing the value to interpolate
  126891. * @param propertyPath defines the path to the property in the target object
  126892. * @param value defines the target value at the end of the interpolation
  126893. * @param duration deines the time it will take for the property to interpolate to the value.
  126894. * @param condition defines the trigger related conditions
  126895. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  126896. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  126897. */
  126898. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  126899. /** @hidden */
  126900. _prepare(): void;
  126901. /**
  126902. * Execute the action starts the value interpolation.
  126903. */
  126904. execute(): void;
  126905. /**
  126906. * Serializes the actions and its related information.
  126907. * @param parent defines the object to serialize in
  126908. * @returns the serialized object
  126909. */
  126910. serialize(parent: any): any;
  126911. }
  126912. }
  126913. declare module BABYLON {
  126914. /**
  126915. * This represents the default audio engine used in babylon.
  126916. * It is responsible to play, synchronize and analyse sounds throughout the application.
  126917. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126918. */
  126919. export class AudioEngine implements IAudioEngine {
  126920. private _audioContext;
  126921. private _audioContextInitialized;
  126922. private _muteButton;
  126923. private _hostElement;
  126924. /**
  126925. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  126926. */
  126927. canUseWebAudio: boolean;
  126928. /**
  126929. * The master gain node defines the global audio volume of your audio engine.
  126930. */
  126931. masterGain: GainNode;
  126932. /**
  126933. * Defines if Babylon should emit a warning if WebAudio is not supported.
  126934. * @ignoreNaming
  126935. */
  126936. WarnedWebAudioUnsupported: boolean;
  126937. /**
  126938. * Gets whether or not mp3 are supported by your browser.
  126939. */
  126940. isMP3supported: boolean;
  126941. /**
  126942. * Gets whether or not ogg are supported by your browser.
  126943. */
  126944. isOGGsupported: boolean;
  126945. /**
  126946. * Gets whether audio has been unlocked on the device.
  126947. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  126948. * a user interaction has happened.
  126949. */
  126950. unlocked: boolean;
  126951. /**
  126952. * Defines if the audio engine relies on a custom unlocked button.
  126953. * In this case, the embedded button will not be displayed.
  126954. */
  126955. useCustomUnlockedButton: boolean;
  126956. /**
  126957. * Event raised when audio has been unlocked on the browser.
  126958. */
  126959. onAudioUnlockedObservable: Observable<IAudioEngine>;
  126960. /**
  126961. * Event raised when audio has been locked on the browser.
  126962. */
  126963. onAudioLockedObservable: Observable<IAudioEngine>;
  126964. /**
  126965. * Gets the current AudioContext if available.
  126966. */
  126967. get audioContext(): Nullable<AudioContext>;
  126968. private _connectedAnalyser;
  126969. /**
  126970. * Instantiates a new audio engine.
  126971. *
  126972. * There should be only one per page as some browsers restrict the number
  126973. * of audio contexts you can create.
  126974. * @param hostElement defines the host element where to display the mute icon if necessary
  126975. */
  126976. constructor(hostElement?: Nullable<HTMLElement>);
  126977. /**
  126978. * Flags the audio engine in Locked state.
  126979. * This happens due to new browser policies preventing audio to autoplay.
  126980. */
  126981. lock(): void;
  126982. /**
  126983. * Unlocks the audio engine once a user action has been done on the dom.
  126984. * This is helpful to resume play once browser policies have been satisfied.
  126985. */
  126986. unlock(): void;
  126987. private _resumeAudioContext;
  126988. private _initializeAudioContext;
  126989. private _tryToRun;
  126990. private _triggerRunningState;
  126991. private _triggerSuspendedState;
  126992. private _displayMuteButton;
  126993. private _moveButtonToTopLeft;
  126994. private _onResize;
  126995. private _hideMuteButton;
  126996. /**
  126997. * Destroy and release the resources associated with the audio ccontext.
  126998. */
  126999. dispose(): void;
  127000. /**
  127001. * Gets the global volume sets on the master gain.
  127002. * @returns the global volume if set or -1 otherwise
  127003. */
  127004. getGlobalVolume(): number;
  127005. /**
  127006. * Sets the global volume of your experience (sets on the master gain).
  127007. * @param newVolume Defines the new global volume of the application
  127008. */
  127009. setGlobalVolume(newVolume: number): void;
  127010. /**
  127011. * Connect the audio engine to an audio analyser allowing some amazing
  127012. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  127013. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  127014. * @param analyser The analyser to connect to the engine
  127015. */
  127016. connectToAnalyser(analyser: Analyser): void;
  127017. }
  127018. }
  127019. declare module BABYLON {
  127020. /**
  127021. * Options allowed during the creation of a sound track.
  127022. */
  127023. export interface ISoundTrackOptions {
  127024. /**
  127025. * The volume the sound track should take during creation
  127026. */
  127027. volume?: number;
  127028. /**
  127029. * Define if the sound track is the main sound track of the scene
  127030. */
  127031. mainTrack?: boolean;
  127032. }
  127033. /**
  127034. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  127035. * It will be also used in a future release to apply effects on a specific track.
  127036. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  127037. */
  127038. export class SoundTrack {
  127039. /**
  127040. * The unique identifier of the sound track in the scene.
  127041. */
  127042. id: number;
  127043. /**
  127044. * The list of sounds included in the sound track.
  127045. */
  127046. soundCollection: Array<Sound>;
  127047. private _outputAudioNode;
  127048. private _scene;
  127049. private _connectedAnalyser;
  127050. private _options;
  127051. private _isInitialized;
  127052. /**
  127053. * Creates a new sound track.
  127054. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  127055. * @param scene Define the scene the sound track belongs to
  127056. * @param options
  127057. */
  127058. constructor(scene: Scene, options?: ISoundTrackOptions);
  127059. private _initializeSoundTrackAudioGraph;
  127060. /**
  127061. * Release the sound track and its associated resources
  127062. */
  127063. dispose(): void;
  127064. /**
  127065. * Adds a sound to this sound track
  127066. * @param sound define the cound to add
  127067. * @ignoreNaming
  127068. */
  127069. addSound(sound: Sound): void;
  127070. /**
  127071. * Removes a sound to this sound track
  127072. * @param sound define the cound to remove
  127073. * @ignoreNaming
  127074. */
  127075. removeSound(sound: Sound): void;
  127076. /**
  127077. * Set a global volume for the full sound track.
  127078. * @param newVolume Define the new volume of the sound track
  127079. */
  127080. setVolume(newVolume: number): void;
  127081. /**
  127082. * Switch the panning model to HRTF:
  127083. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  127084. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  127085. */
  127086. switchPanningModelToHRTF(): void;
  127087. /**
  127088. * Switch the panning model to Equal Power:
  127089. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  127090. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  127091. */
  127092. switchPanningModelToEqualPower(): void;
  127093. /**
  127094. * Connect the sound track to an audio analyser allowing some amazing
  127095. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  127096. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  127097. * @param analyser The analyser to connect to the engine
  127098. */
  127099. connectToAnalyser(analyser: Analyser): void;
  127100. }
  127101. }
  127102. declare module BABYLON {
  127103. interface AbstractScene {
  127104. /**
  127105. * The list of sounds used in the scene.
  127106. */
  127107. sounds: Nullable<Array<Sound>>;
  127108. }
  127109. interface Scene {
  127110. /**
  127111. * @hidden
  127112. * Backing field
  127113. */
  127114. _mainSoundTrack: SoundTrack;
  127115. /**
  127116. * The main sound track played by the scene.
  127117. * It cotains your primary collection of sounds.
  127118. */
  127119. mainSoundTrack: SoundTrack;
  127120. /**
  127121. * The list of sound tracks added to the scene
  127122. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127123. */
  127124. soundTracks: Nullable<Array<SoundTrack>>;
  127125. /**
  127126. * Gets a sound using a given name
  127127. * @param name defines the name to search for
  127128. * @return the found sound or null if not found at all.
  127129. */
  127130. getSoundByName(name: string): Nullable<Sound>;
  127131. /**
  127132. * Gets or sets if audio support is enabled
  127133. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127134. */
  127135. audioEnabled: boolean;
  127136. /**
  127137. * Gets or sets if audio will be output to headphones
  127138. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127139. */
  127140. headphone: boolean;
  127141. /**
  127142. * Gets or sets custom audio listener position provider
  127143. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127144. */
  127145. audioListenerPositionProvider: Nullable<() => Vector3>;
  127146. /**
  127147. * Gets or sets a refresh rate when using 3D audio positioning
  127148. */
  127149. audioPositioningRefreshRate: number;
  127150. }
  127151. /**
  127152. * Defines the sound scene component responsible to manage any sounds
  127153. * in a given scene.
  127154. */
  127155. export class AudioSceneComponent implements ISceneSerializableComponent {
  127156. private static _CameraDirectionLH;
  127157. private static _CameraDirectionRH;
  127158. /**
  127159. * The component name helpfull to identify the component in the list of scene components.
  127160. */
  127161. readonly name: string;
  127162. /**
  127163. * The scene the component belongs to.
  127164. */
  127165. scene: Scene;
  127166. private _audioEnabled;
  127167. /**
  127168. * Gets whether audio is enabled or not.
  127169. * Please use related enable/disable method to switch state.
  127170. */
  127171. get audioEnabled(): boolean;
  127172. private _headphone;
  127173. /**
  127174. * Gets whether audio is outputing to headphone or not.
  127175. * Please use the according Switch methods to change output.
  127176. */
  127177. get headphone(): boolean;
  127178. /**
  127179. * Gets or sets a refresh rate when using 3D audio positioning
  127180. */
  127181. audioPositioningRefreshRate: number;
  127182. private _audioListenerPositionProvider;
  127183. /**
  127184. * Gets the current audio listener position provider
  127185. */
  127186. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  127187. /**
  127188. * Sets a custom listener position for all sounds in the scene
  127189. * By default, this is the position of the first active camera
  127190. */
  127191. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  127192. /**
  127193. * Creates a new instance of the component for the given scene
  127194. * @param scene Defines the scene to register the component in
  127195. */
  127196. constructor(scene: Scene);
  127197. /**
  127198. * Registers the component in a given scene
  127199. */
  127200. register(): void;
  127201. /**
  127202. * Rebuilds the elements related to this component in case of
  127203. * context lost for instance.
  127204. */
  127205. rebuild(): void;
  127206. /**
  127207. * Serializes the component data to the specified json object
  127208. * @param serializationObject The object to serialize to
  127209. */
  127210. serialize(serializationObject: any): void;
  127211. /**
  127212. * Adds all the elements from the container to the scene
  127213. * @param container the container holding the elements
  127214. */
  127215. addFromContainer(container: AbstractScene): void;
  127216. /**
  127217. * Removes all the elements in the container from the scene
  127218. * @param container contains the elements to remove
  127219. * @param dispose if the removed element should be disposed (default: false)
  127220. */
  127221. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127222. /**
  127223. * Disposes the component and the associated ressources.
  127224. */
  127225. dispose(): void;
  127226. /**
  127227. * Disables audio in the associated scene.
  127228. */
  127229. disableAudio(): void;
  127230. /**
  127231. * Enables audio in the associated scene.
  127232. */
  127233. enableAudio(): void;
  127234. /**
  127235. * Switch audio to headphone output.
  127236. */
  127237. switchAudioModeForHeadphones(): void;
  127238. /**
  127239. * Switch audio to normal speakers.
  127240. */
  127241. switchAudioModeForNormalSpeakers(): void;
  127242. private _cachedCameraDirection;
  127243. private _cachedCameraPosition;
  127244. private _lastCheck;
  127245. private _afterRender;
  127246. }
  127247. }
  127248. declare module BABYLON {
  127249. /**
  127250. * Wraps one or more Sound objects and selects one with random weight for playback.
  127251. */
  127252. export class WeightedSound {
  127253. /** When true a Sound will be selected and played when the current playing Sound completes. */
  127254. loop: boolean;
  127255. private _coneInnerAngle;
  127256. private _coneOuterAngle;
  127257. private _volume;
  127258. /** A Sound is currently playing. */
  127259. isPlaying: boolean;
  127260. /** A Sound is currently paused. */
  127261. isPaused: boolean;
  127262. private _sounds;
  127263. private _weights;
  127264. private _currentIndex?;
  127265. /**
  127266. * Creates a new WeightedSound from the list of sounds given.
  127267. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  127268. * @param sounds Array of Sounds that will be selected from.
  127269. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  127270. */
  127271. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  127272. /**
  127273. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  127274. */
  127275. get directionalConeInnerAngle(): number;
  127276. /**
  127277. * The size of cone in degress for a directional sound in which there will be no attenuation.
  127278. */
  127279. set directionalConeInnerAngle(value: number);
  127280. /**
  127281. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  127282. * Listener angles between innerAngle and outerAngle will falloff linearly.
  127283. */
  127284. get directionalConeOuterAngle(): number;
  127285. /**
  127286. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  127287. * Listener angles between innerAngle and outerAngle will falloff linearly.
  127288. */
  127289. set directionalConeOuterAngle(value: number);
  127290. /**
  127291. * Playback volume.
  127292. */
  127293. get volume(): number;
  127294. /**
  127295. * Playback volume.
  127296. */
  127297. set volume(value: number);
  127298. private _onended;
  127299. /**
  127300. * Suspend playback
  127301. */
  127302. pause(): void;
  127303. /**
  127304. * Stop playback
  127305. */
  127306. stop(): void;
  127307. /**
  127308. * Start playback.
  127309. * @param startOffset Position the clip head at a specific time in seconds.
  127310. */
  127311. play(startOffset?: number): void;
  127312. }
  127313. }
  127314. declare module BABYLON {
  127315. /**
  127316. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  127317. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  127318. */
  127319. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  127320. /**
  127321. * Gets the name of the behavior.
  127322. */
  127323. get name(): string;
  127324. /**
  127325. * The easing function used by animations
  127326. */
  127327. static EasingFunction: BackEase;
  127328. /**
  127329. * The easing mode used by animations
  127330. */
  127331. static EasingMode: number;
  127332. /**
  127333. * The duration of the animation, in milliseconds
  127334. */
  127335. transitionDuration: number;
  127336. /**
  127337. * Length of the distance animated by the transition when lower radius is reached
  127338. */
  127339. lowerRadiusTransitionRange: number;
  127340. /**
  127341. * Length of the distance animated by the transition when upper radius is reached
  127342. */
  127343. upperRadiusTransitionRange: number;
  127344. private _autoTransitionRange;
  127345. /**
  127346. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  127347. */
  127348. get autoTransitionRange(): boolean;
  127349. /**
  127350. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  127351. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  127352. */
  127353. set autoTransitionRange(value: boolean);
  127354. private _attachedCamera;
  127355. private _onAfterCheckInputsObserver;
  127356. private _onMeshTargetChangedObserver;
  127357. /**
  127358. * Initializes the behavior.
  127359. */
  127360. init(): void;
  127361. /**
  127362. * Attaches the behavior to its arc rotate camera.
  127363. * @param camera Defines the camera to attach the behavior to
  127364. */
  127365. attach(camera: ArcRotateCamera): void;
  127366. /**
  127367. * Detaches the behavior from its current arc rotate camera.
  127368. */
  127369. detach(): void;
  127370. private _radiusIsAnimating;
  127371. private _radiusBounceTransition;
  127372. private _animatables;
  127373. private _cachedWheelPrecision;
  127374. /**
  127375. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  127376. * @param radiusLimit The limit to check against.
  127377. * @return Bool to indicate if at limit.
  127378. */
  127379. private _isRadiusAtLimit;
  127380. /**
  127381. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  127382. * @param radiusDelta The delta by which to animate to. Can be negative.
  127383. */
  127384. private _applyBoundRadiusAnimation;
  127385. /**
  127386. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  127387. */
  127388. protected _clearAnimationLocks(): void;
  127389. /**
  127390. * Stops and removes all animations that have been applied to the camera
  127391. */
  127392. stopAllAnimations(): void;
  127393. }
  127394. }
  127395. declare module BABYLON {
  127396. /**
  127397. * 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.
  127398. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  127399. */
  127400. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  127401. /**
  127402. * Gets the name of the behavior.
  127403. */
  127404. get name(): string;
  127405. private _mode;
  127406. private _radiusScale;
  127407. private _positionScale;
  127408. private _defaultElevation;
  127409. private _elevationReturnTime;
  127410. private _elevationReturnWaitTime;
  127411. private _zoomStopsAnimation;
  127412. private _framingTime;
  127413. /**
  127414. * The easing function used by animations
  127415. */
  127416. static EasingFunction: ExponentialEase;
  127417. /**
  127418. * The easing mode used by animations
  127419. */
  127420. static EasingMode: number;
  127421. /**
  127422. * Sets the current mode used by the behavior
  127423. */
  127424. set mode(mode: number);
  127425. /**
  127426. * Gets current mode used by the behavior.
  127427. */
  127428. get mode(): number;
  127429. /**
  127430. * Sets the scale applied to the radius (1 by default)
  127431. */
  127432. set radiusScale(radius: number);
  127433. /**
  127434. * Gets the scale applied to the radius
  127435. */
  127436. get radiusScale(): number;
  127437. /**
  127438. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  127439. */
  127440. set positionScale(scale: number);
  127441. /**
  127442. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  127443. */
  127444. get positionScale(): number;
  127445. /**
  127446. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  127447. * behaviour is triggered, in radians.
  127448. */
  127449. set defaultElevation(elevation: number);
  127450. /**
  127451. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  127452. * behaviour is triggered, in radians.
  127453. */
  127454. get defaultElevation(): number;
  127455. /**
  127456. * Sets the time (in milliseconds) taken to return to the default beta position.
  127457. * Negative value indicates camera should not return to default.
  127458. */
  127459. set elevationReturnTime(speed: number);
  127460. /**
  127461. * Gets the time (in milliseconds) taken to return to the default beta position.
  127462. * Negative value indicates camera should not return to default.
  127463. */
  127464. get elevationReturnTime(): number;
  127465. /**
  127466. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  127467. */
  127468. set elevationReturnWaitTime(time: number);
  127469. /**
  127470. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  127471. */
  127472. get elevationReturnWaitTime(): number;
  127473. /**
  127474. * Sets the flag that indicates if user zooming should stop animation.
  127475. */
  127476. set zoomStopsAnimation(flag: boolean);
  127477. /**
  127478. * Gets the flag that indicates if user zooming should stop animation.
  127479. */
  127480. get zoomStopsAnimation(): boolean;
  127481. /**
  127482. * Sets the transition time when framing the mesh, in milliseconds
  127483. */
  127484. set framingTime(time: number);
  127485. /**
  127486. * Gets the transition time when framing the mesh, in milliseconds
  127487. */
  127488. get framingTime(): number;
  127489. /**
  127490. * Define if the behavior should automatically change the configured
  127491. * camera limits and sensibilities.
  127492. */
  127493. autoCorrectCameraLimitsAndSensibility: boolean;
  127494. private _onPrePointerObservableObserver;
  127495. private _onAfterCheckInputsObserver;
  127496. private _onMeshTargetChangedObserver;
  127497. private _attachedCamera;
  127498. private _isPointerDown;
  127499. private _lastInteractionTime;
  127500. /**
  127501. * Initializes the behavior.
  127502. */
  127503. init(): void;
  127504. /**
  127505. * Attaches the behavior to its arc rotate camera.
  127506. * @param camera Defines the camera to attach the behavior to
  127507. */
  127508. attach(camera: ArcRotateCamera): void;
  127509. /**
  127510. * Detaches the behavior from its current arc rotate camera.
  127511. */
  127512. detach(): void;
  127513. private _animatables;
  127514. private _betaIsAnimating;
  127515. private _betaTransition;
  127516. private _radiusTransition;
  127517. private _vectorTransition;
  127518. /**
  127519. * Targets the given mesh and updates zoom level accordingly.
  127520. * @param mesh The mesh to target.
  127521. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127522. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127523. */
  127524. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127525. /**
  127526. * Targets the given mesh with its children and updates zoom level accordingly.
  127527. * @param mesh The mesh to target.
  127528. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127529. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127530. */
  127531. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127532. /**
  127533. * Targets the given meshes with their children and updates zoom level accordingly.
  127534. * @param meshes The mesh to target.
  127535. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127536. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127537. */
  127538. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127539. /**
  127540. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  127541. * @param minimumWorld Determines the smaller position of the bounding box extend
  127542. * @param maximumWorld Determines the bigger position of the bounding box extend
  127543. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127544. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127545. */
  127546. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127547. /**
  127548. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  127549. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  127550. * frustum width.
  127551. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  127552. * to fully enclose the mesh in the viewing frustum.
  127553. */
  127554. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  127555. /**
  127556. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  127557. * is automatically returned to its default position (expected to be above ground plane).
  127558. */
  127559. private _maintainCameraAboveGround;
  127560. /**
  127561. * Returns the frustum slope based on the canvas ratio and camera FOV
  127562. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  127563. */
  127564. private _getFrustumSlope;
  127565. /**
  127566. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  127567. */
  127568. private _clearAnimationLocks;
  127569. /**
  127570. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  127571. */
  127572. private _applyUserInteraction;
  127573. /**
  127574. * Stops and removes all animations that have been applied to the camera
  127575. */
  127576. stopAllAnimations(): void;
  127577. /**
  127578. * Gets a value indicating if the user is moving the camera
  127579. */
  127580. get isUserIsMoving(): boolean;
  127581. /**
  127582. * The camera can move all the way towards the mesh.
  127583. */
  127584. static IgnoreBoundsSizeMode: number;
  127585. /**
  127586. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  127587. */
  127588. static FitFrustumSidesMode: number;
  127589. }
  127590. }
  127591. declare module BABYLON {
  127592. /**
  127593. * Base class for Camera Pointer Inputs.
  127594. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  127595. * for example usage.
  127596. */
  127597. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  127598. /**
  127599. * Defines the camera the input is attached to.
  127600. */
  127601. abstract camera: Camera;
  127602. /**
  127603. * Whether keyboard modifier keys are pressed at time of last mouse event.
  127604. */
  127605. protected _altKey: boolean;
  127606. protected _ctrlKey: boolean;
  127607. protected _metaKey: boolean;
  127608. protected _shiftKey: boolean;
  127609. /**
  127610. * Which mouse buttons were pressed at time of last mouse event.
  127611. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  127612. */
  127613. protected _buttonsPressed: number;
  127614. /**
  127615. * Defines the buttons associated with the input to handle camera move.
  127616. */
  127617. buttons: number[];
  127618. /**
  127619. * Attach the input controls to a specific dom element to get the input from.
  127620. * @param element Defines the element the controls should be listened from
  127621. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127622. */
  127623. attachControl(noPreventDefault?: boolean): void;
  127624. /**
  127625. * Detach the current controls from the specified dom element.
  127626. */
  127627. detachControl(): void;
  127628. /**
  127629. * Gets the class name of the current input.
  127630. * @returns the class name
  127631. */
  127632. getClassName(): string;
  127633. /**
  127634. * Get the friendly name associated with the input class.
  127635. * @returns the input friendly name
  127636. */
  127637. getSimpleName(): string;
  127638. /**
  127639. * Called on pointer POINTERDOUBLETAP event.
  127640. * Override this method to provide functionality on POINTERDOUBLETAP event.
  127641. */
  127642. protected onDoubleTap(type: string): void;
  127643. /**
  127644. * Called on pointer POINTERMOVE event if only a single touch is active.
  127645. * Override this method to provide functionality.
  127646. */
  127647. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  127648. /**
  127649. * Called on pointer POINTERMOVE event if multiple touches are active.
  127650. * Override this method to provide functionality.
  127651. */
  127652. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  127653. /**
  127654. * Called on JS contextmenu event.
  127655. * Override this method to provide functionality.
  127656. */
  127657. protected onContextMenu(evt: PointerEvent): void;
  127658. /**
  127659. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  127660. * press.
  127661. * Override this method to provide functionality.
  127662. */
  127663. protected onButtonDown(evt: PointerEvent): void;
  127664. /**
  127665. * Called each time a new POINTERUP event occurs. Ie, for each button
  127666. * release.
  127667. * Override this method to provide functionality.
  127668. */
  127669. protected onButtonUp(evt: PointerEvent): void;
  127670. /**
  127671. * Called when window becomes inactive.
  127672. * Override this method to provide functionality.
  127673. */
  127674. protected onLostFocus(): void;
  127675. private _pointerInput;
  127676. private _observer;
  127677. private _onLostFocus;
  127678. private pointA;
  127679. private pointB;
  127680. }
  127681. }
  127682. declare module BABYLON {
  127683. /**
  127684. * Manage the pointers inputs to control an arc rotate camera.
  127685. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127686. */
  127687. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  127688. /**
  127689. * Defines the camera the input is attached to.
  127690. */
  127691. camera: ArcRotateCamera;
  127692. /**
  127693. * Gets the class name of the current input.
  127694. * @returns the class name
  127695. */
  127696. getClassName(): string;
  127697. /**
  127698. * Defines the buttons associated with the input to handle camera move.
  127699. */
  127700. buttons: number[];
  127701. /**
  127702. * Defines the pointer angular sensibility along the X axis or how fast is
  127703. * the camera rotating.
  127704. */
  127705. angularSensibilityX: number;
  127706. /**
  127707. * Defines the pointer angular sensibility along the Y axis or how fast is
  127708. * the camera rotating.
  127709. */
  127710. angularSensibilityY: number;
  127711. /**
  127712. * Defines the pointer pinch precision or how fast is the camera zooming.
  127713. */
  127714. pinchPrecision: number;
  127715. /**
  127716. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  127717. * from 0.
  127718. * It defines the percentage of current camera.radius to use as delta when
  127719. * pinch zoom is used.
  127720. */
  127721. pinchDeltaPercentage: number;
  127722. /**
  127723. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  127724. * that any object in the plane at the camera's target point will scale
  127725. * perfectly with finger motion.
  127726. * Overrides pinchDeltaPercentage and pinchPrecision.
  127727. */
  127728. useNaturalPinchZoom: boolean;
  127729. /**
  127730. * Defines the pointer panning sensibility or how fast is the camera moving.
  127731. */
  127732. panningSensibility: number;
  127733. /**
  127734. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  127735. */
  127736. multiTouchPanning: boolean;
  127737. /**
  127738. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  127739. * zoom (pinch) through multitouch.
  127740. */
  127741. multiTouchPanAndZoom: boolean;
  127742. /**
  127743. * Revers pinch action direction.
  127744. */
  127745. pinchInwards: boolean;
  127746. private _isPanClick;
  127747. private _twoFingerActivityCount;
  127748. private _isPinching;
  127749. /**
  127750. * Called on pointer POINTERMOVE event if only a single touch is active.
  127751. */
  127752. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  127753. /**
  127754. * Called on pointer POINTERDOUBLETAP event.
  127755. */
  127756. protected onDoubleTap(type: string): void;
  127757. /**
  127758. * Called on pointer POINTERMOVE event if multiple touches are active.
  127759. */
  127760. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  127761. /**
  127762. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  127763. * press.
  127764. */
  127765. protected onButtonDown(evt: PointerEvent): void;
  127766. /**
  127767. * Called each time a new POINTERUP event occurs. Ie, for each button
  127768. * release.
  127769. */
  127770. protected onButtonUp(evt: PointerEvent): void;
  127771. /**
  127772. * Called when window becomes inactive.
  127773. */
  127774. protected onLostFocus(): void;
  127775. }
  127776. }
  127777. declare module BABYLON {
  127778. /**
  127779. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  127780. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127781. */
  127782. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  127783. /**
  127784. * Defines the camera the input is attached to.
  127785. */
  127786. camera: ArcRotateCamera;
  127787. /**
  127788. * Defines the list of key codes associated with the up action (increase alpha)
  127789. */
  127790. keysUp: number[];
  127791. /**
  127792. * Defines the list of key codes associated with the down action (decrease alpha)
  127793. */
  127794. keysDown: number[];
  127795. /**
  127796. * Defines the list of key codes associated with the left action (increase beta)
  127797. */
  127798. keysLeft: number[];
  127799. /**
  127800. * Defines the list of key codes associated with the right action (decrease beta)
  127801. */
  127802. keysRight: number[];
  127803. /**
  127804. * Defines the list of key codes associated with the reset action.
  127805. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  127806. */
  127807. keysReset: number[];
  127808. /**
  127809. * Defines the panning sensibility of the inputs.
  127810. * (How fast is the camera panning)
  127811. */
  127812. panningSensibility: number;
  127813. /**
  127814. * Defines the zooming sensibility of the inputs.
  127815. * (How fast is the camera zooming)
  127816. */
  127817. zoomingSensibility: number;
  127818. /**
  127819. * Defines whether maintaining the alt key down switch the movement mode from
  127820. * orientation to zoom.
  127821. */
  127822. useAltToZoom: boolean;
  127823. /**
  127824. * Rotation speed of the camera
  127825. */
  127826. angularSpeed: number;
  127827. private _keys;
  127828. private _ctrlPressed;
  127829. private _altPressed;
  127830. private _onCanvasBlurObserver;
  127831. private _onKeyboardObserver;
  127832. private _engine;
  127833. private _scene;
  127834. /**
  127835. * Attach the input controls to a specific dom element to get the input from.
  127836. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127837. */
  127838. attachControl(noPreventDefault?: boolean): void;
  127839. /**
  127840. * Detach the current controls from the specified dom element.
  127841. */
  127842. detachControl(): void;
  127843. /**
  127844. * Update the current camera state depending on the inputs that have been used this frame.
  127845. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127846. */
  127847. checkInputs(): void;
  127848. /**
  127849. * Gets the class name of the current intput.
  127850. * @returns the class name
  127851. */
  127852. getClassName(): string;
  127853. /**
  127854. * Get the friendly name associated with the input class.
  127855. * @returns the input friendly name
  127856. */
  127857. getSimpleName(): string;
  127858. }
  127859. }
  127860. declare module BABYLON {
  127861. /**
  127862. * Manage the mouse wheel inputs to control an arc rotate camera.
  127863. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127864. */
  127865. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  127866. /**
  127867. * Defines the camera the input is attached to.
  127868. */
  127869. camera: ArcRotateCamera;
  127870. /**
  127871. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  127872. */
  127873. wheelPrecision: number;
  127874. /**
  127875. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  127876. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  127877. */
  127878. wheelDeltaPercentage: number;
  127879. private _wheel;
  127880. private _observer;
  127881. private computeDeltaFromMouseWheelLegacyEvent;
  127882. /**
  127883. * Attach the input controls to a specific dom element to get the input from.
  127884. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127885. */
  127886. attachControl(noPreventDefault?: boolean): void;
  127887. /**
  127888. * Detach the current controls from the specified dom element.
  127889. */
  127890. detachControl(): void;
  127891. /**
  127892. * Gets the class name of the current intput.
  127893. * @returns the class name
  127894. */
  127895. getClassName(): string;
  127896. /**
  127897. * Get the friendly name associated with the input class.
  127898. * @returns the input friendly name
  127899. */
  127900. getSimpleName(): string;
  127901. }
  127902. }
  127903. declare module BABYLON {
  127904. /**
  127905. * Default Inputs manager for the ArcRotateCamera.
  127906. * It groups all the default supported inputs for ease of use.
  127907. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127908. */
  127909. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  127910. /**
  127911. * Instantiates a new ArcRotateCameraInputsManager.
  127912. * @param camera Defines the camera the inputs belong to
  127913. */
  127914. constructor(camera: ArcRotateCamera);
  127915. /**
  127916. * Add mouse wheel input support to the input manager.
  127917. * @returns the current input manager
  127918. */
  127919. addMouseWheel(): ArcRotateCameraInputsManager;
  127920. /**
  127921. * Add pointers input support to the input manager.
  127922. * @returns the current input manager
  127923. */
  127924. addPointers(): ArcRotateCameraInputsManager;
  127925. /**
  127926. * Add keyboard input support to the input manager.
  127927. * @returns the current input manager
  127928. */
  127929. addKeyboard(): ArcRotateCameraInputsManager;
  127930. }
  127931. }
  127932. declare module BABYLON {
  127933. /**
  127934. * This represents an orbital type of camera.
  127935. *
  127936. * 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.
  127937. * 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.
  127938. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  127939. */
  127940. export class ArcRotateCamera extends TargetCamera {
  127941. /**
  127942. * Defines the rotation angle of the camera along the longitudinal axis.
  127943. */
  127944. alpha: number;
  127945. /**
  127946. * Defines the rotation angle of the camera along the latitudinal axis.
  127947. */
  127948. beta: number;
  127949. /**
  127950. * Defines the radius of the camera from it s target point.
  127951. */
  127952. radius: number;
  127953. protected _target: Vector3;
  127954. protected _targetHost: Nullable<AbstractMesh>;
  127955. /**
  127956. * Defines the target point of the camera.
  127957. * The camera looks towards it form the radius distance.
  127958. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  127959. */
  127960. get target(): Vector3;
  127961. set target(value: Vector3);
  127962. /**
  127963. * Define the current local position of the camera in the scene
  127964. */
  127965. get position(): Vector3;
  127966. set position(newPosition: Vector3);
  127967. protected _upToYMatrix: Matrix;
  127968. protected _YToUpMatrix: Matrix;
  127969. /**
  127970. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  127971. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  127972. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  127973. */
  127974. set upVector(vec: Vector3);
  127975. get upVector(): Vector3;
  127976. /**
  127977. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  127978. */
  127979. setMatUp(): void;
  127980. /**
  127981. * Current inertia value on the longitudinal axis.
  127982. * The bigger this number the longer it will take for the camera to stop.
  127983. */
  127984. inertialAlphaOffset: number;
  127985. /**
  127986. * Current inertia value on the latitudinal axis.
  127987. * The bigger this number the longer it will take for the camera to stop.
  127988. */
  127989. inertialBetaOffset: number;
  127990. /**
  127991. * Current inertia value on the radius axis.
  127992. * The bigger this number the longer it will take for the camera to stop.
  127993. */
  127994. inertialRadiusOffset: number;
  127995. /**
  127996. * Minimum allowed angle on the longitudinal axis.
  127997. * This can help limiting how the Camera is able to move in the scene.
  127998. */
  127999. lowerAlphaLimit: Nullable<number>;
  128000. /**
  128001. * Maximum allowed angle on the longitudinal axis.
  128002. * This can help limiting how the Camera is able to move in the scene.
  128003. */
  128004. upperAlphaLimit: Nullable<number>;
  128005. /**
  128006. * Minimum allowed angle on the latitudinal axis.
  128007. * This can help limiting how the Camera is able to move in the scene.
  128008. */
  128009. lowerBetaLimit: number;
  128010. /**
  128011. * Maximum allowed angle on the latitudinal axis.
  128012. * This can help limiting how the Camera is able to move in the scene.
  128013. */
  128014. upperBetaLimit: number;
  128015. /**
  128016. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  128017. * This can help limiting how the Camera is able to move in the scene.
  128018. */
  128019. lowerRadiusLimit: Nullable<number>;
  128020. /**
  128021. * Maximum allowed distance of the camera to the target (The camera can not get further).
  128022. * This can help limiting how the Camera is able to move in the scene.
  128023. */
  128024. upperRadiusLimit: Nullable<number>;
  128025. /**
  128026. * Defines the current inertia value used during panning of the camera along the X axis.
  128027. */
  128028. inertialPanningX: number;
  128029. /**
  128030. * Defines the current inertia value used during panning of the camera along the Y axis.
  128031. */
  128032. inertialPanningY: number;
  128033. /**
  128034. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  128035. * Basically if your fingers moves away from more than this distance you will be considered
  128036. * in pinch mode.
  128037. */
  128038. pinchToPanMaxDistance: number;
  128039. /**
  128040. * Defines the maximum distance the camera can pan.
  128041. * This could help keeping the cammera always in your scene.
  128042. */
  128043. panningDistanceLimit: Nullable<number>;
  128044. /**
  128045. * Defines the target of the camera before paning.
  128046. */
  128047. panningOriginTarget: Vector3;
  128048. /**
  128049. * Defines the value of the inertia used during panning.
  128050. * 0 would mean stop inertia and one would mean no decelleration at all.
  128051. */
  128052. panningInertia: number;
  128053. /**
  128054. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  128055. */
  128056. get angularSensibilityX(): number;
  128057. set angularSensibilityX(value: number);
  128058. /**
  128059. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  128060. */
  128061. get angularSensibilityY(): number;
  128062. set angularSensibilityY(value: number);
  128063. /**
  128064. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  128065. */
  128066. get pinchPrecision(): number;
  128067. set pinchPrecision(value: number);
  128068. /**
  128069. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  128070. * It will be used instead of pinchDeltaPrecision if different from 0.
  128071. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  128072. */
  128073. get pinchDeltaPercentage(): number;
  128074. set pinchDeltaPercentage(value: number);
  128075. /**
  128076. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  128077. * and pinch delta percentage.
  128078. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  128079. * that any object in the plane at the camera's target point will scale
  128080. * perfectly with finger motion.
  128081. */
  128082. get useNaturalPinchZoom(): boolean;
  128083. set useNaturalPinchZoom(value: boolean);
  128084. /**
  128085. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  128086. */
  128087. get panningSensibility(): number;
  128088. set panningSensibility(value: number);
  128089. /**
  128090. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  128091. */
  128092. get keysUp(): number[];
  128093. set keysUp(value: number[]);
  128094. /**
  128095. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  128096. */
  128097. get keysDown(): number[];
  128098. set keysDown(value: number[]);
  128099. /**
  128100. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  128101. */
  128102. get keysLeft(): number[];
  128103. set keysLeft(value: number[]);
  128104. /**
  128105. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  128106. */
  128107. get keysRight(): number[];
  128108. set keysRight(value: number[]);
  128109. /**
  128110. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  128111. */
  128112. get wheelPrecision(): number;
  128113. set wheelPrecision(value: number);
  128114. /**
  128115. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  128116. * It will be used instead of pinchDeltaPrecision if different from 0.
  128117. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  128118. */
  128119. get wheelDeltaPercentage(): number;
  128120. set wheelDeltaPercentage(value: number);
  128121. /**
  128122. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  128123. */
  128124. zoomOnFactor: number;
  128125. /**
  128126. * Defines a screen offset for the camera position.
  128127. */
  128128. targetScreenOffset: Vector2;
  128129. /**
  128130. * Allows the camera to be completely reversed.
  128131. * If false the camera can not arrive upside down.
  128132. */
  128133. allowUpsideDown: boolean;
  128134. /**
  128135. * Define if double tap/click is used to restore the previously saved state of the camera.
  128136. */
  128137. useInputToRestoreState: boolean;
  128138. /** @hidden */
  128139. _viewMatrix: Matrix;
  128140. /** @hidden */
  128141. _useCtrlForPanning: boolean;
  128142. /** @hidden */
  128143. _panningMouseButton: number;
  128144. /**
  128145. * Defines the input associated to the camera.
  128146. */
  128147. inputs: ArcRotateCameraInputsManager;
  128148. /** @hidden */
  128149. _reset: () => void;
  128150. /**
  128151. * Defines the allowed panning axis.
  128152. */
  128153. panningAxis: Vector3;
  128154. protected _localDirection: Vector3;
  128155. protected _transformedDirection: Vector3;
  128156. private _bouncingBehavior;
  128157. /**
  128158. * Gets the bouncing behavior of the camera if it has been enabled.
  128159. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  128160. */
  128161. get bouncingBehavior(): Nullable<BouncingBehavior>;
  128162. /**
  128163. * Defines if the bouncing behavior of the camera is enabled on the camera.
  128164. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  128165. */
  128166. get useBouncingBehavior(): boolean;
  128167. set useBouncingBehavior(value: boolean);
  128168. private _framingBehavior;
  128169. /**
  128170. * Gets the framing behavior of the camera if it has been enabled.
  128171. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  128172. */
  128173. get framingBehavior(): Nullable<FramingBehavior>;
  128174. /**
  128175. * Defines if the framing behavior of the camera is enabled on the camera.
  128176. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  128177. */
  128178. get useFramingBehavior(): boolean;
  128179. set useFramingBehavior(value: boolean);
  128180. private _autoRotationBehavior;
  128181. /**
  128182. * Gets the auto rotation behavior of the camera if it has been enabled.
  128183. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  128184. */
  128185. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  128186. /**
  128187. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  128188. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  128189. */
  128190. get useAutoRotationBehavior(): boolean;
  128191. set useAutoRotationBehavior(value: boolean);
  128192. /**
  128193. * Observable triggered when the mesh target has been changed on the camera.
  128194. */
  128195. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  128196. /**
  128197. * Event raised when the camera is colliding with a mesh.
  128198. */
  128199. onCollide: (collidedMesh: AbstractMesh) => void;
  128200. /**
  128201. * Defines whether the camera should check collision with the objects oh the scene.
  128202. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  128203. */
  128204. checkCollisions: boolean;
  128205. /**
  128206. * Defines the collision radius of the camera.
  128207. * This simulates a sphere around the camera.
  128208. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  128209. */
  128210. collisionRadius: Vector3;
  128211. protected _collider: Collider;
  128212. protected _previousPosition: Vector3;
  128213. protected _collisionVelocity: Vector3;
  128214. protected _newPosition: Vector3;
  128215. protected _previousAlpha: number;
  128216. protected _previousBeta: number;
  128217. protected _previousRadius: number;
  128218. protected _collisionTriggered: boolean;
  128219. protected _targetBoundingCenter: Nullable<Vector3>;
  128220. private _computationVector;
  128221. /**
  128222. * Instantiates a new ArcRotateCamera in a given scene
  128223. * @param name Defines the name of the camera
  128224. * @param alpha Defines the camera rotation along the logitudinal axis
  128225. * @param beta Defines the camera rotation along the latitudinal axis
  128226. * @param radius Defines the camera distance from its target
  128227. * @param target Defines the camera target
  128228. * @param scene Defines the scene the camera belongs to
  128229. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  128230. */
  128231. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  128232. /** @hidden */
  128233. _initCache(): void;
  128234. /** @hidden */
  128235. _updateCache(ignoreParentClass?: boolean): void;
  128236. protected _getTargetPosition(): Vector3;
  128237. private _storedAlpha;
  128238. private _storedBeta;
  128239. private _storedRadius;
  128240. private _storedTarget;
  128241. private _storedTargetScreenOffset;
  128242. /**
  128243. * Stores the current state of the camera (alpha, beta, radius and target)
  128244. * @returns the camera itself
  128245. */
  128246. storeState(): Camera;
  128247. /**
  128248. * @hidden
  128249. * Restored camera state. You must call storeState() first
  128250. */
  128251. _restoreStateValues(): boolean;
  128252. /** @hidden */
  128253. _isSynchronizedViewMatrix(): boolean;
  128254. /**
  128255. * Attach the input controls to a specific dom element to get the input from.
  128256. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128257. */
  128258. attachControl(noPreventDefault?: boolean): void;
  128259. /**
  128260. * Attach the input controls to a specific dom element to get the input from.
  128261. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  128262. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128263. */
  128264. attachControl(ignored: any, noPreventDefault?: boolean): void;
  128265. /**
  128266. * Attached controls to the current camera.
  128267. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128268. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  128269. */
  128270. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  128271. /**
  128272. * Attached controls to the current camera.
  128273. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  128274. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128275. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  128276. */
  128277. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  128278. /**
  128279. * Attached controls to the current camera.
  128280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128281. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  128282. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  128283. */
  128284. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  128285. /**
  128286. * Detach the current controls from the specified dom element.
  128287. */
  128288. detachControl(): void;
  128289. /**
  128290. * Detach the current controls from the specified dom element.
  128291. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  128292. */
  128293. detachControl(ignored: any): void;
  128294. /** @hidden */
  128295. _checkInputs(): void;
  128296. protected _checkLimits(): void;
  128297. /**
  128298. * Rebuilds angles (alpha, beta) and radius from the give position and target
  128299. */
  128300. rebuildAnglesAndRadius(): void;
  128301. /**
  128302. * Use a position to define the current camera related information like alpha, beta and radius
  128303. * @param position Defines the position to set the camera at
  128304. */
  128305. setPosition(position: Vector3): void;
  128306. /**
  128307. * Defines the target the camera should look at.
  128308. * This will automatically adapt alpha beta and radius to fit within the new target.
  128309. * @param target Defines the new target as a Vector or a mesh
  128310. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  128311. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  128312. */
  128313. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  128314. /** @hidden */
  128315. _getViewMatrix(): Matrix;
  128316. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  128317. /**
  128318. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  128319. * @param meshes Defines the mesh to zoom on
  128320. * @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)
  128321. */
  128322. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  128323. /**
  128324. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  128325. * The target will be changed but the radius
  128326. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  128327. * @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)
  128328. */
  128329. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  128330. min: Vector3;
  128331. max: Vector3;
  128332. distance: number;
  128333. }, doNotUpdateMaxZ?: boolean): void;
  128334. /**
  128335. * @override
  128336. * Override Camera.createRigCamera
  128337. */
  128338. createRigCamera(name: string, cameraIndex: number): Camera;
  128339. /**
  128340. * @hidden
  128341. * @override
  128342. * Override Camera._updateRigCameras
  128343. */
  128344. _updateRigCameras(): void;
  128345. /**
  128346. * Destroy the camera and release the current resources hold by it.
  128347. */
  128348. dispose(): void;
  128349. /**
  128350. * Gets the current object class name.
  128351. * @return the class name
  128352. */
  128353. getClassName(): string;
  128354. }
  128355. }
  128356. declare module BABYLON {
  128357. /**
  128358. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  128359. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  128360. */
  128361. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  128362. /**
  128363. * Gets the name of the behavior.
  128364. */
  128365. get name(): string;
  128366. private _zoomStopsAnimation;
  128367. private _idleRotationSpeed;
  128368. private _idleRotationWaitTime;
  128369. private _idleRotationSpinupTime;
  128370. /**
  128371. * Sets the flag that indicates if user zooming should stop animation.
  128372. */
  128373. set zoomStopsAnimation(flag: boolean);
  128374. /**
  128375. * Gets the flag that indicates if user zooming should stop animation.
  128376. */
  128377. get zoomStopsAnimation(): boolean;
  128378. /**
  128379. * Sets the default speed at which the camera rotates around the model.
  128380. */
  128381. set idleRotationSpeed(speed: number);
  128382. /**
  128383. * Gets the default speed at which the camera rotates around the model.
  128384. */
  128385. get idleRotationSpeed(): number;
  128386. /**
  128387. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  128388. */
  128389. set idleRotationWaitTime(time: number);
  128390. /**
  128391. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  128392. */
  128393. get idleRotationWaitTime(): number;
  128394. /**
  128395. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  128396. */
  128397. set idleRotationSpinupTime(time: number);
  128398. /**
  128399. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  128400. */
  128401. get idleRotationSpinupTime(): number;
  128402. /**
  128403. * Gets a value indicating if the camera is currently rotating because of this behavior
  128404. */
  128405. get rotationInProgress(): boolean;
  128406. private _onPrePointerObservableObserver;
  128407. private _onAfterCheckInputsObserver;
  128408. private _attachedCamera;
  128409. private _isPointerDown;
  128410. private _lastFrameTime;
  128411. private _lastInteractionTime;
  128412. private _cameraRotationSpeed;
  128413. /**
  128414. * Initializes the behavior.
  128415. */
  128416. init(): void;
  128417. /**
  128418. * Attaches the behavior to its arc rotate camera.
  128419. * @param camera Defines the camera to attach the behavior to
  128420. */
  128421. attach(camera: ArcRotateCamera): void;
  128422. /**
  128423. * Detaches the behavior from its current arc rotate camera.
  128424. */
  128425. detach(): void;
  128426. /**
  128427. * Returns true if user is scrolling.
  128428. * @return true if user is scrolling.
  128429. */
  128430. private _userIsZooming;
  128431. private _lastFrameRadius;
  128432. private _shouldAnimationStopForInteraction;
  128433. /**
  128434. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  128435. */
  128436. private _applyUserInteraction;
  128437. private _userIsMoving;
  128438. }
  128439. }
  128440. declare module BABYLON {
  128441. /**
  128442. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  128443. */
  128444. export class AttachToBoxBehavior implements Behavior<Mesh> {
  128445. private ui;
  128446. /**
  128447. * The name of the behavior
  128448. */
  128449. name: string;
  128450. /**
  128451. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  128452. */
  128453. distanceAwayFromFace: number;
  128454. /**
  128455. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  128456. */
  128457. distanceAwayFromBottomOfFace: number;
  128458. private _faceVectors;
  128459. private _target;
  128460. private _scene;
  128461. private _onRenderObserver;
  128462. private _tmpMatrix;
  128463. private _tmpVector;
  128464. /**
  128465. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  128466. * @param ui The transform node that should be attched to the mesh
  128467. */
  128468. constructor(ui: TransformNode);
  128469. /**
  128470. * Initializes the behavior
  128471. */
  128472. init(): void;
  128473. private _closestFace;
  128474. private _zeroVector;
  128475. private _lookAtTmpMatrix;
  128476. private _lookAtToRef;
  128477. /**
  128478. * Attaches the AttachToBoxBehavior to the passed in mesh
  128479. * @param target The mesh that the specified node will be attached to
  128480. */
  128481. attach(target: Mesh): void;
  128482. /**
  128483. * Detaches the behavior from the mesh
  128484. */
  128485. detach(): void;
  128486. }
  128487. }
  128488. declare module BABYLON {
  128489. /**
  128490. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  128491. */
  128492. export class FadeInOutBehavior implements Behavior<Mesh> {
  128493. /**
  128494. * Time in milliseconds to delay before fading in (Default: 0)
  128495. */
  128496. delay: number;
  128497. /**
  128498. * Time in milliseconds for the mesh to fade in (Default: 300)
  128499. */
  128500. fadeInTime: number;
  128501. private _millisecondsPerFrame;
  128502. private _hovered;
  128503. private _hoverValue;
  128504. private _ownerNode;
  128505. /**
  128506. * Instatiates the FadeInOutBehavior
  128507. */
  128508. constructor();
  128509. /**
  128510. * The name of the behavior
  128511. */
  128512. get name(): string;
  128513. /**
  128514. * Initializes the behavior
  128515. */
  128516. init(): void;
  128517. /**
  128518. * Attaches the fade behavior on the passed in mesh
  128519. * @param ownerNode The mesh that will be faded in/out once attached
  128520. */
  128521. attach(ownerNode: Mesh): void;
  128522. /**
  128523. * Detaches the behavior from the mesh
  128524. */
  128525. detach(): void;
  128526. /**
  128527. * Triggers the mesh to begin fading in or out
  128528. * @param value if the object should fade in or out (true to fade in)
  128529. */
  128530. fadeIn(value: boolean): void;
  128531. private _update;
  128532. private _setAllVisibility;
  128533. }
  128534. }
  128535. declare module BABYLON {
  128536. /**
  128537. * Class containing a set of static utilities functions for managing Pivots
  128538. * @hidden
  128539. */
  128540. export class PivotTools {
  128541. private static _PivotCached;
  128542. private static _OldPivotPoint;
  128543. private static _PivotTranslation;
  128544. private static _PivotTmpVector;
  128545. private static _PivotPostMultiplyPivotMatrix;
  128546. /** @hidden */
  128547. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  128548. /** @hidden */
  128549. static _RestorePivotPoint(mesh: AbstractMesh): void;
  128550. }
  128551. }
  128552. declare module BABYLON {
  128553. /**
  128554. * Class containing static functions to help procedurally build meshes
  128555. */
  128556. export class PlaneBuilder {
  128557. /**
  128558. * Creates a plane mesh
  128559. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  128560. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  128561. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  128562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128563. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128565. * @param name defines the name of the mesh
  128566. * @param options defines the options used to create the mesh
  128567. * @param scene defines the hosting scene
  128568. * @returns the plane mesh
  128569. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  128570. */
  128571. static CreatePlane(name: string, options: {
  128572. size?: number;
  128573. width?: number;
  128574. height?: number;
  128575. sideOrientation?: number;
  128576. frontUVs?: Vector4;
  128577. backUVs?: Vector4;
  128578. updatable?: boolean;
  128579. sourcePlane?: Plane;
  128580. }, scene?: Nullable<Scene>): Mesh;
  128581. }
  128582. }
  128583. declare module BABYLON {
  128584. /**
  128585. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  128586. */
  128587. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  128588. private static _AnyMouseID;
  128589. /**
  128590. * Abstract mesh the behavior is set on
  128591. */
  128592. attachedNode: AbstractMesh;
  128593. private _dragPlane;
  128594. private _scene;
  128595. private _pointerObserver;
  128596. private _beforeRenderObserver;
  128597. private static _planeScene;
  128598. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  128599. /**
  128600. * 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)
  128601. */
  128602. maxDragAngle: number;
  128603. /**
  128604. * @hidden
  128605. */
  128606. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  128607. /**
  128608. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  128609. */
  128610. currentDraggingPointerID: number;
  128611. /**
  128612. * The last position where the pointer hit the drag plane in world space
  128613. */
  128614. lastDragPosition: Vector3;
  128615. /**
  128616. * If the behavior is currently in a dragging state
  128617. */
  128618. dragging: boolean;
  128619. /**
  128620. * 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)
  128621. */
  128622. dragDeltaRatio: number;
  128623. /**
  128624. * If the drag plane orientation should be updated during the dragging (Default: true)
  128625. */
  128626. updateDragPlane: boolean;
  128627. private _debugMode;
  128628. private _moving;
  128629. /**
  128630. * Fires each time the attached mesh is dragged with the pointer
  128631. * * delta between last drag position and current drag position in world space
  128632. * * dragDistance along the drag axis
  128633. * * dragPlaneNormal normal of the current drag plane used during the drag
  128634. * * dragPlanePoint in world space where the drag intersects the drag plane
  128635. */
  128636. onDragObservable: Observable<{
  128637. delta: Vector3;
  128638. dragPlanePoint: Vector3;
  128639. dragPlaneNormal: Vector3;
  128640. dragDistance: number;
  128641. pointerId: number;
  128642. }>;
  128643. /**
  128644. * Fires each time a drag begins (eg. mouse down on mesh)
  128645. */
  128646. onDragStartObservable: Observable<{
  128647. dragPlanePoint: Vector3;
  128648. pointerId: number;
  128649. }>;
  128650. /**
  128651. * Fires each time a drag ends (eg. mouse release after drag)
  128652. */
  128653. onDragEndObservable: Observable<{
  128654. dragPlanePoint: Vector3;
  128655. pointerId: number;
  128656. }>;
  128657. /**
  128658. * If the attached mesh should be moved when dragged
  128659. */
  128660. moveAttached: boolean;
  128661. /**
  128662. * If the drag behavior will react to drag events (Default: true)
  128663. */
  128664. enabled: boolean;
  128665. /**
  128666. * If pointer events should start and release the drag (Default: true)
  128667. */
  128668. startAndReleaseDragOnPointerEvents: boolean;
  128669. /**
  128670. * If camera controls should be detached during the drag
  128671. */
  128672. detachCameraControls: boolean;
  128673. /**
  128674. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  128675. */
  128676. useObjectOrientationForDragging: boolean;
  128677. private _options;
  128678. /**
  128679. * Gets the options used by the behavior
  128680. */
  128681. get options(): {
  128682. dragAxis?: Vector3;
  128683. dragPlaneNormal?: Vector3;
  128684. };
  128685. /**
  128686. * Sets the options used by the behavior
  128687. */
  128688. set options(options: {
  128689. dragAxis?: Vector3;
  128690. dragPlaneNormal?: Vector3;
  128691. });
  128692. /**
  128693. * Creates a pointer drag behavior that can be attached to a mesh
  128694. * @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)
  128695. */
  128696. constructor(options?: {
  128697. dragAxis?: Vector3;
  128698. dragPlaneNormal?: Vector3;
  128699. });
  128700. /**
  128701. * Predicate to determine if it is valid to move the object to a new position when it is moved
  128702. */
  128703. validateDrag: (targetPosition: Vector3) => boolean;
  128704. /**
  128705. * The name of the behavior
  128706. */
  128707. get name(): string;
  128708. /**
  128709. * Initializes the behavior
  128710. */
  128711. init(): void;
  128712. private _tmpVector;
  128713. private _alternatePickedPoint;
  128714. private _worldDragAxis;
  128715. private _targetPosition;
  128716. private _attachedToElement;
  128717. /**
  128718. * Attaches the drag behavior the passed in mesh
  128719. * @param ownerNode The mesh that will be dragged around once attached
  128720. * @param predicate Predicate to use for pick filtering
  128721. */
  128722. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  128723. /**
  128724. * Force relase the drag action by code.
  128725. */
  128726. releaseDrag(): void;
  128727. private _startDragRay;
  128728. private _lastPointerRay;
  128729. /**
  128730. * Simulates the start of a pointer drag event on the behavior
  128731. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  128732. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  128733. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  128734. */
  128735. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  128736. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  128737. private _dragDelta;
  128738. protected _moveDrag(ray: Ray): void;
  128739. private _pickWithRayOnDragPlane;
  128740. private _pointA;
  128741. private _pointC;
  128742. private _localAxis;
  128743. private _lookAt;
  128744. private _updateDragPlanePosition;
  128745. /**
  128746. * Detaches the behavior from the mesh
  128747. */
  128748. detach(): void;
  128749. }
  128750. }
  128751. declare module BABYLON {
  128752. /**
  128753. * A behavior that when attached to a mesh will allow the mesh to be scaled
  128754. */
  128755. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  128756. private _dragBehaviorA;
  128757. private _dragBehaviorB;
  128758. private _startDistance;
  128759. private _initialScale;
  128760. private _targetScale;
  128761. private _ownerNode;
  128762. private _sceneRenderObserver;
  128763. /**
  128764. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  128765. */
  128766. constructor();
  128767. /**
  128768. * The name of the behavior
  128769. */
  128770. get name(): string;
  128771. /**
  128772. * Initializes the behavior
  128773. */
  128774. init(): void;
  128775. private _getCurrentDistance;
  128776. /**
  128777. * Attaches the scale behavior the passed in mesh
  128778. * @param ownerNode The mesh that will be scaled around once attached
  128779. */
  128780. attach(ownerNode: Mesh): void;
  128781. /**
  128782. * Detaches the behavior from the mesh
  128783. */
  128784. detach(): void;
  128785. }
  128786. }
  128787. declare module BABYLON {
  128788. /**
  128789. * 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
  128790. */
  128791. export class SixDofDragBehavior implements Behavior<Mesh> {
  128792. private static _virtualScene;
  128793. private _ownerNode;
  128794. private _sceneRenderObserver;
  128795. private _scene;
  128796. private _targetPosition;
  128797. private _virtualOriginMesh;
  128798. private _virtualDragMesh;
  128799. private _pointerObserver;
  128800. private _moving;
  128801. private _startingOrientation;
  128802. private _attachedToElement;
  128803. /**
  128804. * 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)
  128805. */
  128806. private zDragFactor;
  128807. /**
  128808. * If the object should rotate to face the drag origin
  128809. */
  128810. rotateDraggedObject: boolean;
  128811. /**
  128812. * If the behavior is currently in a dragging state
  128813. */
  128814. dragging: boolean;
  128815. /**
  128816. * 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)
  128817. */
  128818. dragDeltaRatio: number;
  128819. /**
  128820. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  128821. */
  128822. currentDraggingPointerID: number;
  128823. /**
  128824. * If camera controls should be detached during the drag
  128825. */
  128826. detachCameraControls: boolean;
  128827. /**
  128828. * Fires each time a drag starts
  128829. */
  128830. onDragStartObservable: Observable<{}>;
  128831. /**
  128832. * Fires each time a drag happens
  128833. */
  128834. onDragObservable: Observable<void>;
  128835. /**
  128836. * Fires each time a drag ends (eg. mouse release after drag)
  128837. */
  128838. onDragEndObservable: Observable<{}>;
  128839. /**
  128840. * 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
  128841. */
  128842. constructor();
  128843. /**
  128844. * The name of the behavior
  128845. */
  128846. get name(): string;
  128847. /**
  128848. * Initializes the behavior
  128849. */
  128850. init(): void;
  128851. /**
  128852. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  128853. */
  128854. private get _pointerCamera();
  128855. /**
  128856. * Attaches the scale behavior the passed in mesh
  128857. * @param ownerNode The mesh that will be scaled around once attached
  128858. */
  128859. attach(ownerNode: Mesh): void;
  128860. /**
  128861. * Detaches the behavior from the mesh
  128862. */
  128863. detach(): void;
  128864. }
  128865. }
  128866. declare module BABYLON {
  128867. /**
  128868. * Class used to apply inverse kinematics to bones
  128869. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  128870. */
  128871. export class BoneIKController {
  128872. private static _tmpVecs;
  128873. private static _tmpQuat;
  128874. private static _tmpMats;
  128875. /**
  128876. * Gets or sets the target mesh
  128877. */
  128878. targetMesh: AbstractMesh;
  128879. /** Gets or sets the mesh used as pole */
  128880. poleTargetMesh: AbstractMesh;
  128881. /**
  128882. * Gets or sets the bone used as pole
  128883. */
  128884. poleTargetBone: Nullable<Bone>;
  128885. /**
  128886. * Gets or sets the target position
  128887. */
  128888. targetPosition: Vector3;
  128889. /**
  128890. * Gets or sets the pole target position
  128891. */
  128892. poleTargetPosition: Vector3;
  128893. /**
  128894. * Gets or sets the pole target local offset
  128895. */
  128896. poleTargetLocalOffset: Vector3;
  128897. /**
  128898. * Gets or sets the pole angle
  128899. */
  128900. poleAngle: number;
  128901. /**
  128902. * Gets or sets the mesh associated with the controller
  128903. */
  128904. mesh: AbstractMesh;
  128905. /**
  128906. * 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)
  128907. */
  128908. slerpAmount: number;
  128909. private _bone1Quat;
  128910. private _bone1Mat;
  128911. private _bone2Ang;
  128912. private _bone1;
  128913. private _bone2;
  128914. private _bone1Length;
  128915. private _bone2Length;
  128916. private _maxAngle;
  128917. private _maxReach;
  128918. private _rightHandedSystem;
  128919. private _bendAxis;
  128920. private _slerping;
  128921. private _adjustRoll;
  128922. /**
  128923. * Gets or sets maximum allowed angle
  128924. */
  128925. get maxAngle(): number;
  128926. set maxAngle(value: number);
  128927. /**
  128928. * Creates a new BoneIKController
  128929. * @param mesh defines the mesh to control
  128930. * @param bone defines the bone to control
  128931. * @param options defines options to set up the controller
  128932. */
  128933. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  128934. targetMesh?: AbstractMesh;
  128935. poleTargetMesh?: AbstractMesh;
  128936. poleTargetBone?: Bone;
  128937. poleTargetLocalOffset?: Vector3;
  128938. poleAngle?: number;
  128939. bendAxis?: Vector3;
  128940. maxAngle?: number;
  128941. slerpAmount?: number;
  128942. });
  128943. private _setMaxAngle;
  128944. /**
  128945. * Force the controller to update the bones
  128946. */
  128947. update(): void;
  128948. }
  128949. }
  128950. declare module BABYLON {
  128951. /**
  128952. * Class used to make a bone look toward a point in space
  128953. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  128954. */
  128955. export class BoneLookController {
  128956. private static _tmpVecs;
  128957. private static _tmpQuat;
  128958. private static _tmpMats;
  128959. /**
  128960. * The target Vector3 that the bone will look at
  128961. */
  128962. target: Vector3;
  128963. /**
  128964. * The mesh that the bone is attached to
  128965. */
  128966. mesh: AbstractMesh;
  128967. /**
  128968. * The bone that will be looking to the target
  128969. */
  128970. bone: Bone;
  128971. /**
  128972. * The up axis of the coordinate system that is used when the bone is rotated
  128973. */
  128974. upAxis: Vector3;
  128975. /**
  128976. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  128977. */
  128978. upAxisSpace: Space;
  128979. /**
  128980. * Used to make an adjustment to the yaw of the bone
  128981. */
  128982. adjustYaw: number;
  128983. /**
  128984. * Used to make an adjustment to the pitch of the bone
  128985. */
  128986. adjustPitch: number;
  128987. /**
  128988. * Used to make an adjustment to the roll of the bone
  128989. */
  128990. adjustRoll: number;
  128991. /**
  128992. * 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)
  128993. */
  128994. slerpAmount: number;
  128995. private _minYaw;
  128996. private _maxYaw;
  128997. private _minPitch;
  128998. private _maxPitch;
  128999. private _minYawSin;
  129000. private _minYawCos;
  129001. private _maxYawSin;
  129002. private _maxYawCos;
  129003. private _midYawConstraint;
  129004. private _minPitchTan;
  129005. private _maxPitchTan;
  129006. private _boneQuat;
  129007. private _slerping;
  129008. private _transformYawPitch;
  129009. private _transformYawPitchInv;
  129010. private _firstFrameSkipped;
  129011. private _yawRange;
  129012. private _fowardAxis;
  129013. /**
  129014. * Gets or sets the minimum yaw angle that the bone can look to
  129015. */
  129016. get minYaw(): number;
  129017. set minYaw(value: number);
  129018. /**
  129019. * Gets or sets the maximum yaw angle that the bone can look to
  129020. */
  129021. get maxYaw(): number;
  129022. set maxYaw(value: number);
  129023. /**
  129024. * Gets or sets the minimum pitch angle that the bone can look to
  129025. */
  129026. get minPitch(): number;
  129027. set minPitch(value: number);
  129028. /**
  129029. * Gets or sets the maximum pitch angle that the bone can look to
  129030. */
  129031. get maxPitch(): number;
  129032. set maxPitch(value: number);
  129033. /**
  129034. * Create a BoneLookController
  129035. * @param mesh the mesh that the bone belongs to
  129036. * @param bone the bone that will be looking to the target
  129037. * @param target the target Vector3 to look at
  129038. * @param options optional settings:
  129039. * * maxYaw: the maximum angle the bone will yaw to
  129040. * * minYaw: the minimum angle the bone will yaw to
  129041. * * maxPitch: the maximum angle the bone will pitch to
  129042. * * minPitch: the minimum angle the bone will yaw to
  129043. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  129044. * * upAxis: the up axis of the coordinate system
  129045. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  129046. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  129047. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  129048. * * adjustYaw: used to make an adjustment to the yaw of the bone
  129049. * * adjustPitch: used to make an adjustment to the pitch of the bone
  129050. * * adjustRoll: used to make an adjustment to the roll of the bone
  129051. **/
  129052. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  129053. maxYaw?: number;
  129054. minYaw?: number;
  129055. maxPitch?: number;
  129056. minPitch?: number;
  129057. slerpAmount?: number;
  129058. upAxis?: Vector3;
  129059. upAxisSpace?: Space;
  129060. yawAxis?: Vector3;
  129061. pitchAxis?: Vector3;
  129062. adjustYaw?: number;
  129063. adjustPitch?: number;
  129064. adjustRoll?: number;
  129065. });
  129066. /**
  129067. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  129068. */
  129069. update(): void;
  129070. private _getAngleDiff;
  129071. private _getAngleBetween;
  129072. private _isAngleBetween;
  129073. }
  129074. }
  129075. declare module BABYLON {
  129076. /**
  129077. * Manage the gamepad inputs to control an arc rotate camera.
  129078. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129079. */
  129080. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  129081. /**
  129082. * Defines the camera the input is attached to.
  129083. */
  129084. camera: ArcRotateCamera;
  129085. /**
  129086. * Defines the gamepad the input is gathering event from.
  129087. */
  129088. gamepad: Nullable<Gamepad>;
  129089. /**
  129090. * Defines the gamepad rotation sensiblity.
  129091. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  129092. */
  129093. gamepadRotationSensibility: number;
  129094. /**
  129095. * Defines the gamepad move sensiblity.
  129096. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  129097. */
  129098. gamepadMoveSensibility: number;
  129099. private _yAxisScale;
  129100. /**
  129101. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  129102. */
  129103. get invertYAxis(): boolean;
  129104. set invertYAxis(value: boolean);
  129105. private _onGamepadConnectedObserver;
  129106. private _onGamepadDisconnectedObserver;
  129107. /**
  129108. * Attach the input controls to a specific dom element to get the input from.
  129109. */
  129110. attachControl(): void;
  129111. /**
  129112. * Detach the current controls from the specified dom element.
  129113. */
  129114. detachControl(): void;
  129115. /**
  129116. * Update the current camera state depending on the inputs that have been used this frame.
  129117. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129118. */
  129119. checkInputs(): void;
  129120. /**
  129121. * Gets the class name of the current intput.
  129122. * @returns the class name
  129123. */
  129124. getClassName(): string;
  129125. /**
  129126. * Get the friendly name associated with the input class.
  129127. * @returns the input friendly name
  129128. */
  129129. getSimpleName(): string;
  129130. }
  129131. }
  129132. declare module BABYLON {
  129133. interface ArcRotateCameraInputsManager {
  129134. /**
  129135. * Add orientation input support to the input manager.
  129136. * @returns the current input manager
  129137. */
  129138. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  129139. }
  129140. /**
  129141. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  129142. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129143. */
  129144. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  129145. /**
  129146. * Defines the camera the input is attached to.
  129147. */
  129148. camera: ArcRotateCamera;
  129149. /**
  129150. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  129151. */
  129152. alphaCorrection: number;
  129153. /**
  129154. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  129155. */
  129156. gammaCorrection: number;
  129157. private _alpha;
  129158. private _gamma;
  129159. private _dirty;
  129160. private _deviceOrientationHandler;
  129161. /**
  129162. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  129163. */
  129164. constructor();
  129165. /**
  129166. * Attach the input controls to a specific dom element to get the input from.
  129167. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129168. */
  129169. attachControl(noPreventDefault?: boolean): void;
  129170. /** @hidden */
  129171. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  129172. /**
  129173. * Update the current camera state depending on the inputs that have been used this frame.
  129174. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129175. */
  129176. checkInputs(): void;
  129177. /**
  129178. * Detach the current controls from the specified dom element.
  129179. */
  129180. detachControl(): void;
  129181. /**
  129182. * Gets the class name of the current intput.
  129183. * @returns the class name
  129184. */
  129185. getClassName(): string;
  129186. /**
  129187. * Get the friendly name associated with the input class.
  129188. * @returns the input friendly name
  129189. */
  129190. getSimpleName(): string;
  129191. }
  129192. }
  129193. declare module BABYLON {
  129194. /**
  129195. * Listen to mouse events to control the camera.
  129196. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129197. */
  129198. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  129199. /**
  129200. * Defines the camera the input is attached to.
  129201. */
  129202. camera: FlyCamera;
  129203. /**
  129204. * Defines if touch is enabled. (Default is true.)
  129205. */
  129206. touchEnabled: boolean;
  129207. /**
  129208. * Defines the buttons associated with the input to handle camera rotation.
  129209. */
  129210. buttons: number[];
  129211. /**
  129212. * Assign buttons for Yaw control.
  129213. */
  129214. buttonsYaw: number[];
  129215. /**
  129216. * Assign buttons for Pitch control.
  129217. */
  129218. buttonsPitch: number[];
  129219. /**
  129220. * Assign buttons for Roll control.
  129221. */
  129222. buttonsRoll: number[];
  129223. /**
  129224. * Detect if any button is being pressed while mouse is moved.
  129225. * -1 = Mouse locked.
  129226. * 0 = Left button.
  129227. * 1 = Middle Button.
  129228. * 2 = Right Button.
  129229. */
  129230. activeButton: number;
  129231. /**
  129232. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  129233. * Higher values reduce its sensitivity.
  129234. */
  129235. angularSensibility: number;
  129236. private _observer;
  129237. private _rollObserver;
  129238. private previousPosition;
  129239. private noPreventDefault;
  129240. private element;
  129241. /**
  129242. * Listen to mouse events to control the camera.
  129243. * @param touchEnabled Define if touch is enabled. (Default is true.)
  129244. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129245. */
  129246. constructor(touchEnabled?: boolean);
  129247. /**
  129248. * Attach the mouse control to the HTML DOM element.
  129249. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  129250. */
  129251. attachControl(noPreventDefault?: boolean): void;
  129252. /**
  129253. * Detach the current controls from the specified dom element.
  129254. */
  129255. detachControl(): void;
  129256. /**
  129257. * Gets the class name of the current input.
  129258. * @returns the class name.
  129259. */
  129260. getClassName(): string;
  129261. /**
  129262. * Get the friendly name associated with the input class.
  129263. * @returns the input's friendly name.
  129264. */
  129265. getSimpleName(): string;
  129266. private _pointerInput;
  129267. private _onMouseMove;
  129268. /**
  129269. * Rotate camera by mouse offset.
  129270. */
  129271. private rotateCamera;
  129272. }
  129273. }
  129274. declare module BABYLON {
  129275. /**
  129276. * Default Inputs manager for the FlyCamera.
  129277. * It groups all the default supported inputs for ease of use.
  129278. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129279. */
  129280. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  129281. /**
  129282. * Instantiates a new FlyCameraInputsManager.
  129283. * @param camera Defines the camera the inputs belong to.
  129284. */
  129285. constructor(camera: FlyCamera);
  129286. /**
  129287. * Add keyboard input support to the input manager.
  129288. * @returns the new FlyCameraKeyboardMoveInput().
  129289. */
  129290. addKeyboard(): FlyCameraInputsManager;
  129291. /**
  129292. * Add mouse input support to the input manager.
  129293. * @param touchEnabled Enable touch screen support.
  129294. * @returns the new FlyCameraMouseInput().
  129295. */
  129296. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  129297. }
  129298. }
  129299. declare module BABYLON {
  129300. /**
  129301. * This is a flying camera, designed for 3D movement and rotation in all directions,
  129302. * such as in a 3D Space Shooter or a Flight Simulator.
  129303. */
  129304. export class FlyCamera extends TargetCamera {
  129305. /**
  129306. * Define the collision ellipsoid of the camera.
  129307. * This is helpful for simulating a camera body, like a player's body.
  129308. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  129309. */
  129310. ellipsoid: Vector3;
  129311. /**
  129312. * Define an offset for the position of the ellipsoid around the camera.
  129313. * This can be helpful if the camera is attached away from the player's body center,
  129314. * such as at its head.
  129315. */
  129316. ellipsoidOffset: Vector3;
  129317. /**
  129318. * Enable or disable collisions of the camera with the rest of the scene objects.
  129319. */
  129320. checkCollisions: boolean;
  129321. /**
  129322. * Enable or disable gravity on the camera.
  129323. */
  129324. applyGravity: boolean;
  129325. /**
  129326. * Define the current direction the camera is moving to.
  129327. */
  129328. cameraDirection: Vector3;
  129329. /**
  129330. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  129331. * This overrides and empties cameraRotation.
  129332. */
  129333. rotationQuaternion: Quaternion;
  129334. /**
  129335. * Track Roll to maintain the wanted Rolling when looking around.
  129336. */
  129337. _trackRoll: number;
  129338. /**
  129339. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  129340. */
  129341. rollCorrect: number;
  129342. /**
  129343. * Mimic a banked turn, Rolling the camera when Yawing.
  129344. * It's recommended to use rollCorrect = 10 for faster banking correction.
  129345. */
  129346. bankedTurn: boolean;
  129347. /**
  129348. * Limit in radians for how much Roll banking will add. (Default: 90°)
  129349. */
  129350. bankedTurnLimit: number;
  129351. /**
  129352. * Value of 0 disables the banked Roll.
  129353. * Value of 1 is equal to the Yaw angle in radians.
  129354. */
  129355. bankedTurnMultiplier: number;
  129356. /**
  129357. * The inputs manager loads all the input sources, such as keyboard and mouse.
  129358. */
  129359. inputs: FlyCameraInputsManager;
  129360. /**
  129361. * Gets the input sensibility for mouse input.
  129362. * Higher values reduce sensitivity.
  129363. */
  129364. get angularSensibility(): number;
  129365. /**
  129366. * Sets the input sensibility for a mouse input.
  129367. * Higher values reduce sensitivity.
  129368. */
  129369. set angularSensibility(value: number);
  129370. /**
  129371. * Get the keys for camera movement forward.
  129372. */
  129373. get keysForward(): number[];
  129374. /**
  129375. * Set the keys for camera movement forward.
  129376. */
  129377. set keysForward(value: number[]);
  129378. /**
  129379. * Get the keys for camera movement backward.
  129380. */
  129381. get keysBackward(): number[];
  129382. set keysBackward(value: number[]);
  129383. /**
  129384. * Get the keys for camera movement up.
  129385. */
  129386. get keysUp(): number[];
  129387. /**
  129388. * Set the keys for camera movement up.
  129389. */
  129390. set keysUp(value: number[]);
  129391. /**
  129392. * Get the keys for camera movement down.
  129393. */
  129394. get keysDown(): number[];
  129395. /**
  129396. * Set the keys for camera movement down.
  129397. */
  129398. set keysDown(value: number[]);
  129399. /**
  129400. * Get the keys for camera movement left.
  129401. */
  129402. get keysLeft(): number[];
  129403. /**
  129404. * Set the keys for camera movement left.
  129405. */
  129406. set keysLeft(value: number[]);
  129407. /**
  129408. * Set the keys for camera movement right.
  129409. */
  129410. get keysRight(): number[];
  129411. /**
  129412. * Set the keys for camera movement right.
  129413. */
  129414. set keysRight(value: number[]);
  129415. /**
  129416. * Event raised when the camera collides with a mesh in the scene.
  129417. */
  129418. onCollide: (collidedMesh: AbstractMesh) => void;
  129419. private _collider;
  129420. private _needMoveForGravity;
  129421. private _oldPosition;
  129422. private _diffPosition;
  129423. private _newPosition;
  129424. /** @hidden */
  129425. _localDirection: Vector3;
  129426. /** @hidden */
  129427. _transformedDirection: Vector3;
  129428. /**
  129429. * Instantiates a FlyCamera.
  129430. * This is a flying camera, designed for 3D movement and rotation in all directions,
  129431. * such as in a 3D Space Shooter or a Flight Simulator.
  129432. * @param name Define the name of the camera in the scene.
  129433. * @param position Define the starting position of the camera in the scene.
  129434. * @param scene Define the scene the camera belongs to.
  129435. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  129436. */
  129437. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  129438. /**
  129439. * Attach the input controls to a specific dom element to get the input from.
  129440. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129441. */
  129442. attachControl(noPreventDefault?: boolean): void;
  129443. /**
  129444. * Detach a control from the HTML DOM element.
  129445. * The camera will stop reacting to that input.
  129446. */
  129447. detachControl(): void;
  129448. private _collisionMask;
  129449. /**
  129450. * Get the mask that the camera ignores in collision events.
  129451. */
  129452. get collisionMask(): number;
  129453. /**
  129454. * Set the mask that the camera ignores in collision events.
  129455. */
  129456. set collisionMask(mask: number);
  129457. /** @hidden */
  129458. _collideWithWorld(displacement: Vector3): void;
  129459. /** @hidden */
  129460. private _onCollisionPositionChange;
  129461. /** @hidden */
  129462. _checkInputs(): void;
  129463. /** @hidden */
  129464. _decideIfNeedsToMove(): boolean;
  129465. /** @hidden */
  129466. _updatePosition(): void;
  129467. /**
  129468. * Restore the Roll to its target value at the rate specified.
  129469. * @param rate - Higher means slower restoring.
  129470. * @hidden
  129471. */
  129472. restoreRoll(rate: number): void;
  129473. /**
  129474. * Destroy the camera and release the current resources held by it.
  129475. */
  129476. dispose(): void;
  129477. /**
  129478. * Get the current object class name.
  129479. * @returns the class name.
  129480. */
  129481. getClassName(): string;
  129482. }
  129483. }
  129484. declare module BABYLON {
  129485. /**
  129486. * Listen to keyboard events to control the camera.
  129487. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129488. */
  129489. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  129490. /**
  129491. * Defines the camera the input is attached to.
  129492. */
  129493. camera: FlyCamera;
  129494. /**
  129495. * The list of keyboard keys used to control the forward move of the camera.
  129496. */
  129497. keysForward: number[];
  129498. /**
  129499. * The list of keyboard keys used to control the backward move of the camera.
  129500. */
  129501. keysBackward: number[];
  129502. /**
  129503. * The list of keyboard keys used to control the forward move of the camera.
  129504. */
  129505. keysUp: number[];
  129506. /**
  129507. * The list of keyboard keys used to control the backward move of the camera.
  129508. */
  129509. keysDown: number[];
  129510. /**
  129511. * The list of keyboard keys used to control the right strafe move of the camera.
  129512. */
  129513. keysRight: number[];
  129514. /**
  129515. * The list of keyboard keys used to control the left strafe move of the camera.
  129516. */
  129517. keysLeft: number[];
  129518. private _keys;
  129519. private _onCanvasBlurObserver;
  129520. private _onKeyboardObserver;
  129521. private _engine;
  129522. private _scene;
  129523. /**
  129524. * Attach the input controls to a specific dom element to get the input from.
  129525. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129526. */
  129527. attachControl(noPreventDefault?: boolean): void;
  129528. /**
  129529. * Detach the current controls from the specified dom element.
  129530. */
  129531. detachControl(): void;
  129532. /**
  129533. * Gets the class name of the current intput.
  129534. * @returns the class name
  129535. */
  129536. getClassName(): string;
  129537. /** @hidden */
  129538. _onLostFocus(e: FocusEvent): void;
  129539. /**
  129540. * Get the friendly name associated with the input class.
  129541. * @returns the input friendly name
  129542. */
  129543. getSimpleName(): string;
  129544. /**
  129545. * Update the current camera state depending on the inputs that have been used this frame.
  129546. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129547. */
  129548. checkInputs(): void;
  129549. }
  129550. }
  129551. declare module BABYLON {
  129552. /**
  129553. * Manage the mouse wheel inputs to control a follow camera.
  129554. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129555. */
  129556. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  129557. /**
  129558. * Defines the camera the input is attached to.
  129559. */
  129560. camera: FollowCamera;
  129561. /**
  129562. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  129563. */
  129564. axisControlRadius: boolean;
  129565. /**
  129566. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  129567. */
  129568. axisControlHeight: boolean;
  129569. /**
  129570. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  129571. */
  129572. axisControlRotation: boolean;
  129573. /**
  129574. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  129575. * relation to mouseWheel events.
  129576. */
  129577. wheelPrecision: number;
  129578. /**
  129579. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  129580. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  129581. */
  129582. wheelDeltaPercentage: number;
  129583. private _wheel;
  129584. private _observer;
  129585. /**
  129586. * Attach the input controls to a specific dom element to get the input from.
  129587. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129588. */
  129589. attachControl(noPreventDefault?: boolean): void;
  129590. /**
  129591. * Detach the current controls from the specified dom element.
  129592. */
  129593. detachControl(): void;
  129594. /**
  129595. * Gets the class name of the current intput.
  129596. * @returns the class name
  129597. */
  129598. getClassName(): string;
  129599. /**
  129600. * Get the friendly name associated with the input class.
  129601. * @returns the input friendly name
  129602. */
  129603. getSimpleName(): string;
  129604. }
  129605. }
  129606. declare module BABYLON {
  129607. /**
  129608. * Manage the pointers inputs to control an follow camera.
  129609. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129610. */
  129611. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  129612. /**
  129613. * Defines the camera the input is attached to.
  129614. */
  129615. camera: FollowCamera;
  129616. /**
  129617. * Gets the class name of the current input.
  129618. * @returns the class name
  129619. */
  129620. getClassName(): string;
  129621. /**
  129622. * Defines the pointer angular sensibility along the X axis or how fast is
  129623. * the camera rotating.
  129624. * A negative number will reverse the axis direction.
  129625. */
  129626. angularSensibilityX: number;
  129627. /**
  129628. * Defines the pointer angular sensibility along the Y axis or how fast is
  129629. * the camera rotating.
  129630. * A negative number will reverse the axis direction.
  129631. */
  129632. angularSensibilityY: number;
  129633. /**
  129634. * Defines the pointer pinch precision or how fast is the camera zooming.
  129635. * A negative number will reverse the axis direction.
  129636. */
  129637. pinchPrecision: number;
  129638. /**
  129639. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  129640. * from 0.
  129641. * It defines the percentage of current camera.radius to use as delta when
  129642. * pinch zoom is used.
  129643. */
  129644. pinchDeltaPercentage: number;
  129645. /**
  129646. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  129647. */
  129648. axisXControlRadius: boolean;
  129649. /**
  129650. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  129651. */
  129652. axisXControlHeight: boolean;
  129653. /**
  129654. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  129655. */
  129656. axisXControlRotation: boolean;
  129657. /**
  129658. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  129659. */
  129660. axisYControlRadius: boolean;
  129661. /**
  129662. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  129663. */
  129664. axisYControlHeight: boolean;
  129665. /**
  129666. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  129667. */
  129668. axisYControlRotation: boolean;
  129669. /**
  129670. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  129671. */
  129672. axisPinchControlRadius: boolean;
  129673. /**
  129674. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  129675. */
  129676. axisPinchControlHeight: boolean;
  129677. /**
  129678. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  129679. */
  129680. axisPinchControlRotation: boolean;
  129681. /**
  129682. * Log error messages if basic misconfiguration has occurred.
  129683. */
  129684. warningEnable: boolean;
  129685. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  129686. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  129687. private _warningCounter;
  129688. private _warning;
  129689. }
  129690. }
  129691. declare module BABYLON {
  129692. /**
  129693. * Default Inputs manager for the FollowCamera.
  129694. * It groups all the default supported inputs for ease of use.
  129695. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129696. */
  129697. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  129698. /**
  129699. * Instantiates a new FollowCameraInputsManager.
  129700. * @param camera Defines the camera the inputs belong to
  129701. */
  129702. constructor(camera: FollowCamera);
  129703. /**
  129704. * Add keyboard input support to the input manager.
  129705. * @returns the current input manager
  129706. */
  129707. addKeyboard(): FollowCameraInputsManager;
  129708. /**
  129709. * Add mouse wheel input support to the input manager.
  129710. * @returns the current input manager
  129711. */
  129712. addMouseWheel(): FollowCameraInputsManager;
  129713. /**
  129714. * Add pointers input support to the input manager.
  129715. * @returns the current input manager
  129716. */
  129717. addPointers(): FollowCameraInputsManager;
  129718. /**
  129719. * Add orientation input support to the input manager.
  129720. * @returns the current input manager
  129721. */
  129722. addVRDeviceOrientation(): FollowCameraInputsManager;
  129723. }
  129724. }
  129725. declare module BABYLON {
  129726. /**
  129727. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  129728. * an arc rotate version arcFollowCamera are available.
  129729. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129730. */
  129731. export class FollowCamera extends TargetCamera {
  129732. /**
  129733. * Distance the follow camera should follow an object at
  129734. */
  129735. radius: number;
  129736. /**
  129737. * Minimum allowed distance of the camera to the axis of rotation
  129738. * (The camera can not get closer).
  129739. * This can help limiting how the Camera is able to move in the scene.
  129740. */
  129741. lowerRadiusLimit: Nullable<number>;
  129742. /**
  129743. * Maximum allowed distance of the camera to the axis of rotation
  129744. * (The camera can not get further).
  129745. * This can help limiting how the Camera is able to move in the scene.
  129746. */
  129747. upperRadiusLimit: Nullable<number>;
  129748. /**
  129749. * Define a rotation offset between the camera and the object it follows
  129750. */
  129751. rotationOffset: number;
  129752. /**
  129753. * Minimum allowed angle to camera position relative to target object.
  129754. * This can help limiting how the Camera is able to move in the scene.
  129755. */
  129756. lowerRotationOffsetLimit: Nullable<number>;
  129757. /**
  129758. * Maximum allowed angle to camera position relative to target object.
  129759. * This can help limiting how the Camera is able to move in the scene.
  129760. */
  129761. upperRotationOffsetLimit: Nullable<number>;
  129762. /**
  129763. * Define a height offset between the camera and the object it follows.
  129764. * It can help following an object from the top (like a car chaing a plane)
  129765. */
  129766. heightOffset: number;
  129767. /**
  129768. * Minimum allowed height of camera position relative to target object.
  129769. * This can help limiting how the Camera is able to move in the scene.
  129770. */
  129771. lowerHeightOffsetLimit: Nullable<number>;
  129772. /**
  129773. * Maximum allowed height of camera position relative to target object.
  129774. * This can help limiting how the Camera is able to move in the scene.
  129775. */
  129776. upperHeightOffsetLimit: Nullable<number>;
  129777. /**
  129778. * Define how fast the camera can accelerate to follow it s target.
  129779. */
  129780. cameraAcceleration: number;
  129781. /**
  129782. * Define the speed limit of the camera following an object.
  129783. */
  129784. maxCameraSpeed: number;
  129785. /**
  129786. * Define the target of the camera.
  129787. */
  129788. lockedTarget: Nullable<AbstractMesh>;
  129789. /**
  129790. * Defines the input associated with the camera.
  129791. */
  129792. inputs: FollowCameraInputsManager;
  129793. /**
  129794. * Instantiates the follow camera.
  129795. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129796. * @param name Define the name of the camera in the scene
  129797. * @param position Define the position of the camera
  129798. * @param scene Define the scene the camera belong to
  129799. * @param lockedTarget Define the target of the camera
  129800. */
  129801. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  129802. private _follow;
  129803. /**
  129804. * Attach the input controls to a specific dom element to get the input from.
  129805. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129806. */
  129807. attachControl(noPreventDefault?: boolean): void;
  129808. /**
  129809. * Detach the current controls from the specified dom element.
  129810. */
  129811. detachControl(): void;
  129812. /** @hidden */
  129813. _checkInputs(): void;
  129814. private _checkLimits;
  129815. /**
  129816. * Gets the camera class name.
  129817. * @returns the class name
  129818. */
  129819. getClassName(): string;
  129820. }
  129821. /**
  129822. * Arc Rotate version of the follow camera.
  129823. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  129824. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129825. */
  129826. export class ArcFollowCamera extends TargetCamera {
  129827. /** The longitudinal angle of the camera */
  129828. alpha: number;
  129829. /** The latitudinal angle of the camera */
  129830. beta: number;
  129831. /** The radius of the camera from its target */
  129832. radius: number;
  129833. private _cartesianCoordinates;
  129834. /** Define the camera target (the mesh it should follow) */
  129835. private _meshTarget;
  129836. /**
  129837. * Instantiates a new ArcFollowCamera
  129838. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129839. * @param name Define the name of the camera
  129840. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  129841. * @param beta Define the rotation angle of the camera around the elevation axis
  129842. * @param radius Define the radius of the camera from its target point
  129843. * @param target Define the target of the camera
  129844. * @param scene Define the scene the camera belongs to
  129845. */
  129846. constructor(name: string,
  129847. /** The longitudinal angle of the camera */
  129848. alpha: number,
  129849. /** The latitudinal angle of the camera */
  129850. beta: number,
  129851. /** The radius of the camera from its target */
  129852. radius: number,
  129853. /** Define the camera target (the mesh it should follow) */
  129854. target: Nullable<AbstractMesh>, scene: Scene);
  129855. private _follow;
  129856. /** @hidden */
  129857. _checkInputs(): void;
  129858. /**
  129859. * Returns the class name of the object.
  129860. * It is mostly used internally for serialization purposes.
  129861. */
  129862. getClassName(): string;
  129863. }
  129864. }
  129865. declare module BABYLON {
  129866. /**
  129867. * Manage the keyboard inputs to control the movement of a follow camera.
  129868. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129869. */
  129870. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  129871. /**
  129872. * Defines the camera the input is attached to.
  129873. */
  129874. camera: FollowCamera;
  129875. /**
  129876. * Defines the list of key codes associated with the up action (increase heightOffset)
  129877. */
  129878. keysHeightOffsetIncr: number[];
  129879. /**
  129880. * Defines the list of key codes associated with the down action (decrease heightOffset)
  129881. */
  129882. keysHeightOffsetDecr: number[];
  129883. /**
  129884. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  129885. */
  129886. keysHeightOffsetModifierAlt: boolean;
  129887. /**
  129888. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  129889. */
  129890. keysHeightOffsetModifierCtrl: boolean;
  129891. /**
  129892. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  129893. */
  129894. keysHeightOffsetModifierShift: boolean;
  129895. /**
  129896. * Defines the list of key codes associated with the left action (increase rotationOffset)
  129897. */
  129898. keysRotationOffsetIncr: number[];
  129899. /**
  129900. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  129901. */
  129902. keysRotationOffsetDecr: number[];
  129903. /**
  129904. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  129905. */
  129906. keysRotationOffsetModifierAlt: boolean;
  129907. /**
  129908. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  129909. */
  129910. keysRotationOffsetModifierCtrl: boolean;
  129911. /**
  129912. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  129913. */
  129914. keysRotationOffsetModifierShift: boolean;
  129915. /**
  129916. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  129917. */
  129918. keysRadiusIncr: number[];
  129919. /**
  129920. * Defines the list of key codes associated with the zoom-out action (increase radius)
  129921. */
  129922. keysRadiusDecr: number[];
  129923. /**
  129924. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  129925. */
  129926. keysRadiusModifierAlt: boolean;
  129927. /**
  129928. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  129929. */
  129930. keysRadiusModifierCtrl: boolean;
  129931. /**
  129932. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  129933. */
  129934. keysRadiusModifierShift: boolean;
  129935. /**
  129936. * Defines the rate of change of heightOffset.
  129937. */
  129938. heightSensibility: number;
  129939. /**
  129940. * Defines the rate of change of rotationOffset.
  129941. */
  129942. rotationSensibility: number;
  129943. /**
  129944. * Defines the rate of change of radius.
  129945. */
  129946. radiusSensibility: number;
  129947. private _keys;
  129948. private _ctrlPressed;
  129949. private _altPressed;
  129950. private _shiftPressed;
  129951. private _onCanvasBlurObserver;
  129952. private _onKeyboardObserver;
  129953. private _engine;
  129954. private _scene;
  129955. /**
  129956. * Attach the input controls to a specific dom element to get the input from.
  129957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129958. */
  129959. attachControl(noPreventDefault?: boolean): void;
  129960. /**
  129961. * Detach the current controls from the specified dom element.
  129962. */
  129963. detachControl(): void;
  129964. /**
  129965. * Update the current camera state depending on the inputs that have been used this frame.
  129966. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129967. */
  129968. checkInputs(): void;
  129969. /**
  129970. * Gets the class name of the current input.
  129971. * @returns the class name
  129972. */
  129973. getClassName(): string;
  129974. /**
  129975. * Get the friendly name associated with the input class.
  129976. * @returns the input friendly name
  129977. */
  129978. getSimpleName(): string;
  129979. /**
  129980. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  129981. * allow modification of the heightOffset value.
  129982. */
  129983. private _modifierHeightOffset;
  129984. /**
  129985. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  129986. * allow modification of the rotationOffset value.
  129987. */
  129988. private _modifierRotationOffset;
  129989. /**
  129990. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  129991. * allow modification of the radius value.
  129992. */
  129993. private _modifierRadius;
  129994. }
  129995. }
  129996. declare module BABYLON {
  129997. interface FreeCameraInputsManager {
  129998. /**
  129999. * @hidden
  130000. */
  130001. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  130002. /**
  130003. * Add orientation input support to the input manager.
  130004. * @returns the current input manager
  130005. */
  130006. addDeviceOrientation(): FreeCameraInputsManager;
  130007. }
  130008. /**
  130009. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  130010. * Screen rotation is taken into account.
  130011. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130012. */
  130013. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  130014. private _camera;
  130015. private _screenOrientationAngle;
  130016. private _constantTranform;
  130017. private _screenQuaternion;
  130018. private _alpha;
  130019. private _beta;
  130020. private _gamma;
  130021. /**
  130022. * Can be used to detect if a device orientation sensor is available on a device
  130023. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  130024. * @returns a promise that will resolve on orientation change
  130025. */
  130026. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  130027. /**
  130028. * @hidden
  130029. */
  130030. _onDeviceOrientationChangedObservable: Observable<void>;
  130031. /**
  130032. * Instantiates a new input
  130033. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130034. */
  130035. constructor();
  130036. /**
  130037. * Define the camera controlled by the input.
  130038. */
  130039. get camera(): FreeCamera;
  130040. set camera(camera: FreeCamera);
  130041. /**
  130042. * Attach the input controls to a specific dom element to get the input from.
  130043. */
  130044. attachControl(): void;
  130045. private _orientationChanged;
  130046. private _deviceOrientation;
  130047. /**
  130048. * Detach the current controls from the specified dom element.
  130049. */
  130050. detachControl(): void;
  130051. /**
  130052. * Update the current camera state depending on the inputs that have been used this frame.
  130053. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  130054. */
  130055. checkInputs(): void;
  130056. /**
  130057. * Gets the class name of the current intput.
  130058. * @returns the class name
  130059. */
  130060. getClassName(): string;
  130061. /**
  130062. * Get the friendly name associated with the input class.
  130063. * @returns the input friendly name
  130064. */
  130065. getSimpleName(): string;
  130066. }
  130067. }
  130068. declare module BABYLON {
  130069. /**
  130070. * Manage the gamepad inputs to control a free camera.
  130071. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130072. */
  130073. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  130074. /**
  130075. * Define the camera the input is attached to.
  130076. */
  130077. camera: FreeCamera;
  130078. /**
  130079. * Define the Gamepad controlling the input
  130080. */
  130081. gamepad: Nullable<Gamepad>;
  130082. /**
  130083. * Defines the gamepad rotation sensiblity.
  130084. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  130085. */
  130086. gamepadAngularSensibility: number;
  130087. /**
  130088. * Defines the gamepad move sensiblity.
  130089. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  130090. */
  130091. gamepadMoveSensibility: number;
  130092. private _yAxisScale;
  130093. /**
  130094. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  130095. */
  130096. get invertYAxis(): boolean;
  130097. set invertYAxis(value: boolean);
  130098. private _onGamepadConnectedObserver;
  130099. private _onGamepadDisconnectedObserver;
  130100. private _cameraTransform;
  130101. private _deltaTransform;
  130102. private _vector3;
  130103. private _vector2;
  130104. /**
  130105. * Attach the input controls to a specific dom element to get the input from.
  130106. */
  130107. attachControl(): void;
  130108. /**
  130109. * Detach the current controls from the specified dom element.
  130110. */
  130111. detachControl(): void;
  130112. /**
  130113. * Update the current camera state depending on the inputs that have been used this frame.
  130114. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  130115. */
  130116. checkInputs(): void;
  130117. /**
  130118. * Gets the class name of the current intput.
  130119. * @returns the class name
  130120. */
  130121. getClassName(): string;
  130122. /**
  130123. * Get the friendly name associated with the input class.
  130124. * @returns the input friendly name
  130125. */
  130126. getSimpleName(): string;
  130127. }
  130128. }
  130129. declare module BABYLON {
  130130. /**
  130131. * Defines the potential axis of a Joystick
  130132. */
  130133. export enum JoystickAxis {
  130134. /** X axis */
  130135. X = 0,
  130136. /** Y axis */
  130137. Y = 1,
  130138. /** Z axis */
  130139. Z = 2
  130140. }
  130141. /**
  130142. * Represents the different customization options available
  130143. * for VirtualJoystick
  130144. */
  130145. interface VirtualJoystickCustomizations {
  130146. /**
  130147. * Size of the joystick's puck
  130148. */
  130149. puckSize: number;
  130150. /**
  130151. * Size of the joystick's container
  130152. */
  130153. containerSize: number;
  130154. /**
  130155. * Color of the joystick && puck
  130156. */
  130157. color: string;
  130158. /**
  130159. * Image URL for the joystick's puck
  130160. */
  130161. puckImage?: string;
  130162. /**
  130163. * Image URL for the joystick's container
  130164. */
  130165. containerImage?: string;
  130166. /**
  130167. * Defines the unmoving position of the joystick container
  130168. */
  130169. position?: {
  130170. x: number;
  130171. y: number;
  130172. };
  130173. /**
  130174. * Defines whether or not the joystick container is always visible
  130175. */
  130176. alwaysVisible: boolean;
  130177. /**
  130178. * Defines whether or not to limit the movement of the puck to the joystick's container
  130179. */
  130180. limitToContainer: boolean;
  130181. }
  130182. /**
  130183. * Class used to define virtual joystick (used in touch mode)
  130184. */
  130185. export class VirtualJoystick {
  130186. /**
  130187. * Gets or sets a boolean indicating that left and right values must be inverted
  130188. */
  130189. reverseLeftRight: boolean;
  130190. /**
  130191. * Gets or sets a boolean indicating that up and down values must be inverted
  130192. */
  130193. reverseUpDown: boolean;
  130194. /**
  130195. * Gets the offset value for the position (ie. the change of the position value)
  130196. */
  130197. deltaPosition: Vector3;
  130198. /**
  130199. * Gets a boolean indicating if the virtual joystick was pressed
  130200. */
  130201. pressed: boolean;
  130202. /**
  130203. * Canvas the virtual joystick will render onto, default z-index of this is 5
  130204. */
  130205. static Canvas: Nullable<HTMLCanvasElement>;
  130206. /**
  130207. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  130208. */
  130209. limitToContainer: boolean;
  130210. private static _globalJoystickIndex;
  130211. private static _alwaysVisibleSticks;
  130212. private static vjCanvasContext;
  130213. private static vjCanvasWidth;
  130214. private static vjCanvasHeight;
  130215. private static halfWidth;
  130216. private static _GetDefaultOptions;
  130217. private _action;
  130218. private _axisTargetedByLeftAndRight;
  130219. private _axisTargetedByUpAndDown;
  130220. private _joystickSensibility;
  130221. private _inversedSensibility;
  130222. private _joystickPointerID;
  130223. private _joystickColor;
  130224. private _joystickPointerPos;
  130225. private _joystickPreviousPointerPos;
  130226. private _joystickPointerStartPos;
  130227. private _deltaJoystickVector;
  130228. private _leftJoystick;
  130229. private _touches;
  130230. private _joystickPosition;
  130231. private _alwaysVisible;
  130232. private _puckImage;
  130233. private _containerImage;
  130234. private _joystickPuckSize;
  130235. private _joystickContainerSize;
  130236. private _clearPuckSize;
  130237. private _clearContainerSize;
  130238. private _clearPuckSizeOffset;
  130239. private _clearContainerSizeOffset;
  130240. private _onPointerDownHandlerRef;
  130241. private _onPointerMoveHandlerRef;
  130242. private _onPointerUpHandlerRef;
  130243. private _onResize;
  130244. /**
  130245. * Creates a new virtual joystick
  130246. * @param leftJoystick defines that the joystick is for left hand (false by default)
  130247. * @param customizations Defines the options we want to customize the VirtualJoystick
  130248. */
  130249. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  130250. /**
  130251. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  130252. * @param newJoystickSensibility defines the new sensibility
  130253. */
  130254. setJoystickSensibility(newJoystickSensibility: number): void;
  130255. private _onPointerDown;
  130256. private _onPointerMove;
  130257. private _onPointerUp;
  130258. /**
  130259. * Change the color of the virtual joystick
  130260. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  130261. */
  130262. setJoystickColor(newColor: string): void;
  130263. /**
  130264. * Size of the joystick's container
  130265. */
  130266. set containerSize(newSize: number);
  130267. get containerSize(): number;
  130268. /**
  130269. * Size of the joystick's puck
  130270. */
  130271. set puckSize(newSize: number);
  130272. get puckSize(): number;
  130273. /**
  130274. * Clears the set position of the joystick
  130275. */
  130276. clearPosition(): void;
  130277. /**
  130278. * Defines whether or not the joystick container is always visible
  130279. */
  130280. set alwaysVisible(value: boolean);
  130281. get alwaysVisible(): boolean;
  130282. /**
  130283. * Sets the constant position of the Joystick container
  130284. * @param x X axis coordinate
  130285. * @param y Y axis coordinate
  130286. */
  130287. setPosition(x: number, y: number): void;
  130288. /**
  130289. * Defines a callback to call when the joystick is touched
  130290. * @param action defines the callback
  130291. */
  130292. setActionOnTouch(action: () => any): void;
  130293. /**
  130294. * Defines which axis you'd like to control for left & right
  130295. * @param axis defines the axis to use
  130296. */
  130297. setAxisForLeftRight(axis: JoystickAxis): void;
  130298. /**
  130299. * Defines which axis you'd like to control for up & down
  130300. * @param axis defines the axis to use
  130301. */
  130302. setAxisForUpDown(axis: JoystickAxis): void;
  130303. /**
  130304. * Clears the canvas from the previous puck / container draw
  130305. */
  130306. private _clearPreviousDraw;
  130307. /**
  130308. * Loads `urlPath` to be used for the container's image
  130309. * @param urlPath defines the urlPath of an image to use
  130310. */
  130311. setContainerImage(urlPath: string): void;
  130312. /**
  130313. * Loads `urlPath` to be used for the puck's image
  130314. * @param urlPath defines the urlPath of an image to use
  130315. */
  130316. setPuckImage(urlPath: string): void;
  130317. /**
  130318. * Draws the Virtual Joystick's container
  130319. */
  130320. private _drawContainer;
  130321. /**
  130322. * Draws the Virtual Joystick's puck
  130323. */
  130324. private _drawPuck;
  130325. private _drawVirtualJoystick;
  130326. /**
  130327. * Release internal HTML canvas
  130328. */
  130329. releaseCanvas(): void;
  130330. }
  130331. }
  130332. declare module BABYLON {
  130333. interface FreeCameraInputsManager {
  130334. /**
  130335. * Add virtual joystick input support to the input manager.
  130336. * @returns the current input manager
  130337. */
  130338. addVirtualJoystick(): FreeCameraInputsManager;
  130339. }
  130340. /**
  130341. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  130342. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130343. */
  130344. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  130345. /**
  130346. * Defines the camera the input is attached to.
  130347. */
  130348. camera: FreeCamera;
  130349. private _leftjoystick;
  130350. private _rightjoystick;
  130351. /**
  130352. * Gets the left stick of the virtual joystick.
  130353. * @returns The virtual Joystick
  130354. */
  130355. getLeftJoystick(): VirtualJoystick;
  130356. /**
  130357. * Gets the right stick of the virtual joystick.
  130358. * @returns The virtual Joystick
  130359. */
  130360. getRightJoystick(): VirtualJoystick;
  130361. /**
  130362. * Update the current camera state depending on the inputs that have been used this frame.
  130363. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  130364. */
  130365. checkInputs(): void;
  130366. /**
  130367. * Attach the input controls to a specific dom element to get the input from.
  130368. */
  130369. attachControl(): void;
  130370. /**
  130371. * Detach the current controls from the specified dom element.
  130372. */
  130373. detachControl(): void;
  130374. /**
  130375. * Gets the class name of the current intput.
  130376. * @returns the class name
  130377. */
  130378. getClassName(): string;
  130379. /**
  130380. * Get the friendly name associated with the input class.
  130381. * @returns the input friendly name
  130382. */
  130383. getSimpleName(): string;
  130384. }
  130385. }
  130386. declare module BABYLON {
  130387. /**
  130388. * This represents a FPS type of camera controlled by touch.
  130389. * This is like a universal camera minus the Gamepad controls.
  130390. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130391. */
  130392. export class TouchCamera extends FreeCamera {
  130393. /**
  130394. * Defines the touch sensibility for rotation.
  130395. * The higher the faster.
  130396. */
  130397. get touchAngularSensibility(): number;
  130398. set touchAngularSensibility(value: number);
  130399. /**
  130400. * Defines the touch sensibility for move.
  130401. * The higher the faster.
  130402. */
  130403. get touchMoveSensibility(): number;
  130404. set touchMoveSensibility(value: number);
  130405. /**
  130406. * Instantiates a new touch camera.
  130407. * This represents a FPS type of camera controlled by touch.
  130408. * This is like a universal camera minus the Gamepad controls.
  130409. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130410. * @param name Define the name of the camera in the scene
  130411. * @param position Define the start position of the camera in the scene
  130412. * @param scene Define the scene the camera belongs to
  130413. */
  130414. constructor(name: string, position: Vector3, scene: Scene);
  130415. /**
  130416. * Gets the current object class name.
  130417. * @return the class name
  130418. */
  130419. getClassName(): string;
  130420. /** @hidden */
  130421. _setupInputs(): void;
  130422. }
  130423. }
  130424. declare module BABYLON {
  130425. /**
  130426. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  130427. * being tilted forward or back and left or right.
  130428. */
  130429. export class DeviceOrientationCamera extends FreeCamera {
  130430. private _initialQuaternion;
  130431. private _quaternionCache;
  130432. private _tmpDragQuaternion;
  130433. private _disablePointerInputWhenUsingDeviceOrientation;
  130434. /**
  130435. * Creates a new device orientation camera
  130436. * @param name The name of the camera
  130437. * @param position The start position camera
  130438. * @param scene The scene the camera belongs to
  130439. */
  130440. constructor(name: string, position: Vector3, scene: Scene);
  130441. /**
  130442. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  130443. */
  130444. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  130445. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  130446. private _dragFactor;
  130447. /**
  130448. * Enabled turning on the y axis when the orientation sensor is active
  130449. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  130450. */
  130451. enableHorizontalDragging(dragFactor?: number): void;
  130452. /**
  130453. * Gets the current instance class name ("DeviceOrientationCamera").
  130454. * This helps avoiding instanceof at run time.
  130455. * @returns the class name
  130456. */
  130457. getClassName(): string;
  130458. /**
  130459. * @hidden
  130460. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  130461. */
  130462. _checkInputs(): void;
  130463. /**
  130464. * Reset the camera to its default orientation on the specified axis only.
  130465. * @param axis The axis to reset
  130466. */
  130467. resetToCurrentRotation(axis?: Axis): void;
  130468. }
  130469. }
  130470. declare module BABYLON {
  130471. /**
  130472. * Defines supported buttons for XBox360 compatible gamepads
  130473. */
  130474. export enum Xbox360Button {
  130475. /** A */
  130476. A = 0,
  130477. /** B */
  130478. B = 1,
  130479. /** X */
  130480. X = 2,
  130481. /** Y */
  130482. Y = 3,
  130483. /** Left button */
  130484. LB = 4,
  130485. /** Right button */
  130486. RB = 5,
  130487. /** Back */
  130488. Back = 8,
  130489. /** Start */
  130490. Start = 9,
  130491. /** Left stick */
  130492. LeftStick = 10,
  130493. /** Right stick */
  130494. RightStick = 11
  130495. }
  130496. /** Defines values for XBox360 DPad */
  130497. export enum Xbox360Dpad {
  130498. /** Up */
  130499. Up = 12,
  130500. /** Down */
  130501. Down = 13,
  130502. /** Left */
  130503. Left = 14,
  130504. /** Right */
  130505. Right = 15
  130506. }
  130507. /**
  130508. * Defines a XBox360 gamepad
  130509. */
  130510. export class Xbox360Pad extends Gamepad {
  130511. private _leftTrigger;
  130512. private _rightTrigger;
  130513. private _onlefttriggerchanged;
  130514. private _onrighttriggerchanged;
  130515. private _onbuttondown;
  130516. private _onbuttonup;
  130517. private _ondpaddown;
  130518. private _ondpadup;
  130519. /** Observable raised when a button is pressed */
  130520. onButtonDownObservable: Observable<Xbox360Button>;
  130521. /** Observable raised when a button is released */
  130522. onButtonUpObservable: Observable<Xbox360Button>;
  130523. /** Observable raised when a pad is pressed */
  130524. onPadDownObservable: Observable<Xbox360Dpad>;
  130525. /** Observable raised when a pad is released */
  130526. onPadUpObservable: Observable<Xbox360Dpad>;
  130527. private _buttonA;
  130528. private _buttonB;
  130529. private _buttonX;
  130530. private _buttonY;
  130531. private _buttonBack;
  130532. private _buttonStart;
  130533. private _buttonLB;
  130534. private _buttonRB;
  130535. private _buttonLeftStick;
  130536. private _buttonRightStick;
  130537. private _dPadUp;
  130538. private _dPadDown;
  130539. private _dPadLeft;
  130540. private _dPadRight;
  130541. private _isXboxOnePad;
  130542. /**
  130543. * Creates a new XBox360 gamepad object
  130544. * @param id defines the id of this gamepad
  130545. * @param index defines its index
  130546. * @param gamepad defines the internal HTML gamepad object
  130547. * @param xboxOne defines if it is a XBox One gamepad
  130548. */
  130549. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  130550. /**
  130551. * Defines the callback to call when left trigger is pressed
  130552. * @param callback defines the callback to use
  130553. */
  130554. onlefttriggerchanged(callback: (value: number) => void): void;
  130555. /**
  130556. * Defines the callback to call when right trigger is pressed
  130557. * @param callback defines the callback to use
  130558. */
  130559. onrighttriggerchanged(callback: (value: number) => void): void;
  130560. /**
  130561. * Gets the left trigger value
  130562. */
  130563. get leftTrigger(): number;
  130564. /**
  130565. * Sets the left trigger value
  130566. */
  130567. set leftTrigger(newValue: number);
  130568. /**
  130569. * Gets the right trigger value
  130570. */
  130571. get rightTrigger(): number;
  130572. /**
  130573. * Sets the right trigger value
  130574. */
  130575. set rightTrigger(newValue: number);
  130576. /**
  130577. * Defines the callback to call when a button is pressed
  130578. * @param callback defines the callback to use
  130579. */
  130580. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  130581. /**
  130582. * Defines the callback to call when a button is released
  130583. * @param callback defines the callback to use
  130584. */
  130585. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  130586. /**
  130587. * Defines the callback to call when a pad is pressed
  130588. * @param callback defines the callback to use
  130589. */
  130590. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  130591. /**
  130592. * Defines the callback to call when a pad is released
  130593. * @param callback defines the callback to use
  130594. */
  130595. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  130596. private _setButtonValue;
  130597. private _setDPadValue;
  130598. /**
  130599. * Gets the value of the `A` button
  130600. */
  130601. get buttonA(): number;
  130602. /**
  130603. * Sets the value of the `A` button
  130604. */
  130605. set buttonA(value: number);
  130606. /**
  130607. * Gets the value of the `B` button
  130608. */
  130609. get buttonB(): number;
  130610. /**
  130611. * Sets the value of the `B` button
  130612. */
  130613. set buttonB(value: number);
  130614. /**
  130615. * Gets the value of the `X` button
  130616. */
  130617. get buttonX(): number;
  130618. /**
  130619. * Sets the value of the `X` button
  130620. */
  130621. set buttonX(value: number);
  130622. /**
  130623. * Gets the value of the `Y` button
  130624. */
  130625. get buttonY(): number;
  130626. /**
  130627. * Sets the value of the `Y` button
  130628. */
  130629. set buttonY(value: number);
  130630. /**
  130631. * Gets the value of the `Start` button
  130632. */
  130633. get buttonStart(): number;
  130634. /**
  130635. * Sets the value of the `Start` button
  130636. */
  130637. set buttonStart(value: number);
  130638. /**
  130639. * Gets the value of the `Back` button
  130640. */
  130641. get buttonBack(): number;
  130642. /**
  130643. * Sets the value of the `Back` button
  130644. */
  130645. set buttonBack(value: number);
  130646. /**
  130647. * Gets the value of the `Left` button
  130648. */
  130649. get buttonLB(): number;
  130650. /**
  130651. * Sets the value of the `Left` button
  130652. */
  130653. set buttonLB(value: number);
  130654. /**
  130655. * Gets the value of the `Right` button
  130656. */
  130657. get buttonRB(): number;
  130658. /**
  130659. * Sets the value of the `Right` button
  130660. */
  130661. set buttonRB(value: number);
  130662. /**
  130663. * Gets the value of the Left joystick
  130664. */
  130665. get buttonLeftStick(): number;
  130666. /**
  130667. * Sets the value of the Left joystick
  130668. */
  130669. set buttonLeftStick(value: number);
  130670. /**
  130671. * Gets the value of the Right joystick
  130672. */
  130673. get buttonRightStick(): number;
  130674. /**
  130675. * Sets the value of the Right joystick
  130676. */
  130677. set buttonRightStick(value: number);
  130678. /**
  130679. * Gets the value of D-pad up
  130680. */
  130681. get dPadUp(): number;
  130682. /**
  130683. * Sets the value of D-pad up
  130684. */
  130685. set dPadUp(value: number);
  130686. /**
  130687. * Gets the value of D-pad down
  130688. */
  130689. get dPadDown(): number;
  130690. /**
  130691. * Sets the value of D-pad down
  130692. */
  130693. set dPadDown(value: number);
  130694. /**
  130695. * Gets the value of D-pad left
  130696. */
  130697. get dPadLeft(): number;
  130698. /**
  130699. * Sets the value of D-pad left
  130700. */
  130701. set dPadLeft(value: number);
  130702. /**
  130703. * Gets the value of D-pad right
  130704. */
  130705. get dPadRight(): number;
  130706. /**
  130707. * Sets the value of D-pad right
  130708. */
  130709. set dPadRight(value: number);
  130710. /**
  130711. * Force the gamepad to synchronize with device values
  130712. */
  130713. update(): void;
  130714. /**
  130715. * Disposes the gamepad
  130716. */
  130717. dispose(): void;
  130718. }
  130719. }
  130720. declare module BABYLON {
  130721. /**
  130722. * Defines supported buttons for DualShock compatible gamepads
  130723. */
  130724. export enum DualShockButton {
  130725. /** Cross */
  130726. Cross = 0,
  130727. /** Circle */
  130728. Circle = 1,
  130729. /** Square */
  130730. Square = 2,
  130731. /** Triangle */
  130732. Triangle = 3,
  130733. /** L1 */
  130734. L1 = 4,
  130735. /** R1 */
  130736. R1 = 5,
  130737. /** Share */
  130738. Share = 8,
  130739. /** Options */
  130740. Options = 9,
  130741. /** Left stick */
  130742. LeftStick = 10,
  130743. /** Right stick */
  130744. RightStick = 11
  130745. }
  130746. /** Defines values for DualShock DPad */
  130747. export enum DualShockDpad {
  130748. /** Up */
  130749. Up = 12,
  130750. /** Down */
  130751. Down = 13,
  130752. /** Left */
  130753. Left = 14,
  130754. /** Right */
  130755. Right = 15
  130756. }
  130757. /**
  130758. * Defines a DualShock gamepad
  130759. */
  130760. export class DualShockPad extends Gamepad {
  130761. private _leftTrigger;
  130762. private _rightTrigger;
  130763. private _onlefttriggerchanged;
  130764. private _onrighttriggerchanged;
  130765. private _onbuttondown;
  130766. private _onbuttonup;
  130767. private _ondpaddown;
  130768. private _ondpadup;
  130769. /** Observable raised when a button is pressed */
  130770. onButtonDownObservable: Observable<DualShockButton>;
  130771. /** Observable raised when a button is released */
  130772. onButtonUpObservable: Observable<DualShockButton>;
  130773. /** Observable raised when a pad is pressed */
  130774. onPadDownObservable: Observable<DualShockDpad>;
  130775. /** Observable raised when a pad is released */
  130776. onPadUpObservable: Observable<DualShockDpad>;
  130777. private _buttonCross;
  130778. private _buttonCircle;
  130779. private _buttonSquare;
  130780. private _buttonTriangle;
  130781. private _buttonShare;
  130782. private _buttonOptions;
  130783. private _buttonL1;
  130784. private _buttonR1;
  130785. private _buttonLeftStick;
  130786. private _buttonRightStick;
  130787. private _dPadUp;
  130788. private _dPadDown;
  130789. private _dPadLeft;
  130790. private _dPadRight;
  130791. /**
  130792. * Creates a new DualShock gamepad object
  130793. * @param id defines the id of this gamepad
  130794. * @param index defines its index
  130795. * @param gamepad defines the internal HTML gamepad object
  130796. */
  130797. constructor(id: string, index: number, gamepad: any);
  130798. /**
  130799. * Defines the callback to call when left trigger is pressed
  130800. * @param callback defines the callback to use
  130801. */
  130802. onlefttriggerchanged(callback: (value: number) => void): void;
  130803. /**
  130804. * Defines the callback to call when right trigger is pressed
  130805. * @param callback defines the callback to use
  130806. */
  130807. onrighttriggerchanged(callback: (value: number) => void): void;
  130808. /**
  130809. * Gets the left trigger value
  130810. */
  130811. get leftTrigger(): number;
  130812. /**
  130813. * Sets the left trigger value
  130814. */
  130815. set leftTrigger(newValue: number);
  130816. /**
  130817. * Gets the right trigger value
  130818. */
  130819. get rightTrigger(): number;
  130820. /**
  130821. * Sets the right trigger value
  130822. */
  130823. set rightTrigger(newValue: number);
  130824. /**
  130825. * Defines the callback to call when a button is pressed
  130826. * @param callback defines the callback to use
  130827. */
  130828. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  130829. /**
  130830. * Defines the callback to call when a button is released
  130831. * @param callback defines the callback to use
  130832. */
  130833. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  130834. /**
  130835. * Defines the callback to call when a pad is pressed
  130836. * @param callback defines the callback to use
  130837. */
  130838. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  130839. /**
  130840. * Defines the callback to call when a pad is released
  130841. * @param callback defines the callback to use
  130842. */
  130843. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  130844. private _setButtonValue;
  130845. private _setDPadValue;
  130846. /**
  130847. * Gets the value of the `Cross` button
  130848. */
  130849. get buttonCross(): number;
  130850. /**
  130851. * Sets the value of the `Cross` button
  130852. */
  130853. set buttonCross(value: number);
  130854. /**
  130855. * Gets the value of the `Circle` button
  130856. */
  130857. get buttonCircle(): number;
  130858. /**
  130859. * Sets the value of the `Circle` button
  130860. */
  130861. set buttonCircle(value: number);
  130862. /**
  130863. * Gets the value of the `Square` button
  130864. */
  130865. get buttonSquare(): number;
  130866. /**
  130867. * Sets the value of the `Square` button
  130868. */
  130869. set buttonSquare(value: number);
  130870. /**
  130871. * Gets the value of the `Triangle` button
  130872. */
  130873. get buttonTriangle(): number;
  130874. /**
  130875. * Sets the value of the `Triangle` button
  130876. */
  130877. set buttonTriangle(value: number);
  130878. /**
  130879. * Gets the value of the `Options` button
  130880. */
  130881. get buttonOptions(): number;
  130882. /**
  130883. * Sets the value of the `Options` button
  130884. */
  130885. set buttonOptions(value: number);
  130886. /**
  130887. * Gets the value of the `Share` button
  130888. */
  130889. get buttonShare(): number;
  130890. /**
  130891. * Sets the value of the `Share` button
  130892. */
  130893. set buttonShare(value: number);
  130894. /**
  130895. * Gets the value of the `L1` button
  130896. */
  130897. get buttonL1(): number;
  130898. /**
  130899. * Sets the value of the `L1` button
  130900. */
  130901. set buttonL1(value: number);
  130902. /**
  130903. * Gets the value of the `R1` button
  130904. */
  130905. get buttonR1(): number;
  130906. /**
  130907. * Sets the value of the `R1` button
  130908. */
  130909. set buttonR1(value: number);
  130910. /**
  130911. * Gets the value of the Left joystick
  130912. */
  130913. get buttonLeftStick(): number;
  130914. /**
  130915. * Sets the value of the Left joystick
  130916. */
  130917. set buttonLeftStick(value: number);
  130918. /**
  130919. * Gets the value of the Right joystick
  130920. */
  130921. get buttonRightStick(): number;
  130922. /**
  130923. * Sets the value of the Right joystick
  130924. */
  130925. set buttonRightStick(value: number);
  130926. /**
  130927. * Gets the value of D-pad up
  130928. */
  130929. get dPadUp(): number;
  130930. /**
  130931. * Sets the value of D-pad up
  130932. */
  130933. set dPadUp(value: number);
  130934. /**
  130935. * Gets the value of D-pad down
  130936. */
  130937. get dPadDown(): number;
  130938. /**
  130939. * Sets the value of D-pad down
  130940. */
  130941. set dPadDown(value: number);
  130942. /**
  130943. * Gets the value of D-pad left
  130944. */
  130945. get dPadLeft(): number;
  130946. /**
  130947. * Sets the value of D-pad left
  130948. */
  130949. set dPadLeft(value: number);
  130950. /**
  130951. * Gets the value of D-pad right
  130952. */
  130953. get dPadRight(): number;
  130954. /**
  130955. * Sets the value of D-pad right
  130956. */
  130957. set dPadRight(value: number);
  130958. /**
  130959. * Force the gamepad to synchronize with device values
  130960. */
  130961. update(): void;
  130962. /**
  130963. * Disposes the gamepad
  130964. */
  130965. dispose(): void;
  130966. }
  130967. }
  130968. declare module BABYLON {
  130969. /**
  130970. * Manager for handling gamepads
  130971. */
  130972. export class GamepadManager {
  130973. private _scene?;
  130974. private _babylonGamepads;
  130975. private _oneGamepadConnected;
  130976. /** @hidden */
  130977. _isMonitoring: boolean;
  130978. private _gamepadEventSupported;
  130979. private _gamepadSupport?;
  130980. /**
  130981. * observable to be triggered when the gamepad controller has been connected
  130982. */
  130983. onGamepadConnectedObservable: Observable<Gamepad>;
  130984. /**
  130985. * observable to be triggered when the gamepad controller has been disconnected
  130986. */
  130987. onGamepadDisconnectedObservable: Observable<Gamepad>;
  130988. private _onGamepadConnectedEvent;
  130989. private _onGamepadDisconnectedEvent;
  130990. /**
  130991. * Initializes the gamepad manager
  130992. * @param _scene BabylonJS scene
  130993. */
  130994. constructor(_scene?: Scene | undefined);
  130995. /**
  130996. * The gamepads in the game pad manager
  130997. */
  130998. get gamepads(): Gamepad[];
  130999. /**
  131000. * Get the gamepad controllers based on type
  131001. * @param type The type of gamepad controller
  131002. * @returns Nullable gamepad
  131003. */
  131004. getGamepadByType(type?: number): Nullable<Gamepad>;
  131005. /**
  131006. * Disposes the gamepad manager
  131007. */
  131008. dispose(): void;
  131009. private _addNewGamepad;
  131010. private _startMonitoringGamepads;
  131011. private _stopMonitoringGamepads;
  131012. /** @hidden */
  131013. _checkGamepadsStatus(): void;
  131014. private _updateGamepadObjects;
  131015. }
  131016. }
  131017. declare module BABYLON {
  131018. interface Scene {
  131019. /** @hidden */
  131020. _gamepadManager: Nullable<GamepadManager>;
  131021. /**
  131022. * Gets the gamepad manager associated with the scene
  131023. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  131024. */
  131025. gamepadManager: GamepadManager;
  131026. }
  131027. /**
  131028. * Interface representing a free camera inputs manager
  131029. */
  131030. interface FreeCameraInputsManager {
  131031. /**
  131032. * Adds gamepad input support to the FreeCameraInputsManager.
  131033. * @returns the FreeCameraInputsManager
  131034. */
  131035. addGamepad(): FreeCameraInputsManager;
  131036. }
  131037. /**
  131038. * Interface representing an arc rotate camera inputs manager
  131039. */
  131040. interface ArcRotateCameraInputsManager {
  131041. /**
  131042. * Adds gamepad input support to the ArcRotateCamera InputManager.
  131043. * @returns the camera inputs manager
  131044. */
  131045. addGamepad(): ArcRotateCameraInputsManager;
  131046. }
  131047. /**
  131048. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  131049. */
  131050. export class GamepadSystemSceneComponent implements ISceneComponent {
  131051. /**
  131052. * The component name helpfull to identify the component in the list of scene components.
  131053. */
  131054. readonly name: string;
  131055. /**
  131056. * The scene the component belongs to.
  131057. */
  131058. scene: Scene;
  131059. /**
  131060. * Creates a new instance of the component for the given scene
  131061. * @param scene Defines the scene to register the component in
  131062. */
  131063. constructor(scene: Scene);
  131064. /**
  131065. * Registers the component in a given scene
  131066. */
  131067. register(): void;
  131068. /**
  131069. * Rebuilds the elements related to this component in case of
  131070. * context lost for instance.
  131071. */
  131072. rebuild(): void;
  131073. /**
  131074. * Disposes the component and the associated ressources
  131075. */
  131076. dispose(): void;
  131077. private _beforeCameraUpdate;
  131078. }
  131079. }
  131080. declare module BABYLON {
  131081. /**
  131082. * 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,
  131083. * which still works and will still be found in many Playgrounds.
  131084. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131085. */
  131086. export class UniversalCamera extends TouchCamera {
  131087. /**
  131088. * Defines the gamepad rotation sensiblity.
  131089. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  131090. */
  131091. get gamepadAngularSensibility(): number;
  131092. set gamepadAngularSensibility(value: number);
  131093. /**
  131094. * Defines the gamepad move sensiblity.
  131095. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  131096. */
  131097. get gamepadMoveSensibility(): number;
  131098. set gamepadMoveSensibility(value: number);
  131099. /**
  131100. * 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,
  131101. * which still works and will still be found in many Playgrounds.
  131102. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131103. * @param name Define the name of the camera in the scene
  131104. * @param position Define the start position of the camera in the scene
  131105. * @param scene Define the scene the camera belongs to
  131106. */
  131107. constructor(name: string, position: Vector3, scene: Scene);
  131108. /**
  131109. * Gets the current object class name.
  131110. * @return the class name
  131111. */
  131112. getClassName(): string;
  131113. }
  131114. }
  131115. declare module BABYLON {
  131116. /**
  131117. * This represents a FPS type of camera. This is only here for back compat purpose.
  131118. * Please use the UniversalCamera instead as both are identical.
  131119. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131120. */
  131121. export class GamepadCamera extends UniversalCamera {
  131122. /**
  131123. * Instantiates a new Gamepad Camera
  131124. * This represents a FPS type of camera. This is only here for back compat purpose.
  131125. * Please use the UniversalCamera instead as both are identical.
  131126. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131127. * @param name Define the name of the camera in the scene
  131128. * @param position Define the start position of the camera in the scene
  131129. * @param scene Define the scene the camera belongs to
  131130. */
  131131. constructor(name: string, position: Vector3, scene: Scene);
  131132. /**
  131133. * Gets the current object class name.
  131134. * @return the class name
  131135. */
  131136. getClassName(): string;
  131137. }
  131138. }
  131139. declare module BABYLON {
  131140. /** @hidden */
  131141. export var passPixelShader: {
  131142. name: string;
  131143. shader: string;
  131144. };
  131145. }
  131146. declare module BABYLON {
  131147. /** @hidden */
  131148. export var passCubePixelShader: {
  131149. name: string;
  131150. shader: string;
  131151. };
  131152. }
  131153. declare module BABYLON {
  131154. /**
  131155. * PassPostProcess which produces an output the same as it's input
  131156. */
  131157. export class PassPostProcess extends PostProcess {
  131158. /**
  131159. * Gets a string identifying the name of the class
  131160. * @returns "PassPostProcess" string
  131161. */
  131162. getClassName(): string;
  131163. /**
  131164. * Creates the PassPostProcess
  131165. * @param name The name of the effect.
  131166. * @param options The required width/height ratio to downsize to before computing the render pass.
  131167. * @param camera The camera to apply the render pass to.
  131168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131169. * @param engine The engine which the post process will be applied. (default: current engine)
  131170. * @param reusable If the post process can be reused on the same frame. (default: false)
  131171. * @param textureType The type of texture to be used when performing the post processing.
  131172. * @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)
  131173. */
  131174. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  131175. /** @hidden */
  131176. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  131177. }
  131178. /**
  131179. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  131180. */
  131181. export class PassCubePostProcess extends PostProcess {
  131182. private _face;
  131183. /**
  131184. * Gets or sets the cube face to display.
  131185. * * 0 is +X
  131186. * * 1 is -X
  131187. * * 2 is +Y
  131188. * * 3 is -Y
  131189. * * 4 is +Z
  131190. * * 5 is -Z
  131191. */
  131192. get face(): number;
  131193. set face(value: number);
  131194. /**
  131195. * Gets a string identifying the name of the class
  131196. * @returns "PassCubePostProcess" string
  131197. */
  131198. getClassName(): string;
  131199. /**
  131200. * Creates the PassCubePostProcess
  131201. * @param name The name of the effect.
  131202. * @param options The required width/height ratio to downsize to before computing the render pass.
  131203. * @param camera The camera to apply the render pass to.
  131204. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131205. * @param engine The engine which the post process will be applied. (default: current engine)
  131206. * @param reusable If the post process can be reused on the same frame. (default: false)
  131207. * @param textureType The type of texture to be used when performing the post processing.
  131208. * @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)
  131209. */
  131210. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  131211. /** @hidden */
  131212. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  131213. }
  131214. }
  131215. declare module BABYLON {
  131216. /** @hidden */
  131217. export var anaglyphPixelShader: {
  131218. name: string;
  131219. shader: string;
  131220. };
  131221. }
  131222. declare module BABYLON {
  131223. /**
  131224. * Postprocess used to generate anaglyphic rendering
  131225. */
  131226. export class AnaglyphPostProcess extends PostProcess {
  131227. private _passedProcess;
  131228. /**
  131229. * Gets a string identifying the name of the class
  131230. * @returns "AnaglyphPostProcess" string
  131231. */
  131232. getClassName(): string;
  131233. /**
  131234. * Creates a new AnaglyphPostProcess
  131235. * @param name defines postprocess name
  131236. * @param options defines creation options or target ratio scale
  131237. * @param rigCameras defines cameras using this postprocess
  131238. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  131239. * @param engine defines hosting engine
  131240. * @param reusable defines if the postprocess will be reused multiple times per frame
  131241. */
  131242. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  131243. }
  131244. }
  131245. declare module BABYLON {
  131246. /**
  131247. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  131248. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131249. */
  131250. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  131251. /**
  131252. * Creates a new AnaglyphArcRotateCamera
  131253. * @param name defines camera name
  131254. * @param alpha defines alpha angle (in radians)
  131255. * @param beta defines beta angle (in radians)
  131256. * @param radius defines radius
  131257. * @param target defines camera target
  131258. * @param interaxialDistance defines distance between each color axis
  131259. * @param scene defines the hosting scene
  131260. */
  131261. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  131262. /**
  131263. * Gets camera class name
  131264. * @returns AnaglyphArcRotateCamera
  131265. */
  131266. getClassName(): string;
  131267. }
  131268. }
  131269. declare module BABYLON {
  131270. /**
  131271. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  131272. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131273. */
  131274. export class AnaglyphFreeCamera extends FreeCamera {
  131275. /**
  131276. * Creates a new AnaglyphFreeCamera
  131277. * @param name defines camera name
  131278. * @param position defines initial position
  131279. * @param interaxialDistance defines distance between each color axis
  131280. * @param scene defines the hosting scene
  131281. */
  131282. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  131283. /**
  131284. * Gets camera class name
  131285. * @returns AnaglyphFreeCamera
  131286. */
  131287. getClassName(): string;
  131288. }
  131289. }
  131290. declare module BABYLON {
  131291. /**
  131292. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  131293. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131294. */
  131295. export class AnaglyphGamepadCamera extends GamepadCamera {
  131296. /**
  131297. * Creates a new AnaglyphGamepadCamera
  131298. * @param name defines camera name
  131299. * @param position defines initial position
  131300. * @param interaxialDistance defines distance between each color axis
  131301. * @param scene defines the hosting scene
  131302. */
  131303. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  131304. /**
  131305. * Gets camera class name
  131306. * @returns AnaglyphGamepadCamera
  131307. */
  131308. getClassName(): string;
  131309. }
  131310. }
  131311. declare module BABYLON {
  131312. /**
  131313. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  131314. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131315. */
  131316. export class AnaglyphUniversalCamera extends UniversalCamera {
  131317. /**
  131318. * Creates a new AnaglyphUniversalCamera
  131319. * @param name defines camera name
  131320. * @param position defines initial position
  131321. * @param interaxialDistance defines distance between each color axis
  131322. * @param scene defines the hosting scene
  131323. */
  131324. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  131325. /**
  131326. * Gets camera class name
  131327. * @returns AnaglyphUniversalCamera
  131328. */
  131329. getClassName(): string;
  131330. }
  131331. }
  131332. declare module BABYLON {
  131333. /**
  131334. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  131335. * @see https://doc.babylonjs.com/features/cameras
  131336. */
  131337. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  131338. /**
  131339. * Creates a new StereoscopicArcRotateCamera
  131340. * @param name defines camera name
  131341. * @param alpha defines alpha angle (in radians)
  131342. * @param beta defines beta angle (in radians)
  131343. * @param radius defines radius
  131344. * @param target defines camera target
  131345. * @param interaxialDistance defines distance between each color axis
  131346. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131347. * @param scene defines the hosting scene
  131348. */
  131349. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131350. /**
  131351. * Gets camera class name
  131352. * @returns StereoscopicArcRotateCamera
  131353. */
  131354. getClassName(): string;
  131355. }
  131356. }
  131357. declare module BABYLON {
  131358. /**
  131359. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  131360. * @see https://doc.babylonjs.com/features/cameras
  131361. */
  131362. export class StereoscopicFreeCamera extends FreeCamera {
  131363. /**
  131364. * Creates a new StereoscopicFreeCamera
  131365. * @param name defines camera name
  131366. * @param position defines initial position
  131367. * @param interaxialDistance defines distance between each color axis
  131368. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131369. * @param scene defines the hosting scene
  131370. */
  131371. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131372. /**
  131373. * Gets camera class name
  131374. * @returns StereoscopicFreeCamera
  131375. */
  131376. getClassName(): string;
  131377. }
  131378. }
  131379. declare module BABYLON {
  131380. /**
  131381. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  131382. * @see https://doc.babylonjs.com/features/cameras
  131383. */
  131384. export class StereoscopicGamepadCamera extends GamepadCamera {
  131385. /**
  131386. * Creates a new StereoscopicGamepadCamera
  131387. * @param name defines camera name
  131388. * @param position defines initial position
  131389. * @param interaxialDistance defines distance between each color axis
  131390. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131391. * @param scene defines the hosting scene
  131392. */
  131393. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131394. /**
  131395. * Gets camera class name
  131396. * @returns StereoscopicGamepadCamera
  131397. */
  131398. getClassName(): string;
  131399. }
  131400. }
  131401. declare module BABYLON {
  131402. /**
  131403. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  131404. * @see https://doc.babylonjs.com/features/cameras
  131405. */
  131406. export class StereoscopicUniversalCamera extends UniversalCamera {
  131407. /**
  131408. * Creates a new StereoscopicUniversalCamera
  131409. * @param name defines camera name
  131410. * @param position defines initial position
  131411. * @param interaxialDistance defines distance between each color axis
  131412. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131413. * @param scene defines the hosting scene
  131414. */
  131415. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131416. /**
  131417. * Gets camera class name
  131418. * @returns StereoscopicUniversalCamera
  131419. */
  131420. getClassName(): string;
  131421. }
  131422. }
  131423. declare module BABYLON {
  131424. /**
  131425. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  131426. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  131427. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  131428. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  131429. */
  131430. export class VirtualJoysticksCamera extends FreeCamera {
  131431. /**
  131432. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  131433. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  131434. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  131435. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  131436. * @param name Define the name of the camera in the scene
  131437. * @param position Define the start position of the camera in the scene
  131438. * @param scene Define the scene the camera belongs to
  131439. */
  131440. constructor(name: string, position: Vector3, scene: Scene);
  131441. /**
  131442. * Gets the current object class name.
  131443. * @return the class name
  131444. */
  131445. getClassName(): string;
  131446. }
  131447. }
  131448. declare module BABYLON {
  131449. /**
  131450. * This represents all the required metrics to create a VR camera.
  131451. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  131452. */
  131453. export class VRCameraMetrics {
  131454. /**
  131455. * Define the horizontal resolution off the screen.
  131456. */
  131457. hResolution: number;
  131458. /**
  131459. * Define the vertical resolution off the screen.
  131460. */
  131461. vResolution: number;
  131462. /**
  131463. * Define the horizontal screen size.
  131464. */
  131465. hScreenSize: number;
  131466. /**
  131467. * Define the vertical screen size.
  131468. */
  131469. vScreenSize: number;
  131470. /**
  131471. * Define the vertical screen center position.
  131472. */
  131473. vScreenCenter: number;
  131474. /**
  131475. * Define the distance of the eyes to the screen.
  131476. */
  131477. eyeToScreenDistance: number;
  131478. /**
  131479. * Define the distance between both lenses
  131480. */
  131481. lensSeparationDistance: number;
  131482. /**
  131483. * Define the distance between both viewer's eyes.
  131484. */
  131485. interpupillaryDistance: number;
  131486. /**
  131487. * Define the distortion factor of the VR postprocess.
  131488. * Please, touch with care.
  131489. */
  131490. distortionK: number[];
  131491. /**
  131492. * Define the chromatic aberration correction factors for the VR post process.
  131493. */
  131494. chromaAbCorrection: number[];
  131495. /**
  131496. * Define the scale factor of the post process.
  131497. * The smaller the better but the slower.
  131498. */
  131499. postProcessScaleFactor: number;
  131500. /**
  131501. * Define an offset for the lens center.
  131502. */
  131503. lensCenterOffset: number;
  131504. /**
  131505. * Define if the current vr camera should compensate the distortion of the lense or not.
  131506. */
  131507. compensateDistortion: boolean;
  131508. /**
  131509. * Defines if multiview should be enabled when rendering (Default: false)
  131510. */
  131511. multiviewEnabled: boolean;
  131512. /**
  131513. * Gets the rendering aspect ratio based on the provided resolutions.
  131514. */
  131515. get aspectRatio(): number;
  131516. /**
  131517. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  131518. */
  131519. get aspectRatioFov(): number;
  131520. /**
  131521. * @hidden
  131522. */
  131523. get leftHMatrix(): Matrix;
  131524. /**
  131525. * @hidden
  131526. */
  131527. get rightHMatrix(): Matrix;
  131528. /**
  131529. * @hidden
  131530. */
  131531. get leftPreViewMatrix(): Matrix;
  131532. /**
  131533. * @hidden
  131534. */
  131535. get rightPreViewMatrix(): Matrix;
  131536. /**
  131537. * Get the default VRMetrics based on the most generic setup.
  131538. * @returns the default vr metrics
  131539. */
  131540. static GetDefault(): VRCameraMetrics;
  131541. }
  131542. }
  131543. declare module BABYLON {
  131544. /** @hidden */
  131545. export var vrDistortionCorrectionPixelShader: {
  131546. name: string;
  131547. shader: string;
  131548. };
  131549. }
  131550. declare module BABYLON {
  131551. /**
  131552. * VRDistortionCorrectionPostProcess used for mobile VR
  131553. */
  131554. export class VRDistortionCorrectionPostProcess extends PostProcess {
  131555. private _isRightEye;
  131556. private _distortionFactors;
  131557. private _postProcessScaleFactor;
  131558. private _lensCenterOffset;
  131559. private _scaleIn;
  131560. private _scaleFactor;
  131561. private _lensCenter;
  131562. /**
  131563. * Gets a string identifying the name of the class
  131564. * @returns "VRDistortionCorrectionPostProcess" string
  131565. */
  131566. getClassName(): string;
  131567. /**
  131568. * Initializes the VRDistortionCorrectionPostProcess
  131569. * @param name The name of the effect.
  131570. * @param camera The camera to apply the render pass to.
  131571. * @param isRightEye If this is for the right eye distortion
  131572. * @param vrMetrics All the required metrics for the VR camera
  131573. */
  131574. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  131575. }
  131576. }
  131577. declare module BABYLON {
  131578. /**
  131579. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  131580. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131581. */
  131582. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  131583. /**
  131584. * Creates a new VRDeviceOrientationArcRotateCamera
  131585. * @param name defines camera name
  131586. * @param alpha defines the camera rotation along the logitudinal axis
  131587. * @param beta defines the camera rotation along the latitudinal axis
  131588. * @param radius defines the camera distance from its target
  131589. * @param target defines the camera target
  131590. * @param scene defines the scene the camera belongs to
  131591. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131592. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131593. */
  131594. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131595. /**
  131596. * Gets camera class name
  131597. * @returns VRDeviceOrientationArcRotateCamera
  131598. */
  131599. getClassName(): string;
  131600. }
  131601. }
  131602. declare module BABYLON {
  131603. /**
  131604. * Camera used to simulate VR rendering (based on FreeCamera)
  131605. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131606. */
  131607. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  131608. /**
  131609. * Creates a new VRDeviceOrientationFreeCamera
  131610. * @param name defines camera name
  131611. * @param position defines the start position of the camera
  131612. * @param scene defines the scene the camera belongs to
  131613. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131614. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131615. */
  131616. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131617. /**
  131618. * Gets camera class name
  131619. * @returns VRDeviceOrientationFreeCamera
  131620. */
  131621. getClassName(): string;
  131622. }
  131623. }
  131624. declare module BABYLON {
  131625. /**
  131626. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  131627. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131628. */
  131629. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  131630. /**
  131631. * Creates a new VRDeviceOrientationGamepadCamera
  131632. * @param name defines camera name
  131633. * @param position defines the start position of the camera
  131634. * @param scene defines the scene the camera belongs to
  131635. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131636. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131637. */
  131638. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131639. /**
  131640. * Gets camera class name
  131641. * @returns VRDeviceOrientationGamepadCamera
  131642. */
  131643. getClassName(): string;
  131644. }
  131645. }
  131646. declare module BABYLON {
  131647. /**
  131648. * A class extending Texture allowing drawing on a texture
  131649. * @see https://doc.babylonjs.com/how_to/dynamictexture
  131650. */
  131651. export class DynamicTexture extends Texture {
  131652. private _generateMipMaps;
  131653. private _canvas;
  131654. private _context;
  131655. /**
  131656. * Creates a DynamicTexture
  131657. * @param name defines the name of the texture
  131658. * @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
  131659. * @param scene defines the scene where you want the texture
  131660. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  131661. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131662. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  131663. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  131664. */
  131665. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  131666. /**
  131667. * Get the current class name of the texture useful for serialization or dynamic coding.
  131668. * @returns "DynamicTexture"
  131669. */
  131670. getClassName(): string;
  131671. /**
  131672. * Gets the current state of canRescale
  131673. */
  131674. get canRescale(): boolean;
  131675. private _recreate;
  131676. /**
  131677. * Scales the texture
  131678. * @param ratio the scale factor to apply to both width and height
  131679. */
  131680. scale(ratio: number): void;
  131681. /**
  131682. * Resizes the texture
  131683. * @param width the new width
  131684. * @param height the new height
  131685. */
  131686. scaleTo(width: number, height: number): void;
  131687. /**
  131688. * Gets the context of the canvas used by the texture
  131689. * @returns the canvas context of the dynamic texture
  131690. */
  131691. getContext(): CanvasRenderingContext2D;
  131692. /**
  131693. * Clears the texture
  131694. */
  131695. clear(): void;
  131696. /**
  131697. * Updates the texture
  131698. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  131699. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  131700. */
  131701. update(invertY?: boolean, premulAlpha?: boolean): void;
  131702. /**
  131703. * Draws text onto the texture
  131704. * @param text defines the text to be drawn
  131705. * @param x defines the placement of the text from the left
  131706. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  131707. * @param font defines the font to be used with font-style, font-size, font-name
  131708. * @param color defines the color used for the text
  131709. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  131710. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  131711. * @param update defines whether texture is immediately update (default is true)
  131712. */
  131713. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  131714. /**
  131715. * Clones the texture
  131716. * @returns the clone of the texture.
  131717. */
  131718. clone(): DynamicTexture;
  131719. /**
  131720. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  131721. * @returns a serialized dynamic texture object
  131722. */
  131723. serialize(): any;
  131724. private _IsCanvasElement;
  131725. /** @hidden */
  131726. _rebuild(): void;
  131727. }
  131728. }
  131729. declare module BABYLON {
  131730. /**
  131731. * Class containing static functions to help procedurally build meshes
  131732. */
  131733. export class GroundBuilder {
  131734. /**
  131735. * Creates a ground mesh
  131736. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  131737. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  131738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131739. * @param name defines the name of the mesh
  131740. * @param options defines the options used to create the mesh
  131741. * @param scene defines the hosting scene
  131742. * @returns the ground mesh
  131743. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  131744. */
  131745. static CreateGround(name: string, options: {
  131746. width?: number;
  131747. height?: number;
  131748. subdivisions?: number;
  131749. subdivisionsX?: number;
  131750. subdivisionsY?: number;
  131751. updatable?: boolean;
  131752. }, scene: any): Mesh;
  131753. /**
  131754. * Creates a tiled ground mesh
  131755. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  131756. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  131757. * * 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
  131758. * * 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
  131759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131760. * @param name defines the name of the mesh
  131761. * @param options defines the options used to create the mesh
  131762. * @param scene defines the hosting scene
  131763. * @returns the tiled ground mesh
  131764. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  131765. */
  131766. static CreateTiledGround(name: string, options: {
  131767. xmin: number;
  131768. zmin: number;
  131769. xmax: number;
  131770. zmax: number;
  131771. subdivisions?: {
  131772. w: number;
  131773. h: number;
  131774. };
  131775. precision?: {
  131776. w: number;
  131777. h: number;
  131778. };
  131779. updatable?: boolean;
  131780. }, scene?: Nullable<Scene>): Mesh;
  131781. /**
  131782. * Creates a ground mesh from a height map
  131783. * * The parameter `url` sets the URL of the height map image resource.
  131784. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  131785. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  131786. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  131787. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  131788. * * 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.
  131789. * * 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).
  131790. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  131791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131792. * @param name defines the name of the mesh
  131793. * @param url defines the url to the height map
  131794. * @param options defines the options used to create the mesh
  131795. * @param scene defines the hosting scene
  131796. * @returns the ground mesh
  131797. * @see https://doc.babylonjs.com/babylon101/height_map
  131798. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  131799. */
  131800. static CreateGroundFromHeightMap(name: string, url: string, options: {
  131801. width?: number;
  131802. height?: number;
  131803. subdivisions?: number;
  131804. minHeight?: number;
  131805. maxHeight?: number;
  131806. colorFilter?: Color3;
  131807. alphaFilter?: number;
  131808. updatable?: boolean;
  131809. onReady?: (mesh: GroundMesh) => void;
  131810. }, scene?: Nullable<Scene>): GroundMesh;
  131811. }
  131812. }
  131813. declare module BABYLON {
  131814. /**
  131815. * Class containing static functions to help procedurally build meshes
  131816. */
  131817. export class TorusBuilder {
  131818. /**
  131819. * Creates a torus mesh
  131820. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  131821. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  131822. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  131823. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131824. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131826. * @param name defines the name of the mesh
  131827. * @param options defines the options used to create the mesh
  131828. * @param scene defines the hosting scene
  131829. * @returns the torus mesh
  131830. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  131831. */
  131832. static CreateTorus(name: string, options: {
  131833. diameter?: number;
  131834. thickness?: number;
  131835. tessellation?: number;
  131836. updatable?: boolean;
  131837. sideOrientation?: number;
  131838. frontUVs?: Vector4;
  131839. backUVs?: Vector4;
  131840. }, scene: any): Mesh;
  131841. }
  131842. }
  131843. declare module BABYLON {
  131844. /**
  131845. * Class containing static functions to help procedurally build meshes
  131846. */
  131847. export class CylinderBuilder {
  131848. /**
  131849. * Creates a cylinder or a cone mesh
  131850. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  131851. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  131852. * * 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.
  131853. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  131854. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  131855. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  131856. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  131857. * * 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).
  131858. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  131859. * * 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).
  131860. * * 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
  131861. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  131862. * * 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
  131863. * * 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.
  131864. * * If `enclose` is false, a ring surface is one element.
  131865. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  131866. * * 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
  131867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131868. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131870. * @param name defines the name of the mesh
  131871. * @param options defines the options used to create the mesh
  131872. * @param scene defines the hosting scene
  131873. * @returns the cylinder mesh
  131874. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  131875. */
  131876. static CreateCylinder(name: string, options: {
  131877. height?: number;
  131878. diameterTop?: number;
  131879. diameterBottom?: number;
  131880. diameter?: number;
  131881. tessellation?: number;
  131882. subdivisions?: number;
  131883. arc?: number;
  131884. faceColors?: Color4[];
  131885. faceUV?: Vector4[];
  131886. updatable?: boolean;
  131887. hasRings?: boolean;
  131888. enclose?: boolean;
  131889. cap?: number;
  131890. sideOrientation?: number;
  131891. frontUVs?: Vector4;
  131892. backUVs?: Vector4;
  131893. }, scene: any): Mesh;
  131894. }
  131895. }
  131896. declare module BABYLON {
  131897. /**
  131898. * States of the webXR experience
  131899. */
  131900. export enum WebXRState {
  131901. /**
  131902. * Transitioning to being in XR mode
  131903. */
  131904. ENTERING_XR = 0,
  131905. /**
  131906. * Transitioning to non XR mode
  131907. */
  131908. EXITING_XR = 1,
  131909. /**
  131910. * In XR mode and presenting
  131911. */
  131912. IN_XR = 2,
  131913. /**
  131914. * Not entered XR mode
  131915. */
  131916. NOT_IN_XR = 3
  131917. }
  131918. /**
  131919. * The state of the XR camera's tracking
  131920. */
  131921. export enum WebXRTrackingState {
  131922. /**
  131923. * No transformation received, device is not being tracked
  131924. */
  131925. NOT_TRACKING = 0,
  131926. /**
  131927. * Tracking lost - using emulated position
  131928. */
  131929. TRACKING_LOST = 1,
  131930. /**
  131931. * Transformation tracking works normally
  131932. */
  131933. TRACKING = 2
  131934. }
  131935. /**
  131936. * Abstraction of the XR render target
  131937. */
  131938. export interface WebXRRenderTarget extends IDisposable {
  131939. /**
  131940. * xrpresent context of the canvas which can be used to display/mirror xr content
  131941. */
  131942. canvasContext: WebGLRenderingContext;
  131943. /**
  131944. * xr layer for the canvas
  131945. */
  131946. xrLayer: Nullable<XRWebGLLayer>;
  131947. /**
  131948. * Initializes the xr layer for the session
  131949. * @param xrSession xr session
  131950. * @returns a promise that will resolve once the XR Layer has been created
  131951. */
  131952. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  131953. }
  131954. }
  131955. declare module BABYLON {
  131956. /**
  131957. * COnfiguration object for WebXR output canvas
  131958. */
  131959. export class WebXRManagedOutputCanvasOptions {
  131960. /**
  131961. * An optional canvas in case you wish to create it yourself and provide it here.
  131962. * If not provided, a new canvas will be created
  131963. */
  131964. canvasElement?: HTMLCanvasElement;
  131965. /**
  131966. * Options for this XR Layer output
  131967. */
  131968. canvasOptions?: XRWebGLLayerInit;
  131969. /**
  131970. * CSS styling for a newly created canvas (if not provided)
  131971. */
  131972. newCanvasCssStyle?: string;
  131973. /**
  131974. * Get the default values of the configuration object
  131975. * @param engine defines the engine to use (can be null)
  131976. * @returns default values of this configuration object
  131977. */
  131978. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  131979. }
  131980. /**
  131981. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  131982. */
  131983. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  131984. private _options;
  131985. private _canvas;
  131986. private _engine;
  131987. private _originalCanvasSize;
  131988. /**
  131989. * Rendering context of the canvas which can be used to display/mirror xr content
  131990. */
  131991. canvasContext: WebGLRenderingContext;
  131992. /**
  131993. * xr layer for the canvas
  131994. */
  131995. xrLayer: Nullable<XRWebGLLayer>;
  131996. /**
  131997. * Obseervers registered here will be triggered when the xr layer was initialized
  131998. */
  131999. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  132000. /**
  132001. * Initializes the canvas to be added/removed upon entering/exiting xr
  132002. * @param _xrSessionManager The XR Session manager
  132003. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  132004. */
  132005. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  132006. /**
  132007. * Disposes of the object
  132008. */
  132009. dispose(): void;
  132010. /**
  132011. * Initializes the xr layer for the session
  132012. * @param xrSession xr session
  132013. * @returns a promise that will resolve once the XR Layer has been created
  132014. */
  132015. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  132016. private _addCanvas;
  132017. private _removeCanvas;
  132018. private _setCanvasSize;
  132019. private _setManagedOutputCanvas;
  132020. }
  132021. }
  132022. declare module BABYLON {
  132023. /**
  132024. * Manages an XRSession to work with Babylon's engine
  132025. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  132026. */
  132027. export class WebXRSessionManager implements IDisposable {
  132028. /** The scene which the session should be created for */
  132029. scene: Scene;
  132030. private _referenceSpace;
  132031. private _rttProvider;
  132032. private _sessionEnded;
  132033. private _xrNavigator;
  132034. private baseLayer;
  132035. /**
  132036. * The base reference space from which the session started. good if you want to reset your
  132037. * reference space
  132038. */
  132039. baseReferenceSpace: XRReferenceSpace;
  132040. /**
  132041. * Current XR frame
  132042. */
  132043. currentFrame: Nullable<XRFrame>;
  132044. /** WebXR timestamp updated every frame */
  132045. currentTimestamp: number;
  132046. /**
  132047. * Used just in case of a failure to initialize an immersive session.
  132048. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  132049. */
  132050. defaultHeightCompensation: number;
  132051. /**
  132052. * Fires every time a new xrFrame arrives which can be used to update the camera
  132053. */
  132054. onXRFrameObservable: Observable<XRFrame>;
  132055. /**
  132056. * Fires when the reference space changed
  132057. */
  132058. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  132059. /**
  132060. * Fires when the xr session is ended either by the device or manually done
  132061. */
  132062. onXRSessionEnded: Observable<any>;
  132063. /**
  132064. * Fires when the xr session is ended either by the device or manually done
  132065. */
  132066. onXRSessionInit: Observable<XRSession>;
  132067. /**
  132068. * Underlying xr session
  132069. */
  132070. session: XRSession;
  132071. /**
  132072. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  132073. * or get the offset the player is currently at.
  132074. */
  132075. viewerReferenceSpace: XRReferenceSpace;
  132076. /**
  132077. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  132078. * @param scene The scene which the session should be created for
  132079. */
  132080. constructor(
  132081. /** The scene which the session should be created for */
  132082. scene: Scene);
  132083. /**
  132084. * The current reference space used in this session. This reference space can constantly change!
  132085. * It is mainly used to offset the camera's position.
  132086. */
  132087. get referenceSpace(): XRReferenceSpace;
  132088. /**
  132089. * Set a new reference space and triggers the observable
  132090. */
  132091. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  132092. /**
  132093. * Disposes of the session manager
  132094. */
  132095. dispose(): void;
  132096. /**
  132097. * Stops the xrSession and restores the render loop
  132098. * @returns Promise which resolves after it exits XR
  132099. */
  132100. exitXRAsync(): Promise<void>;
  132101. /**
  132102. * Gets the correct render target texture to be rendered this frame for this eye
  132103. * @param eye the eye for which to get the render target
  132104. * @returns the render target for the specified eye
  132105. */
  132106. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  132107. /**
  132108. * Creates a WebXRRenderTarget object for the XR session
  132109. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  132110. * @param options optional options to provide when creating a new render target
  132111. * @returns a WebXR render target to which the session can render
  132112. */
  132113. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  132114. /**
  132115. * Initializes the manager
  132116. * After initialization enterXR can be called to start an XR session
  132117. * @returns Promise which resolves after it is initialized
  132118. */
  132119. initializeAsync(): Promise<void>;
  132120. /**
  132121. * Initializes an xr session
  132122. * @param xrSessionMode mode to initialize
  132123. * @param xrSessionInit defines optional and required values to pass to the session builder
  132124. * @returns a promise which will resolve once the session has been initialized
  132125. */
  132126. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  132127. /**
  132128. * Checks if a session would be supported for the creation options specified
  132129. * @param sessionMode session mode to check if supported eg. immersive-vr
  132130. * @returns A Promise that resolves to true if supported and false if not
  132131. */
  132132. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  132133. /**
  132134. * Resets the reference space to the one started the session
  132135. */
  132136. resetReferenceSpace(): void;
  132137. /**
  132138. * Starts rendering to the xr layer
  132139. */
  132140. runXRRenderLoop(): void;
  132141. /**
  132142. * Sets the reference space on the xr session
  132143. * @param referenceSpaceType space to set
  132144. * @returns a promise that will resolve once the reference space has been set
  132145. */
  132146. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  132147. /**
  132148. * Updates the render state of the session
  132149. * @param state state to set
  132150. * @returns a promise that resolves once the render state has been updated
  132151. */
  132152. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  132153. /**
  132154. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  132155. * @param sessionMode defines the session to test
  132156. * @returns a promise with boolean as final value
  132157. */
  132158. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  132159. private _createRenderTargetTexture;
  132160. }
  132161. }
  132162. declare module BABYLON {
  132163. /**
  132164. * WebXR Camera which holds the views for the xrSession
  132165. * @see https://doc.babylonjs.com/how_to/webxr_camera
  132166. */
  132167. export class WebXRCamera extends FreeCamera {
  132168. private _xrSessionManager;
  132169. private _firstFrame;
  132170. private _referenceQuaternion;
  132171. private _referencedPosition;
  132172. private _xrInvPositionCache;
  132173. private _xrInvQuaternionCache;
  132174. private _trackingState;
  132175. /**
  132176. * Observable raised before camera teleportation
  132177. */
  132178. onBeforeCameraTeleport: Observable<Vector3>;
  132179. /**
  132180. * Observable raised after camera teleportation
  132181. */
  132182. onAfterCameraTeleport: Observable<Vector3>;
  132183. /**
  132184. * Notifies when the camera's tracking state has changed.
  132185. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  132186. */
  132187. onTrackingStateChanged: Observable<WebXRTrackingState>;
  132188. /**
  132189. * Should position compensation execute on first frame.
  132190. * This is used when copying the position from a native (non XR) camera
  132191. */
  132192. compensateOnFirstFrame: boolean;
  132193. /**
  132194. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  132195. * @param name the name of the camera
  132196. * @param scene the scene to add the camera to
  132197. * @param _xrSessionManager a constructed xr session manager
  132198. */
  132199. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  132200. /**
  132201. * Get the current XR tracking state of the camera
  132202. */
  132203. get trackingState(): WebXRTrackingState;
  132204. private _setTrackingState;
  132205. /**
  132206. * Return the user's height, unrelated to the current ground.
  132207. * This will be the y position of this camera, when ground level is 0.
  132208. */
  132209. get realWorldHeight(): number;
  132210. /** @hidden */
  132211. _updateForDualEyeDebugging(): void;
  132212. /**
  132213. * Sets this camera's transformation based on a non-vr camera
  132214. * @param otherCamera the non-vr camera to copy the transformation from
  132215. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  132216. */
  132217. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  132218. /**
  132219. * Gets the current instance class name ("WebXRCamera").
  132220. * @returns the class name
  132221. */
  132222. getClassName(): string;
  132223. private _rotate180;
  132224. private _updateFromXRSession;
  132225. private _updateNumberOfRigCameras;
  132226. private _updateReferenceSpace;
  132227. private _updateReferenceSpaceOffset;
  132228. }
  132229. }
  132230. declare module BABYLON {
  132231. /**
  132232. * Defining the interface required for a (webxr) feature
  132233. */
  132234. export interface IWebXRFeature extends IDisposable {
  132235. /**
  132236. * Is this feature attached
  132237. */
  132238. attached: boolean;
  132239. /**
  132240. * Should auto-attach be disabled?
  132241. */
  132242. disableAutoAttach: boolean;
  132243. /**
  132244. * Attach the feature to the session
  132245. * Will usually be called by the features manager
  132246. *
  132247. * @param force should attachment be forced (even when already attached)
  132248. * @returns true if successful.
  132249. */
  132250. attach(force?: boolean): boolean;
  132251. /**
  132252. * Detach the feature from the session
  132253. * Will usually be called by the features manager
  132254. *
  132255. * @returns true if successful.
  132256. */
  132257. detach(): boolean;
  132258. /**
  132259. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  132260. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  132261. *
  132262. * @returns whether or not the feature is compatible in this environment
  132263. */
  132264. isCompatible(): boolean;
  132265. /**
  132266. * Was this feature disposed;
  132267. */
  132268. isDisposed: boolean;
  132269. /**
  132270. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  132271. */
  132272. xrNativeFeatureName?: string;
  132273. /**
  132274. * A list of (Babylon WebXR) features this feature depends on
  132275. */
  132276. dependsOn?: string[];
  132277. }
  132278. /**
  132279. * A list of the currently available features without referencing them
  132280. */
  132281. export class WebXRFeatureName {
  132282. /**
  132283. * The name of the anchor system feature
  132284. */
  132285. static readonly ANCHOR_SYSTEM: string;
  132286. /**
  132287. * The name of the background remover feature
  132288. */
  132289. static readonly BACKGROUND_REMOVER: string;
  132290. /**
  132291. * The name of the hit test feature
  132292. */
  132293. static readonly HIT_TEST: string;
  132294. /**
  132295. * physics impostors for xr controllers feature
  132296. */
  132297. static readonly PHYSICS_CONTROLLERS: string;
  132298. /**
  132299. * The name of the plane detection feature
  132300. */
  132301. static readonly PLANE_DETECTION: string;
  132302. /**
  132303. * The name of the pointer selection feature
  132304. */
  132305. static readonly POINTER_SELECTION: string;
  132306. /**
  132307. * The name of the teleportation feature
  132308. */
  132309. static readonly TELEPORTATION: string;
  132310. /**
  132311. * The name of the feature points feature.
  132312. */
  132313. static readonly FEATURE_POINTS: string;
  132314. /**
  132315. * The name of the hand tracking feature.
  132316. */
  132317. static readonly HAND_TRACKING: string;
  132318. }
  132319. /**
  132320. * Defining the constructor of a feature. Used to register the modules.
  132321. */
  132322. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  132323. /**
  132324. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  132325. * It is mainly used in AR sessions.
  132326. *
  132327. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  132328. */
  132329. export class WebXRFeaturesManager implements IDisposable {
  132330. private _xrSessionManager;
  132331. private static readonly _AvailableFeatures;
  132332. private _features;
  132333. /**
  132334. * constructs a new features manages.
  132335. *
  132336. * @param _xrSessionManager an instance of WebXRSessionManager
  132337. */
  132338. constructor(_xrSessionManager: WebXRSessionManager);
  132339. /**
  132340. * Used to register a module. After calling this function a developer can use this feature in the scene.
  132341. * Mainly used internally.
  132342. *
  132343. * @param featureName the name of the feature to register
  132344. * @param constructorFunction the function used to construct the module
  132345. * @param version the (babylon) version of the module
  132346. * @param stable is that a stable version of this module
  132347. */
  132348. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  132349. /**
  132350. * Returns a constructor of a specific feature.
  132351. *
  132352. * @param featureName the name of the feature to construct
  132353. * @param version the version of the feature to load
  132354. * @param xrSessionManager the xrSessionManager. Used to construct the module
  132355. * @param options optional options provided to the module.
  132356. * @returns a function that, when called, will return a new instance of this feature
  132357. */
  132358. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  132359. /**
  132360. * Can be used to return the list of features currently registered
  132361. *
  132362. * @returns an Array of available features
  132363. */
  132364. static GetAvailableFeatures(): string[];
  132365. /**
  132366. * Gets the versions available for a specific feature
  132367. * @param featureName the name of the feature
  132368. * @returns an array with the available versions
  132369. */
  132370. static GetAvailableVersions(featureName: string): string[];
  132371. /**
  132372. * Return the latest unstable version of this feature
  132373. * @param featureName the name of the feature to search
  132374. * @returns the version number. if not found will return -1
  132375. */
  132376. static GetLatestVersionOfFeature(featureName: string): number;
  132377. /**
  132378. * Return the latest stable version of this feature
  132379. * @param featureName the name of the feature to search
  132380. * @returns the version number. if not found will return -1
  132381. */
  132382. static GetStableVersionOfFeature(featureName: string): number;
  132383. /**
  132384. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  132385. * Can be used during a session to start a feature
  132386. * @param featureName the name of feature to attach
  132387. */
  132388. attachFeature(featureName: string): void;
  132389. /**
  132390. * Can be used inside a session or when the session ends to detach a specific feature
  132391. * @param featureName the name of the feature to detach
  132392. */
  132393. detachFeature(featureName: string): void;
  132394. /**
  132395. * Used to disable an already-enabled feature
  132396. * The feature will be disposed and will be recreated once enabled.
  132397. * @param featureName the feature to disable
  132398. * @returns true if disable was successful
  132399. */
  132400. disableFeature(featureName: string | {
  132401. Name: string;
  132402. }): boolean;
  132403. /**
  132404. * dispose this features manager
  132405. */
  132406. dispose(): void;
  132407. /**
  132408. * 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.
  132409. * 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.
  132410. *
  132411. * @param featureName the name of the feature to load or the class of the feature
  132412. * @param version optional version to load. if not provided the latest version will be enabled
  132413. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  132414. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  132415. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  132416. * @returns a new constructed feature or throws an error if feature not found.
  132417. */
  132418. enableFeature(featureName: string | {
  132419. Name: string;
  132420. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  132421. /**
  132422. * get the implementation of an enabled feature.
  132423. * @param featureName the name of the feature to load
  132424. * @returns the feature class, if found
  132425. */
  132426. getEnabledFeature(featureName: string): IWebXRFeature;
  132427. /**
  132428. * Get the list of enabled features
  132429. * @returns an array of enabled features
  132430. */
  132431. getEnabledFeatures(): string[];
  132432. /**
  132433. * This function will exten the session creation configuration object with enabled features.
  132434. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  132435. * according to the defined "required" variable, provided during enableFeature call
  132436. * @param xrSessionInit the xr Session init object to extend
  132437. *
  132438. * @returns an extended XRSessionInit object
  132439. */
  132440. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  132441. }
  132442. }
  132443. declare module BABYLON {
  132444. /**
  132445. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  132446. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  132447. */
  132448. export class WebXRExperienceHelper implements IDisposable {
  132449. private scene;
  132450. private _nonVRCamera;
  132451. private _originalSceneAutoClear;
  132452. private _supported;
  132453. /**
  132454. * Camera used to render xr content
  132455. */
  132456. camera: WebXRCamera;
  132457. /** A features manager for this xr session */
  132458. featuresManager: WebXRFeaturesManager;
  132459. /**
  132460. * Observers registered here will be triggered after the camera's initial transformation is set
  132461. * This can be used to set a different ground level or an extra rotation.
  132462. *
  132463. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  132464. * to the position set after this observable is done executing.
  132465. */
  132466. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  132467. /**
  132468. * Fires when the state of the experience helper has changed
  132469. */
  132470. onStateChangedObservable: Observable<WebXRState>;
  132471. /** Session manager used to keep track of xr session */
  132472. sessionManager: WebXRSessionManager;
  132473. /**
  132474. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  132475. */
  132476. state: WebXRState;
  132477. /**
  132478. * Creates a WebXRExperienceHelper
  132479. * @param scene The scene the helper should be created in
  132480. */
  132481. private constructor();
  132482. /**
  132483. * Creates the experience helper
  132484. * @param scene the scene to attach the experience helper to
  132485. * @returns a promise for the experience helper
  132486. */
  132487. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  132488. /**
  132489. * Disposes of the experience helper
  132490. */
  132491. dispose(): void;
  132492. /**
  132493. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  132494. * @param sessionMode options for the XR session
  132495. * @param referenceSpaceType frame of reference of the XR session
  132496. * @param renderTarget the output canvas that will be used to enter XR mode
  132497. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  132498. * @returns promise that resolves after xr mode has entered
  132499. */
  132500. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  132501. /**
  132502. * Exits XR mode and returns the scene to its original state
  132503. * @returns promise that resolves after xr mode has exited
  132504. */
  132505. exitXRAsync(): Promise<void>;
  132506. private _nonXRToXRCamera;
  132507. private _setState;
  132508. }
  132509. }
  132510. declare module BABYLON {
  132511. /**
  132512. * X-Y values for axes in WebXR
  132513. */
  132514. export interface IWebXRMotionControllerAxesValue {
  132515. /**
  132516. * The value of the x axis
  132517. */
  132518. x: number;
  132519. /**
  132520. * The value of the y-axis
  132521. */
  132522. y: number;
  132523. }
  132524. /**
  132525. * changed / previous values for the values of this component
  132526. */
  132527. export interface IWebXRMotionControllerComponentChangesValues<T> {
  132528. /**
  132529. * current (this frame) value
  132530. */
  132531. current: T;
  132532. /**
  132533. * previous (last change) value
  132534. */
  132535. previous: T;
  132536. }
  132537. /**
  132538. * Represents changes in the component between current frame and last values recorded
  132539. */
  132540. export interface IWebXRMotionControllerComponentChanges {
  132541. /**
  132542. * will be populated with previous and current values if axes changed
  132543. */
  132544. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  132545. /**
  132546. * will be populated with previous and current values if pressed changed
  132547. */
  132548. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  132549. /**
  132550. * will be populated with previous and current values if touched changed
  132551. */
  132552. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  132553. /**
  132554. * will be populated with previous and current values if value changed
  132555. */
  132556. value?: IWebXRMotionControllerComponentChangesValues<number>;
  132557. }
  132558. /**
  132559. * This class represents a single component (for example button or thumbstick) of a motion controller
  132560. */
  132561. export class WebXRControllerComponent implements IDisposable {
  132562. /**
  132563. * the id of this component
  132564. */
  132565. id: string;
  132566. /**
  132567. * the type of the component
  132568. */
  132569. type: MotionControllerComponentType;
  132570. private _buttonIndex;
  132571. private _axesIndices;
  132572. private _axes;
  132573. private _changes;
  132574. private _currentValue;
  132575. private _hasChanges;
  132576. private _pressed;
  132577. private _touched;
  132578. /**
  132579. * button component type
  132580. */
  132581. static BUTTON_TYPE: MotionControllerComponentType;
  132582. /**
  132583. * squeeze component type
  132584. */
  132585. static SQUEEZE_TYPE: MotionControllerComponentType;
  132586. /**
  132587. * Thumbstick component type
  132588. */
  132589. static THUMBSTICK_TYPE: MotionControllerComponentType;
  132590. /**
  132591. * Touchpad component type
  132592. */
  132593. static TOUCHPAD_TYPE: MotionControllerComponentType;
  132594. /**
  132595. * trigger component type
  132596. */
  132597. static TRIGGER_TYPE: MotionControllerComponentType;
  132598. /**
  132599. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  132600. * the axes data changes
  132601. */
  132602. onAxisValueChangedObservable: Observable<{
  132603. x: number;
  132604. y: number;
  132605. }>;
  132606. /**
  132607. * Observers registered here will be triggered when the state of a button changes
  132608. * State change is either pressed / touched / value
  132609. */
  132610. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  132611. /**
  132612. * Creates a new component for a motion controller.
  132613. * It is created by the motion controller itself
  132614. *
  132615. * @param id the id of this component
  132616. * @param type the type of the component
  132617. * @param _buttonIndex index in the buttons array of the gamepad
  132618. * @param _axesIndices indices of the values in the axes array of the gamepad
  132619. */
  132620. constructor(
  132621. /**
  132622. * the id of this component
  132623. */
  132624. id: string,
  132625. /**
  132626. * the type of the component
  132627. */
  132628. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  132629. /**
  132630. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  132631. */
  132632. get axes(): IWebXRMotionControllerAxesValue;
  132633. /**
  132634. * Get the changes. Elements will be populated only if they changed with their previous and current value
  132635. */
  132636. get changes(): IWebXRMotionControllerComponentChanges;
  132637. /**
  132638. * Return whether or not the component changed the last frame
  132639. */
  132640. get hasChanges(): boolean;
  132641. /**
  132642. * is the button currently pressed
  132643. */
  132644. get pressed(): boolean;
  132645. /**
  132646. * is the button currently touched
  132647. */
  132648. get touched(): boolean;
  132649. /**
  132650. * Get the current value of this component
  132651. */
  132652. get value(): number;
  132653. /**
  132654. * Dispose this component
  132655. */
  132656. dispose(): void;
  132657. /**
  132658. * Are there axes correlating to this component
  132659. * @return true is axes data is available
  132660. */
  132661. isAxes(): boolean;
  132662. /**
  132663. * Is this component a button (hence - pressable)
  132664. * @returns true if can be pressed
  132665. */
  132666. isButton(): boolean;
  132667. /**
  132668. * update this component using the gamepad object it is in. Called on every frame
  132669. * @param nativeController the native gamepad controller object
  132670. */
  132671. update(nativeController: IMinimalMotionControllerObject): void;
  132672. }
  132673. }
  132674. declare module BABYLON {
  132675. /**
  132676. * Interface used to represent data loading progression
  132677. */
  132678. export interface ISceneLoaderProgressEvent {
  132679. /**
  132680. * Defines if data length to load can be evaluated
  132681. */
  132682. readonly lengthComputable: boolean;
  132683. /**
  132684. * Defines the loaded data length
  132685. */
  132686. readonly loaded: number;
  132687. /**
  132688. * Defines the data length to load
  132689. */
  132690. readonly total: number;
  132691. }
  132692. /**
  132693. * Interface used by SceneLoader plugins to define supported file extensions
  132694. */
  132695. export interface ISceneLoaderPluginExtensions {
  132696. /**
  132697. * Defines the list of supported extensions
  132698. */
  132699. [extension: string]: {
  132700. isBinary: boolean;
  132701. };
  132702. }
  132703. /**
  132704. * Interface used by SceneLoader plugin factory
  132705. */
  132706. export interface ISceneLoaderPluginFactory {
  132707. /**
  132708. * Defines the name of the factory
  132709. */
  132710. name: string;
  132711. /**
  132712. * Function called to create a new plugin
  132713. * @return the new plugin
  132714. */
  132715. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  132716. /**
  132717. * The callback that returns true if the data can be directly loaded.
  132718. * @param data string containing the file data
  132719. * @returns if the data can be loaded directly
  132720. */
  132721. canDirectLoad?(data: string): boolean;
  132722. }
  132723. /**
  132724. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  132725. */
  132726. export interface ISceneLoaderPluginBase {
  132727. /**
  132728. * The friendly name of this plugin.
  132729. */
  132730. name: string;
  132731. /**
  132732. * The file extensions supported by this plugin.
  132733. */
  132734. extensions: string | ISceneLoaderPluginExtensions;
  132735. /**
  132736. * The callback called when loading from a url.
  132737. * @param scene scene loading this url
  132738. * @param url url to load
  132739. * @param onSuccess callback called when the file successfully loads
  132740. * @param onProgress callback called while file is loading (if the server supports this mode)
  132741. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  132742. * @param onError callback called when the file fails to load
  132743. * @returns a file request object
  132744. */
  132745. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  132746. /**
  132747. * The callback called when loading from a file object.
  132748. * @param scene scene loading this file
  132749. * @param file defines the file to load
  132750. * @param onSuccess defines the callback to call when data is loaded
  132751. * @param onProgress defines the callback to call during loading process
  132752. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  132753. * @param onError defines the callback to call when an error occurs
  132754. * @returns a file request object
  132755. */
  132756. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  132757. /**
  132758. * The callback that returns true if the data can be directly loaded.
  132759. * @param data string containing the file data
  132760. * @returns if the data can be loaded directly
  132761. */
  132762. canDirectLoad?(data: string): boolean;
  132763. /**
  132764. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  132765. * @param scene scene loading this data
  132766. * @param data string containing the data
  132767. * @returns data to pass to the plugin
  132768. */
  132769. directLoad?(scene: Scene, data: string): any;
  132770. /**
  132771. * The callback that allows custom handling of the root url based on the response url.
  132772. * @param rootUrl the original root url
  132773. * @param responseURL the response url if available
  132774. * @returns the new root url
  132775. */
  132776. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  132777. }
  132778. /**
  132779. * Interface used to define a SceneLoader plugin
  132780. */
  132781. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  132782. /**
  132783. * Import meshes into a scene.
  132784. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132785. * @param scene The scene to import into
  132786. * @param data The data to import
  132787. * @param rootUrl The root url for scene and resources
  132788. * @param meshes The meshes array to import into
  132789. * @param particleSystems The particle systems array to import into
  132790. * @param skeletons The skeletons array to import into
  132791. * @param onError The callback when import fails
  132792. * @returns True if successful or false otherwise
  132793. */
  132794. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  132795. /**
  132796. * Load into a scene.
  132797. * @param scene The scene to load into
  132798. * @param data The data to import
  132799. * @param rootUrl The root url for scene and resources
  132800. * @param onError The callback when import fails
  132801. * @returns True if successful or false otherwise
  132802. */
  132803. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  132804. /**
  132805. * Load into an asset container.
  132806. * @param scene The scene to load into
  132807. * @param data The data to import
  132808. * @param rootUrl The root url for scene and resources
  132809. * @param onError The callback when import fails
  132810. * @returns The loaded asset container
  132811. */
  132812. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  132813. }
  132814. /**
  132815. * Interface used to define an async SceneLoader plugin
  132816. */
  132817. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  132818. /**
  132819. * Import meshes into a scene.
  132820. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132821. * @param scene The scene to import into
  132822. * @param data The data to import
  132823. * @param rootUrl The root url for scene and resources
  132824. * @param onProgress The callback when the load progresses
  132825. * @param fileName Defines the name of the file to load
  132826. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  132827. */
  132828. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  132829. meshes: AbstractMesh[];
  132830. particleSystems: IParticleSystem[];
  132831. skeletons: Skeleton[];
  132832. animationGroups: AnimationGroup[];
  132833. }>;
  132834. /**
  132835. * Load into a scene.
  132836. * @param scene The scene to load into
  132837. * @param data The data to import
  132838. * @param rootUrl The root url for scene and resources
  132839. * @param onProgress The callback when the load progresses
  132840. * @param fileName Defines the name of the file to load
  132841. * @returns Nothing
  132842. */
  132843. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  132844. /**
  132845. * Load into an asset container.
  132846. * @param scene The scene to load into
  132847. * @param data The data to import
  132848. * @param rootUrl The root url for scene and resources
  132849. * @param onProgress The callback when the load progresses
  132850. * @param fileName Defines the name of the file to load
  132851. * @returns The loaded asset container
  132852. */
  132853. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  132854. }
  132855. /**
  132856. * Mode that determines how to handle old animation groups before loading new ones.
  132857. */
  132858. export enum SceneLoaderAnimationGroupLoadingMode {
  132859. /**
  132860. * Reset all old animations to initial state then dispose them.
  132861. */
  132862. Clean = 0,
  132863. /**
  132864. * Stop all old animations.
  132865. */
  132866. Stop = 1,
  132867. /**
  132868. * Restart old animations from first frame.
  132869. */
  132870. Sync = 2,
  132871. /**
  132872. * Old animations remains untouched.
  132873. */
  132874. NoSync = 3
  132875. }
  132876. /**
  132877. * Defines a plugin registered by the SceneLoader
  132878. */
  132879. interface IRegisteredPlugin {
  132880. /**
  132881. * Defines the plugin to use
  132882. */
  132883. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  132884. /**
  132885. * Defines if the plugin supports binary data
  132886. */
  132887. isBinary: boolean;
  132888. }
  132889. /**
  132890. * Class used to load scene from various file formats using registered plugins
  132891. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  132892. */
  132893. export class SceneLoader {
  132894. /**
  132895. * No logging while loading
  132896. */
  132897. static readonly NO_LOGGING: number;
  132898. /**
  132899. * Minimal logging while loading
  132900. */
  132901. static readonly MINIMAL_LOGGING: number;
  132902. /**
  132903. * Summary logging while loading
  132904. */
  132905. static readonly SUMMARY_LOGGING: number;
  132906. /**
  132907. * Detailled logging while loading
  132908. */
  132909. static readonly DETAILED_LOGGING: number;
  132910. /**
  132911. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  132912. */
  132913. static get ForceFullSceneLoadingForIncremental(): boolean;
  132914. static set ForceFullSceneLoadingForIncremental(value: boolean);
  132915. /**
  132916. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  132917. */
  132918. static get ShowLoadingScreen(): boolean;
  132919. static set ShowLoadingScreen(value: boolean);
  132920. /**
  132921. * Defines the current logging level (while loading the scene)
  132922. * @ignorenaming
  132923. */
  132924. static get loggingLevel(): number;
  132925. static set loggingLevel(value: number);
  132926. /**
  132927. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  132928. */
  132929. static get CleanBoneMatrixWeights(): boolean;
  132930. static set CleanBoneMatrixWeights(value: boolean);
  132931. /**
  132932. * Event raised when a plugin is used to load a scene
  132933. */
  132934. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  132935. private static _registeredPlugins;
  132936. private static _showingLoadingScreen;
  132937. /**
  132938. * Gets the default plugin (used to load Babylon files)
  132939. * @returns the .babylon plugin
  132940. */
  132941. static GetDefaultPlugin(): IRegisteredPlugin;
  132942. private static _GetPluginForExtension;
  132943. private static _GetPluginForDirectLoad;
  132944. private static _GetPluginForFilename;
  132945. private static _GetDirectLoad;
  132946. private static _LoadData;
  132947. private static _GetFileInfo;
  132948. /**
  132949. * Gets a plugin that can load the given extension
  132950. * @param extension defines the extension to load
  132951. * @returns a plugin or null if none works
  132952. */
  132953. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  132954. /**
  132955. * Gets a boolean indicating that the given extension can be loaded
  132956. * @param extension defines the extension to load
  132957. * @returns true if the extension is supported
  132958. */
  132959. static IsPluginForExtensionAvailable(extension: string): boolean;
  132960. /**
  132961. * Adds a new plugin to the list of registered plugins
  132962. * @param plugin defines the plugin to add
  132963. */
  132964. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  132965. /**
  132966. * Import meshes into a scene
  132967. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132968. * @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)
  132969. * @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)
  132970. * @param scene the instance of BABYLON.Scene to append to
  132971. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  132972. * @param onProgress a callback with a progress event for each file being loaded
  132973. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132974. * @param pluginExtension the extension used to determine the plugin
  132975. * @returns The loaded plugin
  132976. */
  132977. 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>;
  132978. /**
  132979. * Import meshes into a scene
  132980. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132981. * @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)
  132982. * @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)
  132983. * @param scene the instance of BABYLON.Scene to append to
  132984. * @param onProgress a callback with a progress event for each file being loaded
  132985. * @param pluginExtension the extension used to determine the plugin
  132986. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  132987. */
  132988. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  132989. meshes: AbstractMesh[];
  132990. particleSystems: IParticleSystem[];
  132991. skeletons: Skeleton[];
  132992. animationGroups: AnimationGroup[];
  132993. }>;
  132994. /**
  132995. * Load a scene
  132996. * @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)
  132997. * @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)
  132998. * @param engine is the instance of BABYLON.Engine to use to create the scene
  132999. * @param onSuccess a callback with the scene when import succeeds
  133000. * @param onProgress a callback with a progress event for each file being loaded
  133001. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133002. * @param pluginExtension the extension used to determine the plugin
  133003. * @returns The loaded plugin
  133004. */
  133005. 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>;
  133006. /**
  133007. * Load a scene
  133008. * @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)
  133009. * @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)
  133010. * @param engine is the instance of BABYLON.Engine to use to create the scene
  133011. * @param onProgress a callback with a progress event for each file being loaded
  133012. * @param pluginExtension the extension used to determine the plugin
  133013. * @returns The loaded scene
  133014. */
  133015. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  133016. /**
  133017. * Append a scene
  133018. * @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)
  133019. * @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)
  133020. * @param scene is the instance of BABYLON.Scene to append to
  133021. * @param onSuccess a callback with the scene when import succeeds
  133022. * @param onProgress a callback with a progress event for each file being loaded
  133023. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133024. * @param pluginExtension the extension used to determine the plugin
  133025. * @returns The loaded plugin
  133026. */
  133027. 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>;
  133028. /**
  133029. * Append a scene
  133030. * @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)
  133031. * @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)
  133032. * @param scene is the instance of BABYLON.Scene to append to
  133033. * @param onProgress a callback with a progress event for each file being loaded
  133034. * @param pluginExtension the extension used to determine the plugin
  133035. * @returns The given scene
  133036. */
  133037. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  133038. /**
  133039. * Load a scene into an asset container
  133040. * @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)
  133041. * @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)
  133042. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  133043. * @param onSuccess a callback with the scene when import succeeds
  133044. * @param onProgress a callback with a progress event for each file being loaded
  133045. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133046. * @param pluginExtension the extension used to determine the plugin
  133047. * @returns The loaded plugin
  133048. */
  133049. 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>;
  133050. /**
  133051. * Load a scene into an asset container
  133052. * @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)
  133053. * @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)
  133054. * @param scene is the instance of Scene to append to
  133055. * @param onProgress a callback with a progress event for each file being loaded
  133056. * @param pluginExtension the extension used to determine the plugin
  133057. * @returns The loaded asset container
  133058. */
  133059. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  133060. /**
  133061. * Import animations from a file into a scene
  133062. * @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)
  133063. * @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)
  133064. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  133065. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  133066. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  133067. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  133068. * @param onSuccess a callback with the scene when import succeeds
  133069. * @param onProgress a callback with a progress event for each file being loaded
  133070. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133071. * @param pluginExtension the extension used to determine the plugin
  133072. */
  133073. 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;
  133074. /**
  133075. * Import animations from a file into a scene
  133076. * @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)
  133077. * @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)
  133078. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  133079. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  133080. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  133081. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  133082. * @param onSuccess a callback with the scene when import succeeds
  133083. * @param onProgress a callback with a progress event for each file being loaded
  133084. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133085. * @param pluginExtension the extension used to determine the plugin
  133086. * @returns the updated scene with imported animations
  133087. */
  133088. 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>;
  133089. }
  133090. }
  133091. declare module BABYLON {
  133092. /**
  133093. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  133094. */
  133095. export type MotionControllerHandedness = "none" | "left" | "right";
  133096. /**
  133097. * The type of components available in motion controllers.
  133098. * This is not the name of the component.
  133099. */
  133100. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  133101. /**
  133102. * The state of a controller component
  133103. */
  133104. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  133105. /**
  133106. * The schema of motion controller layout.
  133107. * No object will be initialized using this interface
  133108. * This is used just to define the profile.
  133109. */
  133110. export interface IMotionControllerLayout {
  133111. /**
  133112. * Path to load the assets. Usually relative to the base path
  133113. */
  133114. assetPath: string;
  133115. /**
  133116. * Available components (unsorted)
  133117. */
  133118. components: {
  133119. /**
  133120. * A map of component Ids
  133121. */
  133122. [componentId: string]: {
  133123. /**
  133124. * The type of input the component outputs
  133125. */
  133126. type: MotionControllerComponentType;
  133127. /**
  133128. * The indices of this component in the gamepad object
  133129. */
  133130. gamepadIndices: {
  133131. /**
  133132. * Index of button
  133133. */
  133134. button?: number;
  133135. /**
  133136. * If available, index of x-axis
  133137. */
  133138. xAxis?: number;
  133139. /**
  133140. * If available, index of y-axis
  133141. */
  133142. yAxis?: number;
  133143. };
  133144. /**
  133145. * The mesh's root node name
  133146. */
  133147. rootNodeName: string;
  133148. /**
  133149. * Animation definitions for this model
  133150. */
  133151. visualResponses: {
  133152. [stateKey: string]: {
  133153. /**
  133154. * What property will be animated
  133155. */
  133156. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  133157. /**
  133158. * What states influence this visual response
  133159. */
  133160. states: MotionControllerComponentStateType[];
  133161. /**
  133162. * Type of animation - movement or visibility
  133163. */
  133164. valueNodeProperty: "transform" | "visibility";
  133165. /**
  133166. * Base node name to move. Its position will be calculated according to the min and max nodes
  133167. */
  133168. valueNodeName?: string;
  133169. /**
  133170. * Minimum movement node
  133171. */
  133172. minNodeName?: string;
  133173. /**
  133174. * Max movement node
  133175. */
  133176. maxNodeName?: string;
  133177. };
  133178. };
  133179. /**
  133180. * If touch enabled, what is the name of node to display user feedback
  133181. */
  133182. touchPointNodeName?: string;
  133183. };
  133184. };
  133185. /**
  133186. * Is it xr standard mapping or not
  133187. */
  133188. gamepadMapping: "" | "xr-standard";
  133189. /**
  133190. * Base root node of this entire model
  133191. */
  133192. rootNodeName: string;
  133193. /**
  133194. * Defines the main button component id
  133195. */
  133196. selectComponentId: string;
  133197. }
  133198. /**
  133199. * A definition for the layout map in the input profile
  133200. */
  133201. export interface IMotionControllerLayoutMap {
  133202. /**
  133203. * Layouts with handedness type as a key
  133204. */
  133205. [handedness: string]: IMotionControllerLayout;
  133206. }
  133207. /**
  133208. * The XR Input profile schema
  133209. * Profiles can be found here:
  133210. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  133211. */
  133212. export interface IMotionControllerProfile {
  133213. /**
  133214. * fallback profiles for this profileId
  133215. */
  133216. fallbackProfileIds: string[];
  133217. /**
  133218. * The layout map, with handedness as key
  133219. */
  133220. layouts: IMotionControllerLayoutMap;
  133221. /**
  133222. * The id of this profile
  133223. * correlates to the profile(s) in the xrInput.profiles array
  133224. */
  133225. profileId: string;
  133226. }
  133227. /**
  133228. * A helper-interface for the 3 meshes needed for controller button animation
  133229. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  133230. */
  133231. export interface IMotionControllerButtonMeshMap {
  133232. /**
  133233. * the mesh that defines the pressed value mesh position.
  133234. * This is used to find the max-position of this button
  133235. */
  133236. pressedMesh: AbstractMesh;
  133237. /**
  133238. * the mesh that defines the unpressed value mesh position.
  133239. * This is used to find the min (or initial) position of this button
  133240. */
  133241. unpressedMesh: AbstractMesh;
  133242. /**
  133243. * The mesh that will be changed when value changes
  133244. */
  133245. valueMesh: AbstractMesh;
  133246. }
  133247. /**
  133248. * A helper-interface for the 3 meshes needed for controller axis animation.
  133249. * This will be expanded when touchpad animations are fully supported
  133250. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  133251. */
  133252. export interface IMotionControllerMeshMap {
  133253. /**
  133254. * the mesh that defines the maximum value mesh position.
  133255. */
  133256. maxMesh?: AbstractMesh;
  133257. /**
  133258. * the mesh that defines the minimum value mesh position.
  133259. */
  133260. minMesh?: AbstractMesh;
  133261. /**
  133262. * The mesh that will be changed when axis value changes
  133263. */
  133264. valueMesh?: AbstractMesh;
  133265. }
  133266. /**
  133267. * The elements needed for change-detection of the gamepad objects in motion controllers
  133268. */
  133269. export interface IMinimalMotionControllerObject {
  133270. /**
  133271. * Available axes of this controller
  133272. */
  133273. axes: number[];
  133274. /**
  133275. * An array of available buttons
  133276. */
  133277. buttons: Array<{
  133278. /**
  133279. * Value of the button/trigger
  133280. */
  133281. value: number;
  133282. /**
  133283. * If the button/trigger is currently touched
  133284. */
  133285. touched: boolean;
  133286. /**
  133287. * If the button/trigger is currently pressed
  133288. */
  133289. pressed: boolean;
  133290. }>;
  133291. /**
  133292. * EXPERIMENTAL haptic support.
  133293. */
  133294. hapticActuators?: Array<{
  133295. pulse: (value: number, duration: number) => Promise<boolean>;
  133296. }>;
  133297. }
  133298. /**
  133299. * An Abstract Motion controller
  133300. * This class receives an xrInput and a profile layout and uses those to initialize the components
  133301. * Each component has an observable to check for changes in value and state
  133302. */
  133303. export abstract class WebXRAbstractMotionController implements IDisposable {
  133304. protected scene: Scene;
  133305. protected layout: IMotionControllerLayout;
  133306. /**
  133307. * The gamepad object correlating to this controller
  133308. */
  133309. gamepadObject: IMinimalMotionControllerObject;
  133310. /**
  133311. * handedness (left/right/none) of this controller
  133312. */
  133313. handedness: MotionControllerHandedness;
  133314. private _initComponent;
  133315. private _modelReady;
  133316. /**
  133317. * A map of components (WebXRControllerComponent) in this motion controller
  133318. * Components have a ComponentType and can also have both button and axis definitions
  133319. */
  133320. readonly components: {
  133321. [id: string]: WebXRControllerComponent;
  133322. };
  133323. /**
  133324. * Disable the model's animation. Can be set at any time.
  133325. */
  133326. disableAnimation: boolean;
  133327. /**
  133328. * Observers registered here will be triggered when the model of this controller is done loading
  133329. */
  133330. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  133331. /**
  133332. * The profile id of this motion controller
  133333. */
  133334. abstract profileId: string;
  133335. /**
  133336. * The root mesh of the model. It is null if the model was not yet initialized
  133337. */
  133338. rootMesh: Nullable<AbstractMesh>;
  133339. /**
  133340. * constructs a new abstract motion controller
  133341. * @param scene the scene to which the model of the controller will be added
  133342. * @param layout The profile layout to load
  133343. * @param gamepadObject The gamepad object correlating to this controller
  133344. * @param handedness handedness (left/right/none) of this controller
  133345. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  133346. */
  133347. constructor(scene: Scene, layout: IMotionControllerLayout,
  133348. /**
  133349. * The gamepad object correlating to this controller
  133350. */
  133351. gamepadObject: IMinimalMotionControllerObject,
  133352. /**
  133353. * handedness (left/right/none) of this controller
  133354. */
  133355. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  133356. /**
  133357. * Dispose this controller, the model mesh and all its components
  133358. */
  133359. dispose(): void;
  133360. /**
  133361. * Returns all components of specific type
  133362. * @param type the type to search for
  133363. * @return an array of components with this type
  133364. */
  133365. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  133366. /**
  133367. * get a component based an its component id as defined in layout.components
  133368. * @param id the id of the component
  133369. * @returns the component correlates to the id or undefined if not found
  133370. */
  133371. getComponent(id: string): WebXRControllerComponent;
  133372. /**
  133373. * Get the list of components available in this motion controller
  133374. * @returns an array of strings correlating to available components
  133375. */
  133376. getComponentIds(): string[];
  133377. /**
  133378. * Get the first component of specific type
  133379. * @param type type of component to find
  133380. * @return a controller component or null if not found
  133381. */
  133382. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  133383. /**
  133384. * Get the main (Select) component of this controller as defined in the layout
  133385. * @returns the main component of this controller
  133386. */
  133387. getMainComponent(): WebXRControllerComponent;
  133388. /**
  133389. * Loads the model correlating to this controller
  133390. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  133391. * @returns A promise fulfilled with the result of the model loading
  133392. */
  133393. loadModel(): Promise<boolean>;
  133394. /**
  133395. * Update this model using the current XRFrame
  133396. * @param xrFrame the current xr frame to use and update the model
  133397. */
  133398. updateFromXRFrame(xrFrame: XRFrame): void;
  133399. /**
  133400. * Backwards compatibility due to a deeply-integrated typo
  133401. */
  133402. get handness(): XREye;
  133403. /**
  133404. * Pulse (vibrate) this controller
  133405. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  133406. * Consecutive calls to this function will cancel the last pulse call
  133407. *
  133408. * @param value the strength of the pulse in 0.0...1.0 range
  133409. * @param duration Duration of the pulse in milliseconds
  133410. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  133411. * @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
  133412. */
  133413. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  133414. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  133415. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  133416. /**
  133417. * Moves the axis on the controller mesh based on its current state
  133418. * @param axis the index of the axis
  133419. * @param axisValue the value of the axis which determines the meshes new position
  133420. * @hidden
  133421. */
  133422. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  133423. /**
  133424. * Update the model itself with the current frame data
  133425. * @param xrFrame the frame to use for updating the model mesh
  133426. */
  133427. protected updateModel(xrFrame: XRFrame): void;
  133428. /**
  133429. * Get the filename and path for this controller's model
  133430. * @returns a map of filename and path
  133431. */
  133432. protected abstract _getFilenameAndPath(): {
  133433. filename: string;
  133434. path: string;
  133435. };
  133436. /**
  133437. * This function is called before the mesh is loaded. It checks for loading constraints.
  133438. * For example, this function can check if the GLB loader is available
  133439. * If this function returns false, the generic controller will be loaded instead
  133440. * @returns Is the client ready to load the mesh
  133441. */
  133442. protected abstract _getModelLoadingConstraints(): boolean;
  133443. /**
  133444. * This function will be called after the model was successfully loaded and can be used
  133445. * for mesh transformations before it is available for the user
  133446. * @param meshes the loaded meshes
  133447. */
  133448. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  133449. /**
  133450. * Set the root mesh for this controller. Important for the WebXR controller class
  133451. * @param meshes the loaded meshes
  133452. */
  133453. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  133454. /**
  133455. * A function executed each frame that updates the mesh (if needed)
  133456. * @param xrFrame the current xrFrame
  133457. */
  133458. protected abstract _updateModel(xrFrame: XRFrame): void;
  133459. private _getGenericFilenameAndPath;
  133460. private _getGenericParentMesh;
  133461. }
  133462. }
  133463. declare module BABYLON {
  133464. /**
  133465. * A generic trigger-only motion controller for WebXR
  133466. */
  133467. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  133468. /**
  133469. * Static version of the profile id of this controller
  133470. */
  133471. static ProfileId: string;
  133472. profileId: string;
  133473. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  133474. protected _getFilenameAndPath(): {
  133475. filename: string;
  133476. path: string;
  133477. };
  133478. protected _getModelLoadingConstraints(): boolean;
  133479. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  133480. protected _setRootMesh(meshes: AbstractMesh[]): void;
  133481. protected _updateModel(): void;
  133482. }
  133483. }
  133484. declare module BABYLON {
  133485. /**
  133486. * Class containing static functions to help procedurally build meshes
  133487. */
  133488. export class SphereBuilder {
  133489. /**
  133490. * Creates a sphere mesh
  133491. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  133492. * * 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`)
  133493. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  133494. * * 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
  133495. * * 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)
  133496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133497. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133499. * @param name defines the name of the mesh
  133500. * @param options defines the options used to create the mesh
  133501. * @param scene defines the hosting scene
  133502. * @returns the sphere mesh
  133503. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  133504. */
  133505. static CreateSphere(name: string, options: {
  133506. segments?: number;
  133507. diameter?: number;
  133508. diameterX?: number;
  133509. diameterY?: number;
  133510. diameterZ?: number;
  133511. arc?: number;
  133512. slice?: number;
  133513. sideOrientation?: number;
  133514. frontUVs?: Vector4;
  133515. backUVs?: Vector4;
  133516. updatable?: boolean;
  133517. }, scene?: Nullable<Scene>): Mesh;
  133518. }
  133519. }
  133520. declare module BABYLON {
  133521. /**
  133522. * A profiled motion controller has its profile loaded from an online repository.
  133523. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  133524. */
  133525. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  133526. private _repositoryUrl;
  133527. private _buttonMeshMapping;
  133528. private _touchDots;
  133529. /**
  133530. * The profile ID of this controller. Will be populated when the controller initializes.
  133531. */
  133532. profileId: string;
  133533. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  133534. dispose(): void;
  133535. protected _getFilenameAndPath(): {
  133536. filename: string;
  133537. path: string;
  133538. };
  133539. protected _getModelLoadingConstraints(): boolean;
  133540. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  133541. protected _setRootMesh(meshes: AbstractMesh[]): void;
  133542. protected _updateModel(_xrFrame: XRFrame): void;
  133543. }
  133544. }
  133545. declare module BABYLON {
  133546. /**
  133547. * A construction function type to create a new controller based on an xrInput object
  133548. */
  133549. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  133550. /**
  133551. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  133552. *
  133553. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  133554. * it should be replaced with auto-loaded controllers.
  133555. *
  133556. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  133557. */
  133558. export class WebXRMotionControllerManager {
  133559. private static _AvailableControllers;
  133560. private static _Fallbacks;
  133561. private static _ProfileLoadingPromises;
  133562. private static _ProfilesList;
  133563. /**
  133564. * The base URL of the online controller repository. Can be changed at any time.
  133565. */
  133566. static BaseRepositoryUrl: string;
  133567. /**
  133568. * Which repository gets priority - local or online
  133569. */
  133570. static PrioritizeOnlineRepository: boolean;
  133571. /**
  133572. * Use the online repository, or use only locally-defined controllers
  133573. */
  133574. static UseOnlineRepository: boolean;
  133575. /**
  133576. * Clear the cache used for profile loading and reload when requested again
  133577. */
  133578. static ClearProfilesCache(): void;
  133579. /**
  133580. * Register the default fallbacks.
  133581. * This function is called automatically when this file is imported.
  133582. */
  133583. static DefaultFallbacks(): void;
  133584. /**
  133585. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  133586. * @param profileId the profile to which a fallback needs to be found
  133587. * @return an array with corresponding fallback profiles
  133588. */
  133589. static FindFallbackWithProfileId(profileId: string): string[];
  133590. /**
  133591. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  133592. * The order of search:
  133593. *
  133594. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  133595. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  133596. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  133597. * 4) return the generic trigger controller if none were found
  133598. *
  133599. * @param xrInput the xrInput to which a new controller is initialized
  133600. * @param scene the scene to which the model will be added
  133601. * @param forceProfile force a certain profile for this controller
  133602. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  133603. */
  133604. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  133605. /**
  133606. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  133607. *
  133608. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  133609. *
  133610. * @param type the profile type to register
  133611. * @param constructFunction the function to be called when loading this profile
  133612. */
  133613. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  133614. /**
  133615. * Register a fallback to a specific profile.
  133616. * @param profileId the profileId that will receive the fallbacks
  133617. * @param fallbacks A list of fallback profiles
  133618. */
  133619. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  133620. /**
  133621. * Will update the list of profiles available in the repository
  133622. * @return a promise that resolves to a map of profiles available online
  133623. */
  133624. static UpdateProfilesList(): Promise<{
  133625. [profile: string]: string;
  133626. }>;
  133627. private static _LoadProfileFromRepository;
  133628. private static _LoadProfilesFromAvailableControllers;
  133629. }
  133630. }
  133631. declare module BABYLON {
  133632. /**
  133633. * Configuration options for the WebXR controller creation
  133634. */
  133635. export interface IWebXRControllerOptions {
  133636. /**
  133637. * Should the controller mesh be animated when a user interacts with it
  133638. * The pressed buttons / thumbstick and touchpad animations will be disabled
  133639. */
  133640. disableMotionControllerAnimation?: boolean;
  133641. /**
  133642. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  133643. */
  133644. doNotLoadControllerMesh?: boolean;
  133645. /**
  133646. * Force a specific controller type for this controller.
  133647. * This can be used when creating your own profile or when testing different controllers
  133648. */
  133649. forceControllerProfile?: string;
  133650. /**
  133651. * Defines a rendering group ID for meshes that will be loaded.
  133652. * This is for the default controllers only.
  133653. */
  133654. renderingGroupId?: number;
  133655. }
  133656. /**
  133657. * Represents an XR controller
  133658. */
  133659. export class WebXRInputSource {
  133660. private _scene;
  133661. /** The underlying input source for the controller */
  133662. inputSource: XRInputSource;
  133663. private _options;
  133664. private _tmpVector;
  133665. private _uniqueId;
  133666. private _disposed;
  133667. /**
  133668. * 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
  133669. */
  133670. grip?: AbstractMesh;
  133671. /**
  133672. * If available, this is the gamepad object related to this controller.
  133673. * Using this object it is possible to get click events and trackpad changes of the
  133674. * webxr controller that is currently being used.
  133675. */
  133676. motionController?: WebXRAbstractMotionController;
  133677. /**
  133678. * Event that fires when the controller is removed/disposed.
  133679. * The object provided as event data is this controller, after associated assets were disposed.
  133680. * uniqueId is still available.
  133681. */
  133682. onDisposeObservable: Observable<WebXRInputSource>;
  133683. /**
  133684. * Will be triggered when the mesh associated with the motion controller is done loading.
  133685. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  133686. * A shortened version of controller -> motion controller -> on mesh loaded.
  133687. */
  133688. onMeshLoadedObservable: Observable<AbstractMesh>;
  133689. /**
  133690. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  133691. */
  133692. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  133693. /**
  133694. * Pointer which can be used to select objects or attach a visible laser to
  133695. */
  133696. pointer: AbstractMesh;
  133697. /**
  133698. * Creates the input source object
  133699. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  133700. * @param _scene the scene which the controller should be associated to
  133701. * @param inputSource the underlying input source for the controller
  133702. * @param _options options for this controller creation
  133703. */
  133704. constructor(_scene: Scene,
  133705. /** The underlying input source for the controller */
  133706. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  133707. /**
  133708. * Get this controllers unique id
  133709. */
  133710. get uniqueId(): string;
  133711. /**
  133712. * Disposes of the object
  133713. */
  133714. dispose(): void;
  133715. /**
  133716. * Gets a world space ray coming from the pointer or grip
  133717. * @param result the resulting ray
  133718. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  133719. */
  133720. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  133721. /**
  133722. * Updates the controller pose based on the given XRFrame
  133723. * @param xrFrame xr frame to update the pose with
  133724. * @param referenceSpace reference space to use
  133725. */
  133726. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  133727. }
  133728. }
  133729. declare module BABYLON {
  133730. /**
  133731. * The schema for initialization options of the XR Input class
  133732. */
  133733. export interface IWebXRInputOptions {
  133734. /**
  133735. * If set to true no model will be automatically loaded
  133736. */
  133737. doNotLoadControllerMeshes?: boolean;
  133738. /**
  133739. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  133740. * If not found, the xr input profile data will be used.
  133741. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  133742. */
  133743. forceInputProfile?: string;
  133744. /**
  133745. * Do not send a request to the controller repository to load the profile.
  133746. *
  133747. * Instead, use the controllers available in babylon itself.
  133748. */
  133749. disableOnlineControllerRepository?: boolean;
  133750. /**
  133751. * A custom URL for the controllers repository
  133752. */
  133753. customControllersRepositoryURL?: string;
  133754. /**
  133755. * Should the controller model's components not move according to the user input
  133756. */
  133757. disableControllerAnimation?: boolean;
  133758. /**
  133759. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  133760. */
  133761. controllerOptions?: IWebXRControllerOptions;
  133762. }
  133763. /**
  133764. * XR input used to track XR inputs such as controllers/rays
  133765. */
  133766. export class WebXRInput implements IDisposable {
  133767. /**
  133768. * the xr session manager for this session
  133769. */
  133770. xrSessionManager: WebXRSessionManager;
  133771. /**
  133772. * the WebXR camera for this session. Mainly used for teleportation
  133773. */
  133774. xrCamera: WebXRCamera;
  133775. private readonly options;
  133776. /**
  133777. * XR controllers being tracked
  133778. */
  133779. controllers: Array<WebXRInputSource>;
  133780. private _frameObserver;
  133781. private _sessionEndedObserver;
  133782. private _sessionInitObserver;
  133783. /**
  133784. * Event when a controller has been connected/added
  133785. */
  133786. onControllerAddedObservable: Observable<WebXRInputSource>;
  133787. /**
  133788. * Event when a controller has been removed/disconnected
  133789. */
  133790. onControllerRemovedObservable: Observable<WebXRInputSource>;
  133791. /**
  133792. * Initializes the WebXRInput
  133793. * @param xrSessionManager the xr session manager for this session
  133794. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  133795. * @param options = initialization options for this xr input
  133796. */
  133797. constructor(
  133798. /**
  133799. * the xr session manager for this session
  133800. */
  133801. xrSessionManager: WebXRSessionManager,
  133802. /**
  133803. * the WebXR camera for this session. Mainly used for teleportation
  133804. */
  133805. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  133806. private _onInputSourcesChange;
  133807. private _addAndRemoveControllers;
  133808. /**
  133809. * Disposes of the object
  133810. */
  133811. dispose(): void;
  133812. }
  133813. }
  133814. declare module BABYLON {
  133815. /**
  133816. * This is the base class for all WebXR features.
  133817. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  133818. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  133819. */
  133820. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  133821. protected _xrSessionManager: WebXRSessionManager;
  133822. private _attached;
  133823. private _removeOnDetach;
  133824. /**
  133825. * Is this feature disposed?
  133826. */
  133827. isDisposed: boolean;
  133828. /**
  133829. * Should auto-attach be disabled?
  133830. */
  133831. disableAutoAttach: boolean;
  133832. /**
  133833. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  133834. */
  133835. xrNativeFeatureName: string;
  133836. /**
  133837. * Construct a new (abstract) WebXR feature
  133838. * @param _xrSessionManager the xr session manager for this feature
  133839. */
  133840. constructor(_xrSessionManager: WebXRSessionManager);
  133841. /**
  133842. * Is this feature attached
  133843. */
  133844. get attached(): boolean;
  133845. /**
  133846. * attach this feature
  133847. *
  133848. * @param force should attachment be forced (even when already attached)
  133849. * @returns true if successful, false is failed or already attached
  133850. */
  133851. attach(force?: boolean): boolean;
  133852. /**
  133853. * detach this feature.
  133854. *
  133855. * @returns true if successful, false if failed or already detached
  133856. */
  133857. detach(): boolean;
  133858. /**
  133859. * Dispose this feature and all of the resources attached
  133860. */
  133861. dispose(): void;
  133862. /**
  133863. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  133864. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  133865. *
  133866. * @returns whether or not the feature is compatible in this environment
  133867. */
  133868. isCompatible(): boolean;
  133869. /**
  133870. * This is used to register callbacks that will automatically be removed when detach is called.
  133871. * @param observable the observable to which the observer will be attached
  133872. * @param callback the callback to register
  133873. */
  133874. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  133875. /**
  133876. * Code in this function will be executed on each xrFrame received from the browser.
  133877. * This function will not execute after the feature is detached.
  133878. * @param _xrFrame the current frame
  133879. */
  133880. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  133881. }
  133882. }
  133883. declare module BABYLON {
  133884. /**
  133885. * Renders a layer on top of an existing scene
  133886. */
  133887. export class UtilityLayerRenderer implements IDisposable {
  133888. /** the original scene that will be rendered on top of */
  133889. originalScene: Scene;
  133890. private _pointerCaptures;
  133891. private _lastPointerEvents;
  133892. private static _DefaultUtilityLayer;
  133893. private static _DefaultKeepDepthUtilityLayer;
  133894. private _sharedGizmoLight;
  133895. private _renderCamera;
  133896. /**
  133897. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  133898. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  133899. * @returns the camera that is used when rendering the utility layer
  133900. */
  133901. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  133902. /**
  133903. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  133904. * @param cam the camera that should be used when rendering the utility layer
  133905. */
  133906. setRenderCamera(cam: Nullable<Camera>): void;
  133907. /**
  133908. * @hidden
  133909. * Light which used by gizmos to get light shading
  133910. */
  133911. _getSharedGizmoLight(): HemisphericLight;
  133912. /**
  133913. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  133914. */
  133915. pickUtilitySceneFirst: boolean;
  133916. /**
  133917. * 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)
  133918. */
  133919. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  133920. /**
  133921. * 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)
  133922. */
  133923. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  133924. /**
  133925. * The scene that is rendered on top of the original scene
  133926. */
  133927. utilityLayerScene: Scene;
  133928. /**
  133929. * If the utility layer should automatically be rendered on top of existing scene
  133930. */
  133931. shouldRender: boolean;
  133932. /**
  133933. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  133934. */
  133935. onlyCheckPointerDownEvents: boolean;
  133936. /**
  133937. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  133938. */
  133939. processAllEvents: boolean;
  133940. /**
  133941. * Observable raised when the pointer move from the utility layer scene to the main scene
  133942. */
  133943. onPointerOutObservable: Observable<number>;
  133944. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  133945. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  133946. private _afterRenderObserver;
  133947. private _sceneDisposeObserver;
  133948. private _originalPointerObserver;
  133949. /**
  133950. * Instantiates a UtilityLayerRenderer
  133951. * @param originalScene the original scene that will be rendered on top of
  133952. * @param handleEvents boolean indicating if the utility layer should handle events
  133953. */
  133954. constructor(
  133955. /** the original scene that will be rendered on top of */
  133956. originalScene: Scene, handleEvents?: boolean);
  133957. private _notifyObservers;
  133958. /**
  133959. * Renders the utility layers scene on top of the original scene
  133960. */
  133961. render(): void;
  133962. /**
  133963. * Disposes of the renderer
  133964. */
  133965. dispose(): void;
  133966. private _updateCamera;
  133967. }
  133968. }
  133969. declare module BABYLON {
  133970. /**
  133971. * Options interface for the pointer selection module
  133972. */
  133973. export interface IWebXRControllerPointerSelectionOptions {
  133974. /**
  133975. * if provided, this scene will be used to render meshes.
  133976. */
  133977. customUtilityLayerScene?: Scene;
  133978. /**
  133979. * 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)
  133980. * If not disabled, the last picked point will be used to execute a pointer up event
  133981. * If disabled, pointer up event will be triggered right after the pointer down event.
  133982. * Used in screen and gaze target ray mode only
  133983. */
  133984. disablePointerUpOnTouchOut: boolean;
  133985. /**
  133986. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  133987. */
  133988. forceGazeMode: boolean;
  133989. /**
  133990. * 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
  133991. * to start a new countdown to the pointer down event.
  133992. * Defaults to 1.
  133993. */
  133994. gazeModePointerMovedFactor?: number;
  133995. /**
  133996. * Different button type to use instead of the main component
  133997. */
  133998. overrideButtonId?: string;
  133999. /**
  134000. * use this rendering group id for the meshes (optional)
  134001. */
  134002. renderingGroupId?: number;
  134003. /**
  134004. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  134005. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  134006. * 3000 means 3 seconds between pointing at something and selecting it
  134007. */
  134008. timeToSelect?: number;
  134009. /**
  134010. * Should meshes created here be added to a utility layer or the main scene
  134011. */
  134012. useUtilityLayer?: boolean;
  134013. /**
  134014. * Optional WebXR camera to be used for gaze selection
  134015. */
  134016. gazeCamera?: WebXRCamera;
  134017. /**
  134018. * the xr input to use with this pointer selection
  134019. */
  134020. xrInput: WebXRInput;
  134021. /**
  134022. * Should the scene pointerX and pointerY update be disabled
  134023. * This is required for fullscreen AR GUI, but might slow down other experiences.
  134024. * Disable in VR, if not needed.
  134025. * The first rig camera (left eye) will be used to calculate the projection
  134026. */
  134027. disableScenePointerVectorUpdate: boolean;
  134028. /**
  134029. * Enable pointer selection on all controllers instead of switching between them
  134030. */
  134031. enablePointerSelectionOnAllControllers?: boolean;
  134032. /**
  134033. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  134034. * If switch is enabled, it will still allow the user to switch between the different controllers
  134035. */
  134036. preferredHandedness?: XRHandedness;
  134037. /**
  134038. * Disable switching the pointer selection from one controller to the other.
  134039. * If the preferred hand is set it will be fixed on this hand, and if not it will be fixed on the first controller added to the scene
  134040. */
  134041. disableSwitchOnClick?: boolean;
  134042. /**
  134043. * The maximum distance of the pointer selection feature. Defaults to 100.
  134044. */
  134045. maxPointerDistance?: number;
  134046. }
  134047. /**
  134048. * A module that will enable pointer selection for motion controllers of XR Input Sources
  134049. */
  134050. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  134051. private readonly _options;
  134052. private static _idCounter;
  134053. private _attachController;
  134054. private _controllers;
  134055. private _scene;
  134056. private _tmpVectorForPickCompare;
  134057. private _attachedController;
  134058. /**
  134059. * The module's name
  134060. */
  134061. static readonly Name: string;
  134062. /**
  134063. * The (Babylon) version of this module.
  134064. * This is an integer representing the implementation version.
  134065. * This number does not correspond to the WebXR specs version
  134066. */
  134067. static readonly Version: number;
  134068. /**
  134069. * Disable lighting on the laser pointer (so it will always be visible)
  134070. */
  134071. disablePointerLighting: boolean;
  134072. /**
  134073. * Disable lighting on the selection mesh (so it will always be visible)
  134074. */
  134075. disableSelectionMeshLighting: boolean;
  134076. /**
  134077. * Should the laser pointer be displayed
  134078. */
  134079. displayLaserPointer: boolean;
  134080. /**
  134081. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  134082. */
  134083. displaySelectionMesh: boolean;
  134084. /**
  134085. * This color will be set to the laser pointer when selection is triggered
  134086. */
  134087. laserPointerPickedColor: Color3;
  134088. /**
  134089. * Default color of the laser pointer
  134090. */
  134091. laserPointerDefaultColor: Color3;
  134092. /**
  134093. * default color of the selection ring
  134094. */
  134095. selectionMeshDefaultColor: Color3;
  134096. /**
  134097. * This color will be applied to the selection ring when selection is triggered
  134098. */
  134099. selectionMeshPickedColor: Color3;
  134100. /**
  134101. * Optional filter to be used for ray selection. This predicate shares behavior with
  134102. * scene.pointerMovePredicate which takes priority if it is also assigned.
  134103. */
  134104. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  134105. /**
  134106. * constructs a new background remover module
  134107. * @param _xrSessionManager the session manager for this module
  134108. * @param _options read-only options to be used in this module
  134109. */
  134110. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  134111. /**
  134112. * attach this feature
  134113. * Will usually be called by the features manager
  134114. *
  134115. * @returns true if successful.
  134116. */
  134117. attach(): boolean;
  134118. /**
  134119. * detach this feature.
  134120. * Will usually be called by the features manager
  134121. *
  134122. * @returns true if successful.
  134123. */
  134124. detach(): boolean;
  134125. /**
  134126. * Will get the mesh under a specific pointer.
  134127. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  134128. * @param controllerId the controllerId to check
  134129. * @returns The mesh under pointer or null if no mesh is under the pointer
  134130. */
  134131. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  134132. /**
  134133. * Get the xr controller that correlates to the pointer id in the pointer event
  134134. *
  134135. * @param id the pointer id to search for
  134136. * @returns the controller that correlates to this id or null if not found
  134137. */
  134138. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  134139. private _identityMatrix;
  134140. private _screenCoordinatesRef;
  134141. private _viewportRef;
  134142. protected _onXRFrame(_xrFrame: XRFrame): void;
  134143. private _attachGazeMode;
  134144. private _attachScreenRayMode;
  134145. private _attachTrackedPointerRayMode;
  134146. private _convertNormalToDirectionOfRay;
  134147. private _detachController;
  134148. private _generateNewMeshPair;
  134149. private _pickingMoved;
  134150. private _updatePointerDistance;
  134151. /** @hidden */
  134152. get lasterPointerDefaultColor(): Color3;
  134153. }
  134154. }
  134155. declare module BABYLON {
  134156. /**
  134157. * Button which can be used to enter a different mode of XR
  134158. */
  134159. export class WebXREnterExitUIButton {
  134160. /** button element */
  134161. element: HTMLElement;
  134162. /** XR initialization options for the button */
  134163. sessionMode: XRSessionMode;
  134164. /** Reference space type */
  134165. referenceSpaceType: XRReferenceSpaceType;
  134166. /**
  134167. * Creates a WebXREnterExitUIButton
  134168. * @param element button element
  134169. * @param sessionMode XR initialization session mode
  134170. * @param referenceSpaceType the type of reference space to be used
  134171. */
  134172. constructor(
  134173. /** button element */
  134174. element: HTMLElement,
  134175. /** XR initialization options for the button */
  134176. sessionMode: XRSessionMode,
  134177. /** Reference space type */
  134178. referenceSpaceType: XRReferenceSpaceType);
  134179. /**
  134180. * Extendable function which can be used to update the button's visuals when the state changes
  134181. * @param activeButton the current active button in the UI
  134182. */
  134183. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  134184. }
  134185. /**
  134186. * Options to create the webXR UI
  134187. */
  134188. export class WebXREnterExitUIOptions {
  134189. /**
  134190. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  134191. */
  134192. customButtons?: Array<WebXREnterExitUIButton>;
  134193. /**
  134194. * A reference space type to use when creating the default button.
  134195. * Default is local-floor
  134196. */
  134197. referenceSpaceType?: XRReferenceSpaceType;
  134198. /**
  134199. * Context to enter xr with
  134200. */
  134201. renderTarget?: Nullable<WebXRRenderTarget>;
  134202. /**
  134203. * A session mode to use when creating the default button.
  134204. * Default is immersive-vr
  134205. */
  134206. sessionMode?: XRSessionMode;
  134207. /**
  134208. * A list of optional features to init the session with
  134209. */
  134210. optionalFeatures?: string[];
  134211. /**
  134212. * A list of optional features to init the session with
  134213. */
  134214. requiredFeatures?: string[];
  134215. /**
  134216. * If defined, this function will be executed if the UI encounters an error when entering XR
  134217. */
  134218. onError?: (error: any) => void;
  134219. }
  134220. /**
  134221. * UI to allow the user to enter/exit XR mode
  134222. */
  134223. export class WebXREnterExitUI implements IDisposable {
  134224. private scene;
  134225. /** version of the options passed to this UI */
  134226. options: WebXREnterExitUIOptions;
  134227. private _activeButton;
  134228. private _buttons;
  134229. /**
  134230. * The HTML Div Element to which buttons are added.
  134231. */
  134232. readonly overlay: HTMLDivElement;
  134233. /**
  134234. * Fired every time the active button is changed.
  134235. *
  134236. * When xr is entered via a button that launches xr that button will be the callback parameter
  134237. *
  134238. * When exiting xr the callback parameter will be null)
  134239. */
  134240. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  134241. /**
  134242. *
  134243. * @param scene babylon scene object to use
  134244. * @param options (read-only) version of the options passed to this UI
  134245. */
  134246. private constructor();
  134247. /**
  134248. * Creates UI to allow the user to enter/exit XR mode
  134249. * @param scene the scene to add the ui to
  134250. * @param helper the xr experience helper to enter/exit xr with
  134251. * @param options options to configure the UI
  134252. * @returns the created ui
  134253. */
  134254. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  134255. /**
  134256. * Disposes of the XR UI component
  134257. */
  134258. dispose(): void;
  134259. private _updateButtons;
  134260. }
  134261. }
  134262. declare module BABYLON {
  134263. /**
  134264. * Class containing static functions to help procedurally build meshes
  134265. */
  134266. export class LinesBuilder {
  134267. /**
  134268. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134269. * * 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
  134270. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134271. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134272. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134273. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134274. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134275. * * 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
  134276. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134278. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134279. * @param name defines the name of the new line system
  134280. * @param options defines the options used to create the line system
  134281. * @param scene defines the hosting scene
  134282. * @returns a new line system mesh
  134283. */
  134284. static CreateLineSystem(name: string, options: {
  134285. lines: Vector3[][];
  134286. updatable?: boolean;
  134287. instance?: Nullable<LinesMesh>;
  134288. colors?: Nullable<Color4[][]>;
  134289. useVertexAlpha?: boolean;
  134290. }, scene: Nullable<Scene>): LinesMesh;
  134291. /**
  134292. * Creates a line mesh
  134293. * 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
  134294. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134295. * * The parameter `points` is an array successive Vector3
  134296. * * 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
  134297. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134298. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134299. * * When updating an instance, remember that only point positions can change, not the number of points
  134300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134301. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134302. * @param name defines the name of the new line system
  134303. * @param options defines the options used to create the line system
  134304. * @param scene defines the hosting scene
  134305. * @returns a new line mesh
  134306. */
  134307. static CreateLines(name: string, options: {
  134308. points: Vector3[];
  134309. updatable?: boolean;
  134310. instance?: Nullable<LinesMesh>;
  134311. colors?: Color4[];
  134312. useVertexAlpha?: boolean;
  134313. }, scene?: Nullable<Scene>): LinesMesh;
  134314. /**
  134315. * Creates a dashed line mesh
  134316. * * 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
  134317. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134318. * * The parameter `points` is an array successive Vector3
  134319. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134320. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134321. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134322. * * 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
  134323. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134324. * * When updating an instance, remember that only point positions can change, not the number of points
  134325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134326. * @param name defines the name of the mesh
  134327. * @param options defines the options used to create the mesh
  134328. * @param scene defines the hosting scene
  134329. * @returns the dashed line mesh
  134330. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134331. */
  134332. static CreateDashedLines(name: string, options: {
  134333. points: Vector3[];
  134334. dashSize?: number;
  134335. gapSize?: number;
  134336. dashNb?: number;
  134337. updatable?: boolean;
  134338. instance?: LinesMesh;
  134339. useVertexAlpha?: boolean;
  134340. }, scene?: Nullable<Scene>): LinesMesh;
  134341. }
  134342. }
  134343. declare module BABYLON {
  134344. /**
  134345. * Construction options for a timer
  134346. */
  134347. export interface ITimerOptions<T> {
  134348. /**
  134349. * Time-to-end
  134350. */
  134351. timeout: number;
  134352. /**
  134353. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  134354. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  134355. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  134356. */
  134357. contextObservable: Observable<T>;
  134358. /**
  134359. * Optional parameters when adding an observer to the observable
  134360. */
  134361. observableParameters?: {
  134362. mask?: number;
  134363. insertFirst?: boolean;
  134364. scope?: any;
  134365. };
  134366. /**
  134367. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  134368. */
  134369. breakCondition?: (data?: ITimerData<T>) => boolean;
  134370. /**
  134371. * Will be triggered when the time condition has met
  134372. */
  134373. onEnded?: (data: ITimerData<any>) => void;
  134374. /**
  134375. * Will be triggered when the break condition has met (prematurely ended)
  134376. */
  134377. onAborted?: (data: ITimerData<any>) => void;
  134378. /**
  134379. * Optional function to execute on each tick (or count)
  134380. */
  134381. onTick?: (data: ITimerData<any>) => void;
  134382. }
  134383. /**
  134384. * An interface defining the data sent by the timer
  134385. */
  134386. export interface ITimerData<T> {
  134387. /**
  134388. * When did it start
  134389. */
  134390. startTime: number;
  134391. /**
  134392. * Time now
  134393. */
  134394. currentTime: number;
  134395. /**
  134396. * Time passed since started
  134397. */
  134398. deltaTime: number;
  134399. /**
  134400. * How much is completed, in [0.0...1.0].
  134401. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  134402. */
  134403. completeRate: number;
  134404. /**
  134405. * What the registered observable sent in the last count
  134406. */
  134407. payload: T;
  134408. }
  134409. /**
  134410. * The current state of the timer
  134411. */
  134412. export enum TimerState {
  134413. /**
  134414. * Timer initialized, not yet started
  134415. */
  134416. INIT = 0,
  134417. /**
  134418. * Timer started and counting
  134419. */
  134420. STARTED = 1,
  134421. /**
  134422. * Timer ended (whether aborted or time reached)
  134423. */
  134424. ENDED = 2
  134425. }
  134426. /**
  134427. * A simple version of the timer. Will take options and start the timer immediately after calling it
  134428. *
  134429. * @param options options with which to initialize this timer
  134430. */
  134431. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  134432. /**
  134433. * An advanced implementation of a timer class
  134434. */
  134435. export class AdvancedTimer<T = any> implements IDisposable {
  134436. /**
  134437. * Will notify each time the timer calculates the remaining time
  134438. */
  134439. onEachCountObservable: Observable<ITimerData<T>>;
  134440. /**
  134441. * Will trigger when the timer was aborted due to the break condition
  134442. */
  134443. onTimerAbortedObservable: Observable<ITimerData<T>>;
  134444. /**
  134445. * Will trigger when the timer ended successfully
  134446. */
  134447. onTimerEndedObservable: Observable<ITimerData<T>>;
  134448. /**
  134449. * Will trigger when the timer state has changed
  134450. */
  134451. onStateChangedObservable: Observable<TimerState>;
  134452. private _observer;
  134453. private _contextObservable;
  134454. private _observableParameters;
  134455. private _startTime;
  134456. private _timer;
  134457. private _state;
  134458. private _breakCondition;
  134459. private _timeToEnd;
  134460. private _breakOnNextTick;
  134461. /**
  134462. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  134463. * @param options construction options for this advanced timer
  134464. */
  134465. constructor(options: ITimerOptions<T>);
  134466. /**
  134467. * set a breaking condition for this timer. Default is to never break during count
  134468. * @param predicate the new break condition. Returns true to break, false otherwise
  134469. */
  134470. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  134471. /**
  134472. * Reset ALL associated observables in this advanced timer
  134473. */
  134474. clearObservables(): void;
  134475. /**
  134476. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  134477. *
  134478. * @param timeToEnd how much time to measure until timer ended
  134479. */
  134480. start(timeToEnd?: number): void;
  134481. /**
  134482. * Will force a stop on the next tick.
  134483. */
  134484. stop(): void;
  134485. /**
  134486. * Dispose this timer, clearing all resources
  134487. */
  134488. dispose(): void;
  134489. private _setState;
  134490. private _tick;
  134491. private _stop;
  134492. }
  134493. }
  134494. declare module BABYLON {
  134495. /**
  134496. * The options container for the teleportation module
  134497. */
  134498. export interface IWebXRTeleportationOptions {
  134499. /**
  134500. * if provided, this scene will be used to render meshes.
  134501. */
  134502. customUtilityLayerScene?: Scene;
  134503. /**
  134504. * Values to configure the default target mesh
  134505. */
  134506. defaultTargetMeshOptions?: {
  134507. /**
  134508. * Fill color of the teleportation area
  134509. */
  134510. teleportationFillColor?: string;
  134511. /**
  134512. * Border color for the teleportation area
  134513. */
  134514. teleportationBorderColor?: string;
  134515. /**
  134516. * Disable the mesh's animation sequence
  134517. */
  134518. disableAnimation?: boolean;
  134519. /**
  134520. * Disable lighting on the material or the ring and arrow
  134521. */
  134522. disableLighting?: boolean;
  134523. /**
  134524. * Override the default material of the torus and arrow
  134525. */
  134526. torusArrowMaterial?: Material;
  134527. };
  134528. /**
  134529. * A list of meshes to use as floor meshes.
  134530. * Meshes can be added and removed after initializing the feature using the
  134531. * addFloorMesh and removeFloorMesh functions
  134532. * If empty, rotation will still work
  134533. */
  134534. floorMeshes?: AbstractMesh[];
  134535. /**
  134536. * use this rendering group id for the meshes (optional)
  134537. */
  134538. renderingGroupId?: number;
  134539. /**
  134540. * Should teleportation move only to snap points
  134541. */
  134542. snapPointsOnly?: boolean;
  134543. /**
  134544. * An array of points to which the teleportation will snap to.
  134545. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  134546. */
  134547. snapPositions?: Vector3[];
  134548. /**
  134549. * How close should the teleportation ray be in order to snap to position.
  134550. * Default to 0.8 units (meters)
  134551. */
  134552. snapToPositionRadius?: number;
  134553. /**
  134554. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  134555. * If you want to support rotation, make sure your mesh has a direction indicator.
  134556. *
  134557. * When left untouched, the default mesh will be initialized.
  134558. */
  134559. teleportationTargetMesh?: AbstractMesh;
  134560. /**
  134561. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  134562. */
  134563. timeToTeleport?: number;
  134564. /**
  134565. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  134566. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  134567. */
  134568. useMainComponentOnly?: boolean;
  134569. /**
  134570. * Should meshes created here be added to a utility layer or the main scene
  134571. */
  134572. useUtilityLayer?: boolean;
  134573. /**
  134574. * Babylon XR Input class for controller
  134575. */
  134576. xrInput: WebXRInput;
  134577. /**
  134578. * Meshes that the teleportation ray cannot go through
  134579. */
  134580. pickBlockerMeshes?: AbstractMesh[];
  134581. /**
  134582. * Should teleport work only on a specific hand?
  134583. */
  134584. forceHandedness?: XRHandedness;
  134585. /**
  134586. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  134587. */
  134588. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  134589. }
  134590. /**
  134591. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  134592. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  134593. * the input of the attached controllers.
  134594. */
  134595. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  134596. private _options;
  134597. private _controllers;
  134598. private _currentTeleportationControllerId;
  134599. private _floorMeshes;
  134600. private _quadraticBezierCurve;
  134601. private _selectionFeature;
  134602. private _snapToPositions;
  134603. private _snappedToPoint;
  134604. private _teleportationRingMaterial?;
  134605. private _tmpRay;
  134606. private _tmpVector;
  134607. private _tmpQuaternion;
  134608. /**
  134609. * The module's name
  134610. */
  134611. static readonly Name: string;
  134612. /**
  134613. * The (Babylon) version of this module.
  134614. * This is an integer representing the implementation version.
  134615. * This number does not correspond to the webxr specs version
  134616. */
  134617. static readonly Version: number;
  134618. /**
  134619. * Is movement backwards enabled
  134620. */
  134621. backwardsMovementEnabled: boolean;
  134622. /**
  134623. * Distance to travel when moving backwards
  134624. */
  134625. backwardsTeleportationDistance: number;
  134626. /**
  134627. * The distance from the user to the inspection point in the direction of the controller
  134628. * A higher number will allow the user to move further
  134629. * defaults to 5 (meters, in xr units)
  134630. */
  134631. parabolicCheckRadius: number;
  134632. /**
  134633. * Should the module support parabolic ray on top of direct ray
  134634. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  134635. * Very helpful when moving between floors / different heights
  134636. */
  134637. parabolicRayEnabled: boolean;
  134638. /**
  134639. * The second type of ray - straight line.
  134640. * Should it be enabled or should the parabolic line be the only one.
  134641. */
  134642. straightRayEnabled: boolean;
  134643. /**
  134644. * How much rotation should be applied when rotating right and left
  134645. */
  134646. rotationAngle: number;
  134647. private _rotationEnabled;
  134648. /**
  134649. * Is rotation enabled when moving forward?
  134650. * Disabling this feature will prevent the user from deciding the direction when teleporting
  134651. */
  134652. get rotationEnabled(): boolean;
  134653. /**
  134654. * Sets wether rotation is enabled or not
  134655. * @param enabled is rotation enabled when teleportation is shown
  134656. */
  134657. set rotationEnabled(enabled: boolean);
  134658. /**
  134659. * Exposes the currently set teleportation target mesh.
  134660. */
  134661. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  134662. /**
  134663. * constructs a new anchor system
  134664. * @param _xrSessionManager an instance of WebXRSessionManager
  134665. * @param _options configuration object for this feature
  134666. */
  134667. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  134668. /**
  134669. * Get the snapPointsOnly flag
  134670. */
  134671. get snapPointsOnly(): boolean;
  134672. /**
  134673. * Sets the snapPointsOnly flag
  134674. * @param snapToPoints should teleportation be exclusively to snap points
  134675. */
  134676. set snapPointsOnly(snapToPoints: boolean);
  134677. /**
  134678. * Add a new mesh to the floor meshes array
  134679. * @param mesh the mesh to use as floor mesh
  134680. */
  134681. addFloorMesh(mesh: AbstractMesh): void;
  134682. /**
  134683. * Add a new snap-to point to fix teleportation to this position
  134684. * @param newSnapPoint The new Snap-To point
  134685. */
  134686. addSnapPoint(newSnapPoint: Vector3): void;
  134687. attach(): boolean;
  134688. detach(): boolean;
  134689. dispose(): void;
  134690. /**
  134691. * Remove a mesh from the floor meshes array
  134692. * @param mesh the mesh to remove
  134693. */
  134694. removeFloorMesh(mesh: AbstractMesh): void;
  134695. /**
  134696. * Remove a mesh from the floor meshes array using its name
  134697. * @param name the mesh name to remove
  134698. */
  134699. removeFloorMeshByName(name: string): void;
  134700. /**
  134701. * 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
  134702. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  134703. * @returns was the point found and removed or not
  134704. */
  134705. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  134706. /**
  134707. * This function sets a selection feature that will be disabled when
  134708. * the forward ray is shown and will be reattached when hidden.
  134709. * This is used to remove the selection rays when moving.
  134710. * @param selectionFeature the feature to disable when forward movement is enabled
  134711. */
  134712. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  134713. protected _onXRFrame(_xrFrame: XRFrame): void;
  134714. private _attachController;
  134715. private _createDefaultTargetMesh;
  134716. private _detachController;
  134717. private _findClosestSnapPointWithRadius;
  134718. private _setTargetMeshPosition;
  134719. private _setTargetMeshVisibility;
  134720. private _showParabolicPath;
  134721. private _teleportForward;
  134722. }
  134723. }
  134724. declare module BABYLON {
  134725. /**
  134726. * Options for the default xr helper
  134727. */
  134728. export class WebXRDefaultExperienceOptions {
  134729. /**
  134730. * Enable or disable default UI to enter XR
  134731. */
  134732. disableDefaultUI?: boolean;
  134733. /**
  134734. * Should teleportation not initialize. defaults to false.
  134735. */
  134736. disableTeleportation?: boolean;
  134737. /**
  134738. * Floor meshes that will be used for teleport
  134739. */
  134740. floorMeshes?: Array<AbstractMesh>;
  134741. /**
  134742. * If set to true, the first frame will not be used to reset position
  134743. * The first frame is mainly used when copying transformation from the old camera
  134744. * Mainly used in AR
  134745. */
  134746. ignoreNativeCameraTransformation?: boolean;
  134747. /**
  134748. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  134749. */
  134750. inputOptions?: IWebXRInputOptions;
  134751. /**
  134752. * optional configuration for the output canvas
  134753. */
  134754. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  134755. /**
  134756. * optional UI options. This can be used among other to change session mode and reference space type
  134757. */
  134758. uiOptions?: WebXREnterExitUIOptions;
  134759. /**
  134760. * When loading teleportation and pointer select, use stable versions instead of latest.
  134761. */
  134762. useStablePlugins?: boolean;
  134763. /**
  134764. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  134765. */
  134766. renderingGroupId?: number;
  134767. /**
  134768. * A list of optional features to init the session with
  134769. * If set to true, all features we support will be added
  134770. */
  134771. optionalFeatures?: boolean | string[];
  134772. }
  134773. /**
  134774. * Default experience which provides a similar setup to the previous webVRExperience
  134775. */
  134776. export class WebXRDefaultExperience {
  134777. /**
  134778. * Base experience
  134779. */
  134780. baseExperience: WebXRExperienceHelper;
  134781. /**
  134782. * Enables ui for entering/exiting xr
  134783. */
  134784. enterExitUI: WebXREnterExitUI;
  134785. /**
  134786. * Input experience extension
  134787. */
  134788. input: WebXRInput;
  134789. /**
  134790. * Enables laser pointer and selection
  134791. */
  134792. pointerSelection: WebXRControllerPointerSelection;
  134793. /**
  134794. * Default target xr should render to
  134795. */
  134796. renderTarget: WebXRRenderTarget;
  134797. /**
  134798. * Enables teleportation
  134799. */
  134800. teleportation: WebXRMotionControllerTeleportation;
  134801. private constructor();
  134802. /**
  134803. * Creates the default xr experience
  134804. * @param scene scene
  134805. * @param options options for basic configuration
  134806. * @returns resulting WebXRDefaultExperience
  134807. */
  134808. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  134809. /**
  134810. * DIsposes of the experience helper
  134811. */
  134812. dispose(): void;
  134813. }
  134814. }
  134815. declare module BABYLON {
  134816. /**
  134817. * Options to modify the vr teleportation behavior.
  134818. */
  134819. export interface VRTeleportationOptions {
  134820. /**
  134821. * The name of the mesh which should be used as the teleportation floor. (default: null)
  134822. */
  134823. floorMeshName?: string;
  134824. /**
  134825. * A list of meshes to be used as the teleportation floor. (default: empty)
  134826. */
  134827. floorMeshes?: Mesh[];
  134828. /**
  134829. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  134830. */
  134831. teleportationMode?: number;
  134832. /**
  134833. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  134834. */
  134835. teleportationTime?: number;
  134836. /**
  134837. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  134838. */
  134839. teleportationSpeed?: number;
  134840. /**
  134841. * The easing function used in the animation or null for Linear. (default CircleEase)
  134842. */
  134843. easingFunction?: EasingFunction;
  134844. }
  134845. /**
  134846. * Options to modify the vr experience helper's behavior.
  134847. */
  134848. export interface VRExperienceHelperOptions extends WebVROptions {
  134849. /**
  134850. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  134851. */
  134852. createDeviceOrientationCamera?: boolean;
  134853. /**
  134854. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  134855. */
  134856. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  134857. /**
  134858. * Uses the main button on the controller to toggle the laser casted. (default: true)
  134859. */
  134860. laserToggle?: boolean;
  134861. /**
  134862. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  134863. */
  134864. floorMeshes?: Mesh[];
  134865. /**
  134866. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  134867. */
  134868. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  134869. /**
  134870. * Defines if WebXR should be used instead of WebVR (if available)
  134871. */
  134872. useXR?: boolean;
  134873. }
  134874. /**
  134875. * Event containing information after VR has been entered
  134876. */
  134877. export class OnAfterEnteringVRObservableEvent {
  134878. /**
  134879. * If entering vr was successful
  134880. */
  134881. success: boolean;
  134882. }
  134883. /**
  134884. * Helps to quickly add VR support to an existing scene.
  134885. * See https://doc.babylonjs.com/how_to/webvr_helper
  134886. */
  134887. export class VRExperienceHelper {
  134888. /** Options to modify the vr experience helper's behavior. */
  134889. webVROptions: VRExperienceHelperOptions;
  134890. private _scene;
  134891. private _position;
  134892. private _btnVR;
  134893. private _btnVRDisplayed;
  134894. private _webVRsupported;
  134895. private _webVRready;
  134896. private _webVRrequesting;
  134897. private _webVRpresenting;
  134898. private _hasEnteredVR;
  134899. private _fullscreenVRpresenting;
  134900. private _inputElement;
  134901. private _webVRCamera;
  134902. private _vrDeviceOrientationCamera;
  134903. private _deviceOrientationCamera;
  134904. private _existingCamera;
  134905. private _onKeyDown;
  134906. private _onVrDisplayPresentChange;
  134907. private _onVRDisplayChanged;
  134908. private _onVRRequestPresentStart;
  134909. private _onVRRequestPresentComplete;
  134910. /**
  134911. * 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)
  134912. */
  134913. enableGazeEvenWhenNoPointerLock: boolean;
  134914. /**
  134915. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  134916. */
  134917. exitVROnDoubleTap: boolean;
  134918. /**
  134919. * Observable raised right before entering VR.
  134920. */
  134921. onEnteringVRObservable: Observable<VRExperienceHelper>;
  134922. /**
  134923. * Observable raised when entering VR has completed.
  134924. */
  134925. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  134926. /**
  134927. * Observable raised when exiting VR.
  134928. */
  134929. onExitingVRObservable: Observable<VRExperienceHelper>;
  134930. /**
  134931. * Observable raised when controller mesh is loaded.
  134932. */
  134933. onControllerMeshLoadedObservable: Observable<WebVRController>;
  134934. /** Return this.onEnteringVRObservable
  134935. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  134936. */
  134937. get onEnteringVR(): Observable<VRExperienceHelper>;
  134938. /** Return this.onExitingVRObservable
  134939. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  134940. */
  134941. get onExitingVR(): Observable<VRExperienceHelper>;
  134942. /** Return this.onControllerMeshLoadedObservable
  134943. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  134944. */
  134945. get onControllerMeshLoaded(): Observable<WebVRController>;
  134946. private _rayLength;
  134947. private _useCustomVRButton;
  134948. private _teleportationRequested;
  134949. private _teleportActive;
  134950. private _floorMeshName;
  134951. private _floorMeshesCollection;
  134952. private _teleportationMode;
  134953. private _teleportationTime;
  134954. private _teleportationSpeed;
  134955. private _teleportationEasing;
  134956. private _rotationAllowed;
  134957. private _teleportBackwardsVector;
  134958. private _teleportationTarget;
  134959. private _isDefaultTeleportationTarget;
  134960. private _postProcessMove;
  134961. private _teleportationFillColor;
  134962. private _teleportationBorderColor;
  134963. private _rotationAngle;
  134964. private _haloCenter;
  134965. private _cameraGazer;
  134966. private _padSensibilityUp;
  134967. private _padSensibilityDown;
  134968. private _leftController;
  134969. private _rightController;
  134970. private _gazeColor;
  134971. private _laserColor;
  134972. private _pickedLaserColor;
  134973. private _pickedGazeColor;
  134974. /**
  134975. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  134976. */
  134977. onNewMeshSelected: Observable<AbstractMesh>;
  134978. /**
  134979. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  134980. * This observable will provide the mesh and the controller used to select the mesh
  134981. */
  134982. onMeshSelectedWithController: Observable<{
  134983. mesh: AbstractMesh;
  134984. controller: WebVRController;
  134985. }>;
  134986. /**
  134987. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  134988. */
  134989. onNewMeshPicked: Observable<PickingInfo>;
  134990. private _circleEase;
  134991. /**
  134992. * Observable raised before camera teleportation
  134993. */
  134994. onBeforeCameraTeleport: Observable<Vector3>;
  134995. /**
  134996. * Observable raised after camera teleportation
  134997. */
  134998. onAfterCameraTeleport: Observable<Vector3>;
  134999. /**
  135000. * Observable raised when current selected mesh gets unselected
  135001. */
  135002. onSelectedMeshUnselected: Observable<AbstractMesh>;
  135003. private _raySelectionPredicate;
  135004. /**
  135005. * To be optionaly changed by user to define custom ray selection
  135006. */
  135007. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  135008. /**
  135009. * To be optionaly changed by user to define custom selection logic (after ray selection)
  135010. */
  135011. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  135012. /**
  135013. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  135014. */
  135015. teleportationEnabled: boolean;
  135016. private _defaultHeight;
  135017. private _teleportationInitialized;
  135018. private _interactionsEnabled;
  135019. private _interactionsRequested;
  135020. private _displayGaze;
  135021. private _displayLaserPointer;
  135022. /**
  135023. * The mesh used to display where the user is going to teleport.
  135024. */
  135025. get teleportationTarget(): Mesh;
  135026. /**
  135027. * Sets the mesh to be used to display where the user is going to teleport.
  135028. */
  135029. set teleportationTarget(value: Mesh);
  135030. /**
  135031. * 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
  135032. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  135033. * See https://doc.babylonjs.com/resources/baking_transformations
  135034. */
  135035. get gazeTrackerMesh(): Mesh;
  135036. set gazeTrackerMesh(value: Mesh);
  135037. /**
  135038. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  135039. */
  135040. updateGazeTrackerScale: boolean;
  135041. /**
  135042. * If the gaze trackers color should be updated when selecting meshes
  135043. */
  135044. updateGazeTrackerColor: boolean;
  135045. /**
  135046. * If the controller laser color should be updated when selecting meshes
  135047. */
  135048. updateControllerLaserColor: boolean;
  135049. /**
  135050. * The gaze tracking mesh corresponding to the left controller
  135051. */
  135052. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  135053. /**
  135054. * The gaze tracking mesh corresponding to the right controller
  135055. */
  135056. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  135057. /**
  135058. * If the ray of the gaze should be displayed.
  135059. */
  135060. get displayGaze(): boolean;
  135061. /**
  135062. * Sets if the ray of the gaze should be displayed.
  135063. */
  135064. set displayGaze(value: boolean);
  135065. /**
  135066. * If the ray of the LaserPointer should be displayed.
  135067. */
  135068. get displayLaserPointer(): boolean;
  135069. /**
  135070. * Sets if the ray of the LaserPointer should be displayed.
  135071. */
  135072. set displayLaserPointer(value: boolean);
  135073. /**
  135074. * The deviceOrientationCamera used as the camera when not in VR.
  135075. */
  135076. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  135077. /**
  135078. * Based on the current WebVR support, returns the current VR camera used.
  135079. */
  135080. get currentVRCamera(): Nullable<Camera>;
  135081. /**
  135082. * The webVRCamera which is used when in VR.
  135083. */
  135084. get webVRCamera(): WebVRFreeCamera;
  135085. /**
  135086. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  135087. */
  135088. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  135089. /**
  135090. * The html button that is used to trigger entering into VR.
  135091. */
  135092. get vrButton(): Nullable<HTMLButtonElement>;
  135093. private get _teleportationRequestInitiated();
  135094. /**
  135095. * Defines whether or not Pointer lock should be requested when switching to
  135096. * full screen.
  135097. */
  135098. requestPointerLockOnFullScreen: boolean;
  135099. /**
  135100. * If asking to force XR, this will be populated with the default xr experience
  135101. */
  135102. xr: WebXRDefaultExperience;
  135103. /**
  135104. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  135105. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  135106. */
  135107. xrTestDone: boolean;
  135108. /**
  135109. * Instantiates a VRExperienceHelper.
  135110. * Helps to quickly add VR support to an existing scene.
  135111. * @param scene The scene the VRExperienceHelper belongs to.
  135112. * @param webVROptions Options to modify the vr experience helper's behavior.
  135113. */
  135114. constructor(scene: Scene,
  135115. /** Options to modify the vr experience helper's behavior. */
  135116. webVROptions?: VRExperienceHelperOptions);
  135117. private completeVRInit;
  135118. private _onDefaultMeshLoaded;
  135119. private _onResize;
  135120. private _onFullscreenChange;
  135121. /**
  135122. * Gets a value indicating if we are currently in VR mode.
  135123. */
  135124. get isInVRMode(): boolean;
  135125. private onVrDisplayPresentChange;
  135126. private onVRDisplayChanged;
  135127. private moveButtonToBottomRight;
  135128. private displayVRButton;
  135129. private updateButtonVisibility;
  135130. private _cachedAngularSensibility;
  135131. /**
  135132. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  135133. * Otherwise, will use the fullscreen API.
  135134. */
  135135. enterVR(): void;
  135136. /**
  135137. * Attempt to exit VR, or fullscreen.
  135138. */
  135139. exitVR(): void;
  135140. /**
  135141. * The position of the vr experience helper.
  135142. */
  135143. get position(): Vector3;
  135144. /**
  135145. * Sets the position of the vr experience helper.
  135146. */
  135147. set position(value: Vector3);
  135148. /**
  135149. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  135150. */
  135151. enableInteractions(): void;
  135152. private get _noControllerIsActive();
  135153. private beforeRender;
  135154. private _isTeleportationFloor;
  135155. /**
  135156. * Adds a floor mesh to be used for teleportation.
  135157. * @param floorMesh the mesh to be used for teleportation.
  135158. */
  135159. addFloorMesh(floorMesh: Mesh): void;
  135160. /**
  135161. * Removes a floor mesh from being used for teleportation.
  135162. * @param floorMesh the mesh to be removed.
  135163. */
  135164. removeFloorMesh(floorMesh: Mesh): void;
  135165. /**
  135166. * Enables interactions and teleportation using the VR controllers and gaze.
  135167. * @param vrTeleportationOptions options to modify teleportation behavior.
  135168. */
  135169. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  135170. private _onNewGamepadConnected;
  135171. private _tryEnableInteractionOnController;
  135172. private _onNewGamepadDisconnected;
  135173. private _enableInteractionOnController;
  135174. private _checkTeleportWithRay;
  135175. private _checkRotate;
  135176. private _checkTeleportBackwards;
  135177. private _enableTeleportationOnController;
  135178. private _createTeleportationCircles;
  135179. private _displayTeleportationTarget;
  135180. private _hideTeleportationTarget;
  135181. private _rotateCamera;
  135182. private _moveTeleportationSelectorTo;
  135183. private _workingVector;
  135184. private _workingQuaternion;
  135185. private _workingMatrix;
  135186. /**
  135187. * Time Constant Teleportation Mode
  135188. */
  135189. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  135190. /**
  135191. * Speed Constant Teleportation Mode
  135192. */
  135193. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  135194. /**
  135195. * Teleports the users feet to the desired location
  135196. * @param location The location where the user's feet should be placed
  135197. */
  135198. teleportCamera(location: Vector3): void;
  135199. private _convertNormalToDirectionOfRay;
  135200. private _castRayAndSelectObject;
  135201. private _notifySelectedMeshUnselected;
  135202. /**
  135203. * Permanently set new colors for the laser pointer
  135204. * @param color the new laser color
  135205. * @param pickedColor the new laser color when picked mesh detected
  135206. */
  135207. setLaserColor(color: Color3, pickedColor?: Color3): void;
  135208. /**
  135209. * Set lighting enabled / disabled on the laser pointer of both controllers
  135210. * @param enabled should the lighting be enabled on the laser pointer
  135211. */
  135212. setLaserLightingState(enabled?: boolean): void;
  135213. /**
  135214. * Permanently set new colors for the gaze pointer
  135215. * @param color the new gaze color
  135216. * @param pickedColor the new gaze color when picked mesh detected
  135217. */
  135218. setGazeColor(color: Color3, pickedColor?: Color3): void;
  135219. /**
  135220. * Sets the color of the laser ray from the vr controllers.
  135221. * @param color new color for the ray.
  135222. */
  135223. changeLaserColor(color: Color3): void;
  135224. /**
  135225. * Sets the color of the ray from the vr headsets gaze.
  135226. * @param color new color for the ray.
  135227. */
  135228. changeGazeColor(color: Color3): void;
  135229. /**
  135230. * Exits VR and disposes of the vr experience helper
  135231. */
  135232. dispose(): void;
  135233. /**
  135234. * Gets the name of the VRExperienceHelper class
  135235. * @returns "VRExperienceHelper"
  135236. */
  135237. getClassName(): string;
  135238. }
  135239. }
  135240. declare module BABYLON {
  135241. /**
  135242. * Contains an array of blocks representing the octree
  135243. */
  135244. export interface IOctreeContainer<T> {
  135245. /**
  135246. * Blocks within the octree
  135247. */
  135248. blocks: Array<OctreeBlock<T>>;
  135249. }
  135250. /**
  135251. * Class used to store a cell in an octree
  135252. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135253. */
  135254. export class OctreeBlock<T> {
  135255. /**
  135256. * Gets the content of the current block
  135257. */
  135258. entries: T[];
  135259. /**
  135260. * Gets the list of block children
  135261. */
  135262. blocks: Array<OctreeBlock<T>>;
  135263. private _depth;
  135264. private _maxDepth;
  135265. private _capacity;
  135266. private _minPoint;
  135267. private _maxPoint;
  135268. private _boundingVectors;
  135269. private _creationFunc;
  135270. /**
  135271. * Creates a new block
  135272. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  135273. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  135274. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  135275. * @param depth defines the current depth of this block in the octree
  135276. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  135277. * @param creationFunc defines a callback to call when an element is added to the block
  135278. */
  135279. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  135280. /**
  135281. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  135282. */
  135283. get capacity(): number;
  135284. /**
  135285. * Gets the minimum vector (in world space) of the block's bounding box
  135286. */
  135287. get minPoint(): Vector3;
  135288. /**
  135289. * Gets the maximum vector (in world space) of the block's bounding box
  135290. */
  135291. get maxPoint(): Vector3;
  135292. /**
  135293. * Add a new element to this block
  135294. * @param entry defines the element to add
  135295. */
  135296. addEntry(entry: T): void;
  135297. /**
  135298. * Remove an element from this block
  135299. * @param entry defines the element to remove
  135300. */
  135301. removeEntry(entry: T): void;
  135302. /**
  135303. * Add an array of elements to this block
  135304. * @param entries defines the array of elements to add
  135305. */
  135306. addEntries(entries: T[]): void;
  135307. /**
  135308. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  135309. * @param frustumPlanes defines the frustum planes to test
  135310. * @param selection defines the array to store current content if selection is positive
  135311. * @param allowDuplicate defines if the selection array can contains duplicated entries
  135312. */
  135313. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  135314. /**
  135315. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  135316. * @param sphereCenter defines the bounding sphere center
  135317. * @param sphereRadius defines the bounding sphere radius
  135318. * @param selection defines the array to store current content if selection is positive
  135319. * @param allowDuplicate defines if the selection array can contains duplicated entries
  135320. */
  135321. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  135322. /**
  135323. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  135324. * @param ray defines the ray to test with
  135325. * @param selection defines the array to store current content if selection is positive
  135326. */
  135327. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  135328. /**
  135329. * Subdivide the content into child blocks (this block will then be empty)
  135330. */
  135331. createInnerBlocks(): void;
  135332. /**
  135333. * @hidden
  135334. */
  135335. 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;
  135336. }
  135337. }
  135338. declare module BABYLON {
  135339. /**
  135340. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  135341. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135342. */
  135343. export class Octree<T> {
  135344. /** 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.) */
  135345. maxDepth: number;
  135346. /**
  135347. * Blocks within the octree containing objects
  135348. */
  135349. blocks: Array<OctreeBlock<T>>;
  135350. /**
  135351. * Content stored in the octree
  135352. */
  135353. dynamicContent: T[];
  135354. private _maxBlockCapacity;
  135355. private _selectionContent;
  135356. private _creationFunc;
  135357. /**
  135358. * Creates a octree
  135359. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135360. * @param creationFunc function to be used to instatiate the octree
  135361. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  135362. * @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.)
  135363. */
  135364. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  135365. /** 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.) */
  135366. maxDepth?: number);
  135367. /**
  135368. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  135369. * @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);
  135370. * @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);
  135371. * @param entries meshes to be added to the octree blocks
  135372. */
  135373. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  135374. /**
  135375. * Adds a mesh to the octree
  135376. * @param entry Mesh to add to the octree
  135377. */
  135378. addMesh(entry: T): void;
  135379. /**
  135380. * Remove an element from the octree
  135381. * @param entry defines the element to remove
  135382. */
  135383. removeMesh(entry: T): void;
  135384. /**
  135385. * Selects an array of meshes within the frustum
  135386. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  135387. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  135388. * @returns array of meshes within the frustum
  135389. */
  135390. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  135391. /**
  135392. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  135393. * @param sphereCenter defines the bounding sphere center
  135394. * @param sphereRadius defines the bounding sphere radius
  135395. * @param allowDuplicate defines if the selection array can contains duplicated entries
  135396. * @returns an array of objects that intersect the sphere
  135397. */
  135398. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  135399. /**
  135400. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  135401. * @param ray defines the ray to test with
  135402. * @returns array of intersected objects
  135403. */
  135404. intersectsRay(ray: Ray): SmartArray<T>;
  135405. /**
  135406. * Adds a mesh into the octree block if it intersects the block
  135407. */
  135408. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  135409. /**
  135410. * Adds a submesh into the octree block if it intersects the block
  135411. */
  135412. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  135413. }
  135414. }
  135415. declare module BABYLON {
  135416. interface Scene {
  135417. /**
  135418. * @hidden
  135419. * Backing Filed
  135420. */
  135421. _selectionOctree: Octree<AbstractMesh>;
  135422. /**
  135423. * Gets the octree used to boost mesh selection (picking)
  135424. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135425. */
  135426. selectionOctree: Octree<AbstractMesh>;
  135427. /**
  135428. * Creates or updates the octree used to boost selection (picking)
  135429. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135430. * @param maxCapacity defines the maximum capacity per leaf
  135431. * @param maxDepth defines the maximum depth of the octree
  135432. * @returns an octree of AbstractMesh
  135433. */
  135434. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  135435. }
  135436. interface AbstractMesh {
  135437. /**
  135438. * @hidden
  135439. * Backing Field
  135440. */
  135441. _submeshesOctree: Octree<SubMesh>;
  135442. /**
  135443. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  135444. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  135445. * @param maxCapacity defines the maximum size of each block (64 by default)
  135446. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  135447. * @returns the new octree
  135448. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  135449. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135450. */
  135451. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  135452. }
  135453. /**
  135454. * Defines the octree scene component responsible to manage any octrees
  135455. * in a given scene.
  135456. */
  135457. export class OctreeSceneComponent {
  135458. /**
  135459. * The component name help to identify the component in the list of scene components.
  135460. */
  135461. readonly name: string;
  135462. /**
  135463. * The scene the component belongs to.
  135464. */
  135465. scene: Scene;
  135466. /**
  135467. * Indicates if the meshes have been checked to make sure they are isEnabled()
  135468. */
  135469. readonly checksIsEnabled: boolean;
  135470. /**
  135471. * Creates a new instance of the component for the given scene
  135472. * @param scene Defines the scene to register the component in
  135473. */
  135474. constructor(scene: Scene);
  135475. /**
  135476. * Registers the component in a given scene
  135477. */
  135478. register(): void;
  135479. /**
  135480. * Return the list of active meshes
  135481. * @returns the list of active meshes
  135482. */
  135483. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  135484. /**
  135485. * Return the list of active sub meshes
  135486. * @param mesh The mesh to get the candidates sub meshes from
  135487. * @returns the list of active sub meshes
  135488. */
  135489. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  135490. private _tempRay;
  135491. /**
  135492. * Return the list of sub meshes intersecting with a given local ray
  135493. * @param mesh defines the mesh to find the submesh for
  135494. * @param localRay defines the ray in local space
  135495. * @returns the list of intersecting sub meshes
  135496. */
  135497. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  135498. /**
  135499. * Return the list of sub meshes colliding with a collider
  135500. * @param mesh defines the mesh to find the submesh for
  135501. * @param collider defines the collider to evaluate the collision against
  135502. * @returns the list of colliding sub meshes
  135503. */
  135504. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  135505. /**
  135506. * Rebuilds the elements related to this component in case of
  135507. * context lost for instance.
  135508. */
  135509. rebuild(): void;
  135510. /**
  135511. * Disposes the component and the associated ressources.
  135512. */
  135513. dispose(): void;
  135514. }
  135515. }
  135516. declare module BABYLON {
  135517. /**
  135518. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  135519. */
  135520. export interface GizmoAxisCache {
  135521. /** Mesh used to runder the Gizmo */
  135522. gizmoMeshes: Mesh[];
  135523. /** Mesh used to detect user interaction with Gizmo */
  135524. colliderMeshes: Mesh[];
  135525. /** Material used to inicate color of gizmo mesh */
  135526. material: StandardMaterial;
  135527. /** Material used to inicate hover state of the Gizmo */
  135528. hoverMaterial: StandardMaterial;
  135529. /** Material used to inicate disabled state of the Gizmo */
  135530. disableMaterial: StandardMaterial;
  135531. /** Used to indicate Active state of the Gizmo */
  135532. active: boolean;
  135533. }
  135534. /**
  135535. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  135536. */
  135537. export class Gizmo implements IDisposable {
  135538. /** The utility layer the gizmo will be added to */
  135539. gizmoLayer: UtilityLayerRenderer;
  135540. /**
  135541. * The root mesh of the gizmo
  135542. */
  135543. _rootMesh: Mesh;
  135544. private _attachedMesh;
  135545. private _attachedNode;
  135546. /**
  135547. * Ratio for the scale of the gizmo (Default: 1)
  135548. */
  135549. protected _scaleRatio: number;
  135550. /**
  135551. * boolean updated by pointermove when a gizmo mesh is hovered
  135552. */
  135553. protected _isHovered: boolean;
  135554. /**
  135555. * Ratio for the scale of the gizmo (Default: 1)
  135556. */
  135557. set scaleRatio(value: number);
  135558. get scaleRatio(): number;
  135559. /**
  135560. * True when the mouse pointer is hovered a gizmo mesh
  135561. */
  135562. get isHovered(): boolean;
  135563. /**
  135564. * If a custom mesh has been set (Default: false)
  135565. */
  135566. protected _customMeshSet: boolean;
  135567. /**
  135568. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  135569. * * When set, interactions will be enabled
  135570. */
  135571. get attachedMesh(): Nullable<AbstractMesh>;
  135572. set attachedMesh(value: Nullable<AbstractMesh>);
  135573. /**
  135574. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  135575. * * When set, interactions will be enabled
  135576. */
  135577. get attachedNode(): Nullable<Node>;
  135578. set attachedNode(value: Nullable<Node>);
  135579. /**
  135580. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  135581. * @param mesh The mesh to replace the default mesh of the gizmo
  135582. */
  135583. setCustomMesh(mesh: Mesh): void;
  135584. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  135585. /**
  135586. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  135587. */
  135588. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  135589. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  135590. /**
  135591. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  135592. */
  135593. updateGizmoPositionToMatchAttachedMesh: boolean;
  135594. /**
  135595. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  135596. */
  135597. updateScale: boolean;
  135598. protected _interactionsEnabled: boolean;
  135599. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135600. private _beforeRenderObserver;
  135601. private _tempQuaternion;
  135602. private _tempVector;
  135603. private _tempVector2;
  135604. private _tempMatrix1;
  135605. private _tempMatrix2;
  135606. private _rightHandtoLeftHandMatrix;
  135607. /**
  135608. * Creates a gizmo
  135609. * @param gizmoLayer The utility layer the gizmo will be added to
  135610. */
  135611. constructor(
  135612. /** The utility layer the gizmo will be added to */
  135613. gizmoLayer?: UtilityLayerRenderer);
  135614. /**
  135615. * Updates the gizmo to match the attached mesh's position/rotation
  135616. */
  135617. protected _update(): void;
  135618. /**
  135619. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  135620. * @param value Node, TransformNode or mesh
  135621. */
  135622. protected _matrixChanged(): void;
  135623. /**
  135624. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  135625. * @param gizmoLayer The utility layer the gizmo will be added to
  135626. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  135627. * @returns {Observer<PointerInfo>} pointerObserver
  135628. */
  135629. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  135630. /**
  135631. * Disposes of the gizmo
  135632. */
  135633. dispose(): void;
  135634. }
  135635. }
  135636. declare module BABYLON {
  135637. /**
  135638. * Single plane drag gizmo
  135639. */
  135640. export class PlaneDragGizmo extends Gizmo {
  135641. /**
  135642. * Drag behavior responsible for the gizmos dragging interactions
  135643. */
  135644. dragBehavior: PointerDragBehavior;
  135645. private _pointerObserver;
  135646. /**
  135647. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  135648. */
  135649. snapDistance: number;
  135650. /**
  135651. * Event that fires each time the gizmo snaps to a new location.
  135652. * * snapDistance is the the change in distance
  135653. */
  135654. onSnapObservable: Observable<{
  135655. snapDistance: number;
  135656. }>;
  135657. private _gizmoMesh;
  135658. private _coloredMaterial;
  135659. private _hoverMaterial;
  135660. private _disableMaterial;
  135661. private _isEnabled;
  135662. private _parent;
  135663. private _dragging;
  135664. /** @hidden */
  135665. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  135666. /**
  135667. * Creates a PlaneDragGizmo
  135668. * @param gizmoLayer The utility layer the gizmo will be added to
  135669. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  135670. * @param color The color of the gizmo
  135671. */
  135672. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  135673. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135674. /**
  135675. * If the gizmo is enabled
  135676. */
  135677. set isEnabled(value: boolean);
  135678. get isEnabled(): boolean;
  135679. /**
  135680. * Disposes of the gizmo
  135681. */
  135682. dispose(): void;
  135683. }
  135684. }
  135685. declare module BABYLON {
  135686. /**
  135687. * Single plane rotation gizmo
  135688. */
  135689. export class PlaneRotationGizmo extends Gizmo {
  135690. /**
  135691. * Drag behavior responsible for the gizmos dragging interactions
  135692. */
  135693. dragBehavior: PointerDragBehavior;
  135694. private _pointerObserver;
  135695. /**
  135696. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  135697. */
  135698. snapDistance: number;
  135699. /**
  135700. * Event that fires each time the gizmo snaps to a new location.
  135701. * * snapDistance is the the change in distance
  135702. */
  135703. onSnapObservable: Observable<{
  135704. snapDistance: number;
  135705. }>;
  135706. private _isEnabled;
  135707. private _parent;
  135708. private _coloredMaterial;
  135709. private _hoverMaterial;
  135710. private _disableMaterial;
  135711. private _gizmoMesh;
  135712. private _rotationCircle;
  135713. private _dragging;
  135714. private static _CircleConstants;
  135715. /**
  135716. * Creates a PlaneRotationGizmo
  135717. * @param gizmoLayer The utility layer the gizmo will be added to
  135718. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  135719. * @param color The color of the gizmo
  135720. * @param tessellation Amount of tessellation to be used when creating rotation circles
  135721. * @param useEulerRotation Use and update Euler angle instead of quaternion
  135722. * @param thickness display gizmo axis thickness
  135723. */
  135724. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  135725. /** Create Geometry for Gizmo */
  135726. private _createGizmoMesh;
  135727. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135728. private setupRotationCircle;
  135729. private updateRotationPath;
  135730. private updateRotationCircle;
  135731. /**
  135732. * If the gizmo is enabled
  135733. */
  135734. set isEnabled(value: boolean);
  135735. get isEnabled(): boolean;
  135736. /**
  135737. * Disposes of the gizmo
  135738. */
  135739. dispose(): void;
  135740. }
  135741. }
  135742. declare module BABYLON {
  135743. /**
  135744. * Gizmo that enables rotating a mesh along 3 axis
  135745. */
  135746. export class RotationGizmo extends Gizmo {
  135747. /**
  135748. * Internal gizmo used for interactions on the x axis
  135749. */
  135750. xGizmo: PlaneRotationGizmo;
  135751. /**
  135752. * Internal gizmo used for interactions on the y axis
  135753. */
  135754. yGizmo: PlaneRotationGizmo;
  135755. /**
  135756. * Internal gizmo used for interactions on the z axis
  135757. */
  135758. zGizmo: PlaneRotationGizmo;
  135759. /** Fires an event when any of it's sub gizmos are dragged */
  135760. onDragStartObservable: Observable<unknown>;
  135761. /** Fires an event when any of it's sub gizmos are released from dragging */
  135762. onDragEndObservable: Observable<unknown>;
  135763. private _meshAttached;
  135764. private _nodeAttached;
  135765. private _observables;
  135766. /** Node Caching for quick lookup */
  135767. private _gizmoAxisCache;
  135768. get attachedMesh(): Nullable<AbstractMesh>;
  135769. set attachedMesh(mesh: Nullable<AbstractMesh>);
  135770. get attachedNode(): Nullable<Node>;
  135771. set attachedNode(node: Nullable<Node>);
  135772. protected _checkBillboardTransform(): void;
  135773. /**
  135774. * True when the mouse pointer is hovering a gizmo mesh
  135775. */
  135776. get isHovered(): boolean;
  135777. /**
  135778. * Creates a RotationGizmo
  135779. * @param gizmoLayer The utility layer the gizmo will be added to
  135780. * @param tessellation Amount of tessellation to be used when creating rotation circles
  135781. * @param useEulerRotation Use and update Euler angle instead of quaternion
  135782. * @param thickness display gizmo axis thickness
  135783. */
  135784. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  135785. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  135786. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  135787. /**
  135788. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  135789. */
  135790. set snapDistance(value: number);
  135791. get snapDistance(): number;
  135792. /**
  135793. * Ratio for the scale of the gizmo (Default: 1)
  135794. */
  135795. set scaleRatio(value: number);
  135796. get scaleRatio(): number;
  135797. /**
  135798. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  135799. * @param mesh Axis gizmo mesh
  135800. * @param cache Gizmo axis definition used for reactive gizmo UI
  135801. */
  135802. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  135803. /**
  135804. * Disposes of the gizmo
  135805. */
  135806. dispose(): void;
  135807. /**
  135808. * CustomMeshes are not supported by this gizmo
  135809. * @param mesh The mesh to replace the default mesh of the gizmo
  135810. */
  135811. setCustomMesh(mesh: Mesh): void;
  135812. }
  135813. }
  135814. declare module BABYLON {
  135815. /**
  135816. * Class containing static functions to help procedurally build meshes
  135817. */
  135818. export class PolyhedronBuilder {
  135819. /**
  135820. * Creates a polyhedron mesh
  135821. * * 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
  135822. * * The parameter `size` (positive float, default 1) sets the polygon size
  135823. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  135824. * * 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`
  135825. * * 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
  135826. * * 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)`)
  135827. * * 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
  135828. * * 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
  135829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135830. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135832. * @param name defines the name of the mesh
  135833. * @param options defines the options used to create the mesh
  135834. * @param scene defines the hosting scene
  135835. * @returns the polyhedron mesh
  135836. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  135837. */
  135838. static CreatePolyhedron(name: string, options: {
  135839. type?: number;
  135840. size?: number;
  135841. sizeX?: number;
  135842. sizeY?: number;
  135843. sizeZ?: number;
  135844. custom?: any;
  135845. faceUV?: Vector4[];
  135846. faceColors?: Color4[];
  135847. flat?: boolean;
  135848. updatable?: boolean;
  135849. sideOrientation?: number;
  135850. frontUVs?: Vector4;
  135851. backUVs?: Vector4;
  135852. }, scene?: Nullable<Scene>): Mesh;
  135853. }
  135854. }
  135855. declare module BABYLON {
  135856. /**
  135857. * Class containing static functions to help procedurally build meshes
  135858. */
  135859. export class BoxBuilder {
  135860. /**
  135861. * Creates a box mesh
  135862. * * The parameter `size` sets the size (float) of each box side (default 1)
  135863. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  135864. * * 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)
  135865. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135866. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135867. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135869. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  135870. * @param name defines the name of the mesh
  135871. * @param options defines the options used to create the mesh
  135872. * @param scene defines the hosting scene
  135873. * @returns the box mesh
  135874. */
  135875. static CreateBox(name: string, options: {
  135876. size?: number;
  135877. width?: number;
  135878. height?: number;
  135879. depth?: number;
  135880. faceUV?: Vector4[];
  135881. faceColors?: Color4[];
  135882. sideOrientation?: number;
  135883. frontUVs?: Vector4;
  135884. backUVs?: Vector4;
  135885. wrap?: boolean;
  135886. topBaseAt?: number;
  135887. bottomBaseAt?: number;
  135888. updatable?: boolean;
  135889. }, scene?: Nullable<Scene>): Mesh;
  135890. }
  135891. }
  135892. declare module BABYLON {
  135893. /**
  135894. * Single axis scale gizmo
  135895. */
  135896. export class AxisScaleGizmo extends Gizmo {
  135897. /**
  135898. * Drag behavior responsible for the gizmos dragging interactions
  135899. */
  135900. dragBehavior: PointerDragBehavior;
  135901. private _pointerObserver;
  135902. /**
  135903. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  135904. */
  135905. snapDistance: number;
  135906. /**
  135907. * Event that fires each time the gizmo snaps to a new location.
  135908. * * snapDistance is the the change in distance
  135909. */
  135910. onSnapObservable: Observable<{
  135911. snapDistance: number;
  135912. }>;
  135913. /**
  135914. * If the scaling operation should be done on all axis (default: false)
  135915. */
  135916. uniformScaling: boolean;
  135917. /**
  135918. * Custom sensitivity value for the drag strength
  135919. */
  135920. sensitivity: number;
  135921. private _isEnabled;
  135922. private _parent;
  135923. private _gizmoMesh;
  135924. private _coloredMaterial;
  135925. private _hoverMaterial;
  135926. private _disableMaterial;
  135927. private _dragging;
  135928. /**
  135929. * Creates an AxisScaleGizmo
  135930. * @param gizmoLayer The utility layer the gizmo will be added to
  135931. * @param dragAxis The axis which the gizmo will be able to scale on
  135932. * @param color The color of the gizmo
  135933. * @param thickness display gizmo axis thickness
  135934. */
  135935. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  135936. /** Create Geometry for Gizmo */
  135937. private _createGizmoMesh;
  135938. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135939. /**
  135940. * If the gizmo is enabled
  135941. */
  135942. set isEnabled(value: boolean);
  135943. get isEnabled(): boolean;
  135944. /**
  135945. * Disposes of the gizmo
  135946. */
  135947. dispose(): void;
  135948. /**
  135949. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  135950. * @param mesh The mesh to replace the default mesh of the gizmo
  135951. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  135952. */
  135953. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  135954. }
  135955. }
  135956. declare module BABYLON {
  135957. /**
  135958. * Gizmo that enables scaling a mesh along 3 axis
  135959. */
  135960. export class ScaleGizmo extends Gizmo {
  135961. /**
  135962. * Internal gizmo used for interactions on the x axis
  135963. */
  135964. xGizmo: AxisScaleGizmo;
  135965. /**
  135966. * Internal gizmo used for interactions on the y axis
  135967. */
  135968. yGizmo: AxisScaleGizmo;
  135969. /**
  135970. * Internal gizmo used for interactions on the z axis
  135971. */
  135972. zGizmo: AxisScaleGizmo;
  135973. /**
  135974. * Internal gizmo used to scale all axis equally
  135975. */
  135976. uniformScaleGizmo: AxisScaleGizmo;
  135977. private _meshAttached;
  135978. private _nodeAttached;
  135979. private _snapDistance;
  135980. private _uniformScalingMesh;
  135981. private _octahedron;
  135982. private _sensitivity;
  135983. private _coloredMaterial;
  135984. private _hoverMaterial;
  135985. private _disableMaterial;
  135986. private _observables;
  135987. /** Node Caching for quick lookup */
  135988. private _gizmoAxisCache;
  135989. /** Fires an event when any of it's sub gizmos are dragged */
  135990. onDragStartObservable: Observable<unknown>;
  135991. /** Fires an event when any of it's sub gizmos are released from dragging */
  135992. onDragEndObservable: Observable<unknown>;
  135993. get attachedMesh(): Nullable<AbstractMesh>;
  135994. set attachedMesh(mesh: Nullable<AbstractMesh>);
  135995. get attachedNode(): Nullable<Node>;
  135996. set attachedNode(node: Nullable<Node>);
  135997. /**
  135998. * True when the mouse pointer is hovering a gizmo mesh
  135999. */
  136000. get isHovered(): boolean;
  136001. /**
  136002. * Creates a ScaleGizmo
  136003. * @param gizmoLayer The utility layer the gizmo will be added to
  136004. * @param thickness display gizmo axis thickness
  136005. */
  136006. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  136007. /** Create Geometry for Gizmo */
  136008. private _createUniformScaleMesh;
  136009. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  136010. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  136011. /**
  136012. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136013. */
  136014. set snapDistance(value: number);
  136015. get snapDistance(): number;
  136016. /**
  136017. * Ratio for the scale of the gizmo (Default: 1)
  136018. */
  136019. set scaleRatio(value: number);
  136020. get scaleRatio(): number;
  136021. /**
  136022. * Sensitivity factor for dragging (Default: 1)
  136023. */
  136024. set sensitivity(value: number);
  136025. get sensitivity(): number;
  136026. /**
  136027. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  136028. * @param mesh Axis gizmo mesh
  136029. * @param cache Gizmo axis definition used for reactive gizmo UI
  136030. */
  136031. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  136032. /**
  136033. * Disposes of the gizmo
  136034. */
  136035. dispose(): void;
  136036. }
  136037. }
  136038. declare module BABYLON {
  136039. /**
  136040. * Bounding box gizmo
  136041. */
  136042. export class BoundingBoxGizmo extends Gizmo {
  136043. private _lineBoundingBox;
  136044. private _rotateSpheresParent;
  136045. private _scaleBoxesParent;
  136046. private _boundingDimensions;
  136047. private _renderObserver;
  136048. private _pointerObserver;
  136049. private _scaleDragSpeed;
  136050. private _tmpQuaternion;
  136051. private _tmpVector;
  136052. private _tmpRotationMatrix;
  136053. /**
  136054. * 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)
  136055. */
  136056. ignoreChildren: boolean;
  136057. /**
  136058. * 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)
  136059. */
  136060. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  136061. /**
  136062. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  136063. */
  136064. rotationSphereSize: number;
  136065. /**
  136066. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  136067. */
  136068. scaleBoxSize: number;
  136069. /**
  136070. * 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)
  136071. */
  136072. fixedDragMeshScreenSize: boolean;
  136073. /**
  136074. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  136075. */
  136076. fixedDragMeshScreenSizeDistanceFactor: number;
  136077. /**
  136078. * Fired when a rotation sphere or scale box is dragged
  136079. */
  136080. onDragStartObservable: Observable<{}>;
  136081. /**
  136082. * Fired when a scale box is dragged
  136083. */
  136084. onScaleBoxDragObservable: Observable<{}>;
  136085. /**
  136086. * Fired when a scale box drag is ended
  136087. */
  136088. onScaleBoxDragEndObservable: Observable<{}>;
  136089. /**
  136090. * Fired when a rotation sphere is dragged
  136091. */
  136092. onRotationSphereDragObservable: Observable<{}>;
  136093. /**
  136094. * Fired when a rotation sphere drag is ended
  136095. */
  136096. onRotationSphereDragEndObservable: Observable<{}>;
  136097. /**
  136098. * 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)
  136099. */
  136100. scalePivot: Nullable<Vector3>;
  136101. /**
  136102. * Mesh used as a pivot to rotate the attached node
  136103. */
  136104. private _anchorMesh;
  136105. private _existingMeshScale;
  136106. private _dragMesh;
  136107. private pointerDragBehavior;
  136108. private coloredMaterial;
  136109. private hoverColoredMaterial;
  136110. /**
  136111. * Sets the color of the bounding box gizmo
  136112. * @param color the color to set
  136113. */
  136114. setColor(color: Color3): void;
  136115. /**
  136116. * Creates an BoundingBoxGizmo
  136117. * @param gizmoLayer The utility layer the gizmo will be added to
  136118. * @param color The color of the gizmo
  136119. */
  136120. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  136121. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  136122. private _selectNode;
  136123. /**
  136124. * Updates the bounding box information for the Gizmo
  136125. */
  136126. updateBoundingBox(): void;
  136127. private _updateRotationSpheres;
  136128. private _updateScaleBoxes;
  136129. /**
  136130. * Enables rotation on the specified axis and disables rotation on the others
  136131. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  136132. */
  136133. setEnabledRotationAxis(axis: string): void;
  136134. /**
  136135. * Enables/disables scaling
  136136. * @param enable if scaling should be enabled
  136137. * @param homogeneousScaling defines if scaling should only be homogeneous
  136138. */
  136139. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  136140. private _updateDummy;
  136141. /**
  136142. * Enables a pointer drag behavior on the bounding box of the gizmo
  136143. */
  136144. enableDragBehavior(): void;
  136145. /**
  136146. * Disposes of the gizmo
  136147. */
  136148. dispose(): void;
  136149. /**
  136150. * 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)
  136151. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  136152. * @returns the bounding box mesh with the passed in mesh as a child
  136153. */
  136154. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  136155. /**
  136156. * CustomMeshes are not supported by this gizmo
  136157. * @param mesh The mesh to replace the default mesh of the gizmo
  136158. */
  136159. setCustomMesh(mesh: Mesh): void;
  136160. }
  136161. }
  136162. declare module BABYLON {
  136163. /**
  136164. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  136165. */
  136166. export class GizmoManager implements IDisposable {
  136167. private scene;
  136168. /**
  136169. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  136170. */
  136171. gizmos: {
  136172. positionGizmo: Nullable<PositionGizmo>;
  136173. rotationGizmo: Nullable<RotationGizmo>;
  136174. scaleGizmo: Nullable<ScaleGizmo>;
  136175. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  136176. };
  136177. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  136178. clearGizmoOnEmptyPointerEvent: boolean;
  136179. /** Fires an event when the manager is attached to a mesh */
  136180. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  136181. /** Fires an event when the manager is attached to a node */
  136182. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  136183. private _gizmosEnabled;
  136184. private _pointerObservers;
  136185. private _attachedMesh;
  136186. private _attachedNode;
  136187. private _boundingBoxColor;
  136188. private _defaultUtilityLayer;
  136189. private _defaultKeepDepthUtilityLayer;
  136190. private _thickness;
  136191. /** Node Caching for quick lookup */
  136192. private _gizmoAxisCache;
  136193. /**
  136194. * When bounding box gizmo is enabled, this can be used to track drag/end events
  136195. */
  136196. boundingBoxDragBehavior: SixDofDragBehavior;
  136197. /**
  136198. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  136199. */
  136200. attachableMeshes: Nullable<Array<AbstractMesh>>;
  136201. /**
  136202. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  136203. */
  136204. attachableNodes: Nullable<Array<Node>>;
  136205. /**
  136206. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  136207. */
  136208. usePointerToAttachGizmos: boolean;
  136209. /**
  136210. * Utility layer that the bounding box gizmo belongs to
  136211. */
  136212. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  136213. /**
  136214. * Utility layer that all gizmos besides bounding box belong to
  136215. */
  136216. get utilityLayer(): UtilityLayerRenderer;
  136217. /**
  136218. * True when the mouse pointer is hovering a gizmo mesh
  136219. */
  136220. get isHovered(): boolean;
  136221. /**
  136222. * Instatiates a gizmo manager
  136223. * @param scene the scene to overlay the gizmos on top of
  136224. * @param thickness display gizmo axis thickness
  136225. * @param utilityLayer the layer where gizmos are rendered
  136226. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  136227. */
  136228. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  136229. /**
  136230. * Subscribes to pointer down events, for attaching and detaching mesh
  136231. * @param scene The sceme layer the observer will be added to
  136232. */
  136233. private _attachToMeshPointerObserver;
  136234. /**
  136235. * Attaches a set of gizmos to the specified mesh
  136236. * @param mesh The mesh the gizmo's should be attached to
  136237. */
  136238. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  136239. /**
  136240. * Attaches a set of gizmos to the specified node
  136241. * @param node The node the gizmo's should be attached to
  136242. */
  136243. attachToNode(node: Nullable<Node>): void;
  136244. /**
  136245. * If the position gizmo is enabled
  136246. */
  136247. set positionGizmoEnabled(value: boolean);
  136248. get positionGizmoEnabled(): boolean;
  136249. /**
  136250. * If the rotation gizmo is enabled
  136251. */
  136252. set rotationGizmoEnabled(value: boolean);
  136253. get rotationGizmoEnabled(): boolean;
  136254. /**
  136255. * If the scale gizmo is enabled
  136256. */
  136257. set scaleGizmoEnabled(value: boolean);
  136258. get scaleGizmoEnabled(): boolean;
  136259. /**
  136260. * If the boundingBox gizmo is enabled
  136261. */
  136262. set boundingBoxGizmoEnabled(value: boolean);
  136263. get boundingBoxGizmoEnabled(): boolean;
  136264. /**
  136265. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  136266. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  136267. */
  136268. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  136269. /**
  136270. * Disposes of the gizmo manager
  136271. */
  136272. dispose(): void;
  136273. }
  136274. }
  136275. declare module BABYLON {
  136276. /**
  136277. * Gizmo that enables dragging a mesh along 3 axis
  136278. */
  136279. export class PositionGizmo extends Gizmo {
  136280. /**
  136281. * Internal gizmo used for interactions on the x axis
  136282. */
  136283. xGizmo: AxisDragGizmo;
  136284. /**
  136285. * Internal gizmo used for interactions on the y axis
  136286. */
  136287. yGizmo: AxisDragGizmo;
  136288. /**
  136289. * Internal gizmo used for interactions on the z axis
  136290. */
  136291. zGizmo: AxisDragGizmo;
  136292. /**
  136293. * Internal gizmo used for interactions on the yz plane
  136294. */
  136295. xPlaneGizmo: PlaneDragGizmo;
  136296. /**
  136297. * Internal gizmo used for interactions on the xz plane
  136298. */
  136299. yPlaneGizmo: PlaneDragGizmo;
  136300. /**
  136301. * Internal gizmo used for interactions on the xy plane
  136302. */
  136303. zPlaneGizmo: PlaneDragGizmo;
  136304. /**
  136305. * private variables
  136306. */
  136307. private _meshAttached;
  136308. private _nodeAttached;
  136309. private _snapDistance;
  136310. private _observables;
  136311. /** Node Caching for quick lookup */
  136312. private _gizmoAxisCache;
  136313. /** Fires an event when any of it's sub gizmos are dragged */
  136314. onDragStartObservable: Observable<unknown>;
  136315. /** Fires an event when any of it's sub gizmos are released from dragging */
  136316. onDragEndObservable: Observable<unknown>;
  136317. /**
  136318. * If set to true, planar drag is enabled
  136319. */
  136320. private _planarGizmoEnabled;
  136321. get attachedMesh(): Nullable<AbstractMesh>;
  136322. set attachedMesh(mesh: Nullable<AbstractMesh>);
  136323. get attachedNode(): Nullable<Node>;
  136324. set attachedNode(node: Nullable<Node>);
  136325. /**
  136326. * True when the mouse pointer is hovering a gizmo mesh
  136327. */
  136328. get isHovered(): boolean;
  136329. /**
  136330. * Creates a PositionGizmo
  136331. * @param gizmoLayer The utility layer the gizmo will be added to
  136332. @param thickness display gizmo axis thickness
  136333. */
  136334. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  136335. /**
  136336. * If the planar drag gizmo is enabled
  136337. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  136338. */
  136339. set planarGizmoEnabled(value: boolean);
  136340. get planarGizmoEnabled(): boolean;
  136341. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  136342. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  136343. /**
  136344. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136345. */
  136346. set snapDistance(value: number);
  136347. get snapDistance(): number;
  136348. /**
  136349. * Ratio for the scale of the gizmo (Default: 1)
  136350. */
  136351. set scaleRatio(value: number);
  136352. get scaleRatio(): number;
  136353. /**
  136354. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  136355. * @param mesh Axis gizmo mesh
  136356. * @param cache Gizmo axis definition used for reactive gizmo UI
  136357. */
  136358. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  136359. /**
  136360. * Disposes of the gizmo
  136361. */
  136362. dispose(): void;
  136363. /**
  136364. * CustomMeshes are not supported by this gizmo
  136365. * @param mesh The mesh to replace the default mesh of the gizmo
  136366. */
  136367. setCustomMesh(mesh: Mesh): void;
  136368. }
  136369. }
  136370. declare module BABYLON {
  136371. /**
  136372. * Single axis drag gizmo
  136373. */
  136374. export class AxisDragGizmo extends Gizmo {
  136375. /**
  136376. * Drag behavior responsible for the gizmos dragging interactions
  136377. */
  136378. dragBehavior: PointerDragBehavior;
  136379. private _pointerObserver;
  136380. /**
  136381. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136382. */
  136383. snapDistance: number;
  136384. /**
  136385. * Event that fires each time the gizmo snaps to a new location.
  136386. * * snapDistance is the the change in distance
  136387. */
  136388. onSnapObservable: Observable<{
  136389. snapDistance: number;
  136390. }>;
  136391. private _isEnabled;
  136392. private _parent;
  136393. private _gizmoMesh;
  136394. private _coloredMaterial;
  136395. private _hoverMaterial;
  136396. private _disableMaterial;
  136397. private _dragging;
  136398. /** @hidden */
  136399. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  136400. /** @hidden */
  136401. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  136402. /**
  136403. * Creates an AxisDragGizmo
  136404. * @param gizmoLayer The utility layer the gizmo will be added to
  136405. * @param dragAxis The axis which the gizmo will be able to drag on
  136406. * @param color The color of the gizmo
  136407. * @param thickness display gizmo axis thickness
  136408. */
  136409. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  136410. protected _attachedNodeChanged(value: Nullable<Node>): void;
  136411. /**
  136412. * If the gizmo is enabled
  136413. */
  136414. set isEnabled(value: boolean);
  136415. get isEnabled(): boolean;
  136416. /**
  136417. * Disposes of the gizmo
  136418. */
  136419. dispose(): void;
  136420. }
  136421. }
  136422. declare module BABYLON.Debug {
  136423. /**
  136424. * The Axes viewer will show 3 axes in a specific point in space
  136425. */
  136426. export class AxesViewer {
  136427. private _xAxis;
  136428. private _yAxis;
  136429. private _zAxis;
  136430. private _scaleLinesFactor;
  136431. private _instanced;
  136432. /**
  136433. * Gets the hosting scene
  136434. */
  136435. scene: Nullable<Scene>;
  136436. /**
  136437. * Gets or sets a number used to scale line length
  136438. */
  136439. scaleLines: number;
  136440. /** Gets the node hierarchy used to render x-axis */
  136441. get xAxis(): TransformNode;
  136442. /** Gets the node hierarchy used to render y-axis */
  136443. get yAxis(): TransformNode;
  136444. /** Gets the node hierarchy used to render z-axis */
  136445. get zAxis(): TransformNode;
  136446. /**
  136447. * Creates a new AxesViewer
  136448. * @param scene defines the hosting scene
  136449. * @param scaleLines defines a number used to scale line length (1 by default)
  136450. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  136451. * @param xAxis defines the node hierarchy used to render the x-axis
  136452. * @param yAxis defines the node hierarchy used to render the y-axis
  136453. * @param zAxis defines the node hierarchy used to render the z-axis
  136454. */
  136455. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  136456. /**
  136457. * Force the viewer to update
  136458. * @param position defines the position of the viewer
  136459. * @param xaxis defines the x axis of the viewer
  136460. * @param yaxis defines the y axis of the viewer
  136461. * @param zaxis defines the z axis of the viewer
  136462. */
  136463. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  136464. /**
  136465. * Creates an instance of this axes viewer.
  136466. * @returns a new axes viewer with instanced meshes
  136467. */
  136468. createInstance(): AxesViewer;
  136469. /** Releases resources */
  136470. dispose(): void;
  136471. private static _SetRenderingGroupId;
  136472. }
  136473. }
  136474. declare module BABYLON.Debug {
  136475. /**
  136476. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  136477. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  136478. */
  136479. export class BoneAxesViewer extends AxesViewer {
  136480. /**
  136481. * Gets or sets the target mesh where to display the axes viewer
  136482. */
  136483. mesh: Nullable<Mesh>;
  136484. /**
  136485. * Gets or sets the target bone where to display the axes viewer
  136486. */
  136487. bone: Nullable<Bone>;
  136488. /** Gets current position */
  136489. pos: Vector3;
  136490. /** Gets direction of X axis */
  136491. xaxis: Vector3;
  136492. /** Gets direction of Y axis */
  136493. yaxis: Vector3;
  136494. /** Gets direction of Z axis */
  136495. zaxis: Vector3;
  136496. /**
  136497. * Creates a new BoneAxesViewer
  136498. * @param scene defines the hosting scene
  136499. * @param bone defines the target bone
  136500. * @param mesh defines the target mesh
  136501. * @param scaleLines defines a scaling factor for line length (1 by default)
  136502. */
  136503. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  136504. /**
  136505. * Force the viewer to update
  136506. */
  136507. update(): void;
  136508. /** Releases resources */
  136509. dispose(): void;
  136510. }
  136511. }
  136512. declare module BABYLON {
  136513. /**
  136514. * Interface used to define scene explorer extensibility option
  136515. */
  136516. export interface IExplorerExtensibilityOption {
  136517. /**
  136518. * Define the option label
  136519. */
  136520. label: string;
  136521. /**
  136522. * Defines the action to execute on click
  136523. */
  136524. action: (entity: any) => void;
  136525. }
  136526. /**
  136527. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  136528. */
  136529. export interface IExplorerExtensibilityGroup {
  136530. /**
  136531. * Defines a predicate to test if a given type mut be extended
  136532. */
  136533. predicate: (entity: any) => boolean;
  136534. /**
  136535. * Gets the list of options added to a type
  136536. */
  136537. entries: IExplorerExtensibilityOption[];
  136538. }
  136539. /**
  136540. * Interface used to define the options to use to create the Inspector
  136541. */
  136542. export interface IInspectorOptions {
  136543. /**
  136544. * Display in overlay mode (default: false)
  136545. */
  136546. overlay?: boolean;
  136547. /**
  136548. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  136549. */
  136550. globalRoot?: HTMLElement;
  136551. /**
  136552. * Display the Scene explorer
  136553. */
  136554. showExplorer?: boolean;
  136555. /**
  136556. * Display the property inspector
  136557. */
  136558. showInspector?: boolean;
  136559. /**
  136560. * Display in embed mode (both panes on the right)
  136561. */
  136562. embedMode?: boolean;
  136563. /**
  136564. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  136565. */
  136566. handleResize?: boolean;
  136567. /**
  136568. * Allow the panes to popup (default: true)
  136569. */
  136570. enablePopup?: boolean;
  136571. /**
  136572. * Allow the panes to be closed by users (default: true)
  136573. */
  136574. enableClose?: boolean;
  136575. /**
  136576. * Optional list of extensibility entries
  136577. */
  136578. explorerExtensibility?: IExplorerExtensibilityGroup[];
  136579. /**
  136580. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  136581. */
  136582. inspectorURL?: string;
  136583. /**
  136584. * Optional initial tab (default to DebugLayerTab.Properties)
  136585. */
  136586. initialTab?: DebugLayerTab;
  136587. }
  136588. interface Scene {
  136589. /**
  136590. * @hidden
  136591. * Backing field
  136592. */
  136593. _debugLayer: DebugLayer;
  136594. /**
  136595. * Gets the debug layer (aka Inspector) associated with the scene
  136596. * @see https://doc.babylonjs.com/features/playground_debuglayer
  136597. */
  136598. debugLayer: DebugLayer;
  136599. }
  136600. /**
  136601. * Enum of inspector action tab
  136602. */
  136603. export enum DebugLayerTab {
  136604. /**
  136605. * Properties tag (default)
  136606. */
  136607. Properties = 0,
  136608. /**
  136609. * Debug tab
  136610. */
  136611. Debug = 1,
  136612. /**
  136613. * Statistics tab
  136614. */
  136615. Statistics = 2,
  136616. /**
  136617. * Tools tab
  136618. */
  136619. Tools = 3,
  136620. /**
  136621. * Settings tab
  136622. */
  136623. Settings = 4
  136624. }
  136625. /**
  136626. * The debug layer (aka Inspector) is the go to tool in order to better understand
  136627. * what is happening in your scene
  136628. * @see https://doc.babylonjs.com/features/playground_debuglayer
  136629. */
  136630. export class DebugLayer {
  136631. /**
  136632. * Define the url to get the inspector script from.
  136633. * By default it uses the babylonjs CDN.
  136634. * @ignoreNaming
  136635. */
  136636. static InspectorURL: string;
  136637. private _scene;
  136638. private BJSINSPECTOR;
  136639. private _onPropertyChangedObservable?;
  136640. /**
  136641. * Observable triggered when a property is changed through the inspector.
  136642. */
  136643. get onPropertyChangedObservable(): any;
  136644. /**
  136645. * Instantiates a new debug layer.
  136646. * The debug layer (aka Inspector) is the go to tool in order to better understand
  136647. * what is happening in your scene
  136648. * @see https://doc.babylonjs.com/features/playground_debuglayer
  136649. * @param scene Defines the scene to inspect
  136650. */
  136651. constructor(scene: Scene);
  136652. /** Creates the inspector window. */
  136653. private _createInspector;
  136654. /**
  136655. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  136656. * @param entity defines the entity to select
  136657. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  136658. */
  136659. select(entity: any, lineContainerTitles?: string | string[]): void;
  136660. /** Get the inspector from bundle or global */
  136661. private _getGlobalInspector;
  136662. /**
  136663. * Get if the inspector is visible or not.
  136664. * @returns true if visible otherwise, false
  136665. */
  136666. isVisible(): boolean;
  136667. /**
  136668. * Hide the inspector and close its window.
  136669. */
  136670. hide(): void;
  136671. /**
  136672. * Update the scene in the inspector
  136673. */
  136674. setAsActiveScene(): void;
  136675. /**
  136676. * Launch the debugLayer.
  136677. * @param config Define the configuration of the inspector
  136678. * @return a promise fulfilled when the debug layer is visible
  136679. */
  136680. show(config?: IInspectorOptions): Promise<DebugLayer>;
  136681. }
  136682. }
  136683. declare module BABYLON.Debug {
  136684. /**
  136685. * Used to show the physics impostor around the specific mesh
  136686. */
  136687. export class PhysicsViewer {
  136688. /** @hidden */
  136689. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  136690. /** @hidden */
  136691. protected _meshes: Array<Nullable<AbstractMesh>>;
  136692. /** @hidden */
  136693. protected _scene: Nullable<Scene>;
  136694. /** @hidden */
  136695. protected _numMeshes: number;
  136696. /** @hidden */
  136697. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  136698. private _renderFunction;
  136699. private _utilityLayer;
  136700. private _debugBoxMesh;
  136701. private _debugSphereMesh;
  136702. private _debugCylinderMesh;
  136703. private _debugMaterial;
  136704. private _debugMeshMeshes;
  136705. /**
  136706. * Creates a new PhysicsViewer
  136707. * @param scene defines the hosting scene
  136708. */
  136709. constructor(scene: Scene);
  136710. /** @hidden */
  136711. protected _updateDebugMeshes(): void;
  136712. /**
  136713. * Renders a specified physic impostor
  136714. * @param impostor defines the impostor to render
  136715. * @param targetMesh defines the mesh represented by the impostor
  136716. * @returns the new debug mesh used to render the impostor
  136717. */
  136718. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  136719. /**
  136720. * Hides a specified physic impostor
  136721. * @param impostor defines the impostor to hide
  136722. */
  136723. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  136724. private _getDebugMaterial;
  136725. private _getDebugBoxMesh;
  136726. private _getDebugSphereMesh;
  136727. private _getDebugCylinderMesh;
  136728. private _getDebugMeshMesh;
  136729. private _getDebugMesh;
  136730. /** Releases all resources */
  136731. dispose(): void;
  136732. }
  136733. }
  136734. declare module BABYLON {
  136735. /**
  136736. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  136737. * in order to better appreciate the issue one might have.
  136738. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  136739. */
  136740. export class RayHelper {
  136741. /**
  136742. * Defines the ray we are currently tryin to visualize.
  136743. */
  136744. ray: Nullable<Ray>;
  136745. private _renderPoints;
  136746. private _renderLine;
  136747. private _renderFunction;
  136748. private _scene;
  136749. private _onAfterRenderObserver;
  136750. private _onAfterStepObserver;
  136751. private _attachedToMesh;
  136752. private _meshSpaceDirection;
  136753. private _meshSpaceOrigin;
  136754. /**
  136755. * Helper function to create a colored helper in a scene in one line.
  136756. * @param ray Defines the ray we are currently tryin to visualize
  136757. * @param scene Defines the scene the ray is used in
  136758. * @param color Defines the color we want to see the ray in
  136759. * @returns The newly created ray helper.
  136760. */
  136761. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  136762. /**
  136763. * Instantiate a new ray helper.
  136764. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  136765. * in order to better appreciate the issue one might have.
  136766. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  136767. * @param ray Defines the ray we are currently tryin to visualize
  136768. */
  136769. constructor(ray: Ray);
  136770. /**
  136771. * Shows the ray we are willing to debug.
  136772. * @param scene Defines the scene the ray needs to be rendered in
  136773. * @param color Defines the color the ray needs to be rendered in
  136774. */
  136775. show(scene: Scene, color?: Color3): void;
  136776. /**
  136777. * Hides the ray we are debugging.
  136778. */
  136779. hide(): void;
  136780. private _render;
  136781. /**
  136782. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  136783. * @param mesh Defines the mesh we want the helper attached to
  136784. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  136785. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  136786. * @param length Defines the length of the ray
  136787. */
  136788. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  136789. /**
  136790. * Detach the ray helper from the mesh it has previously been attached to.
  136791. */
  136792. detachFromMesh(): void;
  136793. private _updateToMesh;
  136794. /**
  136795. * Dispose the helper and release its associated resources.
  136796. */
  136797. dispose(): void;
  136798. }
  136799. }
  136800. declare module BABYLON {
  136801. /**
  136802. * Defines the options associated with the creation of a SkeletonViewer.
  136803. */
  136804. export interface ISkeletonViewerOptions {
  136805. /** Should the system pause animations before building the Viewer? */
  136806. pauseAnimations: boolean;
  136807. /** Should the system return the skeleton to rest before building? */
  136808. returnToRest: boolean;
  136809. /** public Display Mode of the Viewer */
  136810. displayMode: number;
  136811. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  136812. displayOptions: ISkeletonViewerDisplayOptions;
  136813. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  136814. computeBonesUsingShaders: boolean;
  136815. /** Flag ignore non weighted bones */
  136816. useAllBones: boolean;
  136817. }
  136818. /**
  136819. * Defines how to display the various bone meshes for the viewer.
  136820. */
  136821. export interface ISkeletonViewerDisplayOptions {
  136822. /** How far down to start tapering the bone spurs */
  136823. midStep?: number;
  136824. /** How big is the midStep? */
  136825. midStepFactor?: number;
  136826. /** Base for the Sphere Size */
  136827. sphereBaseSize?: number;
  136828. /** The ratio of the sphere to the longest bone in units */
  136829. sphereScaleUnit?: number;
  136830. /** Ratio for the Sphere Size */
  136831. sphereFactor?: number;
  136832. /** Whether a spur should attach its far end to the child bone position */
  136833. spurFollowsChild?: boolean;
  136834. /** Whether to show local axes or not */
  136835. showLocalAxes?: boolean;
  136836. /** Length of each local axis */
  136837. localAxesSize?: number;
  136838. }
  136839. /**
  136840. * Defines the constructor options for the BoneWeight Shader.
  136841. */
  136842. export interface IBoneWeightShaderOptions {
  136843. /** Skeleton to Map */
  136844. skeleton: Skeleton;
  136845. /** Colors for Uninfluenced bones */
  136846. colorBase?: Color3;
  136847. /** Colors for 0.0-0.25 Weight bones */
  136848. colorZero?: Color3;
  136849. /** Color for 0.25-0.5 Weight Influence */
  136850. colorQuarter?: Color3;
  136851. /** Color for 0.5-0.75 Weight Influence */
  136852. colorHalf?: Color3;
  136853. /** Color for 0.75-1 Weight Influence */
  136854. colorFull?: Color3;
  136855. /** Color for Zero Weight Influence */
  136856. targetBoneIndex?: number;
  136857. }
  136858. /**
  136859. * Simple structure of the gradient steps for the Color Map.
  136860. */
  136861. export interface ISkeletonMapShaderColorMapKnot {
  136862. /** Color of the Knot */
  136863. color: Color3;
  136864. /** Location of the Knot */
  136865. location: number;
  136866. }
  136867. /**
  136868. * Defines the constructor options for the SkeletonMap Shader.
  136869. */
  136870. export interface ISkeletonMapShaderOptions {
  136871. /** Skeleton to Map */
  136872. skeleton: Skeleton;
  136873. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  136874. colorMap?: ISkeletonMapShaderColorMapKnot[];
  136875. }
  136876. }
  136877. declare module BABYLON {
  136878. /**
  136879. * Class containing static functions to help procedurally build meshes
  136880. */
  136881. export class RibbonBuilder {
  136882. /**
  136883. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  136884. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  136885. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  136886. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  136887. * * 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
  136888. * * 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
  136889. * * 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
  136890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136891. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136892. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136893. * * 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
  136894. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  136895. * * 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
  136896. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  136897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136898. * @param name defines the name of the mesh
  136899. * @param options defines the options used to create the mesh
  136900. * @param scene defines the hosting scene
  136901. * @returns the ribbon mesh
  136902. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  136903. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136904. */
  136905. static CreateRibbon(name: string, options: {
  136906. pathArray: Vector3[][];
  136907. closeArray?: boolean;
  136908. closePath?: boolean;
  136909. offset?: number;
  136910. updatable?: boolean;
  136911. sideOrientation?: number;
  136912. frontUVs?: Vector4;
  136913. backUVs?: Vector4;
  136914. instance?: Mesh;
  136915. invertUV?: boolean;
  136916. uvs?: Vector2[];
  136917. colors?: Color4[];
  136918. }, scene?: Nullable<Scene>): Mesh;
  136919. }
  136920. }
  136921. declare module BABYLON {
  136922. /**
  136923. * Class containing static functions to help procedurally build meshes
  136924. */
  136925. export class ShapeBuilder {
  136926. /**
  136927. * 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.
  136928. * * 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.
  136929. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136930. * * 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.
  136931. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  136932. * * 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
  136933. * * 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
  136934. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  136935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136936. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136937. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  136938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136939. * @param name defines the name of the mesh
  136940. * @param options defines the options used to create the mesh
  136941. * @param scene defines the hosting scene
  136942. * @returns the extruded shape mesh
  136943. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136944. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136945. */
  136946. static ExtrudeShape(name: string, options: {
  136947. shape: Vector3[];
  136948. path: Vector3[];
  136949. scale?: number;
  136950. rotation?: number;
  136951. cap?: number;
  136952. updatable?: boolean;
  136953. sideOrientation?: number;
  136954. frontUVs?: Vector4;
  136955. backUVs?: Vector4;
  136956. instance?: Mesh;
  136957. invertUV?: boolean;
  136958. }, scene?: Nullable<Scene>): Mesh;
  136959. /**
  136960. * Creates an custom extruded shape mesh.
  136961. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  136962. * * 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.
  136963. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136964. * * 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
  136965. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  136966. * * 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
  136967. * * It must returns a float value that will be the scale value applied to the shape on each path point
  136968. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  136969. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  136970. * * 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
  136971. * * 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
  136972. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  136973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136974. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136975. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136977. * @param name defines the name of the mesh
  136978. * @param options defines the options used to create the mesh
  136979. * @param scene defines the hosting scene
  136980. * @returns the custom extruded shape mesh
  136981. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  136982. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136983. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136984. */
  136985. static ExtrudeShapeCustom(name: string, options: {
  136986. shape: Vector3[];
  136987. path: Vector3[];
  136988. scaleFunction?: any;
  136989. rotationFunction?: any;
  136990. ribbonCloseArray?: boolean;
  136991. ribbonClosePath?: boolean;
  136992. cap?: number;
  136993. updatable?: boolean;
  136994. sideOrientation?: number;
  136995. frontUVs?: Vector4;
  136996. backUVs?: Vector4;
  136997. instance?: Mesh;
  136998. invertUV?: boolean;
  136999. }, scene?: Nullable<Scene>): Mesh;
  137000. private static _ExtrudeShapeGeneric;
  137001. }
  137002. }
  137003. declare module BABYLON.Debug {
  137004. /**
  137005. * Class used to render a debug view of a given skeleton
  137006. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  137007. */
  137008. export class SkeletonViewer {
  137009. /** defines the skeleton to render */
  137010. skeleton: Skeleton;
  137011. /** defines the mesh attached to the skeleton */
  137012. mesh: AbstractMesh;
  137013. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  137014. autoUpdateBonesMatrices: boolean;
  137015. /** defines the rendering group id to use with the viewer */
  137016. renderingGroupId: number;
  137017. /** is the options for the viewer */
  137018. options: Partial<ISkeletonViewerOptions>;
  137019. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  137020. static readonly DISPLAY_LINES: number;
  137021. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  137022. static readonly DISPLAY_SPHERES: number;
  137023. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  137024. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  137025. /** public static method to create a BoneWeight Shader
  137026. * @param options The constructor options
  137027. * @param scene The scene that the shader is scoped to
  137028. * @returns The created ShaderMaterial
  137029. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  137030. */
  137031. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  137032. /** public static method to create a BoneWeight Shader
  137033. * @param options The constructor options
  137034. * @param scene The scene that the shader is scoped to
  137035. * @returns The created ShaderMaterial
  137036. */
  137037. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  137038. /** private static method to create a BoneWeight Shader
  137039. * @param size The size of the buffer to create (usually the bone count)
  137040. * @param colorMap The gradient data to generate
  137041. * @param scene The scene that the shader is scoped to
  137042. * @returns an Array of floats from the color gradient values
  137043. */
  137044. private static _CreateBoneMapColorBuffer;
  137045. /** If SkeletonViewer scene scope. */
  137046. private _scene;
  137047. /** Gets or sets the color used to render the skeleton */
  137048. color: Color3;
  137049. /** Array of the points of the skeleton fo the line view. */
  137050. private _debugLines;
  137051. /** The SkeletonViewers Mesh. */
  137052. private _debugMesh;
  137053. /** The local axes Meshes. */
  137054. private _localAxes;
  137055. /** If SkeletonViewer is enabled. */
  137056. private _isEnabled;
  137057. /** If SkeletonViewer is ready. */
  137058. private _ready;
  137059. /** SkeletonViewer render observable. */
  137060. private _obs;
  137061. /** The Utility Layer to render the gizmos in. */
  137062. private _utilityLayer;
  137063. private _boneIndices;
  137064. /** Gets the Scene. */
  137065. get scene(): Scene;
  137066. /** Gets the utilityLayer. */
  137067. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  137068. /** Checks Ready Status. */
  137069. get isReady(): Boolean;
  137070. /** Sets Ready Status. */
  137071. set ready(value: boolean);
  137072. /** Gets the debugMesh */
  137073. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  137074. /** Sets the debugMesh */
  137075. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  137076. /** Gets the displayMode */
  137077. get displayMode(): number;
  137078. /** Sets the displayMode */
  137079. set displayMode(value: number);
  137080. /**
  137081. * Creates a new SkeletonViewer
  137082. * @param skeleton defines the skeleton to render
  137083. * @param mesh defines the mesh attached to the skeleton
  137084. * @param scene defines the hosting scene
  137085. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  137086. * @param renderingGroupId defines the rendering group id to use with the viewer
  137087. * @param options All of the extra constructor options for the SkeletonViewer
  137088. */
  137089. constructor(
  137090. /** defines the skeleton to render */
  137091. skeleton: Skeleton,
  137092. /** defines the mesh attached to the skeleton */
  137093. mesh: AbstractMesh,
  137094. /** The Scene scope*/
  137095. scene: Scene,
  137096. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  137097. autoUpdateBonesMatrices?: boolean,
  137098. /** defines the rendering group id to use with the viewer */
  137099. renderingGroupId?: number,
  137100. /** is the options for the viewer */
  137101. options?: Partial<ISkeletonViewerOptions>);
  137102. /** The Dynamic bindings for the update functions */
  137103. private _bindObs;
  137104. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  137105. update(): void;
  137106. /** Gets or sets a boolean indicating if the viewer is enabled */
  137107. set isEnabled(value: boolean);
  137108. get isEnabled(): boolean;
  137109. private _getBonePosition;
  137110. private _getLinesForBonesWithLength;
  137111. private _getLinesForBonesNoLength;
  137112. /** function to revert the mesh and scene back to the initial state. */
  137113. private _revert;
  137114. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  137115. private _getAbsoluteBindPoseToRef;
  137116. /** function to build and bind sphere joint points and spur bone representations. */
  137117. private _buildSpheresAndSpurs;
  137118. private _buildLocalAxes;
  137119. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  137120. private _displayLinesUpdate;
  137121. /** Changes the displayMode of the skeleton viewer
  137122. * @param mode The displayMode numerical value
  137123. */
  137124. changeDisplayMode(mode: number): void;
  137125. /** Sets a display option of the skeleton viewer
  137126. *
  137127. * | Option | Type | Default | Description |
  137128. * | ---------------- | ------- | ------- | ----------- |
  137129. * | 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`. |
  137130. * | 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`. |
  137131. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  137132. * | 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`. |
  137133. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  137134. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  137135. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  137136. *
  137137. * @param option String of the option name
  137138. * @param value The numerical option value
  137139. */
  137140. changeDisplayOptions(option: string, value: number): void;
  137141. /** Release associated resources */
  137142. dispose(): void;
  137143. }
  137144. }
  137145. declare module BABYLON {
  137146. /**
  137147. * Enum for Device Types
  137148. */
  137149. export enum DeviceType {
  137150. /** Generic */
  137151. Generic = 0,
  137152. /** Keyboard */
  137153. Keyboard = 1,
  137154. /** Mouse */
  137155. Mouse = 2,
  137156. /** Touch Pointers */
  137157. Touch = 3,
  137158. /** PS4 Dual Shock */
  137159. DualShock = 4,
  137160. /** Xbox */
  137161. Xbox = 5,
  137162. /** Switch Controller */
  137163. Switch = 6
  137164. }
  137165. /**
  137166. * Enum for All Pointers (Touch/Mouse)
  137167. */
  137168. export enum PointerInput {
  137169. /** Horizontal Axis */
  137170. Horizontal = 0,
  137171. /** Vertical Axis */
  137172. Vertical = 1,
  137173. /** Left Click or Touch */
  137174. LeftClick = 2,
  137175. /** Middle Click */
  137176. MiddleClick = 3,
  137177. /** Right Click */
  137178. RightClick = 4,
  137179. /** Browser Back */
  137180. BrowserBack = 5,
  137181. /** Browser Forward */
  137182. BrowserForward = 6
  137183. }
  137184. /**
  137185. * Enum for Dual Shock Gamepad
  137186. */
  137187. export enum DualShockInput {
  137188. /** Cross */
  137189. Cross = 0,
  137190. /** Circle */
  137191. Circle = 1,
  137192. /** Square */
  137193. Square = 2,
  137194. /** Triangle */
  137195. Triangle = 3,
  137196. /** L1 */
  137197. L1 = 4,
  137198. /** R1 */
  137199. R1 = 5,
  137200. /** L2 */
  137201. L2 = 6,
  137202. /** R2 */
  137203. R2 = 7,
  137204. /** Share */
  137205. Share = 8,
  137206. /** Options */
  137207. Options = 9,
  137208. /** L3 */
  137209. L3 = 10,
  137210. /** R3 */
  137211. R3 = 11,
  137212. /** DPadUp */
  137213. DPadUp = 12,
  137214. /** DPadDown */
  137215. DPadDown = 13,
  137216. /** DPadLeft */
  137217. DPadLeft = 14,
  137218. /** DRight */
  137219. DPadRight = 15,
  137220. /** Home */
  137221. Home = 16,
  137222. /** TouchPad */
  137223. TouchPad = 17,
  137224. /** LStickXAxis */
  137225. LStickXAxis = 18,
  137226. /** LStickYAxis */
  137227. LStickYAxis = 19,
  137228. /** RStickXAxis */
  137229. RStickXAxis = 20,
  137230. /** RStickYAxis */
  137231. RStickYAxis = 21
  137232. }
  137233. /**
  137234. * Enum for Xbox Gamepad
  137235. */
  137236. export enum XboxInput {
  137237. /** A */
  137238. A = 0,
  137239. /** B */
  137240. B = 1,
  137241. /** X */
  137242. X = 2,
  137243. /** Y */
  137244. Y = 3,
  137245. /** LB */
  137246. LB = 4,
  137247. /** RB */
  137248. RB = 5,
  137249. /** LT */
  137250. LT = 6,
  137251. /** RT */
  137252. RT = 7,
  137253. /** Back */
  137254. Back = 8,
  137255. /** Start */
  137256. Start = 9,
  137257. /** LS */
  137258. LS = 10,
  137259. /** RS */
  137260. RS = 11,
  137261. /** DPadUp */
  137262. DPadUp = 12,
  137263. /** DPadDown */
  137264. DPadDown = 13,
  137265. /** DPadLeft */
  137266. DPadLeft = 14,
  137267. /** DRight */
  137268. DPadRight = 15,
  137269. /** Home */
  137270. Home = 16,
  137271. /** LStickXAxis */
  137272. LStickXAxis = 17,
  137273. /** LStickYAxis */
  137274. LStickYAxis = 18,
  137275. /** RStickXAxis */
  137276. RStickXAxis = 19,
  137277. /** RStickYAxis */
  137278. RStickYAxis = 20
  137279. }
  137280. /**
  137281. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  137282. */
  137283. export enum SwitchInput {
  137284. /** B */
  137285. B = 0,
  137286. /** A */
  137287. A = 1,
  137288. /** Y */
  137289. Y = 2,
  137290. /** X */
  137291. X = 3,
  137292. /** L */
  137293. L = 4,
  137294. /** R */
  137295. R = 5,
  137296. /** ZL */
  137297. ZL = 6,
  137298. /** ZR */
  137299. ZR = 7,
  137300. /** Minus */
  137301. Minus = 8,
  137302. /** Plus */
  137303. Plus = 9,
  137304. /** LS */
  137305. LS = 10,
  137306. /** RS */
  137307. RS = 11,
  137308. /** DPadUp */
  137309. DPadUp = 12,
  137310. /** DPadDown */
  137311. DPadDown = 13,
  137312. /** DPadLeft */
  137313. DPadLeft = 14,
  137314. /** DRight */
  137315. DPadRight = 15,
  137316. /** Home */
  137317. Home = 16,
  137318. /** Capture */
  137319. Capture = 17,
  137320. /** LStickXAxis */
  137321. LStickXAxis = 18,
  137322. /** LStickYAxis */
  137323. LStickYAxis = 19,
  137324. /** RStickXAxis */
  137325. RStickXAxis = 20,
  137326. /** RStickYAxis */
  137327. RStickYAxis = 21
  137328. }
  137329. }
  137330. declare module BABYLON {
  137331. /**
  137332. * This class will take all inputs from Keyboard, Pointer, and
  137333. * any Gamepads and provide a polling system that all devices
  137334. * will use. This class assumes that there will only be one
  137335. * pointer device and one keyboard.
  137336. */
  137337. export class DeviceInputSystem implements IDisposable {
  137338. /**
  137339. * Returns onDeviceConnected callback property
  137340. * @returns Callback with function to execute when a device is connected
  137341. */
  137342. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  137343. /**
  137344. * Sets callback function when a device is connected and executes against all connected devices
  137345. * @param callback Function to execute when a device is connected
  137346. */
  137347. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  137348. /**
  137349. * Callback to be triggered when a device is disconnected
  137350. */
  137351. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  137352. /**
  137353. * Callback to be triggered when event driven input is updated
  137354. */
  137355. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  137356. private _inputs;
  137357. private _gamepads;
  137358. private _keyboardActive;
  137359. private _pointerActive;
  137360. private _elementToAttachTo;
  137361. private _keyboardDownEvent;
  137362. private _keyboardUpEvent;
  137363. private _pointerMoveEvent;
  137364. private _pointerDownEvent;
  137365. private _pointerUpEvent;
  137366. private _gamepadConnectedEvent;
  137367. private _gamepadDisconnectedEvent;
  137368. private _onDeviceConnected;
  137369. private static _MAX_KEYCODES;
  137370. private static _MAX_POINTER_INPUTS;
  137371. private constructor();
  137372. /**
  137373. * Creates a new DeviceInputSystem instance
  137374. * @param engine Engine to pull input element from
  137375. * @returns The new instance
  137376. */
  137377. static Create(engine: Engine): DeviceInputSystem;
  137378. /**
  137379. * Checks for current device input value, given an id and input index
  137380. * @param deviceName Id of connected device
  137381. * @param inputIndex Index of device input
  137382. * @returns Current value of input
  137383. */
  137384. /**
  137385. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  137386. * @param deviceType Enum specifiying device type
  137387. * @param deviceSlot "Slot" or index that device is referenced in
  137388. * @param inputIndex Id of input to be checked
  137389. * @returns Current value of input
  137390. */
  137391. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  137392. /**
  137393. * Dispose of all the eventlisteners
  137394. */
  137395. dispose(): void;
  137396. /**
  137397. * Checks for existing connections to devices and register them, if necessary
  137398. * Currently handles gamepads and mouse
  137399. */
  137400. private _checkForConnectedDevices;
  137401. /**
  137402. * Add a gamepad to the DeviceInputSystem
  137403. * @param gamepad A single DOM Gamepad object
  137404. */
  137405. private _addGamePad;
  137406. /**
  137407. * Add pointer device to DeviceInputSystem
  137408. * @param deviceType Type of Pointer to add
  137409. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  137410. * @param currentX Current X at point of adding
  137411. * @param currentY Current Y at point of adding
  137412. */
  137413. private _addPointerDevice;
  137414. /**
  137415. * Add device and inputs to device array
  137416. * @param deviceType Enum specifiying device type
  137417. * @param deviceSlot "Slot" or index that device is referenced in
  137418. * @param numberOfInputs Number of input entries to create for given device
  137419. */
  137420. private _registerDevice;
  137421. /**
  137422. * Given a specific device name, remove that device from the device map
  137423. * @param deviceType Enum specifiying device type
  137424. * @param deviceSlot "Slot" or index that device is referenced in
  137425. */
  137426. private _unregisterDevice;
  137427. /**
  137428. * Handle all actions that come from keyboard interaction
  137429. */
  137430. private _handleKeyActions;
  137431. /**
  137432. * Handle all actions that come from pointer interaction
  137433. */
  137434. private _handlePointerActions;
  137435. /**
  137436. * Handle all actions that come from gamepad interaction
  137437. */
  137438. private _handleGamepadActions;
  137439. /**
  137440. * Update all non-event based devices with each frame
  137441. * @param deviceType Enum specifiying device type
  137442. * @param deviceSlot "Slot" or index that device is referenced in
  137443. * @param inputIndex Id of input to be checked
  137444. */
  137445. private _updateDevice;
  137446. /**
  137447. * Gets DeviceType from the device name
  137448. * @param deviceName Name of Device from DeviceInputSystem
  137449. * @returns DeviceType enum value
  137450. */
  137451. private _getGamepadDeviceType;
  137452. }
  137453. }
  137454. declare module BABYLON {
  137455. /**
  137456. * Type to handle enforcement of inputs
  137457. */
  137458. 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;
  137459. }
  137460. declare module BABYLON {
  137461. /**
  137462. * Class that handles all input for a specific device
  137463. */
  137464. export class DeviceSource<T extends DeviceType> {
  137465. /** Type of device */
  137466. readonly deviceType: DeviceType;
  137467. /** "Slot" or index that device is referenced in */
  137468. readonly deviceSlot: number;
  137469. /**
  137470. * Observable to handle device input changes per device
  137471. */
  137472. readonly onInputChangedObservable: Observable<{
  137473. inputIndex: DeviceInput<T>;
  137474. previousState: Nullable<number>;
  137475. currentState: Nullable<number>;
  137476. }>;
  137477. private readonly _deviceInputSystem;
  137478. /**
  137479. * Default Constructor
  137480. * @param deviceInputSystem Reference to DeviceInputSystem
  137481. * @param deviceType Type of device
  137482. * @param deviceSlot "Slot" or index that device is referenced in
  137483. */
  137484. constructor(deviceInputSystem: DeviceInputSystem,
  137485. /** Type of device */
  137486. deviceType: DeviceType,
  137487. /** "Slot" or index that device is referenced in */
  137488. deviceSlot?: number);
  137489. /**
  137490. * Get input for specific input
  137491. * @param inputIndex index of specific input on device
  137492. * @returns Input value from DeviceInputSystem
  137493. */
  137494. getInput(inputIndex: DeviceInput<T>): number;
  137495. }
  137496. /**
  137497. * Class to keep track of devices
  137498. */
  137499. export class DeviceSourceManager implements IDisposable {
  137500. /**
  137501. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  137502. */
  137503. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  137504. /**
  137505. * Observable to be triggered when after a device is disconnected
  137506. */
  137507. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  137508. private readonly _devices;
  137509. private readonly _firstDevice;
  137510. private readonly _deviceInputSystem;
  137511. /**
  137512. * Default Constructor
  137513. * @param engine engine to pull input element from
  137514. */
  137515. constructor(engine: Engine);
  137516. /**
  137517. * Gets a DeviceSource, given a type and slot
  137518. * @param deviceType Enum specifying device type
  137519. * @param deviceSlot "Slot" or index that device is referenced in
  137520. * @returns DeviceSource object
  137521. */
  137522. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  137523. /**
  137524. * Gets an array of DeviceSource objects for a given device type
  137525. * @param deviceType Enum specifying device type
  137526. * @returns Array of DeviceSource objects
  137527. */
  137528. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  137529. /**
  137530. * Returns a read-only list of all available devices
  137531. * @returns Read-only array with active devices
  137532. */
  137533. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  137534. /**
  137535. * Dispose of DeviceInputSystem and other parts
  137536. */
  137537. dispose(): void;
  137538. /**
  137539. * Function to add device name to device list
  137540. * @param deviceType Enum specifying device type
  137541. * @param deviceSlot "Slot" or index that device is referenced in
  137542. */
  137543. private _addDevice;
  137544. /**
  137545. * Function to remove device name to device list
  137546. * @param deviceType Enum specifying device type
  137547. * @param deviceSlot "Slot" or index that device is referenced in
  137548. */
  137549. private _removeDevice;
  137550. /**
  137551. * Updates array storing first connected device of each type
  137552. * @param type Type of Device
  137553. */
  137554. private _updateFirstDevices;
  137555. }
  137556. }
  137557. declare module BABYLON {
  137558. /**
  137559. * Options to create the null engine
  137560. */
  137561. export class NullEngineOptions {
  137562. /**
  137563. * Render width (Default: 512)
  137564. */
  137565. renderWidth: number;
  137566. /**
  137567. * Render height (Default: 256)
  137568. */
  137569. renderHeight: number;
  137570. /**
  137571. * Texture size (Default: 512)
  137572. */
  137573. textureSize: number;
  137574. /**
  137575. * If delta time between frames should be constant
  137576. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137577. */
  137578. deterministicLockstep: boolean;
  137579. /**
  137580. * Maximum about of steps between frames (Default: 4)
  137581. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137582. */
  137583. lockstepMaxSteps: number;
  137584. /**
  137585. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  137586. */
  137587. useHighPrecisionMatrix?: boolean;
  137588. }
  137589. /**
  137590. * The null engine class provides support for headless version of babylon.js.
  137591. * This can be used in server side scenario or for testing purposes
  137592. */
  137593. export class NullEngine extends Engine {
  137594. private _options;
  137595. /**
  137596. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  137597. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137598. * @returns true if engine is in deterministic lock step mode
  137599. */
  137600. isDeterministicLockStep(): boolean;
  137601. /**
  137602. * Gets the max steps when engine is running in deterministic lock step
  137603. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137604. * @returns the max steps
  137605. */
  137606. getLockstepMaxSteps(): number;
  137607. /**
  137608. * Gets the current hardware scaling level.
  137609. * By default the hardware scaling level is computed from the window device ratio.
  137610. * 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.
  137611. * @returns a number indicating the current hardware scaling level
  137612. */
  137613. getHardwareScalingLevel(): number;
  137614. constructor(options?: NullEngineOptions);
  137615. /**
  137616. * Creates a vertex buffer
  137617. * @param vertices the data for the vertex buffer
  137618. * @returns the new WebGL static buffer
  137619. */
  137620. createVertexBuffer(vertices: FloatArray): DataBuffer;
  137621. /**
  137622. * Creates a new index buffer
  137623. * @param indices defines the content of the index buffer
  137624. * @param updatable defines if the index buffer must be updatable
  137625. * @returns a new webGL buffer
  137626. */
  137627. createIndexBuffer(indices: IndicesArray): DataBuffer;
  137628. /**
  137629. * Clear the current render buffer or the current render target (if any is set up)
  137630. * @param color defines the color to use
  137631. * @param backBuffer defines if the back buffer must be cleared
  137632. * @param depth defines if the depth buffer must be cleared
  137633. * @param stencil defines if the stencil buffer must be cleared
  137634. */
  137635. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  137636. /**
  137637. * Gets the current render width
  137638. * @param useScreen defines if screen size must be used (or the current render target if any)
  137639. * @returns a number defining the current render width
  137640. */
  137641. getRenderWidth(useScreen?: boolean): number;
  137642. /**
  137643. * Gets the current render height
  137644. * @param useScreen defines if screen size must be used (or the current render target if any)
  137645. * @returns a number defining the current render height
  137646. */
  137647. getRenderHeight(useScreen?: boolean): number;
  137648. /**
  137649. * Set the WebGL's viewport
  137650. * @param viewport defines the viewport element to be used
  137651. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  137652. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  137653. */
  137654. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  137655. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  137656. /**
  137657. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  137658. * @param pipelineContext defines the pipeline context to use
  137659. * @param uniformsNames defines the list of uniform names
  137660. * @returns an array of webGL uniform locations
  137661. */
  137662. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  137663. /**
  137664. * Gets the lsit of active attributes for a given webGL program
  137665. * @param pipelineContext defines the pipeline context to use
  137666. * @param attributesNames defines the list of attribute names to get
  137667. * @returns an array of indices indicating the offset of each attribute
  137668. */
  137669. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  137670. /**
  137671. * Binds an effect to the webGL context
  137672. * @param effect defines the effect to bind
  137673. */
  137674. bindSamplers(effect: Effect): void;
  137675. /**
  137676. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  137677. * @param effect defines the effect to activate
  137678. */
  137679. enableEffect(effect: Effect): void;
  137680. /**
  137681. * Set various states to the webGL context
  137682. * @param culling defines backface culling state
  137683. * @param zOffset defines the value to apply to zOffset (0 by default)
  137684. * @param force defines if states must be applied even if cache is up to date
  137685. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  137686. */
  137687. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  137688. /**
  137689. * Set the value of an uniform to an array of int32
  137690. * @param uniform defines the webGL uniform location where to store the value
  137691. * @param array defines the array of int32 to store
  137692. * @returns true if value was set
  137693. */
  137694. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137695. /**
  137696. * Set the value of an uniform to an array of int32 (stored as vec2)
  137697. * @param uniform defines the webGL uniform location where to store the value
  137698. * @param array defines the array of int32 to store
  137699. * @returns true if value was set
  137700. */
  137701. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137702. /**
  137703. * Set the value of an uniform to an array of int32 (stored as vec3)
  137704. * @param uniform defines the webGL uniform location where to store the value
  137705. * @param array defines the array of int32 to store
  137706. * @returns true if value was set
  137707. */
  137708. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137709. /**
  137710. * Set the value of an uniform to an array of int32 (stored as vec4)
  137711. * @param uniform defines the webGL uniform location where to store the value
  137712. * @param array defines the array of int32 to store
  137713. * @returns true if value was set
  137714. */
  137715. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137716. /**
  137717. * Set the value of an uniform to an array of float32
  137718. * @param uniform defines the webGL uniform location where to store the value
  137719. * @param array defines the array of float32 to store
  137720. * @returns true if value was set
  137721. */
  137722. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137723. /**
  137724. * Set the value of an uniform to an array of float32 (stored as vec2)
  137725. * @param uniform defines the webGL uniform location where to store the value
  137726. * @param array defines the array of float32 to store
  137727. * @returns true if value was set
  137728. */
  137729. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137730. /**
  137731. * Set the value of an uniform to an array of float32 (stored as vec3)
  137732. * @param uniform defines the webGL uniform location where to store the value
  137733. * @param array defines the array of float32 to store
  137734. * @returns true if value was set
  137735. */
  137736. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137737. /**
  137738. * Set the value of an uniform to an array of float32 (stored as vec4)
  137739. * @param uniform defines the webGL uniform location where to store the value
  137740. * @param array defines the array of float32 to store
  137741. * @returns true if value was set
  137742. */
  137743. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137744. /**
  137745. * Set the value of an uniform to an array of number
  137746. * @param uniform defines the webGL uniform location where to store the value
  137747. * @param array defines the array of number to store
  137748. * @returns true if value was set
  137749. */
  137750. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  137751. /**
  137752. * Set the value of an uniform to an array of number (stored as vec2)
  137753. * @param uniform defines the webGL uniform location where to store the value
  137754. * @param array defines the array of number to store
  137755. * @returns true if value was set
  137756. */
  137757. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  137758. /**
  137759. * Set the value of an uniform to an array of number (stored as vec3)
  137760. * @param uniform defines the webGL uniform location where to store the value
  137761. * @param array defines the array of number to store
  137762. * @returns true if value was set
  137763. */
  137764. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  137765. /**
  137766. * Set the value of an uniform to an array of number (stored as vec4)
  137767. * @param uniform defines the webGL uniform location where to store the value
  137768. * @param array defines the array of number to store
  137769. * @returns true if value was set
  137770. */
  137771. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  137772. /**
  137773. * Set the value of an uniform to an array of float32 (stored as matrices)
  137774. * @param uniform defines the webGL uniform location where to store the value
  137775. * @param matrices defines the array of float32 to store
  137776. * @returns true if value was set
  137777. */
  137778. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  137779. /**
  137780. * Set the value of an uniform to a matrix (3x3)
  137781. * @param uniform defines the webGL uniform location where to store the value
  137782. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  137783. * @returns true if value was set
  137784. */
  137785. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  137786. /**
  137787. * Set the value of an uniform to a matrix (2x2)
  137788. * @param uniform defines the webGL uniform location where to store the value
  137789. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  137790. * @returns true if value was set
  137791. */
  137792. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  137793. /**
  137794. * Set the value of an uniform to a number (float)
  137795. * @param uniform defines the webGL uniform location where to store the value
  137796. * @param value defines the float number to store
  137797. * @returns true if value was set
  137798. */
  137799. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  137800. /**
  137801. * Set the value of an uniform to a vec2
  137802. * @param uniform defines the webGL uniform location where to store the value
  137803. * @param x defines the 1st component of the value
  137804. * @param y defines the 2nd component of the value
  137805. * @returns true if value was set
  137806. */
  137807. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  137808. /**
  137809. * Set the value of an uniform to a vec3
  137810. * @param uniform defines the webGL uniform location where to store the value
  137811. * @param x defines the 1st component of the value
  137812. * @param y defines the 2nd component of the value
  137813. * @param z defines the 3rd component of the value
  137814. * @returns true if value was set
  137815. */
  137816. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  137817. /**
  137818. * Set the value of an uniform to a boolean
  137819. * @param uniform defines the webGL uniform location where to store the value
  137820. * @param bool defines the boolean to store
  137821. * @returns true if value was set
  137822. */
  137823. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  137824. /**
  137825. * Set the value of an uniform to a vec4
  137826. * @param uniform defines the webGL uniform location where to store the value
  137827. * @param x defines the 1st component of the value
  137828. * @param y defines the 2nd component of the value
  137829. * @param z defines the 3rd component of the value
  137830. * @param w defines the 4th component of the value
  137831. * @returns true if value was set
  137832. */
  137833. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  137834. /**
  137835. * Sets the current alpha mode
  137836. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  137837. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  137838. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  137839. */
  137840. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  137841. /**
  137842. * Bind webGl buffers directly to the webGL context
  137843. * @param vertexBuffers defines the vertex buffer to bind
  137844. * @param indexBuffer defines the index buffer to bind
  137845. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  137846. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  137847. * @param effect defines the effect associated with the vertex buffer
  137848. */
  137849. bindBuffers(vertexBuffers: {
  137850. [key: string]: VertexBuffer;
  137851. }, indexBuffer: DataBuffer, effect: Effect): void;
  137852. /**
  137853. * Force the entire cache to be cleared
  137854. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  137855. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  137856. */
  137857. wipeCaches(bruteForce?: boolean): void;
  137858. /**
  137859. * Send a draw order
  137860. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  137861. * @param indexStart defines the starting index
  137862. * @param indexCount defines the number of index to draw
  137863. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  137864. */
  137865. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  137866. /**
  137867. * Draw a list of indexed primitives
  137868. * @param fillMode defines the primitive to use
  137869. * @param indexStart defines the starting index
  137870. * @param indexCount defines the number of index to draw
  137871. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  137872. */
  137873. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  137874. /**
  137875. * Draw a list of unindexed primitives
  137876. * @param fillMode defines the primitive to use
  137877. * @param verticesStart defines the index of first vertex to draw
  137878. * @param verticesCount defines the count of vertices to draw
  137879. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  137880. */
  137881. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  137882. /** @hidden */
  137883. _createTexture(): WebGLTexture;
  137884. /** @hidden */
  137885. _releaseTexture(texture: InternalTexture): void;
  137886. /**
  137887. * Usually called from Texture.ts.
  137888. * Passed information to create a WebGLTexture
  137889. * @param urlArg defines a value which contains one of the following:
  137890. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  137891. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  137892. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  137893. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  137894. * @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)
  137895. * @param scene needed for loading to the correct scene
  137896. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  137897. * @param onLoad optional callback to be called upon successful completion
  137898. * @param onError optional callback to be called upon failure
  137899. * @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
  137900. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  137901. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  137902. * @param forcedExtension defines the extension to use to pick the right loader
  137903. * @param mimeType defines an optional mime type
  137904. * @returns a InternalTexture for assignment back into BABYLON.Texture
  137905. */
  137906. 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;
  137907. /**
  137908. * Creates a new render target texture
  137909. * @param size defines the size of the texture
  137910. * @param options defines the options used to create the texture
  137911. * @returns a new render target texture stored in an InternalTexture
  137912. */
  137913. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  137914. /**
  137915. * Update the sampling mode of a given texture
  137916. * @param samplingMode defines the required sampling mode
  137917. * @param texture defines the texture to update
  137918. */
  137919. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  137920. /**
  137921. * Binds the frame buffer to the specified texture.
  137922. * @param texture The texture to render to or null for the default canvas
  137923. * @param faceIndex The face of the texture to render to in case of cube texture
  137924. * @param requiredWidth The width of the target to render to
  137925. * @param requiredHeight The height of the target to render to
  137926. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  137927. * @param lodLevel defines le lod level to bind to the frame buffer
  137928. */
  137929. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  137930. /**
  137931. * Unbind the current render target texture from the webGL context
  137932. * @param texture defines the render target texture to unbind
  137933. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  137934. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  137935. */
  137936. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  137937. /**
  137938. * Creates a dynamic vertex buffer
  137939. * @param vertices the data for the dynamic vertex buffer
  137940. * @returns the new WebGL dynamic buffer
  137941. */
  137942. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  137943. /**
  137944. * Update the content of a dynamic texture
  137945. * @param texture defines the texture to update
  137946. * @param canvas defines the canvas containing the source
  137947. * @param invertY defines if data must be stored with Y axis inverted
  137948. * @param premulAlpha defines if alpha is stored as premultiplied
  137949. * @param format defines the format of the data
  137950. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  137951. */
  137952. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  137953. /**
  137954. * Gets a boolean indicating if all created effects are ready
  137955. * @returns true if all effects are ready
  137956. */
  137957. areAllEffectsReady(): boolean;
  137958. /**
  137959. * @hidden
  137960. * Get the current error code of the webGL context
  137961. * @returns the error code
  137962. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  137963. */
  137964. getError(): number;
  137965. /** @hidden */
  137966. _getUnpackAlignement(): number;
  137967. /** @hidden */
  137968. _unpackFlipY(value: boolean): void;
  137969. /**
  137970. * Update a dynamic index buffer
  137971. * @param indexBuffer defines the target index buffer
  137972. * @param indices defines the data to update
  137973. * @param offset defines the offset in the target index buffer where update should start
  137974. */
  137975. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  137976. /**
  137977. * Updates a dynamic vertex buffer.
  137978. * @param vertexBuffer the vertex buffer to update
  137979. * @param vertices the data used to update the vertex buffer
  137980. * @param byteOffset the byte offset of the data (optional)
  137981. * @param byteLength the byte length of the data (optional)
  137982. */
  137983. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  137984. /** @hidden */
  137985. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  137986. /** @hidden */
  137987. _bindTexture(channel: number, texture: InternalTexture): void;
  137988. protected _deleteBuffer(buffer: WebGLBuffer): void;
  137989. /**
  137990. * 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
  137991. */
  137992. releaseEffects(): void;
  137993. displayLoadingUI(): void;
  137994. hideLoadingUI(): void;
  137995. /** @hidden */
  137996. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  137997. /** @hidden */
  137998. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  137999. /** @hidden */
  138000. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138001. /** @hidden */
  138002. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  138003. }
  138004. }
  138005. declare module BABYLON {
  138006. /**
  138007. * @hidden
  138008. **/
  138009. export class _TimeToken {
  138010. _startTimeQuery: Nullable<WebGLQuery>;
  138011. _endTimeQuery: Nullable<WebGLQuery>;
  138012. _timeElapsedQuery: Nullable<WebGLQuery>;
  138013. _timeElapsedQueryEnded: boolean;
  138014. }
  138015. }
  138016. declare module BABYLON {
  138017. /** @hidden */
  138018. export class _OcclusionDataStorage {
  138019. /** @hidden */
  138020. occlusionInternalRetryCounter: number;
  138021. /** @hidden */
  138022. isOcclusionQueryInProgress: boolean;
  138023. /** @hidden */
  138024. isOccluded: boolean;
  138025. /** @hidden */
  138026. occlusionRetryCount: number;
  138027. /** @hidden */
  138028. occlusionType: number;
  138029. /** @hidden */
  138030. occlusionQueryAlgorithmType: number;
  138031. }
  138032. interface Engine {
  138033. /**
  138034. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  138035. * @return the new query
  138036. */
  138037. createQuery(): WebGLQuery;
  138038. /**
  138039. * Delete and release a webGL query
  138040. * @param query defines the query to delete
  138041. * @return the current engine
  138042. */
  138043. deleteQuery(query: WebGLQuery): Engine;
  138044. /**
  138045. * Check if a given query has resolved and got its value
  138046. * @param query defines the query to check
  138047. * @returns true if the query got its value
  138048. */
  138049. isQueryResultAvailable(query: WebGLQuery): boolean;
  138050. /**
  138051. * Gets the value of a given query
  138052. * @param query defines the query to check
  138053. * @returns the value of the query
  138054. */
  138055. getQueryResult(query: WebGLQuery): number;
  138056. /**
  138057. * Initiates an occlusion query
  138058. * @param algorithmType defines the algorithm to use
  138059. * @param query defines the query to use
  138060. * @returns the current engine
  138061. * @see https://doc.babylonjs.com/features/occlusionquery
  138062. */
  138063. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  138064. /**
  138065. * Ends an occlusion query
  138066. * @see https://doc.babylonjs.com/features/occlusionquery
  138067. * @param algorithmType defines the algorithm to use
  138068. * @returns the current engine
  138069. */
  138070. endOcclusionQuery(algorithmType: number): Engine;
  138071. /**
  138072. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  138073. * Please note that only one query can be issued at a time
  138074. * @returns a time token used to track the time span
  138075. */
  138076. startTimeQuery(): Nullable<_TimeToken>;
  138077. /**
  138078. * Ends a time query
  138079. * @param token defines the token used to measure the time span
  138080. * @returns the time spent (in ns)
  138081. */
  138082. endTimeQuery(token: _TimeToken): int;
  138083. /** @hidden */
  138084. _currentNonTimestampToken: Nullable<_TimeToken>;
  138085. /** @hidden */
  138086. _createTimeQuery(): WebGLQuery;
  138087. /** @hidden */
  138088. _deleteTimeQuery(query: WebGLQuery): void;
  138089. /** @hidden */
  138090. _getGlAlgorithmType(algorithmType: number): number;
  138091. /** @hidden */
  138092. _getTimeQueryResult(query: WebGLQuery): any;
  138093. /** @hidden */
  138094. _getTimeQueryAvailability(query: WebGLQuery): any;
  138095. }
  138096. interface AbstractMesh {
  138097. /**
  138098. * Backing filed
  138099. * @hidden
  138100. */
  138101. __occlusionDataStorage: _OcclusionDataStorage;
  138102. /**
  138103. * Access property
  138104. * @hidden
  138105. */
  138106. _occlusionDataStorage: _OcclusionDataStorage;
  138107. /**
  138108. * 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.
  138109. * The default value is -1 which means don't break the query and wait till the result
  138110. * @see https://doc.babylonjs.com/features/occlusionquery
  138111. */
  138112. occlusionRetryCount: number;
  138113. /**
  138114. * 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:
  138115. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  138116. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  138117. * * 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.
  138118. * @see https://doc.babylonjs.com/features/occlusionquery
  138119. */
  138120. occlusionType: number;
  138121. /**
  138122. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  138123. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  138124. * * 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.
  138125. * @see https://doc.babylonjs.com/features/occlusionquery
  138126. */
  138127. occlusionQueryAlgorithmType: number;
  138128. /**
  138129. * 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
  138130. * @see https://doc.babylonjs.com/features/occlusionquery
  138131. */
  138132. isOccluded: boolean;
  138133. /**
  138134. * Flag to check the progress status of the query
  138135. * @see https://doc.babylonjs.com/features/occlusionquery
  138136. */
  138137. isOcclusionQueryInProgress: boolean;
  138138. }
  138139. }
  138140. declare module BABYLON {
  138141. /** @hidden */
  138142. export var _forceTransformFeedbackToBundle: boolean;
  138143. interface Engine {
  138144. /**
  138145. * Creates a webGL transform feedback object
  138146. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  138147. * @returns the webGL transform feedback object
  138148. */
  138149. createTransformFeedback(): WebGLTransformFeedback;
  138150. /**
  138151. * Delete a webGL transform feedback object
  138152. * @param value defines the webGL transform feedback object to delete
  138153. */
  138154. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  138155. /**
  138156. * Bind a webGL transform feedback object to the webgl context
  138157. * @param value defines the webGL transform feedback object to bind
  138158. */
  138159. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  138160. /**
  138161. * Begins a transform feedback operation
  138162. * @param usePoints defines if points or triangles must be used
  138163. */
  138164. beginTransformFeedback(usePoints: boolean): void;
  138165. /**
  138166. * Ends a transform feedback operation
  138167. */
  138168. endTransformFeedback(): void;
  138169. /**
  138170. * Specify the varyings to use with transform feedback
  138171. * @param program defines the associated webGL program
  138172. * @param value defines the list of strings representing the varying names
  138173. */
  138174. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  138175. /**
  138176. * Bind a webGL buffer for a transform feedback operation
  138177. * @param value defines the webGL buffer to bind
  138178. */
  138179. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  138180. }
  138181. }
  138182. declare module BABYLON {
  138183. /**
  138184. * Class used to define an additional view for the engine
  138185. * @see https://doc.babylonjs.com/how_to/multi_canvases
  138186. */
  138187. export class EngineView {
  138188. /** Defines the canvas where to render the view */
  138189. target: HTMLCanvasElement;
  138190. /** Defines an optional camera used to render the view (will use active camera else) */
  138191. camera?: Camera;
  138192. }
  138193. interface Engine {
  138194. /**
  138195. * Gets or sets the HTML element to use for attaching events
  138196. */
  138197. inputElement: Nullable<HTMLElement>;
  138198. /**
  138199. * Gets the current engine view
  138200. * @see https://doc.babylonjs.com/how_to/multi_canvases
  138201. */
  138202. activeView: Nullable<EngineView>;
  138203. /** Gets or sets the list of views */
  138204. views: EngineView[];
  138205. /**
  138206. * Register a new child canvas
  138207. * @param canvas defines the canvas to register
  138208. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  138209. * @returns the associated view
  138210. */
  138211. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  138212. /**
  138213. * Remove a registered child canvas
  138214. * @param canvas defines the canvas to remove
  138215. * @returns the current engine
  138216. */
  138217. unRegisterView(canvas: HTMLCanvasElement): Engine;
  138218. }
  138219. }
  138220. declare module BABYLON {
  138221. interface Engine {
  138222. /** @hidden */
  138223. _excludedCompressedTextures: string[];
  138224. /** @hidden */
  138225. _textureFormatInUse: string;
  138226. /**
  138227. * Gets the list of texture formats supported
  138228. */
  138229. readonly texturesSupported: Array<string>;
  138230. /**
  138231. * Gets the texture format in use
  138232. */
  138233. readonly textureFormatInUse: Nullable<string>;
  138234. /**
  138235. * Set the compressed texture extensions or file names to skip.
  138236. *
  138237. * @param skippedFiles defines the list of those texture files you want to skip
  138238. * Example: [".dds", ".env", "myfile.png"]
  138239. */
  138240. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  138241. /**
  138242. * Set the compressed texture format to use, based on the formats you have, and the formats
  138243. * supported by the hardware / browser.
  138244. *
  138245. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  138246. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  138247. * to API arguments needed to compressed textures. This puts the burden on the container
  138248. * generator to house the arcane code for determining these for current & future formats.
  138249. *
  138250. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  138251. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  138252. *
  138253. * Note: The result of this call is not taken into account when a texture is base64.
  138254. *
  138255. * @param formatsAvailable defines the list of those format families you have created
  138256. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  138257. *
  138258. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  138259. * @returns The extension selected.
  138260. */
  138261. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  138262. }
  138263. }
  138264. declare module BABYLON {
  138265. /** @hidden */
  138266. export var rgbdEncodePixelShader: {
  138267. name: string;
  138268. shader: string;
  138269. };
  138270. }
  138271. declare module BABYLON {
  138272. /**
  138273. * Raw texture data and descriptor sufficient for WebGL texture upload
  138274. */
  138275. export interface EnvironmentTextureInfo {
  138276. /**
  138277. * Version of the environment map
  138278. */
  138279. version: number;
  138280. /**
  138281. * Width of image
  138282. */
  138283. width: number;
  138284. /**
  138285. * Irradiance information stored in the file.
  138286. */
  138287. irradiance: any;
  138288. /**
  138289. * Specular information stored in the file.
  138290. */
  138291. specular: any;
  138292. }
  138293. /**
  138294. * Defines One Image in the file. It requires only the position in the file
  138295. * as well as the length.
  138296. */
  138297. interface BufferImageData {
  138298. /**
  138299. * Length of the image data.
  138300. */
  138301. length: number;
  138302. /**
  138303. * Position of the data from the null terminator delimiting the end of the JSON.
  138304. */
  138305. position: number;
  138306. }
  138307. /**
  138308. * Defines the specular data enclosed in the file.
  138309. * This corresponds to the version 1 of the data.
  138310. */
  138311. export interface EnvironmentTextureSpecularInfoV1 {
  138312. /**
  138313. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  138314. */
  138315. specularDataPosition?: number;
  138316. /**
  138317. * This contains all the images data needed to reconstruct the cubemap.
  138318. */
  138319. mipmaps: Array<BufferImageData>;
  138320. /**
  138321. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  138322. */
  138323. lodGenerationScale: number;
  138324. }
  138325. /**
  138326. * Sets of helpers addressing the serialization and deserialization of environment texture
  138327. * stored in a BabylonJS env file.
  138328. * Those files are usually stored as .env files.
  138329. */
  138330. export class EnvironmentTextureTools {
  138331. /**
  138332. * Magic number identifying the env file.
  138333. */
  138334. private static _MagicBytes;
  138335. /**
  138336. * Gets the environment info from an env file.
  138337. * @param data The array buffer containing the .env bytes.
  138338. * @returns the environment file info (the json header) if successfully parsed.
  138339. */
  138340. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  138341. /**
  138342. * Creates an environment texture from a loaded cube texture.
  138343. * @param texture defines the cube texture to convert in env file
  138344. * @return a promise containing the environment data if succesfull.
  138345. */
  138346. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  138347. /**
  138348. * Creates a JSON representation of the spherical data.
  138349. * @param texture defines the texture containing the polynomials
  138350. * @return the JSON representation of the spherical info
  138351. */
  138352. private static _CreateEnvTextureIrradiance;
  138353. /**
  138354. * Creates the ArrayBufferViews used for initializing environment texture image data.
  138355. * @param data the image data
  138356. * @param info parameters that determine what views will be created for accessing the underlying buffer
  138357. * @return the views described by info providing access to the underlying buffer
  138358. */
  138359. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  138360. /**
  138361. * Uploads the texture info contained in the env file to the GPU.
  138362. * @param texture defines the internal texture to upload to
  138363. * @param data defines the data to load
  138364. * @param info defines the texture info retrieved through the GetEnvInfo method
  138365. * @returns a promise
  138366. */
  138367. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  138368. private static _OnImageReadyAsync;
  138369. /**
  138370. * Uploads the levels of image data to the GPU.
  138371. * @param texture defines the internal texture to upload to
  138372. * @param imageData defines the array buffer views of image data [mipmap][face]
  138373. * @returns a promise
  138374. */
  138375. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  138376. /**
  138377. * Uploads spherical polynomials information to the texture.
  138378. * @param texture defines the texture we are trying to upload the information to
  138379. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  138380. */
  138381. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  138382. /** @hidden */
  138383. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  138384. }
  138385. }
  138386. declare module BABYLON {
  138387. /**
  138388. * Class used to inline functions in shader code
  138389. */
  138390. export class ShaderCodeInliner {
  138391. private static readonly _RegexpFindFunctionNameAndType;
  138392. private _sourceCode;
  138393. private _functionDescr;
  138394. private _numMaxIterations;
  138395. /** Gets or sets the token used to mark the functions to inline */
  138396. inlineToken: string;
  138397. /** Gets or sets the debug mode */
  138398. debug: boolean;
  138399. /** Gets the code after the inlining process */
  138400. get code(): string;
  138401. /**
  138402. * Initializes the inliner
  138403. * @param sourceCode shader code source to inline
  138404. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  138405. */
  138406. constructor(sourceCode: string, numMaxIterations?: number);
  138407. /**
  138408. * Start the processing of the shader code
  138409. */
  138410. processCode(): void;
  138411. private _collectFunctions;
  138412. private _processInlining;
  138413. private _extractBetweenMarkers;
  138414. private _skipWhitespaces;
  138415. private _removeComments;
  138416. private _replaceFunctionCallsByCode;
  138417. private _findBackward;
  138418. private _escapeRegExp;
  138419. private _replaceNames;
  138420. }
  138421. }
  138422. declare module BABYLON {
  138423. /**
  138424. * Container for accessors for natively-stored mesh data buffers.
  138425. */
  138426. class NativeDataBuffer extends DataBuffer {
  138427. /**
  138428. * Accessor value used to identify/retrieve a natively-stored index buffer.
  138429. */
  138430. nativeIndexBuffer?: any;
  138431. /**
  138432. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  138433. */
  138434. nativeVertexBuffer?: any;
  138435. }
  138436. /** @hidden */
  138437. class NativeTexture extends InternalTexture {
  138438. getInternalTexture(): InternalTexture;
  138439. getViewCount(): number;
  138440. }
  138441. /** @hidden */
  138442. export class NativeEngine extends Engine {
  138443. private readonly _native;
  138444. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  138445. private readonly INVALID_HANDLE;
  138446. private _boundBuffersVertexArray;
  138447. private _currentDepthTest;
  138448. getHardwareScalingLevel(): number;
  138449. constructor();
  138450. dispose(): void;
  138451. /**
  138452. * Can be used to override the current requestAnimationFrame requester.
  138453. * @hidden
  138454. */
  138455. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  138456. /**
  138457. * Override default engine behavior.
  138458. * @param color
  138459. * @param backBuffer
  138460. * @param depth
  138461. * @param stencil
  138462. */
  138463. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  138464. /**
  138465. * Gets host document
  138466. * @returns the host document object
  138467. */
  138468. getHostDocument(): Nullable<Document>;
  138469. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  138470. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  138471. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  138472. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  138473. [key: string]: VertexBuffer;
  138474. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  138475. bindBuffers(vertexBuffers: {
  138476. [key: string]: VertexBuffer;
  138477. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  138478. recordVertexArrayObject(vertexBuffers: {
  138479. [key: string]: VertexBuffer;
  138480. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  138481. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  138482. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  138483. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  138484. /**
  138485. * Draw a list of indexed primitives
  138486. * @param fillMode defines the primitive to use
  138487. * @param indexStart defines the starting index
  138488. * @param indexCount defines the number of index to draw
  138489. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  138490. */
  138491. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  138492. /**
  138493. * Draw a list of unindexed primitives
  138494. * @param fillMode defines the primitive to use
  138495. * @param verticesStart defines the index of first vertex to draw
  138496. * @param verticesCount defines the count of vertices to draw
  138497. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  138498. */
  138499. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  138500. createPipelineContext(): IPipelineContext;
  138501. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  138502. /** @hidden */
  138503. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  138504. /** @hidden */
  138505. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  138506. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  138507. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  138508. protected _setProgram(program: WebGLProgram): void;
  138509. _releaseEffect(effect: Effect): void;
  138510. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  138511. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  138512. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  138513. bindSamplers(effect: Effect): void;
  138514. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  138515. getRenderWidth(useScreen?: boolean): number;
  138516. getRenderHeight(useScreen?: boolean): number;
  138517. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  138518. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  138519. /**
  138520. * Set the z offset to apply to current rendering
  138521. * @param value defines the offset to apply
  138522. */
  138523. setZOffset(value: number): void;
  138524. /**
  138525. * Gets the current value of the zOffset
  138526. * @returns the current zOffset state
  138527. */
  138528. getZOffset(): number;
  138529. /**
  138530. * Enable or disable depth buffering
  138531. * @param enable defines the state to set
  138532. */
  138533. setDepthBuffer(enable: boolean): void;
  138534. /**
  138535. * Gets a boolean indicating if depth writing is enabled
  138536. * @returns the current depth writing state
  138537. */
  138538. getDepthWrite(): boolean;
  138539. setDepthFunctionToGreater(): void;
  138540. setDepthFunctionToGreaterOrEqual(): void;
  138541. setDepthFunctionToLess(): void;
  138542. setDepthFunctionToLessOrEqual(): void;
  138543. /**
  138544. * Enable or disable depth writing
  138545. * @param enable defines the state to set
  138546. */
  138547. setDepthWrite(enable: boolean): void;
  138548. /**
  138549. * Enable or disable color writing
  138550. * @param enable defines the state to set
  138551. */
  138552. setColorWrite(enable: boolean): void;
  138553. /**
  138554. * Gets a boolean indicating if color writing is enabled
  138555. * @returns the current color writing state
  138556. */
  138557. getColorWrite(): boolean;
  138558. /**
  138559. * Sets alpha constants used by some alpha blending modes
  138560. * @param r defines the red component
  138561. * @param g defines the green component
  138562. * @param b defines the blue component
  138563. * @param a defines the alpha component
  138564. */
  138565. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  138566. /**
  138567. * Sets the current alpha mode
  138568. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  138569. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  138570. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  138571. */
  138572. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  138573. /**
  138574. * Gets the current alpha mode
  138575. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  138576. * @returns the current alpha mode
  138577. */
  138578. getAlphaMode(): number;
  138579. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  138580. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138581. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138582. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138583. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138584. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138585. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138586. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138587. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138588. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  138589. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  138590. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  138591. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  138592. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  138593. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  138594. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  138595. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  138596. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  138597. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  138598. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  138599. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  138600. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  138601. wipeCaches(bruteForce?: boolean): void;
  138602. _createTexture(): WebGLTexture;
  138603. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  138604. /**
  138605. * Update the content of a dynamic texture
  138606. * @param texture defines the texture to update
  138607. * @param canvas defines the canvas containing the source
  138608. * @param invertY defines if data must be stored with Y axis inverted
  138609. * @param premulAlpha defines if alpha is stored as premultiplied
  138610. * @param format defines the format of the data
  138611. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  138612. */
  138613. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  138614. /**
  138615. * Usually called from Texture.ts.
  138616. * Passed information to create a WebGLTexture
  138617. * @param url defines a value which contains one of the following:
  138618. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  138619. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  138620. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  138621. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  138622. * @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)
  138623. * @param scene needed for loading to the correct scene
  138624. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  138625. * @param onLoad optional callback to be called upon successful completion
  138626. * @param onError optional callback to be called upon failure
  138627. * @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
  138628. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  138629. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  138630. * @param forcedExtension defines the extension to use to pick the right loader
  138631. * @param mimeType defines an optional mime type
  138632. * @param loaderOptions options to be passed to the loader
  138633. * @returns a InternalTexture for assignment back into BABYLON.Texture
  138634. */
  138635. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  138636. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  138637. _releaseFramebufferObjects(texture: InternalTexture): void;
  138638. /**
  138639. * Creates a cube texture
  138640. * @param rootUrl defines the url where the files to load is located
  138641. * @param scene defines the current scene
  138642. * @param files defines the list of files to load (1 per face)
  138643. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  138644. * @param onLoad defines an optional callback raised when the texture is loaded
  138645. * @param onError defines an optional callback raised if there is an issue to load the texture
  138646. * @param format defines the format of the data
  138647. * @param forcedExtension defines the extension to use to pick the right loader
  138648. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  138649. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  138650. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  138651. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  138652. * @returns the cube texture as an InternalTexture
  138653. */
  138654. 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;
  138655. createRenderTargetTexture(size: number | {
  138656. width: number;
  138657. height: number;
  138658. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  138659. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  138660. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  138661. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  138662. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  138663. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  138664. /**
  138665. * Updates a dynamic vertex buffer.
  138666. * @param vertexBuffer the vertex buffer to update
  138667. * @param data the data used to update the vertex buffer
  138668. * @param byteOffset the byte offset of the data (optional)
  138669. * @param byteLength the byte length of the data (optional)
  138670. */
  138671. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  138672. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  138673. private _updateAnisotropicLevel;
  138674. private _getAddressMode;
  138675. /** @hidden */
  138676. _bindTexture(channel: number, texture: InternalTexture): void;
  138677. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  138678. releaseEffects(): void;
  138679. /** @hidden */
  138680. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138681. /** @hidden */
  138682. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138683. /** @hidden */
  138684. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138685. /** @hidden */
  138686. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  138687. private _getNativeSamplingMode;
  138688. private _getNativeTextureFormat;
  138689. private _getNativeAlphaMode;
  138690. private _getNativeAttribType;
  138691. }
  138692. }
  138693. declare module BABYLON {
  138694. /**
  138695. * Gather the list of clipboard event types as constants.
  138696. */
  138697. export class ClipboardEventTypes {
  138698. /**
  138699. * The clipboard event is fired when a copy command is active (pressed).
  138700. */
  138701. static readonly COPY: number;
  138702. /**
  138703. * The clipboard event is fired when a cut command is active (pressed).
  138704. */
  138705. static readonly CUT: number;
  138706. /**
  138707. * The clipboard event is fired when a paste command is active (pressed).
  138708. */
  138709. static readonly PASTE: number;
  138710. }
  138711. /**
  138712. * This class is used to store clipboard related info for the onClipboardObservable event.
  138713. */
  138714. export class ClipboardInfo {
  138715. /**
  138716. * Defines the type of event (BABYLON.ClipboardEventTypes)
  138717. */
  138718. type: number;
  138719. /**
  138720. * Defines the related dom event
  138721. */
  138722. event: ClipboardEvent;
  138723. /**
  138724. *Creates an instance of ClipboardInfo.
  138725. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  138726. * @param event Defines the related dom event
  138727. */
  138728. constructor(
  138729. /**
  138730. * Defines the type of event (BABYLON.ClipboardEventTypes)
  138731. */
  138732. type: number,
  138733. /**
  138734. * Defines the related dom event
  138735. */
  138736. event: ClipboardEvent);
  138737. /**
  138738. * Get the clipboard event's type from the keycode.
  138739. * @param keyCode Defines the keyCode for the current keyboard event.
  138740. * @return {number}
  138741. */
  138742. static GetTypeFromCharacter(keyCode: number): number;
  138743. }
  138744. }
  138745. declare module BABYLON {
  138746. /**
  138747. * Google Daydream controller
  138748. */
  138749. export class DaydreamController extends WebVRController {
  138750. /**
  138751. * Base Url for the controller model.
  138752. */
  138753. static MODEL_BASE_URL: string;
  138754. /**
  138755. * File name for the controller model.
  138756. */
  138757. static MODEL_FILENAME: string;
  138758. /**
  138759. * Gamepad Id prefix used to identify Daydream Controller.
  138760. */
  138761. static readonly GAMEPAD_ID_PREFIX: string;
  138762. /**
  138763. * Creates a new DaydreamController from a gamepad
  138764. * @param vrGamepad the gamepad that the controller should be created from
  138765. */
  138766. constructor(vrGamepad: any);
  138767. /**
  138768. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  138769. * @param scene scene in which to add meshes
  138770. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  138771. */
  138772. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  138773. /**
  138774. * Called once for each button that changed state since the last frame
  138775. * @param buttonIdx Which button index changed
  138776. * @param state New state of the button
  138777. * @param changes Which properties on the state changed since last frame
  138778. */
  138779. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  138780. }
  138781. }
  138782. declare module BABYLON {
  138783. /**
  138784. * Gear VR Controller
  138785. */
  138786. export class GearVRController extends WebVRController {
  138787. /**
  138788. * Base Url for the controller model.
  138789. */
  138790. static MODEL_BASE_URL: string;
  138791. /**
  138792. * File name for the controller model.
  138793. */
  138794. static MODEL_FILENAME: string;
  138795. /**
  138796. * Gamepad Id prefix used to identify this controller.
  138797. */
  138798. static readonly GAMEPAD_ID_PREFIX: string;
  138799. private readonly _buttonIndexToObservableNameMap;
  138800. /**
  138801. * Creates a new GearVRController from a gamepad
  138802. * @param vrGamepad the gamepad that the controller should be created from
  138803. */
  138804. constructor(vrGamepad: any);
  138805. /**
  138806. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  138807. * @param scene scene in which to add meshes
  138808. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  138809. */
  138810. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  138811. /**
  138812. * Called once for each button that changed state since the last frame
  138813. * @param buttonIdx Which button index changed
  138814. * @param state New state of the button
  138815. * @param changes Which properties on the state changed since last frame
  138816. */
  138817. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  138818. }
  138819. }
  138820. declare module BABYLON {
  138821. /**
  138822. * Generic Controller
  138823. */
  138824. export class GenericController extends WebVRController {
  138825. /**
  138826. * Base Url for the controller model.
  138827. */
  138828. static readonly MODEL_BASE_URL: string;
  138829. /**
  138830. * File name for the controller model.
  138831. */
  138832. static readonly MODEL_FILENAME: string;
  138833. /**
  138834. * Creates a new GenericController from a gamepad
  138835. * @param vrGamepad the gamepad that the controller should be created from
  138836. */
  138837. constructor(vrGamepad: any);
  138838. /**
  138839. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  138840. * @param scene scene in which to add meshes
  138841. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  138842. */
  138843. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  138844. /**
  138845. * Called once for each button that changed state since the last frame
  138846. * @param buttonIdx Which button index changed
  138847. * @param state New state of the button
  138848. * @param changes Which properties on the state changed since last frame
  138849. */
  138850. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  138851. }
  138852. }
  138853. declare module BABYLON {
  138854. /**
  138855. * Oculus Touch Controller
  138856. */
  138857. export class OculusTouchController extends WebVRController {
  138858. /**
  138859. * Base Url for the controller model.
  138860. */
  138861. static MODEL_BASE_URL: string;
  138862. /**
  138863. * File name for the left controller model.
  138864. */
  138865. static MODEL_LEFT_FILENAME: string;
  138866. /**
  138867. * File name for the right controller model.
  138868. */
  138869. static MODEL_RIGHT_FILENAME: string;
  138870. /**
  138871. * Base Url for the Quest controller model.
  138872. */
  138873. static QUEST_MODEL_BASE_URL: string;
  138874. /**
  138875. * @hidden
  138876. * If the controllers are running on a device that needs the updated Quest controller models
  138877. */
  138878. static _IsQuest: boolean;
  138879. /**
  138880. * Fired when the secondary trigger on this controller is modified
  138881. */
  138882. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  138883. /**
  138884. * Fired when the thumb rest on this controller is modified
  138885. */
  138886. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  138887. /**
  138888. * Creates a new OculusTouchController from a gamepad
  138889. * @param vrGamepad the gamepad that the controller should be created from
  138890. */
  138891. constructor(vrGamepad: any);
  138892. /**
  138893. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  138894. * @param scene scene in which to add meshes
  138895. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  138896. */
  138897. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  138898. /**
  138899. * Fired when the A button on this controller is modified
  138900. */
  138901. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  138902. /**
  138903. * Fired when the B button on this controller is modified
  138904. */
  138905. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  138906. /**
  138907. * Fired when the X button on this controller is modified
  138908. */
  138909. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  138910. /**
  138911. * Fired when the Y button on this controller is modified
  138912. */
  138913. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  138914. /**
  138915. * Called once for each button that changed state since the last frame
  138916. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  138917. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  138918. * 2) secondary trigger (same)
  138919. * 3) A (right) X (left), touch, pressed = value
  138920. * 4) B / Y
  138921. * 5) thumb rest
  138922. * @param buttonIdx Which button index changed
  138923. * @param state New state of the button
  138924. * @param changes Which properties on the state changed since last frame
  138925. */
  138926. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  138927. }
  138928. }
  138929. declare module BABYLON {
  138930. /**
  138931. * Vive Controller
  138932. */
  138933. export class ViveController extends WebVRController {
  138934. /**
  138935. * Base Url for the controller model.
  138936. */
  138937. static MODEL_BASE_URL: string;
  138938. /**
  138939. * File name for the controller model.
  138940. */
  138941. static MODEL_FILENAME: string;
  138942. /**
  138943. * Creates a new ViveController from a gamepad
  138944. * @param vrGamepad the gamepad that the controller should be created from
  138945. */
  138946. constructor(vrGamepad: any);
  138947. /**
  138948. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  138949. * @param scene scene in which to add meshes
  138950. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  138951. */
  138952. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  138953. /**
  138954. * Fired when the left button on this controller is modified
  138955. */
  138956. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  138957. /**
  138958. * Fired when the right button on this controller is modified
  138959. */
  138960. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  138961. /**
  138962. * Fired when the menu button on this controller is modified
  138963. */
  138964. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  138965. /**
  138966. * Called once for each button that changed state since the last frame
  138967. * Vive mapping:
  138968. * 0: touchpad
  138969. * 1: trigger
  138970. * 2: left AND right buttons
  138971. * 3: menu button
  138972. * @param buttonIdx Which button index changed
  138973. * @param state New state of the button
  138974. * @param changes Which properties on the state changed since last frame
  138975. */
  138976. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  138977. }
  138978. }
  138979. declare module BABYLON {
  138980. /**
  138981. * Defines the WindowsMotionController object that the state of the windows motion controller
  138982. */
  138983. export class WindowsMotionController extends WebVRController {
  138984. /**
  138985. * The base url used to load the left and right controller models
  138986. */
  138987. static MODEL_BASE_URL: string;
  138988. /**
  138989. * The name of the left controller model file
  138990. */
  138991. static MODEL_LEFT_FILENAME: string;
  138992. /**
  138993. * The name of the right controller model file
  138994. */
  138995. static MODEL_RIGHT_FILENAME: string;
  138996. /**
  138997. * The controller name prefix for this controller type
  138998. */
  138999. static readonly GAMEPAD_ID_PREFIX: string;
  139000. /**
  139001. * The controller id pattern for this controller type
  139002. */
  139003. private static readonly GAMEPAD_ID_PATTERN;
  139004. private _loadedMeshInfo;
  139005. protected readonly _mapping: {
  139006. buttons: string[];
  139007. buttonMeshNames: {
  139008. trigger: string;
  139009. menu: string;
  139010. grip: string;
  139011. thumbstick: string;
  139012. trackpad: string;
  139013. };
  139014. buttonObservableNames: {
  139015. trigger: string;
  139016. menu: string;
  139017. grip: string;
  139018. thumbstick: string;
  139019. trackpad: string;
  139020. };
  139021. axisMeshNames: string[];
  139022. pointingPoseMeshName: string;
  139023. };
  139024. /**
  139025. * Fired when the trackpad on this controller is clicked
  139026. */
  139027. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  139028. /**
  139029. * Fired when the trackpad on this controller is modified
  139030. */
  139031. onTrackpadValuesChangedObservable: Observable<StickValues>;
  139032. /**
  139033. * The current x and y values of this controller's trackpad
  139034. */
  139035. trackpad: StickValues;
  139036. /**
  139037. * Creates a new WindowsMotionController from a gamepad
  139038. * @param vrGamepad the gamepad that the controller should be created from
  139039. */
  139040. constructor(vrGamepad: any);
  139041. /**
  139042. * Fired when the trigger on this controller is modified
  139043. */
  139044. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139045. /**
  139046. * Fired when the menu button on this controller is modified
  139047. */
  139048. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139049. /**
  139050. * Fired when the grip button on this controller is modified
  139051. */
  139052. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139053. /**
  139054. * Fired when the thumbstick button on this controller is modified
  139055. */
  139056. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139057. /**
  139058. * Fired when the touchpad button on this controller is modified
  139059. */
  139060. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139061. /**
  139062. * Fired when the touchpad values on this controller are modified
  139063. */
  139064. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  139065. protected _updateTrackpad(): void;
  139066. /**
  139067. * Called once per frame by the engine.
  139068. */
  139069. update(): void;
  139070. /**
  139071. * Called once for each button that changed state since the last frame
  139072. * @param buttonIdx Which button index changed
  139073. * @param state New state of the button
  139074. * @param changes Which properties on the state changed since last frame
  139075. */
  139076. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  139077. /**
  139078. * Moves the buttons on the controller mesh based on their current state
  139079. * @param buttonName the name of the button to move
  139080. * @param buttonValue the value of the button which determines the buttons new position
  139081. */
  139082. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  139083. /**
  139084. * Moves the axis on the controller mesh based on its current state
  139085. * @param axis the index of the axis
  139086. * @param axisValue the value of the axis which determines the meshes new position
  139087. * @hidden
  139088. */
  139089. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  139090. /**
  139091. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  139092. * @param scene scene in which to add meshes
  139093. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  139094. */
  139095. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  139096. /**
  139097. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  139098. * can be transformed by button presses and axes values, based on this._mapping.
  139099. *
  139100. * @param scene scene in which the meshes exist
  139101. * @param meshes list of meshes that make up the controller model to process
  139102. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  139103. */
  139104. private processModel;
  139105. private createMeshInfo;
  139106. /**
  139107. * Gets the ray of the controller in the direction the controller is pointing
  139108. * @param length the length the resulting ray should be
  139109. * @returns a ray in the direction the controller is pointing
  139110. */
  139111. getForwardRay(length?: number): Ray;
  139112. /**
  139113. * Disposes of the controller
  139114. */
  139115. dispose(): void;
  139116. }
  139117. /**
  139118. * This class represents a new windows motion controller in XR.
  139119. */
  139120. export class XRWindowsMotionController extends WindowsMotionController {
  139121. /**
  139122. * Changing the original WIndowsMotionController mapping to fir the new mapping
  139123. */
  139124. protected readonly _mapping: {
  139125. buttons: string[];
  139126. buttonMeshNames: {
  139127. trigger: string;
  139128. menu: string;
  139129. grip: string;
  139130. thumbstick: string;
  139131. trackpad: string;
  139132. };
  139133. buttonObservableNames: {
  139134. trigger: string;
  139135. menu: string;
  139136. grip: string;
  139137. thumbstick: string;
  139138. trackpad: string;
  139139. };
  139140. axisMeshNames: string[];
  139141. pointingPoseMeshName: string;
  139142. };
  139143. /**
  139144. * Construct a new XR-Based windows motion controller
  139145. *
  139146. * @param gamepadInfo the gamepad object from the browser
  139147. */
  139148. constructor(gamepadInfo: any);
  139149. /**
  139150. * holds the thumbstick values (X,Y)
  139151. */
  139152. thumbstickValues: StickValues;
  139153. /**
  139154. * Fired when the thumbstick on this controller is clicked
  139155. */
  139156. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  139157. /**
  139158. * Fired when the thumbstick on this controller is modified
  139159. */
  139160. onThumbstickValuesChangedObservable: Observable<StickValues>;
  139161. /**
  139162. * Fired when the touchpad button on this controller is modified
  139163. */
  139164. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  139165. /**
  139166. * Fired when the touchpad values on this controller are modified
  139167. */
  139168. onTrackpadValuesChangedObservable: Observable<StickValues>;
  139169. /**
  139170. * Fired when the thumbstick button on this controller is modified
  139171. * here to prevent breaking changes
  139172. */
  139173. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139174. /**
  139175. * updating the thumbstick(!) and not the trackpad.
  139176. * This is named this way due to the difference between WebVR and XR and to avoid
  139177. * changing the parent class.
  139178. */
  139179. protected _updateTrackpad(): void;
  139180. /**
  139181. * Disposes the class with joy
  139182. */
  139183. dispose(): void;
  139184. }
  139185. }
  139186. declare module BABYLON {
  139187. /**
  139188. * A directional light is defined by a direction (what a surprise!).
  139189. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  139190. * 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.
  139191. * Documentation: https://doc.babylonjs.com/babylon101/lights
  139192. */
  139193. export class DirectionalLight extends ShadowLight {
  139194. private _shadowFrustumSize;
  139195. /**
  139196. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  139197. */
  139198. get shadowFrustumSize(): number;
  139199. /**
  139200. * Specifies a fix frustum size for the shadow generation.
  139201. */
  139202. set shadowFrustumSize(value: number);
  139203. private _shadowOrthoScale;
  139204. /**
  139205. * Gets the shadow projection scale against the optimal computed one.
  139206. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  139207. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  139208. */
  139209. get shadowOrthoScale(): number;
  139210. /**
  139211. * Sets the shadow projection scale against the optimal computed one.
  139212. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  139213. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  139214. */
  139215. set shadowOrthoScale(value: number);
  139216. /**
  139217. * Automatically compute the projection matrix to best fit (including all the casters)
  139218. * on each frame.
  139219. */
  139220. autoUpdateExtends: boolean;
  139221. /**
  139222. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  139223. * on each frame. autoUpdateExtends must be set to true for this to work
  139224. */
  139225. autoCalcShadowZBounds: boolean;
  139226. private _orthoLeft;
  139227. private _orthoRight;
  139228. private _orthoTop;
  139229. private _orthoBottom;
  139230. /**
  139231. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  139232. * The directional light is emitted from everywhere in the given direction.
  139233. * It can cast shadows.
  139234. * Documentation : https://doc.babylonjs.com/babylon101/lights
  139235. * @param name The friendly name of the light
  139236. * @param direction The direction of the light
  139237. * @param scene The scene the light belongs to
  139238. */
  139239. constructor(name: string, direction: Vector3, scene: Scene);
  139240. /**
  139241. * Returns the string "DirectionalLight".
  139242. * @return The class name
  139243. */
  139244. getClassName(): string;
  139245. /**
  139246. * Returns the integer 1.
  139247. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  139248. */
  139249. getTypeID(): number;
  139250. /**
  139251. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  139252. * Returns the DirectionalLight Shadow projection matrix.
  139253. */
  139254. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139255. /**
  139256. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  139257. * Returns the DirectionalLight Shadow projection matrix.
  139258. */
  139259. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  139260. /**
  139261. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  139262. * Returns the DirectionalLight Shadow projection matrix.
  139263. */
  139264. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139265. protected _buildUniformLayout(): void;
  139266. /**
  139267. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  139268. * @param effect The effect to update
  139269. * @param lightIndex The index of the light in the effect to update
  139270. * @returns The directional light
  139271. */
  139272. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  139273. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  139274. /**
  139275. * Gets the minZ used for shadow according to both the scene and the light.
  139276. *
  139277. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  139278. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  139279. * @param activeCamera The camera we are returning the min for
  139280. * @returns the depth min z
  139281. */
  139282. getDepthMinZ(activeCamera: Camera): number;
  139283. /**
  139284. * Gets the maxZ used for shadow according to both the scene and the light.
  139285. *
  139286. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  139287. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  139288. * @param activeCamera The camera we are returning the max for
  139289. * @returns the depth max z
  139290. */
  139291. getDepthMaxZ(activeCamera: Camera): number;
  139292. /**
  139293. * Prepares the list of defines specific to the light type.
  139294. * @param defines the list of defines
  139295. * @param lightIndex defines the index of the light for the effect
  139296. */
  139297. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  139298. }
  139299. }
  139300. declare module BABYLON {
  139301. /**
  139302. * Class containing static functions to help procedurally build meshes
  139303. */
  139304. export class HemisphereBuilder {
  139305. /**
  139306. * Creates a hemisphere mesh
  139307. * @param name defines the name of the mesh
  139308. * @param options defines the options used to create the mesh
  139309. * @param scene defines the hosting scene
  139310. * @returns the hemisphere mesh
  139311. */
  139312. static CreateHemisphere(name: string, options: {
  139313. segments?: number;
  139314. diameter?: number;
  139315. sideOrientation?: number;
  139316. }, scene: any): Mesh;
  139317. }
  139318. }
  139319. declare module BABYLON {
  139320. /**
  139321. * A spot light is defined by a position, a direction, an angle, and an exponent.
  139322. * These values define a cone of light starting from the position, emitting toward the direction.
  139323. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  139324. * and the exponent defines the speed of the decay of the light with distance (reach).
  139325. * Documentation: https://doc.babylonjs.com/babylon101/lights
  139326. */
  139327. export class SpotLight extends ShadowLight {
  139328. private _angle;
  139329. private _innerAngle;
  139330. private _cosHalfAngle;
  139331. private _lightAngleScale;
  139332. private _lightAngleOffset;
  139333. /**
  139334. * Gets the cone angle of the spot light in Radians.
  139335. */
  139336. get angle(): number;
  139337. /**
  139338. * Sets the cone angle of the spot light in Radians.
  139339. */
  139340. set angle(value: number);
  139341. /**
  139342. * Only used in gltf falloff mode, this defines the angle where
  139343. * the directional falloff will start before cutting at angle which could be seen
  139344. * as outer angle.
  139345. */
  139346. get innerAngle(): number;
  139347. /**
  139348. * Only used in gltf falloff mode, this defines the angle where
  139349. * the directional falloff will start before cutting at angle which could be seen
  139350. * as outer angle.
  139351. */
  139352. set innerAngle(value: number);
  139353. private _shadowAngleScale;
  139354. /**
  139355. * Allows scaling the angle of the light for shadow generation only.
  139356. */
  139357. get shadowAngleScale(): number;
  139358. /**
  139359. * Allows scaling the angle of the light for shadow generation only.
  139360. */
  139361. set shadowAngleScale(value: number);
  139362. /**
  139363. * The light decay speed with the distance from the emission spot.
  139364. */
  139365. exponent: number;
  139366. private _projectionTextureMatrix;
  139367. /**
  139368. * Allows reading the projecton texture
  139369. */
  139370. get projectionTextureMatrix(): Matrix;
  139371. protected _projectionTextureLightNear: number;
  139372. /**
  139373. * Gets the near clip of the Spotlight for texture projection.
  139374. */
  139375. get projectionTextureLightNear(): number;
  139376. /**
  139377. * Sets the near clip of the Spotlight for texture projection.
  139378. */
  139379. set projectionTextureLightNear(value: number);
  139380. protected _projectionTextureLightFar: number;
  139381. /**
  139382. * Gets the far clip of the Spotlight for texture projection.
  139383. */
  139384. get projectionTextureLightFar(): number;
  139385. /**
  139386. * Sets the far clip of the Spotlight for texture projection.
  139387. */
  139388. set projectionTextureLightFar(value: number);
  139389. protected _projectionTextureUpDirection: Vector3;
  139390. /**
  139391. * Gets the Up vector of the Spotlight for texture projection.
  139392. */
  139393. get projectionTextureUpDirection(): Vector3;
  139394. /**
  139395. * Sets the Up vector of the Spotlight for texture projection.
  139396. */
  139397. set projectionTextureUpDirection(value: Vector3);
  139398. private _projectionTexture;
  139399. /**
  139400. * Gets the projection texture of the light.
  139401. */
  139402. get projectionTexture(): Nullable<BaseTexture>;
  139403. /**
  139404. * Sets the projection texture of the light.
  139405. */
  139406. set projectionTexture(value: Nullable<BaseTexture>);
  139407. private static _IsProceduralTexture;
  139408. private static _IsTexture;
  139409. private _projectionTextureViewLightDirty;
  139410. private _projectionTextureProjectionLightDirty;
  139411. private _projectionTextureDirty;
  139412. private _projectionTextureViewTargetVector;
  139413. private _projectionTextureViewLightMatrix;
  139414. private _projectionTextureProjectionLightMatrix;
  139415. private _projectionTextureScalingMatrix;
  139416. /**
  139417. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  139418. * It can cast shadows.
  139419. * Documentation : https://doc.babylonjs.com/babylon101/lights
  139420. * @param name The light friendly name
  139421. * @param position The position of the spot light in the scene
  139422. * @param direction The direction of the light in the scene
  139423. * @param angle The cone angle of the light in Radians
  139424. * @param exponent The light decay speed with the distance from the emission spot
  139425. * @param scene The scene the lights belongs to
  139426. */
  139427. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  139428. /**
  139429. * Returns the string "SpotLight".
  139430. * @returns the class name
  139431. */
  139432. getClassName(): string;
  139433. /**
  139434. * Returns the integer 2.
  139435. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  139436. */
  139437. getTypeID(): number;
  139438. /**
  139439. * Overrides the direction setter to recompute the projection texture view light Matrix.
  139440. */
  139441. protected _setDirection(value: Vector3): void;
  139442. /**
  139443. * Overrides the position setter to recompute the projection texture view light Matrix.
  139444. */
  139445. protected _setPosition(value: Vector3): void;
  139446. /**
  139447. * 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.
  139448. * Returns the SpotLight.
  139449. */
  139450. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139451. protected _computeProjectionTextureViewLightMatrix(): void;
  139452. protected _computeProjectionTextureProjectionLightMatrix(): void;
  139453. /**
  139454. * Main function for light texture projection matrix computing.
  139455. */
  139456. protected _computeProjectionTextureMatrix(): void;
  139457. protected _buildUniformLayout(): void;
  139458. private _computeAngleValues;
  139459. /**
  139460. * Sets the passed Effect "effect" with the Light textures.
  139461. * @param effect The effect to update
  139462. * @param lightIndex The index of the light in the effect to update
  139463. * @returns The light
  139464. */
  139465. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  139466. /**
  139467. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  139468. * @param effect The effect to update
  139469. * @param lightIndex The index of the light in the effect to update
  139470. * @returns The spot light
  139471. */
  139472. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  139473. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  139474. /**
  139475. * Disposes the light and the associated resources.
  139476. */
  139477. dispose(): void;
  139478. /**
  139479. * Prepares the list of defines specific to the light type.
  139480. * @param defines the list of defines
  139481. * @param lightIndex defines the index of the light for the effect
  139482. */
  139483. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  139484. }
  139485. }
  139486. declare module BABYLON {
  139487. /**
  139488. * Gizmo that enables viewing a light
  139489. */
  139490. export class LightGizmo extends Gizmo {
  139491. private _lightMesh;
  139492. private _material;
  139493. private _cachedPosition;
  139494. private _cachedForward;
  139495. private _attachedMeshParent;
  139496. private _pointerObserver;
  139497. /**
  139498. * Event that fires each time the gizmo is clicked
  139499. */
  139500. onClickedObservable: Observable<Light>;
  139501. /**
  139502. * Creates a LightGizmo
  139503. * @param gizmoLayer The utility layer the gizmo will be added to
  139504. */
  139505. constructor(gizmoLayer?: UtilityLayerRenderer);
  139506. private _light;
  139507. /**
  139508. * The light that the gizmo is attached to
  139509. */
  139510. set light(light: Nullable<Light>);
  139511. get light(): Nullable<Light>;
  139512. /**
  139513. * Gets the material used to render the light gizmo
  139514. */
  139515. get material(): StandardMaterial;
  139516. /**
  139517. * @hidden
  139518. * Updates the gizmo to match the attached mesh's position/rotation
  139519. */
  139520. protected _update(): void;
  139521. private static _Scale;
  139522. /**
  139523. * Creates the lines for a light mesh
  139524. */
  139525. private static _CreateLightLines;
  139526. /**
  139527. * Disposes of the light gizmo
  139528. */
  139529. dispose(): void;
  139530. private static _CreateHemisphericLightMesh;
  139531. private static _CreatePointLightMesh;
  139532. private static _CreateSpotLightMesh;
  139533. private static _CreateDirectionalLightMesh;
  139534. }
  139535. }
  139536. declare module BABYLON {
  139537. /**
  139538. * Gizmo that enables viewing a camera
  139539. */
  139540. export class CameraGizmo extends Gizmo {
  139541. private _cameraMesh;
  139542. private _cameraLinesMesh;
  139543. private _material;
  139544. private _pointerObserver;
  139545. /**
  139546. * Event that fires each time the gizmo is clicked
  139547. */
  139548. onClickedObservable: Observable<Camera>;
  139549. /**
  139550. * Creates a CameraGizmo
  139551. * @param gizmoLayer The utility layer the gizmo will be added to
  139552. */
  139553. constructor(gizmoLayer?: UtilityLayerRenderer);
  139554. private _camera;
  139555. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  139556. get displayFrustum(): boolean;
  139557. set displayFrustum(value: boolean);
  139558. /**
  139559. * The camera that the gizmo is attached to
  139560. */
  139561. set camera(camera: Nullable<Camera>);
  139562. get camera(): Nullable<Camera>;
  139563. /**
  139564. * Gets the material used to render the camera gizmo
  139565. */
  139566. get material(): StandardMaterial;
  139567. /**
  139568. * @hidden
  139569. * Updates the gizmo to match the attached mesh's position/rotation
  139570. */
  139571. protected _update(): void;
  139572. private static _Scale;
  139573. private _invProjection;
  139574. /**
  139575. * Disposes of the camera gizmo
  139576. */
  139577. dispose(): void;
  139578. private static _CreateCameraMesh;
  139579. private static _CreateCameraFrustum;
  139580. }
  139581. }
  139582. declare module BABYLON {
  139583. /** @hidden */
  139584. export var backgroundFragmentDeclaration: {
  139585. name: string;
  139586. shader: string;
  139587. };
  139588. }
  139589. declare module BABYLON {
  139590. /** @hidden */
  139591. export var backgroundUboDeclaration: {
  139592. name: string;
  139593. shader: string;
  139594. };
  139595. }
  139596. declare module BABYLON {
  139597. /** @hidden */
  139598. export var backgroundPixelShader: {
  139599. name: string;
  139600. shader: string;
  139601. };
  139602. }
  139603. declare module BABYLON {
  139604. /** @hidden */
  139605. export var backgroundVertexDeclaration: {
  139606. name: string;
  139607. shader: string;
  139608. };
  139609. }
  139610. declare module BABYLON {
  139611. /** @hidden */
  139612. export var backgroundVertexShader: {
  139613. name: string;
  139614. shader: string;
  139615. };
  139616. }
  139617. declare module BABYLON {
  139618. /**
  139619. * Background material used to create an efficient environement around your scene.
  139620. */
  139621. export class BackgroundMaterial extends PushMaterial {
  139622. /**
  139623. * Standard reflectance value at parallel view angle.
  139624. */
  139625. static StandardReflectance0: number;
  139626. /**
  139627. * Standard reflectance value at grazing angle.
  139628. */
  139629. static StandardReflectance90: number;
  139630. protected _primaryColor: Color3;
  139631. /**
  139632. * Key light Color (multiply against the environement texture)
  139633. */
  139634. primaryColor: Color3;
  139635. protected __perceptualColor: Nullable<Color3>;
  139636. /**
  139637. * Experimental Internal Use Only.
  139638. *
  139639. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  139640. * This acts as a helper to set the primary color to a more "human friendly" value.
  139641. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  139642. * output color as close as possible from the chosen value.
  139643. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  139644. * part of lighting setup.)
  139645. */
  139646. get _perceptualColor(): Nullable<Color3>;
  139647. set _perceptualColor(value: Nullable<Color3>);
  139648. protected _primaryColorShadowLevel: float;
  139649. /**
  139650. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  139651. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  139652. */
  139653. get primaryColorShadowLevel(): float;
  139654. set primaryColorShadowLevel(value: float);
  139655. protected _primaryColorHighlightLevel: float;
  139656. /**
  139657. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  139658. * The primary color is used at the level chosen to define what the white area would look.
  139659. */
  139660. get primaryColorHighlightLevel(): float;
  139661. set primaryColorHighlightLevel(value: float);
  139662. protected _reflectionTexture: Nullable<BaseTexture>;
  139663. /**
  139664. * Reflection Texture used in the material.
  139665. * Should be author in a specific way for the best result (refer to the documentation).
  139666. */
  139667. reflectionTexture: Nullable<BaseTexture>;
  139668. protected _reflectionBlur: float;
  139669. /**
  139670. * Reflection Texture level of blur.
  139671. *
  139672. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  139673. * texture twice.
  139674. */
  139675. reflectionBlur: float;
  139676. protected _diffuseTexture: Nullable<BaseTexture>;
  139677. /**
  139678. * Diffuse Texture used in the material.
  139679. * Should be author in a specific way for the best result (refer to the documentation).
  139680. */
  139681. diffuseTexture: Nullable<BaseTexture>;
  139682. protected _shadowLights: Nullable<IShadowLight[]>;
  139683. /**
  139684. * Specify the list of lights casting shadow on the material.
  139685. * All scene shadow lights will be included if null.
  139686. */
  139687. shadowLights: Nullable<IShadowLight[]>;
  139688. protected _shadowLevel: float;
  139689. /**
  139690. * Helps adjusting the shadow to a softer level if required.
  139691. * 0 means black shadows and 1 means no shadows.
  139692. */
  139693. shadowLevel: float;
  139694. protected _sceneCenter: Vector3;
  139695. /**
  139696. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  139697. * It is usually zero but might be interesting to modify according to your setup.
  139698. */
  139699. sceneCenter: Vector3;
  139700. protected _opacityFresnel: boolean;
  139701. /**
  139702. * This helps specifying that the material is falling off to the sky box at grazing angle.
  139703. * This helps ensuring a nice transition when the camera goes under the ground.
  139704. */
  139705. opacityFresnel: boolean;
  139706. protected _reflectionFresnel: boolean;
  139707. /**
  139708. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  139709. * This helps adding a mirror texture on the ground.
  139710. */
  139711. reflectionFresnel: boolean;
  139712. protected _reflectionFalloffDistance: number;
  139713. /**
  139714. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  139715. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  139716. */
  139717. reflectionFalloffDistance: number;
  139718. protected _reflectionAmount: number;
  139719. /**
  139720. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  139721. */
  139722. reflectionAmount: number;
  139723. protected _reflectionReflectance0: number;
  139724. /**
  139725. * This specifies the weight of the reflection at grazing angle.
  139726. */
  139727. reflectionReflectance0: number;
  139728. protected _reflectionReflectance90: number;
  139729. /**
  139730. * This specifies the weight of the reflection at a perpendicular point of view.
  139731. */
  139732. reflectionReflectance90: number;
  139733. /**
  139734. * Sets the reflection reflectance fresnel values according to the default standard
  139735. * empirically know to work well :-)
  139736. */
  139737. set reflectionStandardFresnelWeight(value: number);
  139738. protected _useRGBColor: boolean;
  139739. /**
  139740. * Helps to directly use the maps channels instead of their level.
  139741. */
  139742. useRGBColor: boolean;
  139743. protected _enableNoise: boolean;
  139744. /**
  139745. * This helps reducing the banding effect that could occur on the background.
  139746. */
  139747. enableNoise: boolean;
  139748. /**
  139749. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  139750. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  139751. * Recommended to be keep at 1.0 except for special cases.
  139752. */
  139753. get fovMultiplier(): number;
  139754. set fovMultiplier(value: number);
  139755. private _fovMultiplier;
  139756. /**
  139757. * Enable the FOV adjustment feature controlled by fovMultiplier.
  139758. */
  139759. useEquirectangularFOV: boolean;
  139760. private _maxSimultaneousLights;
  139761. /**
  139762. * Number of Simultaneous lights allowed on the material.
  139763. */
  139764. maxSimultaneousLights: int;
  139765. private _shadowOnly;
  139766. /**
  139767. * Make the material only render shadows
  139768. */
  139769. shadowOnly: boolean;
  139770. /**
  139771. * Default configuration related to image processing available in the Background Material.
  139772. */
  139773. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  139774. /**
  139775. * Keep track of the image processing observer to allow dispose and replace.
  139776. */
  139777. private _imageProcessingObserver;
  139778. /**
  139779. * Attaches a new image processing configuration to the PBR Material.
  139780. * @param configuration (if null the scene configuration will be use)
  139781. */
  139782. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  139783. /**
  139784. * Gets the image processing configuration used either in this material.
  139785. */
  139786. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  139787. /**
  139788. * Sets the Default image processing configuration used either in the this material.
  139789. *
  139790. * If sets to null, the scene one is in use.
  139791. */
  139792. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  139793. /**
  139794. * Gets wether the color curves effect is enabled.
  139795. */
  139796. get cameraColorCurvesEnabled(): boolean;
  139797. /**
  139798. * Sets wether the color curves effect is enabled.
  139799. */
  139800. set cameraColorCurvesEnabled(value: boolean);
  139801. /**
  139802. * Gets wether the color grading effect is enabled.
  139803. */
  139804. get cameraColorGradingEnabled(): boolean;
  139805. /**
  139806. * Gets wether the color grading effect is enabled.
  139807. */
  139808. set cameraColorGradingEnabled(value: boolean);
  139809. /**
  139810. * Gets wether tonemapping is enabled or not.
  139811. */
  139812. get cameraToneMappingEnabled(): boolean;
  139813. /**
  139814. * Sets wether tonemapping is enabled or not
  139815. */
  139816. set cameraToneMappingEnabled(value: boolean);
  139817. /**
  139818. * The camera exposure used on this material.
  139819. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  139820. * This corresponds to a photographic exposure.
  139821. */
  139822. get cameraExposure(): float;
  139823. /**
  139824. * The camera exposure used on this material.
  139825. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  139826. * This corresponds to a photographic exposure.
  139827. */
  139828. set cameraExposure(value: float);
  139829. /**
  139830. * Gets The camera contrast used on this material.
  139831. */
  139832. get cameraContrast(): float;
  139833. /**
  139834. * Sets The camera contrast used on this material.
  139835. */
  139836. set cameraContrast(value: float);
  139837. /**
  139838. * Gets the Color Grading 2D Lookup Texture.
  139839. */
  139840. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  139841. /**
  139842. * Sets the Color Grading 2D Lookup Texture.
  139843. */
  139844. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  139845. /**
  139846. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  139847. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  139848. * 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;
  139849. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  139850. */
  139851. get cameraColorCurves(): Nullable<ColorCurves>;
  139852. /**
  139853. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  139854. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  139855. * 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;
  139856. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  139857. */
  139858. set cameraColorCurves(value: Nullable<ColorCurves>);
  139859. /**
  139860. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  139861. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  139862. */
  139863. switchToBGR: boolean;
  139864. private _renderTargets;
  139865. private _reflectionControls;
  139866. private _white;
  139867. private _primaryShadowColor;
  139868. private _primaryHighlightColor;
  139869. /**
  139870. * Instantiates a Background Material in the given scene
  139871. * @param name The friendly name of the material
  139872. * @param scene The scene to add the material to
  139873. */
  139874. constructor(name: string, scene: Scene);
  139875. /**
  139876. * Gets a boolean indicating that current material needs to register RTT
  139877. */
  139878. get hasRenderTargetTextures(): boolean;
  139879. /**
  139880. * The entire material has been created in order to prevent overdraw.
  139881. * @returns false
  139882. */
  139883. needAlphaTesting(): boolean;
  139884. /**
  139885. * The entire material has been created in order to prevent overdraw.
  139886. * @returns true if blending is enable
  139887. */
  139888. needAlphaBlending(): boolean;
  139889. /**
  139890. * Checks wether the material is ready to be rendered for a given mesh.
  139891. * @param mesh The mesh to render
  139892. * @param subMesh The submesh to check against
  139893. * @param useInstances Specify wether or not the material is used with instances
  139894. * @returns true if all the dependencies are ready (Textures, Effects...)
  139895. */
  139896. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  139897. /**
  139898. * Compute the primary color according to the chosen perceptual color.
  139899. */
  139900. private _computePrimaryColorFromPerceptualColor;
  139901. /**
  139902. * Compute the highlights and shadow colors according to their chosen levels.
  139903. */
  139904. private _computePrimaryColors;
  139905. /**
  139906. * Build the uniform buffer used in the material.
  139907. */
  139908. buildUniformLayout(): void;
  139909. /**
  139910. * Unbind the material.
  139911. */
  139912. unbind(): void;
  139913. /**
  139914. * Bind only the world matrix to the material.
  139915. * @param world The world matrix to bind.
  139916. */
  139917. bindOnlyWorldMatrix(world: Matrix): void;
  139918. /**
  139919. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  139920. * @param world The world matrix to bind.
  139921. * @param subMesh The submesh to bind for.
  139922. */
  139923. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  139924. /**
  139925. * Checks to see if a texture is used in the material.
  139926. * @param texture - Base texture to use.
  139927. * @returns - Boolean specifying if a texture is used in the material.
  139928. */
  139929. hasTexture(texture: BaseTexture): boolean;
  139930. /**
  139931. * Dispose the material.
  139932. * @param forceDisposeEffect Force disposal of the associated effect.
  139933. * @param forceDisposeTextures Force disposal of the associated textures.
  139934. */
  139935. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  139936. /**
  139937. * Clones the material.
  139938. * @param name The cloned name.
  139939. * @returns The cloned material.
  139940. */
  139941. clone(name: string): BackgroundMaterial;
  139942. /**
  139943. * Serializes the current material to its JSON representation.
  139944. * @returns The JSON representation.
  139945. */
  139946. serialize(): any;
  139947. /**
  139948. * Gets the class name of the material
  139949. * @returns "BackgroundMaterial"
  139950. */
  139951. getClassName(): string;
  139952. /**
  139953. * Parse a JSON input to create back a background material.
  139954. * @param source The JSON data to parse
  139955. * @param scene The scene to create the parsed material in
  139956. * @param rootUrl The root url of the assets the material depends upon
  139957. * @returns the instantiated BackgroundMaterial.
  139958. */
  139959. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  139960. }
  139961. }
  139962. declare module BABYLON {
  139963. /**
  139964. * Represents the different options available during the creation of
  139965. * a Environment helper.
  139966. *
  139967. * This can control the default ground, skybox and image processing setup of your scene.
  139968. */
  139969. export interface IEnvironmentHelperOptions {
  139970. /**
  139971. * Specifies whether or not to create a ground.
  139972. * True by default.
  139973. */
  139974. createGround: boolean;
  139975. /**
  139976. * Specifies the ground size.
  139977. * 15 by default.
  139978. */
  139979. groundSize: number;
  139980. /**
  139981. * The texture used on the ground for the main color.
  139982. * Comes from the BabylonJS CDN by default.
  139983. *
  139984. * Remarks: Can be either a texture or a url.
  139985. */
  139986. groundTexture: string | BaseTexture;
  139987. /**
  139988. * The color mixed in the ground texture by default.
  139989. * BabylonJS clearColor by default.
  139990. */
  139991. groundColor: Color3;
  139992. /**
  139993. * Specifies the ground opacity.
  139994. * 1 by default.
  139995. */
  139996. groundOpacity: number;
  139997. /**
  139998. * Enables the ground to receive shadows.
  139999. * True by default.
  140000. */
  140001. enableGroundShadow: boolean;
  140002. /**
  140003. * Helps preventing the shadow to be fully black on the ground.
  140004. * 0.5 by default.
  140005. */
  140006. groundShadowLevel: number;
  140007. /**
  140008. * Creates a mirror texture attach to the ground.
  140009. * false by default.
  140010. */
  140011. enableGroundMirror: boolean;
  140012. /**
  140013. * Specifies the ground mirror size ratio.
  140014. * 0.3 by default as the default kernel is 64.
  140015. */
  140016. groundMirrorSizeRatio: number;
  140017. /**
  140018. * Specifies the ground mirror blur kernel size.
  140019. * 64 by default.
  140020. */
  140021. groundMirrorBlurKernel: number;
  140022. /**
  140023. * Specifies the ground mirror visibility amount.
  140024. * 1 by default
  140025. */
  140026. groundMirrorAmount: number;
  140027. /**
  140028. * Specifies the ground mirror reflectance weight.
  140029. * This uses the standard weight of the background material to setup the fresnel effect
  140030. * of the mirror.
  140031. * 1 by default.
  140032. */
  140033. groundMirrorFresnelWeight: number;
  140034. /**
  140035. * Specifies the ground mirror Falloff distance.
  140036. * This can helps reducing the size of the reflection.
  140037. * 0 by Default.
  140038. */
  140039. groundMirrorFallOffDistance: number;
  140040. /**
  140041. * Specifies the ground mirror texture type.
  140042. * Unsigned Int by Default.
  140043. */
  140044. groundMirrorTextureType: number;
  140045. /**
  140046. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  140047. * the shown objects.
  140048. */
  140049. groundYBias: number;
  140050. /**
  140051. * Specifies whether or not to create a skybox.
  140052. * True by default.
  140053. */
  140054. createSkybox: boolean;
  140055. /**
  140056. * Specifies the skybox size.
  140057. * 20 by default.
  140058. */
  140059. skyboxSize: number;
  140060. /**
  140061. * The texture used on the skybox for the main color.
  140062. * Comes from the BabylonJS CDN by default.
  140063. *
  140064. * Remarks: Can be either a texture or a url.
  140065. */
  140066. skyboxTexture: string | BaseTexture;
  140067. /**
  140068. * The color mixed in the skybox texture by default.
  140069. * BabylonJS clearColor by default.
  140070. */
  140071. skyboxColor: Color3;
  140072. /**
  140073. * The background rotation around the Y axis of the scene.
  140074. * This helps aligning the key lights of your scene with the background.
  140075. * 0 by default.
  140076. */
  140077. backgroundYRotation: number;
  140078. /**
  140079. * Compute automatically the size of the elements to best fit with the scene.
  140080. */
  140081. sizeAuto: boolean;
  140082. /**
  140083. * Default position of the rootMesh if autoSize is not true.
  140084. */
  140085. rootPosition: Vector3;
  140086. /**
  140087. * Sets up the image processing in the scene.
  140088. * true by default.
  140089. */
  140090. setupImageProcessing: boolean;
  140091. /**
  140092. * The texture used as your environment texture in the scene.
  140093. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  140094. *
  140095. * Remarks: Can be either a texture or a url.
  140096. */
  140097. environmentTexture: string | BaseTexture;
  140098. /**
  140099. * The value of the exposure to apply to the scene.
  140100. * 0.6 by default if setupImageProcessing is true.
  140101. */
  140102. cameraExposure: number;
  140103. /**
  140104. * The value of the contrast to apply to the scene.
  140105. * 1.6 by default if setupImageProcessing is true.
  140106. */
  140107. cameraContrast: number;
  140108. /**
  140109. * Specifies whether or not tonemapping should be enabled in the scene.
  140110. * true by default if setupImageProcessing is true.
  140111. */
  140112. toneMappingEnabled: boolean;
  140113. }
  140114. /**
  140115. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  140116. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  140117. * It also helps with the default setup of your imageProcessing configuration.
  140118. */
  140119. export class EnvironmentHelper {
  140120. /**
  140121. * Default ground texture URL.
  140122. */
  140123. private static _groundTextureCDNUrl;
  140124. /**
  140125. * Default skybox texture URL.
  140126. */
  140127. private static _skyboxTextureCDNUrl;
  140128. /**
  140129. * Default environment texture URL.
  140130. */
  140131. private static _environmentTextureCDNUrl;
  140132. /**
  140133. * Creates the default options for the helper.
  140134. */
  140135. private static _getDefaultOptions;
  140136. private _rootMesh;
  140137. /**
  140138. * Gets the root mesh created by the helper.
  140139. */
  140140. get rootMesh(): Mesh;
  140141. private _skybox;
  140142. /**
  140143. * Gets the skybox created by the helper.
  140144. */
  140145. get skybox(): Nullable<Mesh>;
  140146. private _skyboxTexture;
  140147. /**
  140148. * Gets the skybox texture created by the helper.
  140149. */
  140150. get skyboxTexture(): Nullable<BaseTexture>;
  140151. private _skyboxMaterial;
  140152. /**
  140153. * Gets the skybox material created by the helper.
  140154. */
  140155. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  140156. private _ground;
  140157. /**
  140158. * Gets the ground mesh created by the helper.
  140159. */
  140160. get ground(): Nullable<Mesh>;
  140161. private _groundTexture;
  140162. /**
  140163. * Gets the ground texture created by the helper.
  140164. */
  140165. get groundTexture(): Nullable<BaseTexture>;
  140166. private _groundMirror;
  140167. /**
  140168. * Gets the ground mirror created by the helper.
  140169. */
  140170. get groundMirror(): Nullable<MirrorTexture>;
  140171. /**
  140172. * Gets the ground mirror render list to helps pushing the meshes
  140173. * you wish in the ground reflection.
  140174. */
  140175. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  140176. private _groundMaterial;
  140177. /**
  140178. * Gets the ground material created by the helper.
  140179. */
  140180. get groundMaterial(): Nullable<BackgroundMaterial>;
  140181. /**
  140182. * Stores the creation options.
  140183. */
  140184. private readonly _scene;
  140185. private _options;
  140186. /**
  140187. * This observable will be notified with any error during the creation of the environment,
  140188. * mainly texture creation errors.
  140189. */
  140190. onErrorObservable: Observable<{
  140191. message?: string;
  140192. exception?: any;
  140193. }>;
  140194. /**
  140195. * constructor
  140196. * @param options Defines the options we want to customize the helper
  140197. * @param scene The scene to add the material to
  140198. */
  140199. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  140200. /**
  140201. * Updates the background according to the new options
  140202. * @param options
  140203. */
  140204. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  140205. /**
  140206. * Sets the primary color of all the available elements.
  140207. * @param color the main color to affect to the ground and the background
  140208. */
  140209. setMainColor(color: Color3): void;
  140210. /**
  140211. * Setup the image processing according to the specified options.
  140212. */
  140213. private _setupImageProcessing;
  140214. /**
  140215. * Setup the environment texture according to the specified options.
  140216. */
  140217. private _setupEnvironmentTexture;
  140218. /**
  140219. * Setup the background according to the specified options.
  140220. */
  140221. private _setupBackground;
  140222. /**
  140223. * Get the scene sizes according to the setup.
  140224. */
  140225. private _getSceneSize;
  140226. /**
  140227. * Setup the ground according to the specified options.
  140228. */
  140229. private _setupGround;
  140230. /**
  140231. * Setup the ground material according to the specified options.
  140232. */
  140233. private _setupGroundMaterial;
  140234. /**
  140235. * Setup the ground diffuse texture according to the specified options.
  140236. */
  140237. private _setupGroundDiffuseTexture;
  140238. /**
  140239. * Setup the ground mirror texture according to the specified options.
  140240. */
  140241. private _setupGroundMirrorTexture;
  140242. /**
  140243. * Setup the ground to receive the mirror texture.
  140244. */
  140245. private _setupMirrorInGroundMaterial;
  140246. /**
  140247. * Setup the skybox according to the specified options.
  140248. */
  140249. private _setupSkybox;
  140250. /**
  140251. * Setup the skybox material according to the specified options.
  140252. */
  140253. private _setupSkyboxMaterial;
  140254. /**
  140255. * Setup the skybox reflection texture according to the specified options.
  140256. */
  140257. private _setupSkyboxReflectionTexture;
  140258. private _errorHandler;
  140259. /**
  140260. * Dispose all the elements created by the Helper.
  140261. */
  140262. dispose(): void;
  140263. }
  140264. }
  140265. declare module BABYLON {
  140266. /**
  140267. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  140268. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  140269. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  140270. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  140271. */
  140272. export abstract class TextureDome<T extends Texture> extends TransformNode {
  140273. protected onError: Nullable<(message?: string, exception?: any) => void>;
  140274. /**
  140275. * Define the source as a Monoscopic panoramic 360/180.
  140276. */
  140277. static readonly MODE_MONOSCOPIC: number;
  140278. /**
  140279. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  140280. */
  140281. static readonly MODE_TOPBOTTOM: number;
  140282. /**
  140283. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  140284. */
  140285. static readonly MODE_SIDEBYSIDE: number;
  140286. private _halfDome;
  140287. private _crossEye;
  140288. protected _useDirectMapping: boolean;
  140289. /**
  140290. * The texture being displayed on the sphere
  140291. */
  140292. protected _texture: T;
  140293. /**
  140294. * Gets the texture being displayed on the sphere
  140295. */
  140296. get texture(): T;
  140297. /**
  140298. * Sets the texture being displayed on the sphere
  140299. */
  140300. set texture(newTexture: T);
  140301. /**
  140302. * The skybox material
  140303. */
  140304. protected _material: BackgroundMaterial;
  140305. /**
  140306. * The surface used for the dome
  140307. */
  140308. protected _mesh: Mesh;
  140309. /**
  140310. * Gets the mesh used for the dome.
  140311. */
  140312. get mesh(): Mesh;
  140313. /**
  140314. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  140315. */
  140316. private _halfDomeMask;
  140317. /**
  140318. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  140319. * Also see the options.resolution property.
  140320. */
  140321. get fovMultiplier(): number;
  140322. set fovMultiplier(value: number);
  140323. protected _textureMode: number;
  140324. /**
  140325. * Gets or set the current texture mode for the texture. It can be:
  140326. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140327. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140328. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140329. */
  140330. get textureMode(): number;
  140331. /**
  140332. * Sets the current texture mode for the texture. It can be:
  140333. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140334. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140335. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140336. */
  140337. set textureMode(value: number);
  140338. /**
  140339. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  140340. */
  140341. get halfDome(): boolean;
  140342. /**
  140343. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  140344. */
  140345. set halfDome(enabled: boolean);
  140346. /**
  140347. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  140348. */
  140349. set crossEye(enabled: boolean);
  140350. /**
  140351. * Is it a cross-eye texture?
  140352. */
  140353. get crossEye(): boolean;
  140354. /**
  140355. * The background material of this dome.
  140356. */
  140357. get material(): BackgroundMaterial;
  140358. /**
  140359. * Oberserver used in Stereoscopic VR Mode.
  140360. */
  140361. private _onBeforeCameraRenderObserver;
  140362. /**
  140363. * Observable raised when an error occured while loading the 360 image
  140364. */
  140365. onLoadErrorObservable: Observable<string>;
  140366. /**
  140367. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  140368. * @param name Element's name, child elements will append suffixes for their own names.
  140369. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  140370. * @param options An object containing optional or exposed sub element properties
  140371. */
  140372. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  140373. resolution?: number;
  140374. clickToPlay?: boolean;
  140375. autoPlay?: boolean;
  140376. loop?: boolean;
  140377. size?: number;
  140378. poster?: string;
  140379. faceForward?: boolean;
  140380. useDirectMapping?: boolean;
  140381. halfDomeMode?: boolean;
  140382. crossEyeMode?: boolean;
  140383. generateMipMaps?: boolean;
  140384. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  140385. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  140386. protected _changeTextureMode(value: number): void;
  140387. /**
  140388. * Releases resources associated with this node.
  140389. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  140390. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  140391. */
  140392. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  140393. }
  140394. }
  140395. declare module BABYLON {
  140396. /**
  140397. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  140398. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  140399. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  140400. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  140401. */
  140402. export class PhotoDome extends TextureDome<Texture> {
  140403. /**
  140404. * Define the image as a Monoscopic panoramic 360 image.
  140405. */
  140406. static readonly MODE_MONOSCOPIC: number;
  140407. /**
  140408. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  140409. */
  140410. static readonly MODE_TOPBOTTOM: number;
  140411. /**
  140412. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  140413. */
  140414. static readonly MODE_SIDEBYSIDE: number;
  140415. /**
  140416. * Gets or sets the texture being displayed on the sphere
  140417. */
  140418. get photoTexture(): Texture;
  140419. /**
  140420. * sets the texture being displayed on the sphere
  140421. */
  140422. set photoTexture(value: Texture);
  140423. /**
  140424. * Gets the current video mode for the video. It can be:
  140425. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140426. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140427. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140428. */
  140429. get imageMode(): number;
  140430. /**
  140431. * Sets the current video mode for the video. It can be:
  140432. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140433. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140434. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140435. */
  140436. set imageMode(value: number);
  140437. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  140438. }
  140439. }
  140440. declare module BABYLON {
  140441. /**
  140442. * Direct draw surface info
  140443. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  140444. */
  140445. export interface DDSInfo {
  140446. /**
  140447. * Width of the texture
  140448. */
  140449. width: number;
  140450. /**
  140451. * Width of the texture
  140452. */
  140453. height: number;
  140454. /**
  140455. * Number of Mipmaps for the texture
  140456. * @see https://en.wikipedia.org/wiki/Mipmap
  140457. */
  140458. mipmapCount: number;
  140459. /**
  140460. * If the textures format is a known fourCC format
  140461. * @see https://www.fourcc.org/
  140462. */
  140463. isFourCC: boolean;
  140464. /**
  140465. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  140466. */
  140467. isRGB: boolean;
  140468. /**
  140469. * If the texture is a lumincance format
  140470. */
  140471. isLuminance: boolean;
  140472. /**
  140473. * If this is a cube texture
  140474. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  140475. */
  140476. isCube: boolean;
  140477. /**
  140478. * If the texture is a compressed format eg. FOURCC_DXT1
  140479. */
  140480. isCompressed: boolean;
  140481. /**
  140482. * The dxgiFormat of the texture
  140483. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  140484. */
  140485. dxgiFormat: number;
  140486. /**
  140487. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  140488. */
  140489. textureType: number;
  140490. /**
  140491. * Sphericle polynomial created for the dds texture
  140492. */
  140493. sphericalPolynomial?: SphericalPolynomial;
  140494. }
  140495. /**
  140496. * Class used to provide DDS decompression tools
  140497. */
  140498. export class DDSTools {
  140499. /**
  140500. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  140501. */
  140502. static StoreLODInAlphaChannel: boolean;
  140503. /**
  140504. * Gets DDS information from an array buffer
  140505. * @param data defines the array buffer view to read data from
  140506. * @returns the DDS information
  140507. */
  140508. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  140509. private static _FloatView;
  140510. private static _Int32View;
  140511. private static _ToHalfFloat;
  140512. private static _FromHalfFloat;
  140513. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  140514. private static _GetHalfFloatRGBAArrayBuffer;
  140515. private static _GetFloatRGBAArrayBuffer;
  140516. private static _GetFloatAsUIntRGBAArrayBuffer;
  140517. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  140518. private static _GetRGBAArrayBuffer;
  140519. private static _ExtractLongWordOrder;
  140520. private static _GetRGBArrayBuffer;
  140521. private static _GetLuminanceArrayBuffer;
  140522. /**
  140523. * Uploads DDS Levels to a Babylon Texture
  140524. * @hidden
  140525. */
  140526. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  140527. }
  140528. interface ThinEngine {
  140529. /**
  140530. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  140531. * @param rootUrl defines the url where the file to load is located
  140532. * @param scene defines the current scene
  140533. * @param lodScale defines scale to apply to the mip map selection
  140534. * @param lodOffset defines offset to apply to the mip map selection
  140535. * @param onLoad defines an optional callback raised when the texture is loaded
  140536. * @param onError defines an optional callback raised if there is an issue to load the texture
  140537. * @param format defines the format of the data
  140538. * @param forcedExtension defines the extension to use to pick the right loader
  140539. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  140540. * @returns the cube texture as an InternalTexture
  140541. */
  140542. 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;
  140543. }
  140544. }
  140545. declare module BABYLON {
  140546. /**
  140547. * Implementation of the DDS Texture Loader.
  140548. * @hidden
  140549. */
  140550. export class _DDSTextureLoader implements IInternalTextureLoader {
  140551. /**
  140552. * Defines wether the loader supports cascade loading the different faces.
  140553. */
  140554. readonly supportCascades: boolean;
  140555. /**
  140556. * This returns if the loader support the current file information.
  140557. * @param extension defines the file extension of the file being loaded
  140558. * @returns true if the loader can load the specified file
  140559. */
  140560. canLoad(extension: string): boolean;
  140561. /**
  140562. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140563. * @param data contains the texture data
  140564. * @param texture defines the BabylonJS internal texture
  140565. * @param createPolynomials will be true if polynomials have been requested
  140566. * @param onLoad defines the callback to trigger once the texture is ready
  140567. * @param onError defines the callback to trigger in case of error
  140568. */
  140569. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140570. /**
  140571. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140572. * @param data contains the texture data
  140573. * @param texture defines the BabylonJS internal texture
  140574. * @param callback defines the method to call once ready to upload
  140575. */
  140576. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140577. }
  140578. }
  140579. declare module BABYLON {
  140580. /**
  140581. * Implementation of the ENV Texture Loader.
  140582. * @hidden
  140583. */
  140584. export class _ENVTextureLoader implements IInternalTextureLoader {
  140585. /**
  140586. * Defines wether the loader supports cascade loading the different faces.
  140587. */
  140588. readonly supportCascades: boolean;
  140589. /**
  140590. * This returns if the loader support the current file information.
  140591. * @param extension defines the file extension of the file being loaded
  140592. * @returns true if the loader can load the specified file
  140593. */
  140594. canLoad(extension: string): boolean;
  140595. /**
  140596. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140597. * @param data contains the texture data
  140598. * @param texture defines the BabylonJS internal texture
  140599. * @param createPolynomials will be true if polynomials have been requested
  140600. * @param onLoad defines the callback to trigger once the texture is ready
  140601. * @param onError defines the callback to trigger in case of error
  140602. */
  140603. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140604. /**
  140605. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140606. * @param data contains the texture data
  140607. * @param texture defines the BabylonJS internal texture
  140608. * @param callback defines the method to call once ready to upload
  140609. */
  140610. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140611. }
  140612. }
  140613. declare module BABYLON {
  140614. /**
  140615. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  140616. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  140617. */
  140618. export class KhronosTextureContainer {
  140619. /** contents of the KTX container file */
  140620. data: ArrayBufferView;
  140621. private static HEADER_LEN;
  140622. private static COMPRESSED_2D;
  140623. private static COMPRESSED_3D;
  140624. private static TEX_2D;
  140625. private static TEX_3D;
  140626. /**
  140627. * Gets the openGL type
  140628. */
  140629. glType: number;
  140630. /**
  140631. * Gets the openGL type size
  140632. */
  140633. glTypeSize: number;
  140634. /**
  140635. * Gets the openGL format
  140636. */
  140637. glFormat: number;
  140638. /**
  140639. * Gets the openGL internal format
  140640. */
  140641. glInternalFormat: number;
  140642. /**
  140643. * Gets the base internal format
  140644. */
  140645. glBaseInternalFormat: number;
  140646. /**
  140647. * Gets image width in pixel
  140648. */
  140649. pixelWidth: number;
  140650. /**
  140651. * Gets image height in pixel
  140652. */
  140653. pixelHeight: number;
  140654. /**
  140655. * Gets image depth in pixels
  140656. */
  140657. pixelDepth: number;
  140658. /**
  140659. * Gets the number of array elements
  140660. */
  140661. numberOfArrayElements: number;
  140662. /**
  140663. * Gets the number of faces
  140664. */
  140665. numberOfFaces: number;
  140666. /**
  140667. * Gets the number of mipmap levels
  140668. */
  140669. numberOfMipmapLevels: number;
  140670. /**
  140671. * Gets the bytes of key value data
  140672. */
  140673. bytesOfKeyValueData: number;
  140674. /**
  140675. * Gets the load type
  140676. */
  140677. loadType: number;
  140678. /**
  140679. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  140680. */
  140681. isInvalid: boolean;
  140682. /**
  140683. * Creates a new KhronosTextureContainer
  140684. * @param data contents of the KTX container file
  140685. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  140686. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  140687. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  140688. */
  140689. constructor(
  140690. /** contents of the KTX container file */
  140691. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  140692. /**
  140693. * Uploads KTX content to a Babylon Texture.
  140694. * It is assumed that the texture has already been created & is currently bound
  140695. * @hidden
  140696. */
  140697. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  140698. private _upload2DCompressedLevels;
  140699. /**
  140700. * Checks if the given data starts with a KTX file identifier.
  140701. * @param data the data to check
  140702. * @returns true if the data is a KTX file or false otherwise
  140703. */
  140704. static IsValid(data: ArrayBufferView): boolean;
  140705. }
  140706. }
  140707. declare module BABYLON {
  140708. /**
  140709. * Helper class to push actions to a pool of workers.
  140710. */
  140711. export class WorkerPool implements IDisposable {
  140712. private _workerInfos;
  140713. private _pendingActions;
  140714. /**
  140715. * Constructor
  140716. * @param workers Array of workers to use for actions
  140717. */
  140718. constructor(workers: Array<Worker>);
  140719. /**
  140720. * Terminates all workers and clears any pending actions.
  140721. */
  140722. dispose(): void;
  140723. /**
  140724. * Pushes an action to the worker pool. If all the workers are active, the action will be
  140725. * pended until a worker has completed its action.
  140726. * @param action The action to perform. Call onComplete when the action is complete.
  140727. */
  140728. push(action: (worker: Worker, onComplete: () => void) => void): void;
  140729. private _execute;
  140730. }
  140731. }
  140732. declare module BABYLON {
  140733. /**
  140734. * Class for loading KTX2 files
  140735. */
  140736. export class KhronosTextureContainer2 {
  140737. private static _WorkerPoolPromise?;
  140738. private static _Initialized;
  140739. private static _Ktx2Decoder;
  140740. /**
  140741. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  140742. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  140743. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  140744. * Urls you can change:
  140745. * URLConfig.jsDecoderModule
  140746. * URLConfig.wasmUASTCToASTC
  140747. * URLConfig.wasmUASTCToBC7
  140748. * URLConfig.wasmUASTCToRGBA_UNORM
  140749. * URLConfig.wasmUASTCToRGBA_SRGB
  140750. * URLConfig.jsMSCTranscoder
  140751. * URLConfig.wasmMSCTranscoder
  140752. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  140753. */
  140754. static URLConfig: {
  140755. jsDecoderModule: string;
  140756. wasmUASTCToASTC: null;
  140757. wasmUASTCToBC7: null;
  140758. wasmUASTCToRGBA_UNORM: null;
  140759. wasmUASTCToRGBA_SRGB: null;
  140760. jsMSCTranscoder: null;
  140761. wasmMSCTranscoder: null;
  140762. };
  140763. /**
  140764. * Default number of workers used to handle data decoding
  140765. */
  140766. static DefaultNumWorkers: number;
  140767. private static GetDefaultNumWorkers;
  140768. private _engine;
  140769. private static _CreateWorkerPool;
  140770. /**
  140771. * Constructor
  140772. * @param engine The engine to use
  140773. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  140774. */
  140775. constructor(engine: ThinEngine, numWorkers?: number);
  140776. /** @hidden */
  140777. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  140778. /**
  140779. * Stop all async operations and release resources.
  140780. */
  140781. dispose(): void;
  140782. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  140783. /**
  140784. * Checks if the given data starts with a KTX2 file identifier.
  140785. * @param data the data to check
  140786. * @returns true if the data is a KTX2 file or false otherwise
  140787. */
  140788. static IsValid(data: ArrayBufferView): boolean;
  140789. }
  140790. }
  140791. declare module BABYLON {
  140792. /**
  140793. * Implementation of the KTX Texture Loader.
  140794. * @hidden
  140795. */
  140796. export class _KTXTextureLoader implements IInternalTextureLoader {
  140797. /**
  140798. * Defines wether the loader supports cascade loading the different faces.
  140799. */
  140800. readonly supportCascades: boolean;
  140801. /**
  140802. * This returns if the loader support the current file information.
  140803. * @param extension defines the file extension of the file being loaded
  140804. * @param mimeType defines the optional mime type of the file being loaded
  140805. * @returns true if the loader can load the specified file
  140806. */
  140807. canLoad(extension: string, mimeType?: string): boolean;
  140808. /**
  140809. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140810. * @param data contains the texture data
  140811. * @param texture defines the BabylonJS internal texture
  140812. * @param createPolynomials will be true if polynomials have been requested
  140813. * @param onLoad defines the callback to trigger once the texture is ready
  140814. * @param onError defines the callback to trigger in case of error
  140815. */
  140816. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140817. /**
  140818. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140819. * @param data contains the texture data
  140820. * @param texture defines the BabylonJS internal texture
  140821. * @param callback defines the method to call once ready to upload
  140822. */
  140823. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  140824. }
  140825. }
  140826. declare module BABYLON {
  140827. /** @hidden */
  140828. export var _forceSceneHelpersToBundle: boolean;
  140829. interface Scene {
  140830. /**
  140831. * Creates a default light for the scene.
  140832. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  140833. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  140834. */
  140835. createDefaultLight(replace?: boolean): void;
  140836. /**
  140837. * Creates a default camera for the scene.
  140838. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  140839. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  140840. * @param replace has default false, when true replaces the active camera in the scene
  140841. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  140842. */
  140843. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  140844. /**
  140845. * Creates a default camera and a default light.
  140846. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  140847. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  140848. * @param replace has the default false, when true replaces the active camera/light in the scene
  140849. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  140850. */
  140851. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  140852. /**
  140853. * Creates a new sky box
  140854. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  140855. * @param environmentTexture defines the texture to use as environment texture
  140856. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  140857. * @param scale defines the overall scale of the skybox
  140858. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  140859. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  140860. * @returns a new mesh holding the sky box
  140861. */
  140862. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  140863. /**
  140864. * Creates a new environment
  140865. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  140866. * @param options defines the options you can use to configure the environment
  140867. * @returns the new EnvironmentHelper
  140868. */
  140869. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  140870. /**
  140871. * Creates a new VREXperienceHelper
  140872. * @see https://doc.babylonjs.com/how_to/webvr_helper
  140873. * @param webVROptions defines the options used to create the new VREXperienceHelper
  140874. * @returns a new VREXperienceHelper
  140875. */
  140876. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  140877. /**
  140878. * Creates a new WebXRDefaultExperience
  140879. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  140880. * @param options experience options
  140881. * @returns a promise for a new WebXRDefaultExperience
  140882. */
  140883. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  140884. }
  140885. }
  140886. declare module BABYLON {
  140887. /**
  140888. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  140889. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  140890. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  140891. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  140892. */
  140893. export class VideoDome extends TextureDome<VideoTexture> {
  140894. /**
  140895. * Define the video source as a Monoscopic panoramic 360 video.
  140896. */
  140897. static readonly MODE_MONOSCOPIC: number;
  140898. /**
  140899. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  140900. */
  140901. static readonly MODE_TOPBOTTOM: number;
  140902. /**
  140903. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  140904. */
  140905. static readonly MODE_SIDEBYSIDE: number;
  140906. /**
  140907. * Get the video texture associated with this video dome
  140908. */
  140909. get videoTexture(): VideoTexture;
  140910. /**
  140911. * Get the video mode of this dome
  140912. */
  140913. get videoMode(): number;
  140914. /**
  140915. * Set the video mode of this dome.
  140916. * @see textureMode
  140917. */
  140918. set videoMode(value: number);
  140919. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  140920. }
  140921. }
  140922. declare module BABYLON {
  140923. /**
  140924. * This class can be used to get instrumentation data from a Babylon engine
  140925. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  140926. */
  140927. export class EngineInstrumentation implements IDisposable {
  140928. /**
  140929. * Define the instrumented engine.
  140930. */
  140931. engine: Engine;
  140932. private _captureGPUFrameTime;
  140933. private _gpuFrameTimeToken;
  140934. private _gpuFrameTime;
  140935. private _captureShaderCompilationTime;
  140936. private _shaderCompilationTime;
  140937. private _onBeginFrameObserver;
  140938. private _onEndFrameObserver;
  140939. private _onBeforeShaderCompilationObserver;
  140940. private _onAfterShaderCompilationObserver;
  140941. /**
  140942. * Gets the perf counter used for GPU frame time
  140943. */
  140944. get gpuFrameTimeCounter(): PerfCounter;
  140945. /**
  140946. * Gets the GPU frame time capture status
  140947. */
  140948. get captureGPUFrameTime(): boolean;
  140949. /**
  140950. * Enable or disable the GPU frame time capture
  140951. */
  140952. set captureGPUFrameTime(value: boolean);
  140953. /**
  140954. * Gets the perf counter used for shader compilation time
  140955. */
  140956. get shaderCompilationTimeCounter(): PerfCounter;
  140957. /**
  140958. * Gets the shader compilation time capture status
  140959. */
  140960. get captureShaderCompilationTime(): boolean;
  140961. /**
  140962. * Enable or disable the shader compilation time capture
  140963. */
  140964. set captureShaderCompilationTime(value: boolean);
  140965. /**
  140966. * Instantiates a new engine instrumentation.
  140967. * This class can be used to get instrumentation data from a Babylon engine
  140968. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  140969. * @param engine Defines the engine to instrument
  140970. */
  140971. constructor(
  140972. /**
  140973. * Define the instrumented engine.
  140974. */
  140975. engine: Engine);
  140976. /**
  140977. * Dispose and release associated resources.
  140978. */
  140979. dispose(): void;
  140980. }
  140981. }
  140982. declare module BABYLON {
  140983. /**
  140984. * This class can be used to get instrumentation data from a Babylon engine
  140985. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  140986. */
  140987. export class SceneInstrumentation implements IDisposable {
  140988. /**
  140989. * Defines the scene to instrument
  140990. */
  140991. scene: Scene;
  140992. private _captureActiveMeshesEvaluationTime;
  140993. private _activeMeshesEvaluationTime;
  140994. private _captureRenderTargetsRenderTime;
  140995. private _renderTargetsRenderTime;
  140996. private _captureFrameTime;
  140997. private _frameTime;
  140998. private _captureRenderTime;
  140999. private _renderTime;
  141000. private _captureInterFrameTime;
  141001. private _interFrameTime;
  141002. private _captureParticlesRenderTime;
  141003. private _particlesRenderTime;
  141004. private _captureSpritesRenderTime;
  141005. private _spritesRenderTime;
  141006. private _capturePhysicsTime;
  141007. private _physicsTime;
  141008. private _captureAnimationsTime;
  141009. private _animationsTime;
  141010. private _captureCameraRenderTime;
  141011. private _cameraRenderTime;
  141012. private _onBeforeActiveMeshesEvaluationObserver;
  141013. private _onAfterActiveMeshesEvaluationObserver;
  141014. private _onBeforeRenderTargetsRenderObserver;
  141015. private _onAfterRenderTargetsRenderObserver;
  141016. private _onAfterRenderObserver;
  141017. private _onBeforeDrawPhaseObserver;
  141018. private _onAfterDrawPhaseObserver;
  141019. private _onBeforeAnimationsObserver;
  141020. private _onBeforeParticlesRenderingObserver;
  141021. private _onAfterParticlesRenderingObserver;
  141022. private _onBeforeSpritesRenderingObserver;
  141023. private _onAfterSpritesRenderingObserver;
  141024. private _onBeforePhysicsObserver;
  141025. private _onAfterPhysicsObserver;
  141026. private _onAfterAnimationsObserver;
  141027. private _onBeforeCameraRenderObserver;
  141028. private _onAfterCameraRenderObserver;
  141029. /**
  141030. * Gets the perf counter used for active meshes evaluation time
  141031. */
  141032. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  141033. /**
  141034. * Gets the active meshes evaluation time capture status
  141035. */
  141036. get captureActiveMeshesEvaluationTime(): boolean;
  141037. /**
  141038. * Enable or disable the active meshes evaluation time capture
  141039. */
  141040. set captureActiveMeshesEvaluationTime(value: boolean);
  141041. /**
  141042. * Gets the perf counter used for render targets render time
  141043. */
  141044. get renderTargetsRenderTimeCounter(): PerfCounter;
  141045. /**
  141046. * Gets the render targets render time capture status
  141047. */
  141048. get captureRenderTargetsRenderTime(): boolean;
  141049. /**
  141050. * Enable or disable the render targets render time capture
  141051. */
  141052. set captureRenderTargetsRenderTime(value: boolean);
  141053. /**
  141054. * Gets the perf counter used for particles render time
  141055. */
  141056. get particlesRenderTimeCounter(): PerfCounter;
  141057. /**
  141058. * Gets the particles render time capture status
  141059. */
  141060. get captureParticlesRenderTime(): boolean;
  141061. /**
  141062. * Enable or disable the particles render time capture
  141063. */
  141064. set captureParticlesRenderTime(value: boolean);
  141065. /**
  141066. * Gets the perf counter used for sprites render time
  141067. */
  141068. get spritesRenderTimeCounter(): PerfCounter;
  141069. /**
  141070. * Gets the sprites render time capture status
  141071. */
  141072. get captureSpritesRenderTime(): boolean;
  141073. /**
  141074. * Enable or disable the sprites render time capture
  141075. */
  141076. set captureSpritesRenderTime(value: boolean);
  141077. /**
  141078. * Gets the perf counter used for physics time
  141079. */
  141080. get physicsTimeCounter(): PerfCounter;
  141081. /**
  141082. * Gets the physics time capture status
  141083. */
  141084. get capturePhysicsTime(): boolean;
  141085. /**
  141086. * Enable or disable the physics time capture
  141087. */
  141088. set capturePhysicsTime(value: boolean);
  141089. /**
  141090. * Gets the perf counter used for animations time
  141091. */
  141092. get animationsTimeCounter(): PerfCounter;
  141093. /**
  141094. * Gets the animations time capture status
  141095. */
  141096. get captureAnimationsTime(): boolean;
  141097. /**
  141098. * Enable or disable the animations time capture
  141099. */
  141100. set captureAnimationsTime(value: boolean);
  141101. /**
  141102. * Gets the perf counter used for frame time capture
  141103. */
  141104. get frameTimeCounter(): PerfCounter;
  141105. /**
  141106. * Gets the frame time capture status
  141107. */
  141108. get captureFrameTime(): boolean;
  141109. /**
  141110. * Enable or disable the frame time capture
  141111. */
  141112. set captureFrameTime(value: boolean);
  141113. /**
  141114. * Gets the perf counter used for inter-frames time capture
  141115. */
  141116. get interFrameTimeCounter(): PerfCounter;
  141117. /**
  141118. * Gets the inter-frames time capture status
  141119. */
  141120. get captureInterFrameTime(): boolean;
  141121. /**
  141122. * Enable or disable the inter-frames time capture
  141123. */
  141124. set captureInterFrameTime(value: boolean);
  141125. /**
  141126. * Gets the perf counter used for render time capture
  141127. */
  141128. get renderTimeCounter(): PerfCounter;
  141129. /**
  141130. * Gets the render time capture status
  141131. */
  141132. get captureRenderTime(): boolean;
  141133. /**
  141134. * Enable or disable the render time capture
  141135. */
  141136. set captureRenderTime(value: boolean);
  141137. /**
  141138. * Gets the perf counter used for camera render time capture
  141139. */
  141140. get cameraRenderTimeCounter(): PerfCounter;
  141141. /**
  141142. * Gets the camera render time capture status
  141143. */
  141144. get captureCameraRenderTime(): boolean;
  141145. /**
  141146. * Enable or disable the camera render time capture
  141147. */
  141148. set captureCameraRenderTime(value: boolean);
  141149. /**
  141150. * Gets the perf counter used for draw calls
  141151. */
  141152. get drawCallsCounter(): PerfCounter;
  141153. /**
  141154. * Instantiates a new scene instrumentation.
  141155. * This class can be used to get instrumentation data from a Babylon engine
  141156. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  141157. * @param scene Defines the scene to instrument
  141158. */
  141159. constructor(
  141160. /**
  141161. * Defines the scene to instrument
  141162. */
  141163. scene: Scene);
  141164. /**
  141165. * Dispose and release associated resources.
  141166. */
  141167. dispose(): void;
  141168. }
  141169. }
  141170. declare module BABYLON {
  141171. /** @hidden */
  141172. export var glowMapGenerationPixelShader: {
  141173. name: string;
  141174. shader: string;
  141175. };
  141176. }
  141177. declare module BABYLON {
  141178. /** @hidden */
  141179. export var glowMapGenerationVertexShader: {
  141180. name: string;
  141181. shader: string;
  141182. };
  141183. }
  141184. declare module BABYLON {
  141185. /**
  141186. * Effect layer options. This helps customizing the behaviour
  141187. * of the effect layer.
  141188. */
  141189. export interface IEffectLayerOptions {
  141190. /**
  141191. * Multiplication factor apply to the canvas size to compute the render target size
  141192. * used to generated the objects (the smaller the faster).
  141193. */
  141194. mainTextureRatio: number;
  141195. /**
  141196. * Enforces a fixed size texture to ensure effect stability across devices.
  141197. */
  141198. mainTextureFixedSize?: number;
  141199. /**
  141200. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  141201. */
  141202. alphaBlendingMode: number;
  141203. /**
  141204. * The camera attached to the layer.
  141205. */
  141206. camera: Nullable<Camera>;
  141207. /**
  141208. * The rendering group to draw the layer in.
  141209. */
  141210. renderingGroupId: number;
  141211. }
  141212. /**
  141213. * The effect layer Helps adding post process effect blended with the main pass.
  141214. *
  141215. * This can be for instance use to generate glow or higlight effects on the scene.
  141216. *
  141217. * The effect layer class can not be used directly and is intented to inherited from to be
  141218. * customized per effects.
  141219. */
  141220. export abstract class EffectLayer {
  141221. private _vertexBuffers;
  141222. private _indexBuffer;
  141223. private _cachedDefines;
  141224. private _effectLayerMapGenerationEffect;
  141225. private _effectLayerOptions;
  141226. private _mergeEffect;
  141227. protected _scene: Scene;
  141228. protected _engine: Engine;
  141229. protected _maxSize: number;
  141230. protected _mainTextureDesiredSize: ISize;
  141231. protected _mainTexture: RenderTargetTexture;
  141232. protected _shouldRender: boolean;
  141233. protected _postProcesses: PostProcess[];
  141234. protected _textures: BaseTexture[];
  141235. protected _emissiveTextureAndColor: {
  141236. texture: Nullable<BaseTexture>;
  141237. color: Color4;
  141238. };
  141239. /**
  141240. * The name of the layer
  141241. */
  141242. name: string;
  141243. /**
  141244. * The clear color of the texture used to generate the glow map.
  141245. */
  141246. neutralColor: Color4;
  141247. /**
  141248. * Specifies whether the highlight layer is enabled or not.
  141249. */
  141250. isEnabled: boolean;
  141251. /**
  141252. * Gets the camera attached to the layer.
  141253. */
  141254. get camera(): Nullable<Camera>;
  141255. /**
  141256. * Gets the rendering group id the layer should render in.
  141257. */
  141258. get renderingGroupId(): number;
  141259. set renderingGroupId(renderingGroupId: number);
  141260. /**
  141261. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  141262. */
  141263. disableBoundingBoxesFromEffectLayer: boolean;
  141264. /**
  141265. * An event triggered when the effect layer has been disposed.
  141266. */
  141267. onDisposeObservable: Observable<EffectLayer>;
  141268. /**
  141269. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  141270. */
  141271. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  141272. /**
  141273. * An event triggered when the generated texture is being merged in the scene.
  141274. */
  141275. onBeforeComposeObservable: Observable<EffectLayer>;
  141276. /**
  141277. * An event triggered when the mesh is rendered into the effect render target.
  141278. */
  141279. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  141280. /**
  141281. * An event triggered after the mesh has been rendered into the effect render target.
  141282. */
  141283. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  141284. /**
  141285. * An event triggered when the generated texture has been merged in the scene.
  141286. */
  141287. onAfterComposeObservable: Observable<EffectLayer>;
  141288. /**
  141289. * An event triggered when the efffect layer changes its size.
  141290. */
  141291. onSizeChangedObservable: Observable<EffectLayer>;
  141292. /** @hidden */
  141293. static _SceneComponentInitialization: (scene: Scene) => void;
  141294. /**
  141295. * Instantiates a new effect Layer and references it in the scene.
  141296. * @param name The name of the layer
  141297. * @param scene The scene to use the layer in
  141298. */
  141299. constructor(
  141300. /** The Friendly of the effect in the scene */
  141301. name: string, scene: Scene);
  141302. /**
  141303. * Get the effect name of the layer.
  141304. * @return The effect name
  141305. */
  141306. abstract getEffectName(): string;
  141307. /**
  141308. * Checks for the readiness of the element composing the layer.
  141309. * @param subMesh the mesh to check for
  141310. * @param useInstances specify whether or not to use instances to render the mesh
  141311. * @return true if ready otherwise, false
  141312. */
  141313. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141314. /**
  141315. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  141316. * @returns true if the effect requires stencil during the main canvas render pass.
  141317. */
  141318. abstract needStencil(): boolean;
  141319. /**
  141320. * Create the merge effect. This is the shader use to blit the information back
  141321. * to the main canvas at the end of the scene rendering.
  141322. * @returns The effect containing the shader used to merge the effect on the main canvas
  141323. */
  141324. protected abstract _createMergeEffect(): Effect;
  141325. /**
  141326. * Creates the render target textures and post processes used in the effect layer.
  141327. */
  141328. protected abstract _createTextureAndPostProcesses(): void;
  141329. /**
  141330. * Implementation specific of rendering the generating effect on the main canvas.
  141331. * @param effect The effect used to render through
  141332. */
  141333. protected abstract _internalRender(effect: Effect): void;
  141334. /**
  141335. * Sets the required values for both the emissive texture and and the main color.
  141336. */
  141337. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  141338. /**
  141339. * Free any resources and references associated to a mesh.
  141340. * Internal use
  141341. * @param mesh The mesh to free.
  141342. */
  141343. abstract _disposeMesh(mesh: Mesh): void;
  141344. /**
  141345. * Serializes this layer (Glow or Highlight for example)
  141346. * @returns a serialized layer object
  141347. */
  141348. abstract serialize?(): any;
  141349. /**
  141350. * Initializes the effect layer with the required options.
  141351. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  141352. */
  141353. protected _init(options: Partial<IEffectLayerOptions>): void;
  141354. /**
  141355. * Generates the index buffer of the full screen quad blending to the main canvas.
  141356. */
  141357. private _generateIndexBuffer;
  141358. /**
  141359. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  141360. */
  141361. private _generateVertexBuffer;
  141362. /**
  141363. * Sets the main texture desired size which is the closest power of two
  141364. * of the engine canvas size.
  141365. */
  141366. private _setMainTextureSize;
  141367. /**
  141368. * Creates the main texture for the effect layer.
  141369. */
  141370. protected _createMainTexture(): void;
  141371. /**
  141372. * Adds specific effects defines.
  141373. * @param defines The defines to add specifics to.
  141374. */
  141375. protected _addCustomEffectDefines(defines: string[]): void;
  141376. /**
  141377. * Checks for the readiness of the element composing the layer.
  141378. * @param subMesh the mesh to check for
  141379. * @param useInstances specify whether or not to use instances to render the mesh
  141380. * @param emissiveTexture the associated emissive texture used to generate the glow
  141381. * @return true if ready otherwise, false
  141382. */
  141383. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  141384. /**
  141385. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  141386. */
  141387. render(): void;
  141388. /**
  141389. * Determine if a given mesh will be used in the current effect.
  141390. * @param mesh mesh to test
  141391. * @returns true if the mesh will be used
  141392. */
  141393. hasMesh(mesh: AbstractMesh): boolean;
  141394. /**
  141395. * Returns true if the layer contains information to display, otherwise false.
  141396. * @returns true if the glow layer should be rendered
  141397. */
  141398. shouldRender(): boolean;
  141399. /**
  141400. * Returns true if the mesh should render, otherwise false.
  141401. * @param mesh The mesh to render
  141402. * @returns true if it should render otherwise false
  141403. */
  141404. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  141405. /**
  141406. * Returns true if the mesh can be rendered, otherwise false.
  141407. * @param mesh The mesh to render
  141408. * @param material The material used on the mesh
  141409. * @returns true if it can be rendered otherwise false
  141410. */
  141411. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  141412. /**
  141413. * Returns true if the mesh should render, otherwise false.
  141414. * @param mesh The mesh to render
  141415. * @returns true if it should render otherwise false
  141416. */
  141417. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  141418. /**
  141419. * Renders the submesh passed in parameter to the generation map.
  141420. */
  141421. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  141422. /**
  141423. * Defines whether the current material of the mesh should be use to render the effect.
  141424. * @param mesh defines the current mesh to render
  141425. */
  141426. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  141427. /**
  141428. * Rebuild the required buffers.
  141429. * @hidden Internal use only.
  141430. */
  141431. _rebuild(): void;
  141432. /**
  141433. * Dispose only the render target textures and post process.
  141434. */
  141435. private _disposeTextureAndPostProcesses;
  141436. /**
  141437. * Dispose the highlight layer and free resources.
  141438. */
  141439. dispose(): void;
  141440. /**
  141441. * Gets the class name of the effect layer
  141442. * @returns the string with the class name of the effect layer
  141443. */
  141444. getClassName(): string;
  141445. /**
  141446. * Creates an effect layer from parsed effect layer data
  141447. * @param parsedEffectLayer defines effect layer data
  141448. * @param scene defines the current scene
  141449. * @param rootUrl defines the root URL containing the effect layer information
  141450. * @returns a parsed effect Layer
  141451. */
  141452. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  141453. }
  141454. }
  141455. declare module BABYLON {
  141456. interface AbstractScene {
  141457. /**
  141458. * The list of effect layers (highlights/glow) added to the scene
  141459. * @see https://doc.babylonjs.com/how_to/highlight_layer
  141460. * @see https://doc.babylonjs.com/how_to/glow_layer
  141461. */
  141462. effectLayers: Array<EffectLayer>;
  141463. /**
  141464. * Removes the given effect layer from this scene.
  141465. * @param toRemove defines the effect layer to remove
  141466. * @returns the index of the removed effect layer
  141467. */
  141468. removeEffectLayer(toRemove: EffectLayer): number;
  141469. /**
  141470. * Adds the given effect layer to this scene
  141471. * @param newEffectLayer defines the effect layer to add
  141472. */
  141473. addEffectLayer(newEffectLayer: EffectLayer): void;
  141474. }
  141475. /**
  141476. * Defines the layer scene component responsible to manage any effect layers
  141477. * in a given scene.
  141478. */
  141479. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  141480. /**
  141481. * The component name helpfull to identify the component in the list of scene components.
  141482. */
  141483. readonly name: string;
  141484. /**
  141485. * The scene the component belongs to.
  141486. */
  141487. scene: Scene;
  141488. private _engine;
  141489. private _renderEffects;
  141490. private _needStencil;
  141491. private _previousStencilState;
  141492. /**
  141493. * Creates a new instance of the component for the given scene
  141494. * @param scene Defines the scene to register the component in
  141495. */
  141496. constructor(scene: Scene);
  141497. /**
  141498. * Registers the component in a given scene
  141499. */
  141500. register(): void;
  141501. /**
  141502. * Rebuilds the elements related to this component in case of
  141503. * context lost for instance.
  141504. */
  141505. rebuild(): void;
  141506. /**
  141507. * Serializes the component data to the specified json object
  141508. * @param serializationObject The object to serialize to
  141509. */
  141510. serialize(serializationObject: any): void;
  141511. /**
  141512. * Adds all the elements from the container to the scene
  141513. * @param container the container holding the elements
  141514. */
  141515. addFromContainer(container: AbstractScene): void;
  141516. /**
  141517. * Removes all the elements in the container from the scene
  141518. * @param container contains the elements to remove
  141519. * @param dispose if the removed element should be disposed (default: false)
  141520. */
  141521. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141522. /**
  141523. * Disposes the component and the associated ressources.
  141524. */
  141525. dispose(): void;
  141526. private _isReadyForMesh;
  141527. private _renderMainTexture;
  141528. private _setStencil;
  141529. private _setStencilBack;
  141530. private _draw;
  141531. private _drawCamera;
  141532. private _drawRenderingGroup;
  141533. }
  141534. }
  141535. declare module BABYLON {
  141536. /** @hidden */
  141537. export var glowMapMergePixelShader: {
  141538. name: string;
  141539. shader: string;
  141540. };
  141541. }
  141542. declare module BABYLON {
  141543. /** @hidden */
  141544. export var glowMapMergeVertexShader: {
  141545. name: string;
  141546. shader: string;
  141547. };
  141548. }
  141549. declare module BABYLON {
  141550. interface AbstractScene {
  141551. /**
  141552. * Return a the first highlight layer of the scene with a given name.
  141553. * @param name The name of the highlight layer to look for.
  141554. * @return The highlight layer if found otherwise null.
  141555. */
  141556. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  141557. }
  141558. /**
  141559. * Glow layer options. This helps customizing the behaviour
  141560. * of the glow layer.
  141561. */
  141562. export interface IGlowLayerOptions {
  141563. /**
  141564. * Multiplication factor apply to the canvas size to compute the render target size
  141565. * used to generated the glowing objects (the smaller the faster).
  141566. */
  141567. mainTextureRatio: number;
  141568. /**
  141569. * Enforces a fixed size texture to ensure resize independant blur.
  141570. */
  141571. mainTextureFixedSize?: number;
  141572. /**
  141573. * How big is the kernel of the blur texture.
  141574. */
  141575. blurKernelSize: number;
  141576. /**
  141577. * The camera attached to the layer.
  141578. */
  141579. camera: Nullable<Camera>;
  141580. /**
  141581. * Enable MSAA by chosing the number of samples.
  141582. */
  141583. mainTextureSamples?: number;
  141584. /**
  141585. * The rendering group to draw the layer in.
  141586. */
  141587. renderingGroupId: number;
  141588. }
  141589. /**
  141590. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  141591. *
  141592. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  141593. *
  141594. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  141595. */
  141596. export class GlowLayer extends EffectLayer {
  141597. /**
  141598. * Effect Name of the layer.
  141599. */
  141600. static readonly EffectName: string;
  141601. /**
  141602. * The default blur kernel size used for the glow.
  141603. */
  141604. static DefaultBlurKernelSize: number;
  141605. /**
  141606. * The default texture size ratio used for the glow.
  141607. */
  141608. static DefaultTextureRatio: number;
  141609. /**
  141610. * Sets the kernel size of the blur.
  141611. */
  141612. set blurKernelSize(value: number);
  141613. /**
  141614. * Gets the kernel size of the blur.
  141615. */
  141616. get blurKernelSize(): number;
  141617. /**
  141618. * Sets the glow intensity.
  141619. */
  141620. set intensity(value: number);
  141621. /**
  141622. * Gets the glow intensity.
  141623. */
  141624. get intensity(): number;
  141625. private _options;
  141626. private _intensity;
  141627. private _horizontalBlurPostprocess1;
  141628. private _verticalBlurPostprocess1;
  141629. private _horizontalBlurPostprocess2;
  141630. private _verticalBlurPostprocess2;
  141631. private _blurTexture1;
  141632. private _blurTexture2;
  141633. private _postProcesses1;
  141634. private _postProcesses2;
  141635. private _includedOnlyMeshes;
  141636. private _excludedMeshes;
  141637. private _meshesUsingTheirOwnMaterials;
  141638. /**
  141639. * Callback used to let the user override the color selection on a per mesh basis
  141640. */
  141641. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  141642. /**
  141643. * Callback used to let the user override the texture selection on a per mesh basis
  141644. */
  141645. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  141646. /**
  141647. * Instantiates a new glow Layer and references it to the scene.
  141648. * @param name The name of the layer
  141649. * @param scene The scene to use the layer in
  141650. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  141651. */
  141652. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  141653. /**
  141654. * Get the effect name of the layer.
  141655. * @return The effect name
  141656. */
  141657. getEffectName(): string;
  141658. /**
  141659. * Create the merge effect. This is the shader use to blit the information back
  141660. * to the main canvas at the end of the scene rendering.
  141661. */
  141662. protected _createMergeEffect(): Effect;
  141663. /**
  141664. * Creates the render target textures and post processes used in the glow layer.
  141665. */
  141666. protected _createTextureAndPostProcesses(): void;
  141667. /**
  141668. * Checks for the readiness of the element composing the layer.
  141669. * @param subMesh the mesh to check for
  141670. * @param useInstances specify wether or not to use instances to render the mesh
  141671. * @param emissiveTexture the associated emissive texture used to generate the glow
  141672. * @return true if ready otherwise, false
  141673. */
  141674. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141675. /**
  141676. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  141677. */
  141678. needStencil(): boolean;
  141679. /**
  141680. * Returns true if the mesh can be rendered, otherwise false.
  141681. * @param mesh The mesh to render
  141682. * @param material The material used on the mesh
  141683. * @returns true if it can be rendered otherwise false
  141684. */
  141685. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  141686. /**
  141687. * Implementation specific of rendering the generating effect on the main canvas.
  141688. * @param effect The effect used to render through
  141689. */
  141690. protected _internalRender(effect: Effect): void;
  141691. /**
  141692. * Sets the required values for both the emissive texture and and the main color.
  141693. */
  141694. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  141695. /**
  141696. * Returns true if the mesh should render, otherwise false.
  141697. * @param mesh The mesh to render
  141698. * @returns true if it should render otherwise false
  141699. */
  141700. protected _shouldRenderMesh(mesh: Mesh): boolean;
  141701. /**
  141702. * Adds specific effects defines.
  141703. * @param defines The defines to add specifics to.
  141704. */
  141705. protected _addCustomEffectDefines(defines: string[]): void;
  141706. /**
  141707. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  141708. * @param mesh The mesh to exclude from the glow layer
  141709. */
  141710. addExcludedMesh(mesh: Mesh): void;
  141711. /**
  141712. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  141713. * @param mesh The mesh to remove
  141714. */
  141715. removeExcludedMesh(mesh: Mesh): void;
  141716. /**
  141717. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  141718. * @param mesh The mesh to include in the glow layer
  141719. */
  141720. addIncludedOnlyMesh(mesh: Mesh): void;
  141721. /**
  141722. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  141723. * @param mesh The mesh to remove
  141724. */
  141725. removeIncludedOnlyMesh(mesh: Mesh): void;
  141726. /**
  141727. * Determine if a given mesh will be used in the glow layer
  141728. * @param mesh The mesh to test
  141729. * @returns true if the mesh will be highlighted by the current glow layer
  141730. */
  141731. hasMesh(mesh: AbstractMesh): boolean;
  141732. /**
  141733. * Defines whether the current material of the mesh should be use to render the effect.
  141734. * @param mesh defines the current mesh to render
  141735. */
  141736. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  141737. /**
  141738. * Add a mesh to be rendered through its own material and not with emissive only.
  141739. * @param mesh The mesh for which we need to use its material
  141740. */
  141741. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  141742. /**
  141743. * Remove a mesh from being rendered through its own material and not with emissive only.
  141744. * @param mesh The mesh for which we need to not use its material
  141745. */
  141746. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  141747. /**
  141748. * Free any resources and references associated to a mesh.
  141749. * Internal use
  141750. * @param mesh The mesh to free.
  141751. * @hidden
  141752. */
  141753. _disposeMesh(mesh: Mesh): void;
  141754. /**
  141755. * Gets the class name of the effect layer
  141756. * @returns the string with the class name of the effect layer
  141757. */
  141758. getClassName(): string;
  141759. /**
  141760. * Serializes this glow layer
  141761. * @returns a serialized glow layer object
  141762. */
  141763. serialize(): any;
  141764. /**
  141765. * Creates a Glow Layer from parsed glow layer data
  141766. * @param parsedGlowLayer defines glow layer data
  141767. * @param scene defines the current scene
  141768. * @param rootUrl defines the root URL containing the glow layer information
  141769. * @returns a parsed Glow Layer
  141770. */
  141771. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  141772. }
  141773. }
  141774. declare module BABYLON {
  141775. /** @hidden */
  141776. export var glowBlurPostProcessPixelShader: {
  141777. name: string;
  141778. shader: string;
  141779. };
  141780. }
  141781. declare module BABYLON {
  141782. interface AbstractScene {
  141783. /**
  141784. * Return a the first highlight layer of the scene with a given name.
  141785. * @param name The name of the highlight layer to look for.
  141786. * @return The highlight layer if found otherwise null.
  141787. */
  141788. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  141789. }
  141790. /**
  141791. * Highlight layer options. This helps customizing the behaviour
  141792. * of the highlight layer.
  141793. */
  141794. export interface IHighlightLayerOptions {
  141795. /**
  141796. * Multiplication factor apply to the canvas size to compute the render target size
  141797. * used to generated the glowing objects (the smaller the faster).
  141798. */
  141799. mainTextureRatio: number;
  141800. /**
  141801. * Enforces a fixed size texture to ensure resize independant blur.
  141802. */
  141803. mainTextureFixedSize?: number;
  141804. /**
  141805. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  141806. * of the picture to blur (the smaller the faster).
  141807. */
  141808. blurTextureSizeRatio: number;
  141809. /**
  141810. * How big in texel of the blur texture is the vertical blur.
  141811. */
  141812. blurVerticalSize: number;
  141813. /**
  141814. * How big in texel of the blur texture is the horizontal blur.
  141815. */
  141816. blurHorizontalSize: number;
  141817. /**
  141818. * Alpha blending mode used to apply the blur. Default is combine.
  141819. */
  141820. alphaBlendingMode: number;
  141821. /**
  141822. * The camera attached to the layer.
  141823. */
  141824. camera: Nullable<Camera>;
  141825. /**
  141826. * Should we display highlight as a solid stroke?
  141827. */
  141828. isStroke?: boolean;
  141829. /**
  141830. * The rendering group to draw the layer in.
  141831. */
  141832. renderingGroupId: number;
  141833. }
  141834. /**
  141835. * The highlight layer Helps adding a glow effect around a mesh.
  141836. *
  141837. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  141838. * glowy meshes to your scene.
  141839. *
  141840. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  141841. */
  141842. export class HighlightLayer extends EffectLayer {
  141843. name: string;
  141844. /**
  141845. * Effect Name of the highlight layer.
  141846. */
  141847. static readonly EffectName: string;
  141848. /**
  141849. * The neutral color used during the preparation of the glow effect.
  141850. * This is black by default as the blend operation is a blend operation.
  141851. */
  141852. static NeutralColor: Color4;
  141853. /**
  141854. * Stencil value used for glowing meshes.
  141855. */
  141856. static GlowingMeshStencilReference: number;
  141857. /**
  141858. * Stencil value used for the other meshes in the scene.
  141859. */
  141860. static NormalMeshStencilReference: number;
  141861. /**
  141862. * Specifies whether or not the inner glow is ACTIVE in the layer.
  141863. */
  141864. innerGlow: boolean;
  141865. /**
  141866. * Specifies whether or not the outer glow is ACTIVE in the layer.
  141867. */
  141868. outerGlow: boolean;
  141869. /**
  141870. * Specifies the horizontal size of the blur.
  141871. */
  141872. set blurHorizontalSize(value: number);
  141873. /**
  141874. * Specifies the vertical size of the blur.
  141875. */
  141876. set blurVerticalSize(value: number);
  141877. /**
  141878. * Gets the horizontal size of the blur.
  141879. */
  141880. get blurHorizontalSize(): number;
  141881. /**
  141882. * Gets the vertical size of the blur.
  141883. */
  141884. get blurVerticalSize(): number;
  141885. /**
  141886. * An event triggered when the highlight layer is being blurred.
  141887. */
  141888. onBeforeBlurObservable: Observable<HighlightLayer>;
  141889. /**
  141890. * An event triggered when the highlight layer has been blurred.
  141891. */
  141892. onAfterBlurObservable: Observable<HighlightLayer>;
  141893. private _instanceGlowingMeshStencilReference;
  141894. private _options;
  141895. private _downSamplePostprocess;
  141896. private _horizontalBlurPostprocess;
  141897. private _verticalBlurPostprocess;
  141898. private _blurTexture;
  141899. private _meshes;
  141900. private _excludedMeshes;
  141901. /**
  141902. * Instantiates a new highlight Layer and references it to the scene..
  141903. * @param name The name of the layer
  141904. * @param scene The scene to use the layer in
  141905. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  141906. */
  141907. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  141908. /**
  141909. * Get the effect name of the layer.
  141910. * @return The effect name
  141911. */
  141912. getEffectName(): string;
  141913. /**
  141914. * Create the merge effect. This is the shader use to blit the information back
  141915. * to the main canvas at the end of the scene rendering.
  141916. */
  141917. protected _createMergeEffect(): Effect;
  141918. /**
  141919. * Creates the render target textures and post processes used in the highlight layer.
  141920. */
  141921. protected _createTextureAndPostProcesses(): void;
  141922. /**
  141923. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  141924. */
  141925. needStencil(): boolean;
  141926. /**
  141927. * Checks for the readiness of the element composing the layer.
  141928. * @param subMesh the mesh to check for
  141929. * @param useInstances specify wether or not to use instances to render the mesh
  141930. * @param emissiveTexture the associated emissive texture used to generate the glow
  141931. * @return true if ready otherwise, false
  141932. */
  141933. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141934. /**
  141935. * Implementation specific of rendering the generating effect on the main canvas.
  141936. * @param effect The effect used to render through
  141937. */
  141938. protected _internalRender(effect: Effect): void;
  141939. /**
  141940. * Returns true if the layer contains information to display, otherwise false.
  141941. */
  141942. shouldRender(): boolean;
  141943. /**
  141944. * Returns true if the mesh should render, otherwise false.
  141945. * @param mesh The mesh to render
  141946. * @returns true if it should render otherwise false
  141947. */
  141948. protected _shouldRenderMesh(mesh: Mesh): boolean;
  141949. /**
  141950. * Returns true if the mesh can be rendered, otherwise false.
  141951. * @param mesh The mesh to render
  141952. * @param material The material used on the mesh
  141953. * @returns true if it can be rendered otherwise false
  141954. */
  141955. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  141956. /**
  141957. * Adds specific effects defines.
  141958. * @param defines The defines to add specifics to.
  141959. */
  141960. protected _addCustomEffectDefines(defines: string[]): void;
  141961. /**
  141962. * Sets the required values for both the emissive texture and and the main color.
  141963. */
  141964. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  141965. /**
  141966. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  141967. * @param mesh The mesh to exclude from the highlight layer
  141968. */
  141969. addExcludedMesh(mesh: Mesh): void;
  141970. /**
  141971. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  141972. * @param mesh The mesh to highlight
  141973. */
  141974. removeExcludedMesh(mesh: Mesh): void;
  141975. /**
  141976. * Determine if a given mesh will be highlighted by the current HighlightLayer
  141977. * @param mesh mesh to test
  141978. * @returns true if the mesh will be highlighted by the current HighlightLayer
  141979. */
  141980. hasMesh(mesh: AbstractMesh): boolean;
  141981. /**
  141982. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  141983. * @param mesh The mesh to highlight
  141984. * @param color The color of the highlight
  141985. * @param glowEmissiveOnly Extract the glow from the emissive texture
  141986. */
  141987. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  141988. /**
  141989. * Remove a mesh from the highlight layer in order to make it stop glowing.
  141990. * @param mesh The mesh to highlight
  141991. */
  141992. removeMesh(mesh: Mesh): void;
  141993. /**
  141994. * Remove all the meshes currently referenced in the highlight layer
  141995. */
  141996. removeAllMeshes(): void;
  141997. /**
  141998. * Force the stencil to the normal expected value for none glowing parts
  141999. */
  142000. private _defaultStencilReference;
  142001. /**
  142002. * Free any resources and references associated to a mesh.
  142003. * Internal use
  142004. * @param mesh The mesh to free.
  142005. * @hidden
  142006. */
  142007. _disposeMesh(mesh: Mesh): void;
  142008. /**
  142009. * Dispose the highlight layer and free resources.
  142010. */
  142011. dispose(): void;
  142012. /**
  142013. * Gets the class name of the effect layer
  142014. * @returns the string with the class name of the effect layer
  142015. */
  142016. getClassName(): string;
  142017. /**
  142018. * Serializes this Highlight layer
  142019. * @returns a serialized Highlight layer object
  142020. */
  142021. serialize(): any;
  142022. /**
  142023. * Creates a Highlight layer from parsed Highlight layer data
  142024. * @param parsedHightlightLayer defines the Highlight layer data
  142025. * @param scene defines the current scene
  142026. * @param rootUrl defines the root URL containing the Highlight layer information
  142027. * @returns a parsed Highlight layer
  142028. */
  142029. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  142030. }
  142031. }
  142032. declare module BABYLON {
  142033. interface AbstractScene {
  142034. /**
  142035. * The list of layers (background and foreground) of the scene
  142036. */
  142037. layers: Array<Layer>;
  142038. }
  142039. /**
  142040. * Defines the layer scene component responsible to manage any layers
  142041. * in a given scene.
  142042. */
  142043. export class LayerSceneComponent implements ISceneComponent {
  142044. /**
  142045. * The component name helpfull to identify the component in the list of scene components.
  142046. */
  142047. readonly name: string;
  142048. /**
  142049. * The scene the component belongs to.
  142050. */
  142051. scene: Scene;
  142052. private _engine;
  142053. /**
  142054. * Creates a new instance of the component for the given scene
  142055. * @param scene Defines the scene to register the component in
  142056. */
  142057. constructor(scene: Scene);
  142058. /**
  142059. * Registers the component in a given scene
  142060. */
  142061. register(): void;
  142062. /**
  142063. * Rebuilds the elements related to this component in case of
  142064. * context lost for instance.
  142065. */
  142066. rebuild(): void;
  142067. /**
  142068. * Disposes the component and the associated ressources.
  142069. */
  142070. dispose(): void;
  142071. private _draw;
  142072. private _drawCameraPredicate;
  142073. private _drawCameraBackground;
  142074. private _drawCameraForeground;
  142075. private _drawRenderTargetPredicate;
  142076. private _drawRenderTargetBackground;
  142077. private _drawRenderTargetForeground;
  142078. /**
  142079. * Adds all the elements from the container to the scene
  142080. * @param container the container holding the elements
  142081. */
  142082. addFromContainer(container: AbstractScene): void;
  142083. /**
  142084. * Removes all the elements in the container from the scene
  142085. * @param container contains the elements to remove
  142086. * @param dispose if the removed element should be disposed (default: false)
  142087. */
  142088. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  142089. }
  142090. }
  142091. declare module BABYLON {
  142092. /** @hidden */
  142093. export var layerPixelShader: {
  142094. name: string;
  142095. shader: string;
  142096. };
  142097. }
  142098. declare module BABYLON {
  142099. /** @hidden */
  142100. export var layerVertexShader: {
  142101. name: string;
  142102. shader: string;
  142103. };
  142104. }
  142105. declare module BABYLON {
  142106. /**
  142107. * This represents a full screen 2d layer.
  142108. * This can be useful to display a picture in the background of your scene for instance.
  142109. * @see https://www.babylonjs-playground.com/#08A2BS#1
  142110. */
  142111. export class Layer {
  142112. /**
  142113. * Define the name of the layer.
  142114. */
  142115. name: string;
  142116. /**
  142117. * Define the texture the layer should display.
  142118. */
  142119. texture: Nullable<Texture>;
  142120. /**
  142121. * Is the layer in background or foreground.
  142122. */
  142123. isBackground: boolean;
  142124. /**
  142125. * Define the color of the layer (instead of texture).
  142126. */
  142127. color: Color4;
  142128. /**
  142129. * Define the scale of the layer in order to zoom in out of the texture.
  142130. */
  142131. scale: Vector2;
  142132. /**
  142133. * Define an offset for the layer in order to shift the texture.
  142134. */
  142135. offset: Vector2;
  142136. /**
  142137. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  142138. */
  142139. alphaBlendingMode: number;
  142140. /**
  142141. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  142142. * Alpha test will not mix with the background color in case of transparency.
  142143. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  142144. */
  142145. alphaTest: boolean;
  142146. /**
  142147. * Define a mask to restrict the layer to only some of the scene cameras.
  142148. */
  142149. layerMask: number;
  142150. /**
  142151. * Define the list of render target the layer is visible into.
  142152. */
  142153. renderTargetTextures: RenderTargetTexture[];
  142154. /**
  142155. * Define if the layer is only used in renderTarget or if it also
  142156. * renders in the main frame buffer of the canvas.
  142157. */
  142158. renderOnlyInRenderTargetTextures: boolean;
  142159. private _scene;
  142160. private _vertexBuffers;
  142161. private _indexBuffer;
  142162. private _effect;
  142163. private _previousDefines;
  142164. /**
  142165. * An event triggered when the layer is disposed.
  142166. */
  142167. onDisposeObservable: Observable<Layer>;
  142168. private _onDisposeObserver;
  142169. /**
  142170. * Back compatibility with callback before the onDisposeObservable existed.
  142171. * The set callback will be triggered when the layer has been disposed.
  142172. */
  142173. set onDispose(callback: () => void);
  142174. /**
  142175. * An event triggered before rendering the scene
  142176. */
  142177. onBeforeRenderObservable: Observable<Layer>;
  142178. private _onBeforeRenderObserver;
  142179. /**
  142180. * Back compatibility with callback before the onBeforeRenderObservable existed.
  142181. * The set callback will be triggered just before rendering the layer.
  142182. */
  142183. set onBeforeRender(callback: () => void);
  142184. /**
  142185. * An event triggered after rendering the scene
  142186. */
  142187. onAfterRenderObservable: Observable<Layer>;
  142188. private _onAfterRenderObserver;
  142189. /**
  142190. * Back compatibility with callback before the onAfterRenderObservable existed.
  142191. * The set callback will be triggered just after rendering the layer.
  142192. */
  142193. set onAfterRender(callback: () => void);
  142194. /**
  142195. * Instantiates a new layer.
  142196. * This represents a full screen 2d layer.
  142197. * This can be useful to display a picture in the background of your scene for instance.
  142198. * @see https://www.babylonjs-playground.com/#08A2BS#1
  142199. * @param name Define the name of the layer in the scene
  142200. * @param imgUrl Define the url of the texture to display in the layer
  142201. * @param scene Define the scene the layer belongs to
  142202. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  142203. * @param color Defines a color for the layer
  142204. */
  142205. constructor(
  142206. /**
  142207. * Define the name of the layer.
  142208. */
  142209. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  142210. private _createIndexBuffer;
  142211. /** @hidden */
  142212. _rebuild(): void;
  142213. /**
  142214. * Renders the layer in the scene.
  142215. */
  142216. render(): void;
  142217. /**
  142218. * Disposes and releases the associated ressources.
  142219. */
  142220. dispose(): void;
  142221. }
  142222. }
  142223. declare module BABYLON {
  142224. /** @hidden */
  142225. export var lensFlarePixelShader: {
  142226. name: string;
  142227. shader: string;
  142228. };
  142229. }
  142230. declare module BABYLON {
  142231. /** @hidden */
  142232. export var lensFlareVertexShader: {
  142233. name: string;
  142234. shader: string;
  142235. };
  142236. }
  142237. declare module BABYLON {
  142238. /**
  142239. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  142240. * It is usually composed of several `lensFlare`.
  142241. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142242. */
  142243. export class LensFlareSystem {
  142244. /**
  142245. * Define the name of the lens flare system
  142246. */
  142247. name: string;
  142248. /**
  142249. * List of lens flares used in this system.
  142250. */
  142251. lensFlares: LensFlare[];
  142252. /**
  142253. * Define a limit from the border the lens flare can be visible.
  142254. */
  142255. borderLimit: number;
  142256. /**
  142257. * Define a viewport border we do not want to see the lens flare in.
  142258. */
  142259. viewportBorder: number;
  142260. /**
  142261. * Define a predicate which could limit the list of meshes able to occlude the effect.
  142262. */
  142263. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  142264. /**
  142265. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  142266. */
  142267. layerMask: number;
  142268. /**
  142269. * Define the id of the lens flare system in the scene.
  142270. * (equal to name by default)
  142271. */
  142272. id: string;
  142273. private _scene;
  142274. private _emitter;
  142275. private _vertexBuffers;
  142276. private _indexBuffer;
  142277. private _effect;
  142278. private _positionX;
  142279. private _positionY;
  142280. private _isEnabled;
  142281. /** @hidden */
  142282. static _SceneComponentInitialization: (scene: Scene) => void;
  142283. /**
  142284. * Instantiates a lens flare system.
  142285. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  142286. * It is usually composed of several `lensFlare`.
  142287. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142288. * @param name Define the name of the lens flare system in the scene
  142289. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  142290. * @param scene Define the scene the lens flare system belongs to
  142291. */
  142292. constructor(
  142293. /**
  142294. * Define the name of the lens flare system
  142295. */
  142296. name: string, emitter: any, scene: Scene);
  142297. /**
  142298. * Define if the lens flare system is enabled.
  142299. */
  142300. get isEnabled(): boolean;
  142301. set isEnabled(value: boolean);
  142302. /**
  142303. * Get the scene the effects belongs to.
  142304. * @returns the scene holding the lens flare system
  142305. */
  142306. getScene(): Scene;
  142307. /**
  142308. * Get the emitter of the lens flare system.
  142309. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  142310. * @returns the emitter of the lens flare system
  142311. */
  142312. getEmitter(): any;
  142313. /**
  142314. * Set the emitter of the lens flare system.
  142315. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  142316. * @param newEmitter Define the new emitter of the system
  142317. */
  142318. setEmitter(newEmitter: any): void;
  142319. /**
  142320. * Get the lens flare system emitter position.
  142321. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  142322. * @returns the position
  142323. */
  142324. getEmitterPosition(): Vector3;
  142325. /**
  142326. * @hidden
  142327. */
  142328. computeEffectivePosition(globalViewport: Viewport): boolean;
  142329. /** @hidden */
  142330. _isVisible(): boolean;
  142331. /**
  142332. * @hidden
  142333. */
  142334. render(): boolean;
  142335. /**
  142336. * Dispose and release the lens flare with its associated resources.
  142337. */
  142338. dispose(): void;
  142339. /**
  142340. * Parse a lens flare system from a JSON repressentation
  142341. * @param parsedLensFlareSystem Define the JSON to parse
  142342. * @param scene Define the scene the parsed system should be instantiated in
  142343. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  142344. * @returns the parsed system
  142345. */
  142346. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  142347. /**
  142348. * Serialize the current Lens Flare System into a JSON representation.
  142349. * @returns the serialized JSON
  142350. */
  142351. serialize(): any;
  142352. }
  142353. }
  142354. declare module BABYLON {
  142355. /**
  142356. * This represents one of the lens effect in a `lensFlareSystem`.
  142357. * It controls one of the indiviual texture used in the effect.
  142358. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142359. */
  142360. export class LensFlare {
  142361. /**
  142362. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  142363. */
  142364. size: number;
  142365. /**
  142366. * 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.
  142367. */
  142368. position: number;
  142369. /**
  142370. * Define the lens color.
  142371. */
  142372. color: Color3;
  142373. /**
  142374. * Define the lens texture.
  142375. */
  142376. texture: Nullable<Texture>;
  142377. /**
  142378. * Define the alpha mode to render this particular lens.
  142379. */
  142380. alphaMode: number;
  142381. private _system;
  142382. /**
  142383. * Creates a new Lens Flare.
  142384. * This represents one of the lens effect in a `lensFlareSystem`.
  142385. * It controls one of the indiviual texture used in the effect.
  142386. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142387. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  142388. * @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.
  142389. * @param color Define the lens color
  142390. * @param imgUrl Define the lens texture url
  142391. * @param system Define the `lensFlareSystem` this flare is part of
  142392. * @returns The newly created Lens Flare
  142393. */
  142394. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  142395. /**
  142396. * Instantiates a new Lens Flare.
  142397. * This represents one of the lens effect in a `lensFlareSystem`.
  142398. * It controls one of the indiviual texture used in the effect.
  142399. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142400. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  142401. * @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.
  142402. * @param color Define the lens color
  142403. * @param imgUrl Define the lens texture url
  142404. * @param system Define the `lensFlareSystem` this flare is part of
  142405. */
  142406. constructor(
  142407. /**
  142408. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  142409. */
  142410. size: number,
  142411. /**
  142412. * 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.
  142413. */
  142414. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  142415. /**
  142416. * Dispose and release the lens flare with its associated resources.
  142417. */
  142418. dispose(): void;
  142419. }
  142420. }
  142421. declare module BABYLON {
  142422. interface AbstractScene {
  142423. /**
  142424. * The list of lens flare system added to the scene
  142425. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142426. */
  142427. lensFlareSystems: Array<LensFlareSystem>;
  142428. /**
  142429. * Removes the given lens flare system from this scene.
  142430. * @param toRemove The lens flare system to remove
  142431. * @returns The index of the removed lens flare system
  142432. */
  142433. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  142434. /**
  142435. * Adds the given lens flare system to this scene
  142436. * @param newLensFlareSystem The lens flare system to add
  142437. */
  142438. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  142439. /**
  142440. * Gets a lens flare system using its name
  142441. * @param name defines the name to look for
  142442. * @returns the lens flare system or null if not found
  142443. */
  142444. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  142445. /**
  142446. * Gets a lens flare system using its id
  142447. * @param id defines the id to look for
  142448. * @returns the lens flare system or null if not found
  142449. */
  142450. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  142451. }
  142452. /**
  142453. * Defines the lens flare scene component responsible to manage any lens flares
  142454. * in a given scene.
  142455. */
  142456. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  142457. /**
  142458. * The component name helpfull to identify the component in the list of scene components.
  142459. */
  142460. readonly name: string;
  142461. /**
  142462. * The scene the component belongs to.
  142463. */
  142464. scene: Scene;
  142465. /**
  142466. * Creates a new instance of the component for the given scene
  142467. * @param scene Defines the scene to register the component in
  142468. */
  142469. constructor(scene: Scene);
  142470. /**
  142471. * Registers the component in a given scene
  142472. */
  142473. register(): void;
  142474. /**
  142475. * Rebuilds the elements related to this component in case of
  142476. * context lost for instance.
  142477. */
  142478. rebuild(): void;
  142479. /**
  142480. * Adds all the elements from the container to the scene
  142481. * @param container the container holding the elements
  142482. */
  142483. addFromContainer(container: AbstractScene): void;
  142484. /**
  142485. * Removes all the elements in the container from the scene
  142486. * @param container contains the elements to remove
  142487. * @param dispose if the removed element should be disposed (default: false)
  142488. */
  142489. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  142490. /**
  142491. * Serializes the component data to the specified json object
  142492. * @param serializationObject The object to serialize to
  142493. */
  142494. serialize(serializationObject: any): void;
  142495. /**
  142496. * Disposes the component and the associated ressources.
  142497. */
  142498. dispose(): void;
  142499. private _draw;
  142500. }
  142501. }
  142502. declare module BABYLON {
  142503. /** @hidden */
  142504. export var depthPixelShader: {
  142505. name: string;
  142506. shader: string;
  142507. };
  142508. }
  142509. declare module BABYLON {
  142510. /** @hidden */
  142511. export var depthVertexShader: {
  142512. name: string;
  142513. shader: string;
  142514. };
  142515. }
  142516. declare module BABYLON {
  142517. /**
  142518. * This represents a depth renderer in Babylon.
  142519. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  142520. */
  142521. export class DepthRenderer {
  142522. private _scene;
  142523. private _depthMap;
  142524. private _effect;
  142525. private readonly _storeNonLinearDepth;
  142526. private readonly _clearColor;
  142527. /** Get if the depth renderer is using packed depth or not */
  142528. readonly isPacked: boolean;
  142529. private _cachedDefines;
  142530. private _camera;
  142531. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  142532. enabled: boolean;
  142533. /**
  142534. * Specifiess that the depth renderer will only be used within
  142535. * the camera it is created for.
  142536. * This can help forcing its rendering during the camera processing.
  142537. */
  142538. useOnlyInActiveCamera: boolean;
  142539. /** @hidden */
  142540. static _SceneComponentInitialization: (scene: Scene) => void;
  142541. /**
  142542. * Instantiates a depth renderer
  142543. * @param scene The scene the renderer belongs to
  142544. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  142545. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  142546. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  142547. */
  142548. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  142549. /**
  142550. * Creates the depth rendering effect and checks if the effect is ready.
  142551. * @param subMesh The submesh to be used to render the depth map of
  142552. * @param useInstances If multiple world instances should be used
  142553. * @returns if the depth renderer is ready to render the depth map
  142554. */
  142555. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  142556. /**
  142557. * Gets the texture which the depth map will be written to.
  142558. * @returns The depth map texture
  142559. */
  142560. getDepthMap(): RenderTargetTexture;
  142561. /**
  142562. * Disposes of the depth renderer.
  142563. */
  142564. dispose(): void;
  142565. }
  142566. }
  142567. declare module BABYLON {
  142568. /** @hidden */
  142569. export var minmaxReduxPixelShader: {
  142570. name: string;
  142571. shader: string;
  142572. };
  142573. }
  142574. declare module BABYLON {
  142575. /**
  142576. * This class computes a min/max reduction from a texture: it means it computes the minimum
  142577. * and maximum values from all values of the texture.
  142578. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  142579. * The source values are read from the red channel of the texture.
  142580. */
  142581. export class MinMaxReducer {
  142582. /**
  142583. * Observable triggered when the computation has been performed
  142584. */
  142585. onAfterReductionPerformed: Observable<{
  142586. min: number;
  142587. max: number;
  142588. }>;
  142589. protected _camera: Camera;
  142590. protected _sourceTexture: Nullable<RenderTargetTexture>;
  142591. protected _reductionSteps: Nullable<Array<PostProcess>>;
  142592. protected _postProcessManager: PostProcessManager;
  142593. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  142594. protected _forceFullscreenViewport: boolean;
  142595. /**
  142596. * Creates a min/max reducer
  142597. * @param camera The camera to use for the post processes
  142598. */
  142599. constructor(camera: Camera);
  142600. /**
  142601. * Gets the texture used to read the values from.
  142602. */
  142603. get sourceTexture(): Nullable<RenderTargetTexture>;
  142604. /**
  142605. * Sets the source texture to read the values from.
  142606. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  142607. * because in such textures '1' value must not be taken into account to compute the maximum
  142608. * as this value is used to clear the texture.
  142609. * Note that the computation is not activated by calling this function, you must call activate() for that!
  142610. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  142611. * @param depthRedux Indicates if the texture is a depth texture or not
  142612. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  142613. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  142614. */
  142615. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  142616. /**
  142617. * Defines the refresh rate of the computation.
  142618. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  142619. */
  142620. get refreshRate(): number;
  142621. set refreshRate(value: number);
  142622. protected _activated: boolean;
  142623. /**
  142624. * Gets the activation status of the reducer
  142625. */
  142626. get activated(): boolean;
  142627. /**
  142628. * Activates the reduction computation.
  142629. * When activated, the observers registered in onAfterReductionPerformed are
  142630. * called after the compuation is performed
  142631. */
  142632. activate(): void;
  142633. /**
  142634. * Deactivates the reduction computation.
  142635. */
  142636. deactivate(): void;
  142637. /**
  142638. * Disposes the min/max reducer
  142639. * @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.
  142640. */
  142641. dispose(disposeAll?: boolean): void;
  142642. }
  142643. }
  142644. declare module BABYLON {
  142645. /**
  142646. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  142647. */
  142648. export class DepthReducer extends MinMaxReducer {
  142649. private _depthRenderer;
  142650. private _depthRendererId;
  142651. /**
  142652. * Gets the depth renderer used for the computation.
  142653. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  142654. */
  142655. get depthRenderer(): Nullable<DepthRenderer>;
  142656. /**
  142657. * Creates a depth reducer
  142658. * @param camera The camera used to render the depth texture
  142659. */
  142660. constructor(camera: Camera);
  142661. /**
  142662. * Sets the depth renderer to use to generate the depth map
  142663. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  142664. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  142665. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  142666. */
  142667. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  142668. /** @hidden */
  142669. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  142670. /**
  142671. * Activates the reduction computation.
  142672. * When activated, the observers registered in onAfterReductionPerformed are
  142673. * called after the compuation is performed
  142674. */
  142675. activate(): void;
  142676. /**
  142677. * Deactivates the reduction computation.
  142678. */
  142679. deactivate(): void;
  142680. /**
  142681. * Disposes the depth reducer
  142682. * @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.
  142683. */
  142684. dispose(disposeAll?: boolean): void;
  142685. }
  142686. }
  142687. declare module BABYLON {
  142688. /**
  142689. * A CSM implementation allowing casting shadows on large scenes.
  142690. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  142691. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  142692. */
  142693. export class CascadedShadowGenerator extends ShadowGenerator {
  142694. private static readonly frustumCornersNDCSpace;
  142695. /**
  142696. * Name of the CSM class
  142697. */
  142698. static CLASSNAME: string;
  142699. /**
  142700. * Defines the default number of cascades used by the CSM.
  142701. */
  142702. static readonly DEFAULT_CASCADES_COUNT: number;
  142703. /**
  142704. * Defines the minimum number of cascades used by the CSM.
  142705. */
  142706. static readonly MIN_CASCADES_COUNT: number;
  142707. /**
  142708. * Defines the maximum number of cascades used by the CSM.
  142709. */
  142710. static readonly MAX_CASCADES_COUNT: number;
  142711. protected _validateFilter(filter: number): number;
  142712. /**
  142713. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  142714. */
  142715. penumbraDarkness: number;
  142716. private _numCascades;
  142717. /**
  142718. * Gets or set the number of cascades used by the CSM.
  142719. */
  142720. get numCascades(): number;
  142721. set numCascades(value: number);
  142722. /**
  142723. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  142724. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  142725. */
  142726. stabilizeCascades: boolean;
  142727. private _freezeShadowCastersBoundingInfo;
  142728. private _freezeShadowCastersBoundingInfoObservable;
  142729. /**
  142730. * Enables or disables the shadow casters bounding info computation.
  142731. * If your shadow casters don't move, you can disable this feature.
  142732. * If it is enabled, the bounding box computation is done every frame.
  142733. */
  142734. get freezeShadowCastersBoundingInfo(): boolean;
  142735. set freezeShadowCastersBoundingInfo(freeze: boolean);
  142736. private _scbiMin;
  142737. private _scbiMax;
  142738. protected _computeShadowCastersBoundingInfo(): void;
  142739. protected _shadowCastersBoundingInfo: BoundingInfo;
  142740. /**
  142741. * Gets or sets the shadow casters bounding info.
  142742. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  142743. * so that the system won't overwrite the bounds you provide
  142744. */
  142745. get shadowCastersBoundingInfo(): BoundingInfo;
  142746. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  142747. protected _breaksAreDirty: boolean;
  142748. protected _minDistance: number;
  142749. protected _maxDistance: number;
  142750. /**
  142751. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  142752. *
  142753. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  142754. * If you don't know these values, simply leave them to their defaults and don't call this function.
  142755. * @param min minimal distance for the breaks (default to 0.)
  142756. * @param max maximal distance for the breaks (default to 1.)
  142757. */
  142758. setMinMaxDistance(min: number, max: number): void;
  142759. /** Gets the minimal distance used in the cascade break computation */
  142760. get minDistance(): number;
  142761. /** Gets the maximal distance used in the cascade break computation */
  142762. get maxDistance(): number;
  142763. /**
  142764. * Gets the class name of that object
  142765. * @returns "CascadedShadowGenerator"
  142766. */
  142767. getClassName(): string;
  142768. private _cascadeMinExtents;
  142769. private _cascadeMaxExtents;
  142770. /**
  142771. * Gets a cascade minimum extents
  142772. * @param cascadeIndex index of the cascade
  142773. * @returns the minimum cascade extents
  142774. */
  142775. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  142776. /**
  142777. * Gets a cascade maximum extents
  142778. * @param cascadeIndex index of the cascade
  142779. * @returns the maximum cascade extents
  142780. */
  142781. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  142782. private _cascades;
  142783. private _currentLayer;
  142784. private _viewSpaceFrustumsZ;
  142785. private _viewMatrices;
  142786. private _projectionMatrices;
  142787. private _transformMatrices;
  142788. private _transformMatricesAsArray;
  142789. private _frustumLengths;
  142790. private _lightSizeUVCorrection;
  142791. private _depthCorrection;
  142792. private _frustumCornersWorldSpace;
  142793. private _frustumCenter;
  142794. private _shadowCameraPos;
  142795. private _shadowMaxZ;
  142796. /**
  142797. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  142798. * It defaults to camera.maxZ
  142799. */
  142800. get shadowMaxZ(): number;
  142801. /**
  142802. * Sets the shadow max z distance.
  142803. */
  142804. set shadowMaxZ(value: number);
  142805. protected _debug: boolean;
  142806. /**
  142807. * Gets or sets the debug flag.
  142808. * When enabled, the cascades are materialized by different colors on the screen.
  142809. */
  142810. get debug(): boolean;
  142811. set debug(dbg: boolean);
  142812. private _depthClamp;
  142813. /**
  142814. * Gets or sets the depth clamping value.
  142815. *
  142816. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  142817. * to account for the shadow casters far away.
  142818. *
  142819. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  142820. */
  142821. get depthClamp(): boolean;
  142822. set depthClamp(value: boolean);
  142823. private _cascadeBlendPercentage;
  142824. /**
  142825. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  142826. * It defaults to 0.1 (10% blending).
  142827. */
  142828. get cascadeBlendPercentage(): number;
  142829. set cascadeBlendPercentage(value: number);
  142830. private _lambda;
  142831. /**
  142832. * Gets or set the lambda parameter.
  142833. * This parameter is used to split the camera frustum and create the cascades.
  142834. * 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.
  142835. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  142836. */
  142837. get lambda(): number;
  142838. set lambda(value: number);
  142839. /**
  142840. * Gets the view matrix corresponding to a given cascade
  142841. * @param cascadeNum cascade to retrieve the view matrix from
  142842. * @returns the cascade view matrix
  142843. */
  142844. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  142845. /**
  142846. * Gets the projection matrix corresponding to a given cascade
  142847. * @param cascadeNum cascade to retrieve the projection matrix from
  142848. * @returns the cascade projection matrix
  142849. */
  142850. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  142851. /**
  142852. * Gets the transformation matrix corresponding to a given cascade
  142853. * @param cascadeNum cascade to retrieve the transformation matrix from
  142854. * @returns the cascade transformation matrix
  142855. */
  142856. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  142857. private _depthRenderer;
  142858. /**
  142859. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  142860. *
  142861. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  142862. *
  142863. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  142864. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  142865. * @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
  142866. */
  142867. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  142868. private _depthReducer;
  142869. private _autoCalcDepthBounds;
  142870. /**
  142871. * Gets or sets the autoCalcDepthBounds property.
  142872. *
  142873. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  142874. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  142875. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  142876. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  142877. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  142878. */
  142879. get autoCalcDepthBounds(): boolean;
  142880. set autoCalcDepthBounds(value: boolean);
  142881. /**
  142882. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  142883. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  142884. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  142885. * for setting the refresh rate on the renderer yourself!
  142886. */
  142887. get autoCalcDepthBoundsRefreshRate(): number;
  142888. set autoCalcDepthBoundsRefreshRate(value: number);
  142889. /**
  142890. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  142891. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  142892. * you change the camera near/far planes!
  142893. */
  142894. splitFrustum(): void;
  142895. private _splitFrustum;
  142896. private _computeMatrices;
  142897. private _computeFrustumInWorldSpace;
  142898. private _computeCascadeFrustum;
  142899. /**
  142900. * Support test.
  142901. */
  142902. static get IsSupported(): boolean;
  142903. /** @hidden */
  142904. static _SceneComponentInitialization: (scene: Scene) => void;
  142905. /**
  142906. * Creates a Cascaded Shadow Generator object.
  142907. * A ShadowGenerator is the required tool to use the shadows.
  142908. * Each directional light casting shadows needs to use its own ShadowGenerator.
  142909. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  142910. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  142911. * @param light The directional light object generating the shadows.
  142912. * @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.
  142913. */
  142914. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  142915. protected _initializeGenerator(): void;
  142916. protected _createTargetRenderTexture(): void;
  142917. protected _initializeShadowMap(): void;
  142918. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  142919. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  142920. /**
  142921. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  142922. * @param defines Defines of the material we want to update
  142923. * @param lightIndex Index of the light in the enabled light list of the material
  142924. */
  142925. prepareDefines(defines: any, lightIndex: number): void;
  142926. /**
  142927. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  142928. * defined in the generator but impacting the effect).
  142929. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  142930. * @param effect The effect we are binfing the information for
  142931. */
  142932. bindShadowLight(lightIndex: string, effect: Effect): void;
  142933. /**
  142934. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  142935. * (eq to view projection * shadow projection matrices)
  142936. * @returns The transform matrix used to create the shadow map
  142937. */
  142938. getTransformMatrix(): Matrix;
  142939. /**
  142940. * Disposes the ShadowGenerator.
  142941. * Returns nothing.
  142942. */
  142943. dispose(): void;
  142944. /**
  142945. * Serializes the shadow generator setup to a json object.
  142946. * @returns The serialized JSON object
  142947. */
  142948. serialize(): any;
  142949. /**
  142950. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  142951. * @param parsedShadowGenerator The JSON object to parse
  142952. * @param scene The scene to create the shadow map for
  142953. * @returns The parsed shadow generator
  142954. */
  142955. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  142956. }
  142957. }
  142958. declare module BABYLON {
  142959. /**
  142960. * Defines the shadow generator component responsible to manage any shadow generators
  142961. * in a given scene.
  142962. */
  142963. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  142964. /**
  142965. * The component name helpfull to identify the component in the list of scene components.
  142966. */
  142967. readonly name: string;
  142968. /**
  142969. * The scene the component belongs to.
  142970. */
  142971. scene: Scene;
  142972. /**
  142973. * Creates a new instance of the component for the given scene
  142974. * @param scene Defines the scene to register the component in
  142975. */
  142976. constructor(scene: Scene);
  142977. /**
  142978. * Registers the component in a given scene
  142979. */
  142980. register(): void;
  142981. /**
  142982. * Rebuilds the elements related to this component in case of
  142983. * context lost for instance.
  142984. */
  142985. rebuild(): void;
  142986. /**
  142987. * Serializes the component data to the specified json object
  142988. * @param serializationObject The object to serialize to
  142989. */
  142990. serialize(serializationObject: any): void;
  142991. /**
  142992. * Adds all the elements from the container to the scene
  142993. * @param container the container holding the elements
  142994. */
  142995. addFromContainer(container: AbstractScene): void;
  142996. /**
  142997. * Removes all the elements in the container from the scene
  142998. * @param container contains the elements to remove
  142999. * @param dispose if the removed element should be disposed (default: false)
  143000. */
  143001. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  143002. /**
  143003. * Rebuilds the elements related to this component in case of
  143004. * context lost for instance.
  143005. */
  143006. dispose(): void;
  143007. private _gatherRenderTargets;
  143008. }
  143009. }
  143010. declare module BABYLON {
  143011. /**
  143012. * A point light is a light defined by an unique point in world space.
  143013. * The light is emitted in every direction from this point.
  143014. * A good example of a point light is a standard light bulb.
  143015. * Documentation: https://doc.babylonjs.com/babylon101/lights
  143016. */
  143017. export class PointLight extends ShadowLight {
  143018. private _shadowAngle;
  143019. /**
  143020. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  143021. * This specifies what angle the shadow will use to be created.
  143022. *
  143023. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  143024. */
  143025. get shadowAngle(): number;
  143026. /**
  143027. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  143028. * This specifies what angle the shadow will use to be created.
  143029. *
  143030. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  143031. */
  143032. set shadowAngle(value: number);
  143033. /**
  143034. * Gets the direction if it has been set.
  143035. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  143036. */
  143037. get direction(): Vector3;
  143038. /**
  143039. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  143040. */
  143041. set direction(value: Vector3);
  143042. /**
  143043. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  143044. * A PointLight emits the light in every direction.
  143045. * It can cast shadows.
  143046. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  143047. * ```javascript
  143048. * var pointLight = new PointLight("pl", camera.position, scene);
  143049. * ```
  143050. * Documentation : https://doc.babylonjs.com/babylon101/lights
  143051. * @param name The light friendly name
  143052. * @param position The position of the point light in the scene
  143053. * @param scene The scene the lights belongs to
  143054. */
  143055. constructor(name: string, position: Vector3, scene: Scene);
  143056. /**
  143057. * Returns the string "PointLight"
  143058. * @returns the class name
  143059. */
  143060. getClassName(): string;
  143061. /**
  143062. * Returns the integer 0.
  143063. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  143064. */
  143065. getTypeID(): number;
  143066. /**
  143067. * Specifies wether or not the shadowmap should be a cube texture.
  143068. * @returns true if the shadowmap needs to be a cube texture.
  143069. */
  143070. needCube(): boolean;
  143071. /**
  143072. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  143073. * @param faceIndex The index of the face we are computed the direction to generate shadow
  143074. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  143075. */
  143076. getShadowDirection(faceIndex?: number): Vector3;
  143077. /**
  143078. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  143079. * - fov = PI / 2
  143080. * - aspect ratio : 1.0
  143081. * - z-near and far equal to the active camera minZ and maxZ.
  143082. * Returns the PointLight.
  143083. */
  143084. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  143085. protected _buildUniformLayout(): void;
  143086. /**
  143087. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  143088. * @param effect The effect to update
  143089. * @param lightIndex The index of the light in the effect to update
  143090. * @returns The point light
  143091. */
  143092. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  143093. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  143094. /**
  143095. * Prepares the list of defines specific to the light type.
  143096. * @param defines the list of defines
  143097. * @param lightIndex defines the index of the light for the effect
  143098. */
  143099. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  143100. }
  143101. }
  143102. declare module BABYLON {
  143103. /**
  143104. * Header information of HDR texture files.
  143105. */
  143106. export interface HDRInfo {
  143107. /**
  143108. * The height of the texture in pixels.
  143109. */
  143110. height: number;
  143111. /**
  143112. * The width of the texture in pixels.
  143113. */
  143114. width: number;
  143115. /**
  143116. * The index of the beginning of the data in the binary file.
  143117. */
  143118. dataPosition: number;
  143119. }
  143120. /**
  143121. * This groups tools to convert HDR texture to native colors array.
  143122. */
  143123. export class HDRTools {
  143124. private static Ldexp;
  143125. private static Rgbe2float;
  143126. private static readStringLine;
  143127. /**
  143128. * Reads header information from an RGBE texture stored in a native array.
  143129. * More information on this format are available here:
  143130. * https://en.wikipedia.org/wiki/RGBE_image_format
  143131. *
  143132. * @param uint8array The binary file stored in native array.
  143133. * @return The header information.
  143134. */
  143135. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  143136. /**
  143137. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  143138. * This RGBE texture needs to store the information as a panorama.
  143139. *
  143140. * More information on this format are available here:
  143141. * https://en.wikipedia.org/wiki/RGBE_image_format
  143142. *
  143143. * @param buffer The binary file stored in an array buffer.
  143144. * @param size The expected size of the extracted cubemap.
  143145. * @return The Cube Map information.
  143146. */
  143147. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  143148. /**
  143149. * Returns the pixels data extracted from an RGBE texture.
  143150. * This pixels will be stored left to right up to down in the R G B order in one array.
  143151. *
  143152. * More information on this format are available here:
  143153. * https://en.wikipedia.org/wiki/RGBE_image_format
  143154. *
  143155. * @param uint8array The binary file stored in an array buffer.
  143156. * @param hdrInfo The header information of the file.
  143157. * @return The pixels data in RGB right to left up to down order.
  143158. */
  143159. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  143160. private static RGBE_ReadPixels_RLE;
  143161. private static RGBE_ReadPixels_NOT_RLE;
  143162. }
  143163. }
  143164. declare module BABYLON {
  143165. /**
  143166. * Effect Render Options
  143167. */
  143168. export interface IEffectRendererOptions {
  143169. /**
  143170. * Defines the vertices positions.
  143171. */
  143172. positions?: number[];
  143173. /**
  143174. * Defines the indices.
  143175. */
  143176. indices?: number[];
  143177. }
  143178. /**
  143179. * Helper class to render one or more effects.
  143180. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  143181. */
  143182. export class EffectRenderer {
  143183. private engine;
  143184. private static _DefaultOptions;
  143185. private _vertexBuffers;
  143186. private _indexBuffer;
  143187. private _fullscreenViewport;
  143188. /**
  143189. * Creates an effect renderer
  143190. * @param engine the engine to use for rendering
  143191. * @param options defines the options of the effect renderer
  143192. */
  143193. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  143194. /**
  143195. * Sets the current viewport in normalized coordinates 0-1
  143196. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  143197. */
  143198. setViewport(viewport?: Viewport): void;
  143199. /**
  143200. * Binds the embedded attributes buffer to the effect.
  143201. * @param effect Defines the effect to bind the attributes for
  143202. */
  143203. bindBuffers(effect: Effect): void;
  143204. /**
  143205. * Sets the current effect wrapper to use during draw.
  143206. * The effect needs to be ready before calling this api.
  143207. * This also sets the default full screen position attribute.
  143208. * @param effectWrapper Defines the effect to draw with
  143209. */
  143210. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  143211. /**
  143212. * Restores engine states
  143213. */
  143214. restoreStates(): void;
  143215. /**
  143216. * Draws a full screen quad.
  143217. */
  143218. draw(): void;
  143219. private isRenderTargetTexture;
  143220. /**
  143221. * renders one or more effects to a specified texture
  143222. * @param effectWrapper the effect to renderer
  143223. * @param outputTexture texture to draw to, if null it will render to the screen.
  143224. */
  143225. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  143226. /**
  143227. * Disposes of the effect renderer
  143228. */
  143229. dispose(): void;
  143230. }
  143231. /**
  143232. * Options to create an EffectWrapper
  143233. */
  143234. interface EffectWrapperCreationOptions {
  143235. /**
  143236. * Engine to use to create the effect
  143237. */
  143238. engine: ThinEngine;
  143239. /**
  143240. * Fragment shader for the effect
  143241. */
  143242. fragmentShader: string;
  143243. /**
  143244. * Use the shader store instead of direct source code
  143245. */
  143246. useShaderStore?: boolean;
  143247. /**
  143248. * Vertex shader for the effect
  143249. */
  143250. vertexShader?: string;
  143251. /**
  143252. * Attributes to use in the shader
  143253. */
  143254. attributeNames?: Array<string>;
  143255. /**
  143256. * Uniforms to use in the shader
  143257. */
  143258. uniformNames?: Array<string>;
  143259. /**
  143260. * Texture sampler names to use in the shader
  143261. */
  143262. samplerNames?: Array<string>;
  143263. /**
  143264. * Defines to use in the shader
  143265. */
  143266. defines?: Array<string>;
  143267. /**
  143268. * Callback when effect is compiled
  143269. */
  143270. onCompiled?: Nullable<(effect: Effect) => void>;
  143271. /**
  143272. * The friendly name of the effect displayed in Spector.
  143273. */
  143274. name?: string;
  143275. }
  143276. /**
  143277. * Wraps an effect to be used for rendering
  143278. */
  143279. export class EffectWrapper {
  143280. /**
  143281. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  143282. */
  143283. onApplyObservable: Observable<{}>;
  143284. /**
  143285. * The underlying effect
  143286. */
  143287. effect: Effect;
  143288. /**
  143289. * Creates an effect to be renderer
  143290. * @param creationOptions options to create the effect
  143291. */
  143292. constructor(creationOptions: EffectWrapperCreationOptions);
  143293. /**
  143294. * Disposes of the effect wrapper
  143295. */
  143296. dispose(): void;
  143297. }
  143298. }
  143299. declare module BABYLON {
  143300. /** @hidden */
  143301. export var hdrFilteringVertexShader: {
  143302. name: string;
  143303. shader: string;
  143304. };
  143305. }
  143306. declare module BABYLON {
  143307. /** @hidden */
  143308. export var hdrFilteringPixelShader: {
  143309. name: string;
  143310. shader: string;
  143311. };
  143312. }
  143313. declare module BABYLON {
  143314. /**
  143315. * Options for texture filtering
  143316. */
  143317. interface IHDRFilteringOptions {
  143318. /**
  143319. * Scales pixel intensity for the input HDR map.
  143320. */
  143321. hdrScale?: number;
  143322. /**
  143323. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  143324. */
  143325. quality?: number;
  143326. }
  143327. /**
  143328. * Filters HDR maps to get correct renderings of PBR reflections
  143329. */
  143330. export class HDRFiltering {
  143331. private _engine;
  143332. private _effectRenderer;
  143333. private _effectWrapper;
  143334. private _lodGenerationOffset;
  143335. private _lodGenerationScale;
  143336. /**
  143337. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  143338. * you care about baking speed.
  143339. */
  143340. quality: number;
  143341. /**
  143342. * Scales pixel intensity for the input HDR map.
  143343. */
  143344. hdrScale: number;
  143345. /**
  143346. * Instantiates HDR filter for reflection maps
  143347. *
  143348. * @param engine Thin engine
  143349. * @param options Options
  143350. */
  143351. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  143352. private _createRenderTarget;
  143353. private _prefilterInternal;
  143354. private _createEffect;
  143355. /**
  143356. * Get a value indicating if the filter is ready to be used
  143357. * @param texture Texture to filter
  143358. * @returns true if the filter is ready
  143359. */
  143360. isReady(texture: BaseTexture): boolean;
  143361. /**
  143362. * Prefilters a cube texture to have mipmap levels representing roughness values.
  143363. * Prefiltering will be invoked at the end of next rendering pass.
  143364. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  143365. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  143366. * @param texture Texture to filter
  143367. * @param onFinished Callback when filtering is done
  143368. * @return Promise called when prefiltering is done
  143369. */
  143370. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  143371. }
  143372. }
  143373. declare module BABYLON {
  143374. /**
  143375. * This represents a texture coming from an HDR input.
  143376. *
  143377. * The only supported format is currently panorama picture stored in RGBE format.
  143378. * Example of such files can be found on HDRLib: http://hdrlib.com/
  143379. */
  143380. export class HDRCubeTexture extends BaseTexture {
  143381. private static _facesMapping;
  143382. private _generateHarmonics;
  143383. private _noMipmap;
  143384. private _prefilterOnLoad;
  143385. private _textureMatrix;
  143386. private _size;
  143387. private _onLoad;
  143388. private _onError;
  143389. /**
  143390. * The texture URL.
  143391. */
  143392. url: string;
  143393. protected _isBlocking: boolean;
  143394. /**
  143395. * Sets wether or not the texture is blocking during loading.
  143396. */
  143397. set isBlocking(value: boolean);
  143398. /**
  143399. * Gets wether or not the texture is blocking during loading.
  143400. */
  143401. get isBlocking(): boolean;
  143402. protected _rotationY: number;
  143403. /**
  143404. * Sets texture matrix rotation angle around Y axis in radians.
  143405. */
  143406. set rotationY(value: number);
  143407. /**
  143408. * Gets texture matrix rotation angle around Y axis radians.
  143409. */
  143410. get rotationY(): number;
  143411. /**
  143412. * Gets or sets the center of the bounding box associated with the cube texture
  143413. * It must define where the camera used to render the texture was set
  143414. */
  143415. boundingBoxPosition: Vector3;
  143416. private _boundingBoxSize;
  143417. /**
  143418. * Gets or sets the size of the bounding box associated with the cube texture
  143419. * When defined, the cubemap will switch to local mode
  143420. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  143421. * @example https://www.babylonjs-playground.com/#RNASML
  143422. */
  143423. set boundingBoxSize(value: Vector3);
  143424. get boundingBoxSize(): Vector3;
  143425. /**
  143426. * Instantiates an HDRTexture from the following parameters.
  143427. *
  143428. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  143429. * @param sceneOrEngine The scene or engine the texture will be used in
  143430. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  143431. * @param noMipmap Forces to not generate the mipmap if true
  143432. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  143433. * @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)
  143434. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  143435. */
  143436. 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>);
  143437. /**
  143438. * Get the current class name of the texture useful for serialization or dynamic coding.
  143439. * @returns "HDRCubeTexture"
  143440. */
  143441. getClassName(): string;
  143442. /**
  143443. * Occurs when the file is raw .hdr file.
  143444. */
  143445. private loadTexture;
  143446. clone(): HDRCubeTexture;
  143447. delayLoad(): void;
  143448. /**
  143449. * Get the texture reflection matrix used to rotate/transform the reflection.
  143450. * @returns the reflection matrix
  143451. */
  143452. getReflectionTextureMatrix(): Matrix;
  143453. /**
  143454. * Set the texture reflection matrix used to rotate/transform the reflection.
  143455. * @param value Define the reflection matrix to set
  143456. */
  143457. setReflectionTextureMatrix(value: Matrix): void;
  143458. /**
  143459. * Parses a JSON representation of an HDR Texture in order to create the texture
  143460. * @param parsedTexture Define the JSON representation
  143461. * @param scene Define the scene the texture should be created in
  143462. * @param rootUrl Define the root url in case we need to load relative dependencies
  143463. * @returns the newly created texture after parsing
  143464. */
  143465. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  143466. serialize(): any;
  143467. }
  143468. }
  143469. declare module BABYLON {
  143470. /**
  143471. * Class used to control physics engine
  143472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  143473. */
  143474. export class PhysicsEngine implements IPhysicsEngine {
  143475. private _physicsPlugin;
  143476. /**
  143477. * Global value used to control the smallest number supported by the simulation
  143478. */
  143479. static Epsilon: number;
  143480. private _impostors;
  143481. private _joints;
  143482. private _subTimeStep;
  143483. /**
  143484. * Gets the gravity vector used by the simulation
  143485. */
  143486. gravity: Vector3;
  143487. /**
  143488. * Factory used to create the default physics plugin.
  143489. * @returns The default physics plugin
  143490. */
  143491. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  143492. /**
  143493. * Creates a new Physics Engine
  143494. * @param gravity defines the gravity vector used by the simulation
  143495. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  143496. */
  143497. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  143498. /**
  143499. * Sets the gravity vector used by the simulation
  143500. * @param gravity defines the gravity vector to use
  143501. */
  143502. setGravity(gravity: Vector3): void;
  143503. /**
  143504. * Set the time step of the physics engine.
  143505. * Default is 1/60.
  143506. * To slow it down, enter 1/600 for example.
  143507. * To speed it up, 1/30
  143508. * @param newTimeStep defines the new timestep to apply to this world.
  143509. */
  143510. setTimeStep(newTimeStep?: number): void;
  143511. /**
  143512. * Get the time step of the physics engine.
  143513. * @returns the current time step
  143514. */
  143515. getTimeStep(): number;
  143516. /**
  143517. * Set the sub time step of the physics engine.
  143518. * Default is 0 meaning there is no sub steps
  143519. * To increase physics resolution precision, set a small value (like 1 ms)
  143520. * @param subTimeStep defines the new sub timestep used for physics resolution.
  143521. */
  143522. setSubTimeStep(subTimeStep?: number): void;
  143523. /**
  143524. * Get the sub time step of the physics engine.
  143525. * @returns the current sub time step
  143526. */
  143527. getSubTimeStep(): number;
  143528. /**
  143529. * Release all resources
  143530. */
  143531. dispose(): void;
  143532. /**
  143533. * Gets the name of the current physics plugin
  143534. * @returns the name of the plugin
  143535. */
  143536. getPhysicsPluginName(): string;
  143537. /**
  143538. * Adding a new impostor for the impostor tracking.
  143539. * This will be done by the impostor itself.
  143540. * @param impostor the impostor to add
  143541. */
  143542. addImpostor(impostor: PhysicsImpostor): void;
  143543. /**
  143544. * Remove an impostor from the engine.
  143545. * This impostor and its mesh will not longer be updated by the physics engine.
  143546. * @param impostor the impostor to remove
  143547. */
  143548. removeImpostor(impostor: PhysicsImpostor): void;
  143549. /**
  143550. * Add a joint to the physics engine
  143551. * @param mainImpostor defines the main impostor to which the joint is added.
  143552. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  143553. * @param joint defines the joint that will connect both impostors.
  143554. */
  143555. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  143556. /**
  143557. * Removes a joint from the simulation
  143558. * @param mainImpostor defines the impostor used with the joint
  143559. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  143560. * @param joint defines the joint to remove
  143561. */
  143562. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  143563. /**
  143564. * Called by the scene. No need to call it.
  143565. * @param delta defines the timespam between frames
  143566. */
  143567. _step(delta: number): void;
  143568. /**
  143569. * Gets the current plugin used to run the simulation
  143570. * @returns current plugin
  143571. */
  143572. getPhysicsPlugin(): IPhysicsEnginePlugin;
  143573. /**
  143574. * Gets the list of physic impostors
  143575. * @returns an array of PhysicsImpostor
  143576. */
  143577. getImpostors(): Array<PhysicsImpostor>;
  143578. /**
  143579. * Gets the impostor for a physics enabled object
  143580. * @param object defines the object impersonated by the impostor
  143581. * @returns the PhysicsImpostor or null if not found
  143582. */
  143583. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  143584. /**
  143585. * Gets the impostor for a physics body object
  143586. * @param body defines physics body used by the impostor
  143587. * @returns the PhysicsImpostor or null if not found
  143588. */
  143589. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  143590. /**
  143591. * Does a raycast in the physics world
  143592. * @param from when should the ray start?
  143593. * @param to when should the ray end?
  143594. * @returns PhysicsRaycastResult
  143595. */
  143596. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143597. }
  143598. }
  143599. declare module BABYLON {
  143600. /** @hidden */
  143601. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  143602. private _useDeltaForWorldStep;
  143603. world: any;
  143604. name: string;
  143605. private _physicsMaterials;
  143606. private _fixedTimeStep;
  143607. private _cannonRaycastResult;
  143608. private _raycastResult;
  143609. private _physicsBodysToRemoveAfterStep;
  143610. private _firstFrame;
  143611. BJSCANNON: any;
  143612. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  143613. setGravity(gravity: Vector3): void;
  143614. setTimeStep(timeStep: number): void;
  143615. getTimeStep(): number;
  143616. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  143617. private _removeMarkedPhysicsBodiesFromWorld;
  143618. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143619. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143620. generatePhysicsBody(impostor: PhysicsImpostor): void;
  143621. private _processChildMeshes;
  143622. removePhysicsBody(impostor: PhysicsImpostor): void;
  143623. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  143624. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  143625. private _addMaterial;
  143626. private _checkWithEpsilon;
  143627. private _createShape;
  143628. private _createHeightmap;
  143629. private _minus90X;
  143630. private _plus90X;
  143631. private _tmpPosition;
  143632. private _tmpDeltaPosition;
  143633. private _tmpUnityRotation;
  143634. private _updatePhysicsBodyTransformation;
  143635. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  143636. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  143637. isSupported(): boolean;
  143638. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143639. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143640. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143641. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143642. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  143643. getBodyMass(impostor: PhysicsImpostor): number;
  143644. getBodyFriction(impostor: PhysicsImpostor): number;
  143645. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  143646. getBodyRestitution(impostor: PhysicsImpostor): number;
  143647. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  143648. sleepBody(impostor: PhysicsImpostor): void;
  143649. wakeUpBody(impostor: PhysicsImpostor): void;
  143650. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  143651. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  143652. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  143653. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  143654. getRadius(impostor: PhysicsImpostor): number;
  143655. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  143656. dispose(): void;
  143657. private _extendNamespace;
  143658. /**
  143659. * Does a raycast in the physics world
  143660. * @param from when should the ray start?
  143661. * @param to when should the ray end?
  143662. * @returns PhysicsRaycastResult
  143663. */
  143664. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143665. }
  143666. }
  143667. declare module BABYLON {
  143668. /** @hidden */
  143669. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  143670. private _useDeltaForWorldStep;
  143671. world: any;
  143672. name: string;
  143673. BJSOIMO: any;
  143674. private _raycastResult;
  143675. private _fixedTimeStep;
  143676. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  143677. setGravity(gravity: Vector3): void;
  143678. setTimeStep(timeStep: number): void;
  143679. getTimeStep(): number;
  143680. private _tmpImpostorsArray;
  143681. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  143682. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143683. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143684. generatePhysicsBody(impostor: PhysicsImpostor): void;
  143685. private _tmpPositionVector;
  143686. removePhysicsBody(impostor: PhysicsImpostor): void;
  143687. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  143688. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  143689. isSupported(): boolean;
  143690. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  143691. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  143692. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143693. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143694. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143695. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143696. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  143697. getBodyMass(impostor: PhysicsImpostor): number;
  143698. getBodyFriction(impostor: PhysicsImpostor): number;
  143699. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  143700. getBodyRestitution(impostor: PhysicsImpostor): number;
  143701. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  143702. sleepBody(impostor: PhysicsImpostor): void;
  143703. wakeUpBody(impostor: PhysicsImpostor): void;
  143704. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  143705. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  143706. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  143707. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  143708. getRadius(impostor: PhysicsImpostor): number;
  143709. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  143710. dispose(): void;
  143711. /**
  143712. * Does a raycast in the physics world
  143713. * @param from when should the ray start?
  143714. * @param to when should the ray end?
  143715. * @returns PhysicsRaycastResult
  143716. */
  143717. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143718. }
  143719. }
  143720. declare module BABYLON {
  143721. /**
  143722. * AmmoJS Physics plugin
  143723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  143724. * @see https://github.com/kripken/ammo.js/
  143725. */
  143726. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  143727. private _useDeltaForWorldStep;
  143728. /**
  143729. * Reference to the Ammo library
  143730. */
  143731. bjsAMMO: any;
  143732. /**
  143733. * Created ammoJS world which physics bodies are added to
  143734. */
  143735. world: any;
  143736. /**
  143737. * Name of the plugin
  143738. */
  143739. name: string;
  143740. private _timeStep;
  143741. private _fixedTimeStep;
  143742. private _maxSteps;
  143743. private _tmpQuaternion;
  143744. private _tmpAmmoTransform;
  143745. private _tmpAmmoQuaternion;
  143746. private _tmpAmmoConcreteContactResultCallback;
  143747. private _collisionConfiguration;
  143748. private _dispatcher;
  143749. private _overlappingPairCache;
  143750. private _solver;
  143751. private _softBodySolver;
  143752. private _tmpAmmoVectorA;
  143753. private _tmpAmmoVectorB;
  143754. private _tmpAmmoVectorC;
  143755. private _tmpAmmoVectorD;
  143756. private _tmpContactCallbackResult;
  143757. private _tmpAmmoVectorRCA;
  143758. private _tmpAmmoVectorRCB;
  143759. private _raycastResult;
  143760. private _tmpContactPoint;
  143761. private static readonly DISABLE_COLLISION_FLAG;
  143762. private static readonly KINEMATIC_FLAG;
  143763. private static readonly DISABLE_DEACTIVATION_FLAG;
  143764. /**
  143765. * Initializes the ammoJS plugin
  143766. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  143767. * @param ammoInjection can be used to inject your own ammo reference
  143768. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  143769. */
  143770. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  143771. /**
  143772. * Sets the gravity of the physics world (m/(s^2))
  143773. * @param gravity Gravity to set
  143774. */
  143775. setGravity(gravity: Vector3): void;
  143776. /**
  143777. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  143778. * @param timeStep timestep to use in seconds
  143779. */
  143780. setTimeStep(timeStep: number): void;
  143781. /**
  143782. * 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)
  143783. * @param fixedTimeStep fixedTimeStep to use in seconds
  143784. */
  143785. setFixedTimeStep(fixedTimeStep: number): void;
  143786. /**
  143787. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  143788. * @param maxSteps the maximum number of steps by the physics engine per frame
  143789. */
  143790. setMaxSteps(maxSteps: number): void;
  143791. /**
  143792. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  143793. * @returns the current timestep in seconds
  143794. */
  143795. getTimeStep(): number;
  143796. /**
  143797. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  143798. */
  143799. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  143800. private _isImpostorInContact;
  143801. private _isImpostorPairInContact;
  143802. private _stepSimulation;
  143803. /**
  143804. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  143805. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  143806. * After the step the babylon meshes are set to the position of the physics imposters
  143807. * @param delta amount of time to step forward
  143808. * @param impostors array of imposters to update before/after the step
  143809. */
  143810. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  143811. /**
  143812. * Update babylon mesh to match physics world object
  143813. * @param impostor imposter to match
  143814. */
  143815. private _afterSoftStep;
  143816. /**
  143817. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  143818. * @param impostor imposter to match
  143819. */
  143820. private _ropeStep;
  143821. /**
  143822. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  143823. * @param impostor imposter to match
  143824. */
  143825. private _softbodyOrClothStep;
  143826. private _tmpMatrix;
  143827. /**
  143828. * Applies an impulse on the imposter
  143829. * @param impostor imposter to apply impulse to
  143830. * @param force amount of force to be applied to the imposter
  143831. * @param contactPoint the location to apply the impulse on the imposter
  143832. */
  143833. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143834. /**
  143835. * Applies a force on the imposter
  143836. * @param impostor imposter to apply force
  143837. * @param force amount of force to be applied to the imposter
  143838. * @param contactPoint the location to apply the force on the imposter
  143839. */
  143840. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143841. /**
  143842. * Creates a physics body using the plugin
  143843. * @param impostor the imposter to create the physics body on
  143844. */
  143845. generatePhysicsBody(impostor: PhysicsImpostor): void;
  143846. /**
  143847. * Removes the physics body from the imposter and disposes of the body's memory
  143848. * @param impostor imposter to remove the physics body from
  143849. */
  143850. removePhysicsBody(impostor: PhysicsImpostor): void;
  143851. /**
  143852. * Generates a joint
  143853. * @param impostorJoint the imposter joint to create the joint with
  143854. */
  143855. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  143856. /**
  143857. * Removes a joint
  143858. * @param impostorJoint the imposter joint to remove the joint from
  143859. */
  143860. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  143861. private _addMeshVerts;
  143862. /**
  143863. * Initialise the soft body vertices to match its object's (mesh) vertices
  143864. * Softbody vertices (nodes) are in world space and to match this
  143865. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  143866. * @param impostor to create the softbody for
  143867. */
  143868. private _softVertexData;
  143869. /**
  143870. * Create an impostor's soft body
  143871. * @param impostor to create the softbody for
  143872. */
  143873. private _createSoftbody;
  143874. /**
  143875. * Create cloth for an impostor
  143876. * @param impostor to create the softbody for
  143877. */
  143878. private _createCloth;
  143879. /**
  143880. * Create rope for an impostor
  143881. * @param impostor to create the softbody for
  143882. */
  143883. private _createRope;
  143884. /**
  143885. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  143886. * @param impostor to create the custom physics shape for
  143887. */
  143888. private _createCustom;
  143889. private _addHullVerts;
  143890. private _createShape;
  143891. /**
  143892. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  143893. * @param impostor imposter containing the physics body and babylon object
  143894. */
  143895. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  143896. /**
  143897. * Sets the babylon object's position/rotation from the physics body's position/rotation
  143898. * @param impostor imposter containing the physics body and babylon object
  143899. * @param newPosition new position
  143900. * @param newRotation new rotation
  143901. */
  143902. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  143903. /**
  143904. * If this plugin is supported
  143905. * @returns true if its supported
  143906. */
  143907. isSupported(): boolean;
  143908. /**
  143909. * Sets the linear velocity of the physics body
  143910. * @param impostor imposter to set the velocity on
  143911. * @param velocity velocity to set
  143912. */
  143913. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143914. /**
  143915. * Sets the angular velocity of the physics body
  143916. * @param impostor imposter to set the velocity on
  143917. * @param velocity velocity to set
  143918. */
  143919. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143920. /**
  143921. * gets the linear velocity
  143922. * @param impostor imposter to get linear velocity from
  143923. * @returns linear velocity
  143924. */
  143925. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143926. /**
  143927. * gets the angular velocity
  143928. * @param impostor imposter to get angular velocity from
  143929. * @returns angular velocity
  143930. */
  143931. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143932. /**
  143933. * Sets the mass of physics body
  143934. * @param impostor imposter to set the mass on
  143935. * @param mass mass to set
  143936. */
  143937. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  143938. /**
  143939. * Gets the mass of the physics body
  143940. * @param impostor imposter to get the mass from
  143941. * @returns mass
  143942. */
  143943. getBodyMass(impostor: PhysicsImpostor): number;
  143944. /**
  143945. * Gets friction of the impostor
  143946. * @param impostor impostor to get friction from
  143947. * @returns friction value
  143948. */
  143949. getBodyFriction(impostor: PhysicsImpostor): number;
  143950. /**
  143951. * Sets friction of the impostor
  143952. * @param impostor impostor to set friction on
  143953. * @param friction friction value
  143954. */
  143955. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  143956. /**
  143957. * Gets restitution of the impostor
  143958. * @param impostor impostor to get restitution from
  143959. * @returns restitution value
  143960. */
  143961. getBodyRestitution(impostor: PhysicsImpostor): number;
  143962. /**
  143963. * Sets resitution of the impostor
  143964. * @param impostor impostor to set resitution on
  143965. * @param restitution resitution value
  143966. */
  143967. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  143968. /**
  143969. * Gets pressure inside the impostor
  143970. * @param impostor impostor to get pressure from
  143971. * @returns pressure value
  143972. */
  143973. getBodyPressure(impostor: PhysicsImpostor): number;
  143974. /**
  143975. * Sets pressure inside a soft body impostor
  143976. * Cloth and rope must remain 0 pressure
  143977. * @param impostor impostor to set pressure on
  143978. * @param pressure pressure value
  143979. */
  143980. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  143981. /**
  143982. * Gets stiffness of the impostor
  143983. * @param impostor impostor to get stiffness from
  143984. * @returns pressure value
  143985. */
  143986. getBodyStiffness(impostor: PhysicsImpostor): number;
  143987. /**
  143988. * Sets stiffness of the impostor
  143989. * @param impostor impostor to set stiffness on
  143990. * @param stiffness stiffness value from 0 to 1
  143991. */
  143992. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  143993. /**
  143994. * Gets velocityIterations of the impostor
  143995. * @param impostor impostor to get velocity iterations from
  143996. * @returns velocityIterations value
  143997. */
  143998. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  143999. /**
  144000. * Sets velocityIterations of the impostor
  144001. * @param impostor impostor to set velocity iterations on
  144002. * @param velocityIterations velocityIterations value
  144003. */
  144004. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  144005. /**
  144006. * Gets positionIterations of the impostor
  144007. * @param impostor impostor to get position iterations from
  144008. * @returns positionIterations value
  144009. */
  144010. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  144011. /**
  144012. * Sets positionIterations of the impostor
  144013. * @param impostor impostor to set position on
  144014. * @param positionIterations positionIterations value
  144015. */
  144016. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  144017. /**
  144018. * Append an anchor to a cloth object
  144019. * @param impostor is the cloth impostor to add anchor to
  144020. * @param otherImpostor is the rigid impostor to anchor to
  144021. * @param width ratio across width from 0 to 1
  144022. * @param height ratio up height from 0 to 1
  144023. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  144024. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  144025. */
  144026. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  144027. /**
  144028. * Append an hook to a rope object
  144029. * @param impostor is the rope impostor to add hook to
  144030. * @param otherImpostor is the rigid impostor to hook to
  144031. * @param length ratio along the rope from 0 to 1
  144032. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  144033. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  144034. */
  144035. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  144036. /**
  144037. * Sleeps the physics body and stops it from being active
  144038. * @param impostor impostor to sleep
  144039. */
  144040. sleepBody(impostor: PhysicsImpostor): void;
  144041. /**
  144042. * Activates the physics body
  144043. * @param impostor impostor to activate
  144044. */
  144045. wakeUpBody(impostor: PhysicsImpostor): void;
  144046. /**
  144047. * Updates the distance parameters of the joint
  144048. * @param joint joint to update
  144049. * @param maxDistance maximum distance of the joint
  144050. * @param minDistance minimum distance of the joint
  144051. */
  144052. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  144053. /**
  144054. * Sets a motor on the joint
  144055. * @param joint joint to set motor on
  144056. * @param speed speed of the motor
  144057. * @param maxForce maximum force of the motor
  144058. * @param motorIndex index of the motor
  144059. */
  144060. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  144061. /**
  144062. * Sets the motors limit
  144063. * @param joint joint to set limit on
  144064. * @param upperLimit upper limit
  144065. * @param lowerLimit lower limit
  144066. */
  144067. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  144068. /**
  144069. * Syncs the position and rotation of a mesh with the impostor
  144070. * @param mesh mesh to sync
  144071. * @param impostor impostor to update the mesh with
  144072. */
  144073. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  144074. /**
  144075. * Gets the radius of the impostor
  144076. * @param impostor impostor to get radius from
  144077. * @returns the radius
  144078. */
  144079. getRadius(impostor: PhysicsImpostor): number;
  144080. /**
  144081. * Gets the box size of the impostor
  144082. * @param impostor impostor to get box size from
  144083. * @param result the resulting box size
  144084. */
  144085. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  144086. /**
  144087. * Disposes of the impostor
  144088. */
  144089. dispose(): void;
  144090. /**
  144091. * Does a raycast in the physics world
  144092. * @param from when should the ray start?
  144093. * @param to when should the ray end?
  144094. * @returns PhysicsRaycastResult
  144095. */
  144096. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  144097. }
  144098. }
  144099. declare module BABYLON {
  144100. interface AbstractScene {
  144101. /**
  144102. * The list of reflection probes added to the scene
  144103. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  144104. */
  144105. reflectionProbes: Array<ReflectionProbe>;
  144106. /**
  144107. * Removes the given reflection probe from this scene.
  144108. * @param toRemove The reflection probe to remove
  144109. * @returns The index of the removed reflection probe
  144110. */
  144111. removeReflectionProbe(toRemove: ReflectionProbe): number;
  144112. /**
  144113. * Adds the given reflection probe to this scene.
  144114. * @param newReflectionProbe The reflection probe to add
  144115. */
  144116. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  144117. }
  144118. /**
  144119. * Class used to generate realtime reflection / refraction cube textures
  144120. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  144121. */
  144122. export class ReflectionProbe {
  144123. /** defines the name of the probe */
  144124. name: string;
  144125. private _scene;
  144126. private _renderTargetTexture;
  144127. private _projectionMatrix;
  144128. private _viewMatrix;
  144129. private _target;
  144130. private _add;
  144131. private _attachedMesh;
  144132. private _invertYAxis;
  144133. /** Gets or sets probe position (center of the cube map) */
  144134. position: Vector3;
  144135. /**
  144136. * Creates a new reflection probe
  144137. * @param name defines the name of the probe
  144138. * @param size defines the texture resolution (for each face)
  144139. * @param scene defines the hosting scene
  144140. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  144141. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  144142. */
  144143. constructor(
  144144. /** defines the name of the probe */
  144145. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  144146. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  144147. get samples(): number;
  144148. set samples(value: number);
  144149. /** Gets or sets the refresh rate to use (on every frame by default) */
  144150. get refreshRate(): number;
  144151. set refreshRate(value: number);
  144152. /**
  144153. * Gets the hosting scene
  144154. * @returns a Scene
  144155. */
  144156. getScene(): Scene;
  144157. /** Gets the internal CubeTexture used to render to */
  144158. get cubeTexture(): RenderTargetTexture;
  144159. /** Gets the list of meshes to render */
  144160. get renderList(): Nullable<AbstractMesh[]>;
  144161. /**
  144162. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  144163. * @param mesh defines the mesh to attach to
  144164. */
  144165. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  144166. /**
  144167. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  144168. * @param renderingGroupId The rendering group id corresponding to its index
  144169. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  144170. */
  144171. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  144172. /**
  144173. * Clean all associated resources
  144174. */
  144175. dispose(): void;
  144176. /**
  144177. * Converts the reflection probe information to a readable string for debug purpose.
  144178. * @param fullDetails Supports for multiple levels of logging within scene loading
  144179. * @returns the human readable reflection probe info
  144180. */
  144181. toString(fullDetails?: boolean): string;
  144182. /**
  144183. * Get the class name of the relfection probe.
  144184. * @returns "ReflectionProbe"
  144185. */
  144186. getClassName(): string;
  144187. /**
  144188. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  144189. * @returns The JSON representation of the texture
  144190. */
  144191. serialize(): any;
  144192. /**
  144193. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  144194. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  144195. * @param scene Define the scene the parsed reflection probe should be instantiated in
  144196. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  144197. * @returns The parsed reflection probe if successful
  144198. */
  144199. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  144200. }
  144201. }
  144202. declare module BABYLON {
  144203. /** @hidden */
  144204. export var _BabylonLoaderRegistered: boolean;
  144205. /**
  144206. * Helps setting up some configuration for the babylon file loader.
  144207. */
  144208. export class BabylonFileLoaderConfiguration {
  144209. /**
  144210. * The loader does not allow injecting custom physix engine into the plugins.
  144211. * Unfortunately in ES6, we need to manually inject them into the plugin.
  144212. * So you could set this variable to your engine import to make it work.
  144213. */
  144214. static LoaderInjectedPhysicsEngine: any;
  144215. }
  144216. }
  144217. declare module BABYLON {
  144218. /**
  144219. * The Physically based simple base material of BJS.
  144220. *
  144221. * This enables better naming and convention enforcements on top of the pbrMaterial.
  144222. * It is used as the base class for both the specGloss and metalRough conventions.
  144223. */
  144224. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  144225. /**
  144226. * Number of Simultaneous lights allowed on the material.
  144227. */
  144228. maxSimultaneousLights: number;
  144229. /**
  144230. * If sets to true, disables all the lights affecting the material.
  144231. */
  144232. disableLighting: boolean;
  144233. /**
  144234. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  144235. */
  144236. environmentTexture: BaseTexture;
  144237. /**
  144238. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  144239. */
  144240. invertNormalMapX: boolean;
  144241. /**
  144242. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  144243. */
  144244. invertNormalMapY: boolean;
  144245. /**
  144246. * Normal map used in the model.
  144247. */
  144248. normalTexture: BaseTexture;
  144249. /**
  144250. * Emissivie color used to self-illuminate the model.
  144251. */
  144252. emissiveColor: Color3;
  144253. /**
  144254. * Emissivie texture used to self-illuminate the model.
  144255. */
  144256. emissiveTexture: BaseTexture;
  144257. /**
  144258. * Occlusion Channel Strenght.
  144259. */
  144260. occlusionStrength: number;
  144261. /**
  144262. * Occlusion Texture of the material (adding extra occlusion effects).
  144263. */
  144264. occlusionTexture: BaseTexture;
  144265. /**
  144266. * Defines the alpha limits in alpha test mode.
  144267. */
  144268. alphaCutOff: number;
  144269. /**
  144270. * Gets the current double sided mode.
  144271. */
  144272. get doubleSided(): boolean;
  144273. /**
  144274. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  144275. */
  144276. set doubleSided(value: boolean);
  144277. /**
  144278. * Stores the pre-calculated light information of a mesh in a texture.
  144279. */
  144280. lightmapTexture: BaseTexture;
  144281. /**
  144282. * If true, the light map contains occlusion information instead of lighting info.
  144283. */
  144284. useLightmapAsShadowmap: boolean;
  144285. /**
  144286. * Instantiates a new PBRMaterial instance.
  144287. *
  144288. * @param name The material name
  144289. * @param scene The scene the material will be use in.
  144290. */
  144291. constructor(name: string, scene: Scene);
  144292. getClassName(): string;
  144293. }
  144294. }
  144295. declare module BABYLON {
  144296. /**
  144297. * The PBR material of BJS following the metal roughness convention.
  144298. *
  144299. * This fits to the PBR convention in the GLTF definition:
  144300. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  144301. */
  144302. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  144303. /**
  144304. * The base color has two different interpretations depending on the value of metalness.
  144305. * When the material is a metal, the base color is the specific measured reflectance value
  144306. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  144307. * of the material.
  144308. */
  144309. baseColor: Color3;
  144310. /**
  144311. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  144312. * well as opacity information in the alpha channel.
  144313. */
  144314. baseTexture: BaseTexture;
  144315. /**
  144316. * Specifies the metallic scalar value of the material.
  144317. * Can also be used to scale the metalness values of the metallic texture.
  144318. */
  144319. metallic: number;
  144320. /**
  144321. * Specifies the roughness scalar value of the material.
  144322. * Can also be used to scale the roughness values of the metallic texture.
  144323. */
  144324. roughness: number;
  144325. /**
  144326. * Texture containing both the metallic value in the B channel and the
  144327. * roughness value in the G channel to keep better precision.
  144328. */
  144329. metallicRoughnessTexture: BaseTexture;
  144330. /**
  144331. * Instantiates a new PBRMetalRoughnessMaterial instance.
  144332. *
  144333. * @param name The material name
  144334. * @param scene The scene the material will be use in.
  144335. */
  144336. constructor(name: string, scene: Scene);
  144337. /**
  144338. * Return the currrent class name of the material.
  144339. */
  144340. getClassName(): string;
  144341. /**
  144342. * Makes a duplicate of the current material.
  144343. * @param name - name to use for the new material.
  144344. */
  144345. clone(name: string): PBRMetallicRoughnessMaterial;
  144346. /**
  144347. * Serialize the material to a parsable JSON object.
  144348. */
  144349. serialize(): any;
  144350. /**
  144351. * Parses a JSON object correponding to the serialize function.
  144352. */
  144353. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  144354. }
  144355. }
  144356. declare module BABYLON {
  144357. /**
  144358. * The PBR material of BJS following the specular glossiness convention.
  144359. *
  144360. * This fits to the PBR convention in the GLTF definition:
  144361. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  144362. */
  144363. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  144364. /**
  144365. * Specifies the diffuse color of the material.
  144366. */
  144367. diffuseColor: Color3;
  144368. /**
  144369. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  144370. * channel.
  144371. */
  144372. diffuseTexture: BaseTexture;
  144373. /**
  144374. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  144375. */
  144376. specularColor: Color3;
  144377. /**
  144378. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  144379. */
  144380. glossiness: number;
  144381. /**
  144382. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  144383. */
  144384. specularGlossinessTexture: BaseTexture;
  144385. /**
  144386. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  144387. *
  144388. * @param name The material name
  144389. * @param scene The scene the material will be use in.
  144390. */
  144391. constructor(name: string, scene: Scene);
  144392. /**
  144393. * Return the currrent class name of the material.
  144394. */
  144395. getClassName(): string;
  144396. /**
  144397. * Makes a duplicate of the current material.
  144398. * @param name - name to use for the new material.
  144399. */
  144400. clone(name: string): PBRSpecularGlossinessMaterial;
  144401. /**
  144402. * Serialize the material to a parsable JSON object.
  144403. */
  144404. serialize(): any;
  144405. /**
  144406. * Parses a JSON object correponding to the serialize function.
  144407. */
  144408. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  144409. }
  144410. }
  144411. declare module BABYLON {
  144412. /**
  144413. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  144414. * It can help converting any input color in a desired output one. This can then be used to create effects
  144415. * from sepia, black and white to sixties or futuristic rendering...
  144416. *
  144417. * The only supported format is currently 3dl.
  144418. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  144419. */
  144420. export class ColorGradingTexture extends BaseTexture {
  144421. /**
  144422. * The texture URL.
  144423. */
  144424. url: string;
  144425. /**
  144426. * Empty line regex stored for GC.
  144427. */
  144428. private static _noneEmptyLineRegex;
  144429. private _textureMatrix;
  144430. private _onLoad;
  144431. /**
  144432. * Instantiates a ColorGradingTexture from the following parameters.
  144433. *
  144434. * @param url The location of the color gradind data (currently only supporting 3dl)
  144435. * @param sceneOrEngine The scene or engine the texture will be used in
  144436. * @param onLoad defines a callback triggered when the texture has been loaded
  144437. */
  144438. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  144439. /**
  144440. * Fires the onload event from the constructor if requested.
  144441. */
  144442. private _triggerOnLoad;
  144443. /**
  144444. * Returns the texture matrix used in most of the material.
  144445. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  144446. */
  144447. getTextureMatrix(): Matrix;
  144448. /**
  144449. * Occurs when the file being loaded is a .3dl LUT file.
  144450. */
  144451. private load3dlTexture;
  144452. /**
  144453. * Starts the loading process of the texture.
  144454. */
  144455. private loadTexture;
  144456. /**
  144457. * Clones the color gradind texture.
  144458. */
  144459. clone(): ColorGradingTexture;
  144460. /**
  144461. * Called during delayed load for textures.
  144462. */
  144463. delayLoad(): void;
  144464. /**
  144465. * Parses a color grading texture serialized by Babylon.
  144466. * @param parsedTexture The texture information being parsedTexture
  144467. * @param scene The scene to load the texture in
  144468. * @param rootUrl The root url of the data assets to load
  144469. * @return A color gradind texture
  144470. */
  144471. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  144472. /**
  144473. * Serializes the LUT texture to json format.
  144474. */
  144475. serialize(): any;
  144476. }
  144477. }
  144478. declare module BABYLON {
  144479. /**
  144480. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  144481. */
  144482. export class EquiRectangularCubeTexture extends BaseTexture {
  144483. /** The six faces of the cube. */
  144484. private static _FacesMapping;
  144485. private _noMipmap;
  144486. private _onLoad;
  144487. private _onError;
  144488. /** The size of the cubemap. */
  144489. private _size;
  144490. /** The buffer of the image. */
  144491. private _buffer;
  144492. /** The width of the input image. */
  144493. private _width;
  144494. /** The height of the input image. */
  144495. private _height;
  144496. /** The URL to the image. */
  144497. url: string;
  144498. /**
  144499. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  144500. * @param url The location of the image
  144501. * @param scene The scene the texture will be used in
  144502. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  144503. * @param noMipmap Forces to not generate the mipmap if true
  144504. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  144505. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  144506. * @param onLoad — defines a callback called when texture is loaded
  144507. * @param onError — defines a callback called if there is an error
  144508. */
  144509. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  144510. /**
  144511. * Load the image data, by putting the image on a canvas and extracting its buffer.
  144512. */
  144513. private loadImage;
  144514. /**
  144515. * Convert the image buffer into a cubemap and create a CubeTexture.
  144516. */
  144517. private loadTexture;
  144518. /**
  144519. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  144520. * @param buffer The ArrayBuffer that should be converted.
  144521. * @returns The buffer as Float32Array.
  144522. */
  144523. private getFloat32ArrayFromArrayBuffer;
  144524. /**
  144525. * Get the current class name of the texture useful for serialization or dynamic coding.
  144526. * @returns "EquiRectangularCubeTexture"
  144527. */
  144528. getClassName(): string;
  144529. /**
  144530. * Create a clone of the current EquiRectangularCubeTexture and return it.
  144531. * @returns A clone of the current EquiRectangularCubeTexture.
  144532. */
  144533. clone(): EquiRectangularCubeTexture;
  144534. }
  144535. }
  144536. declare module BABYLON {
  144537. /**
  144538. * Defines the options related to the creation of an HtmlElementTexture
  144539. */
  144540. export interface IHtmlElementTextureOptions {
  144541. /**
  144542. * Defines wether mip maps should be created or not.
  144543. */
  144544. generateMipMaps?: boolean;
  144545. /**
  144546. * Defines the sampling mode of the texture.
  144547. */
  144548. samplingMode?: number;
  144549. /**
  144550. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  144551. */
  144552. engine: Nullable<ThinEngine>;
  144553. /**
  144554. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  144555. */
  144556. scene: Nullable<Scene>;
  144557. }
  144558. /**
  144559. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  144560. * To be as efficient as possible depending on your constraints nothing aside the first upload
  144561. * is automatically managed.
  144562. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  144563. * in your application.
  144564. *
  144565. * As the update is not automatic, you need to call them manually.
  144566. */
  144567. export class HtmlElementTexture extends BaseTexture {
  144568. /**
  144569. * The texture URL.
  144570. */
  144571. element: HTMLVideoElement | HTMLCanvasElement;
  144572. private static readonly DefaultOptions;
  144573. private _textureMatrix;
  144574. private _isVideo;
  144575. private _generateMipMaps;
  144576. private _samplingMode;
  144577. /**
  144578. * Instantiates a HtmlElementTexture from the following parameters.
  144579. *
  144580. * @param name Defines the name of the texture
  144581. * @param element Defines the video or canvas the texture is filled with
  144582. * @param options Defines the other none mandatory texture creation options
  144583. */
  144584. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  144585. private _createInternalTexture;
  144586. /**
  144587. * Returns the texture matrix used in most of the material.
  144588. */
  144589. getTextureMatrix(): Matrix;
  144590. /**
  144591. * Updates the content of the texture.
  144592. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  144593. */
  144594. update(invertY?: Nullable<boolean>): void;
  144595. }
  144596. }
  144597. declare module BABYLON {
  144598. /**
  144599. * Based on jsTGALoader - Javascript loader for TGA file
  144600. * By Vincent Thibault
  144601. * @see http://blog.robrowser.com/javascript-tga-loader.html
  144602. */
  144603. export class TGATools {
  144604. private static _TYPE_INDEXED;
  144605. private static _TYPE_RGB;
  144606. private static _TYPE_GREY;
  144607. private static _TYPE_RLE_INDEXED;
  144608. private static _TYPE_RLE_RGB;
  144609. private static _TYPE_RLE_GREY;
  144610. private static _ORIGIN_MASK;
  144611. private static _ORIGIN_SHIFT;
  144612. private static _ORIGIN_BL;
  144613. private static _ORIGIN_BR;
  144614. private static _ORIGIN_UL;
  144615. private static _ORIGIN_UR;
  144616. /**
  144617. * Gets the header of a TGA file
  144618. * @param data defines the TGA data
  144619. * @returns the header
  144620. */
  144621. static GetTGAHeader(data: Uint8Array): any;
  144622. /**
  144623. * Uploads TGA content to a Babylon Texture
  144624. * @hidden
  144625. */
  144626. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  144627. /** @hidden */
  144628. 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;
  144629. /** @hidden */
  144630. 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;
  144631. /** @hidden */
  144632. 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;
  144633. /** @hidden */
  144634. 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;
  144635. /** @hidden */
  144636. 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;
  144637. /** @hidden */
  144638. 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;
  144639. }
  144640. }
  144641. declare module BABYLON {
  144642. /**
  144643. * Implementation of the TGA Texture Loader.
  144644. * @hidden
  144645. */
  144646. export class _TGATextureLoader implements IInternalTextureLoader {
  144647. /**
  144648. * Defines wether the loader supports cascade loading the different faces.
  144649. */
  144650. readonly supportCascades: boolean;
  144651. /**
  144652. * This returns if the loader support the current file information.
  144653. * @param extension defines the file extension of the file being loaded
  144654. * @returns true if the loader can load the specified file
  144655. */
  144656. canLoad(extension: string): boolean;
  144657. /**
  144658. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  144659. * @param data contains the texture data
  144660. * @param texture defines the BabylonJS internal texture
  144661. * @param createPolynomials will be true if polynomials have been requested
  144662. * @param onLoad defines the callback to trigger once the texture is ready
  144663. * @param onError defines the callback to trigger in case of error
  144664. */
  144665. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  144666. /**
  144667. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  144668. * @param data contains the texture data
  144669. * @param texture defines the BabylonJS internal texture
  144670. * @param callback defines the method to call once ready to upload
  144671. */
  144672. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  144673. }
  144674. }
  144675. declare module BABYLON {
  144676. /**
  144677. * Info about the .basis files
  144678. */
  144679. class BasisFileInfo {
  144680. /**
  144681. * If the file has alpha
  144682. */
  144683. hasAlpha: boolean;
  144684. /**
  144685. * Info about each image of the basis file
  144686. */
  144687. images: Array<{
  144688. levels: Array<{
  144689. width: number;
  144690. height: number;
  144691. transcodedPixels: ArrayBufferView;
  144692. }>;
  144693. }>;
  144694. }
  144695. /**
  144696. * Result of transcoding a basis file
  144697. */
  144698. class TranscodeResult {
  144699. /**
  144700. * Info about the .basis file
  144701. */
  144702. fileInfo: BasisFileInfo;
  144703. /**
  144704. * Format to use when loading the file
  144705. */
  144706. format: number;
  144707. }
  144708. /**
  144709. * Configuration options for the Basis transcoder
  144710. */
  144711. export class BasisTranscodeConfiguration {
  144712. /**
  144713. * Supported compression formats used to determine the supported output format of the transcoder
  144714. */
  144715. supportedCompressionFormats?: {
  144716. /**
  144717. * etc1 compression format
  144718. */
  144719. etc1?: boolean;
  144720. /**
  144721. * s3tc compression format
  144722. */
  144723. s3tc?: boolean;
  144724. /**
  144725. * pvrtc compression format
  144726. */
  144727. pvrtc?: boolean;
  144728. /**
  144729. * etc2 compression format
  144730. */
  144731. etc2?: boolean;
  144732. };
  144733. /**
  144734. * If mipmap levels should be loaded for transcoded images (Default: true)
  144735. */
  144736. loadMipmapLevels?: boolean;
  144737. /**
  144738. * Index of a single image to load (Default: all images)
  144739. */
  144740. loadSingleImage?: number;
  144741. }
  144742. /**
  144743. * Used to load .Basis files
  144744. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  144745. */
  144746. export class BasisTools {
  144747. private static _IgnoreSupportedFormats;
  144748. /**
  144749. * URL to use when loading the basis transcoder
  144750. */
  144751. static JSModuleURL: string;
  144752. /**
  144753. * URL to use when loading the wasm module for the transcoder
  144754. */
  144755. static WasmModuleURL: string;
  144756. /**
  144757. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  144758. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  144759. * @returns internal format corresponding to the Basis format
  144760. */
  144761. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  144762. private static _WorkerPromise;
  144763. private static _Worker;
  144764. private static _actionId;
  144765. private static _CreateWorkerAsync;
  144766. /**
  144767. * Transcodes a loaded image file to compressed pixel data
  144768. * @param data image data to transcode
  144769. * @param config configuration options for the transcoding
  144770. * @returns a promise resulting in the transcoded image
  144771. */
  144772. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  144773. /**
  144774. * Loads a texture from the transcode result
  144775. * @param texture texture load to
  144776. * @param transcodeResult the result of transcoding the basis file to load from
  144777. */
  144778. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  144779. }
  144780. }
  144781. declare module BABYLON {
  144782. /**
  144783. * Loader for .basis file format
  144784. */
  144785. export class _BasisTextureLoader implements IInternalTextureLoader {
  144786. /**
  144787. * Defines whether the loader supports cascade loading the different faces.
  144788. */
  144789. readonly supportCascades: boolean;
  144790. /**
  144791. * This returns if the loader support the current file information.
  144792. * @param extension defines the file extension of the file being loaded
  144793. * @returns true if the loader can load the specified file
  144794. */
  144795. canLoad(extension: string): boolean;
  144796. /**
  144797. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  144798. * @param data contains the texture data
  144799. * @param texture defines the BabylonJS internal texture
  144800. * @param createPolynomials will be true if polynomials have been requested
  144801. * @param onLoad defines the callback to trigger once the texture is ready
  144802. * @param onError defines the callback to trigger in case of error
  144803. */
  144804. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  144805. /**
  144806. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  144807. * @param data contains the texture data
  144808. * @param texture defines the BabylonJS internal texture
  144809. * @param callback defines the method to call once ready to upload
  144810. */
  144811. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  144812. }
  144813. }
  144814. declare module BABYLON {
  144815. /**
  144816. * Defines the basic options interface of a TexturePacker Frame
  144817. */
  144818. export interface ITexturePackerFrame {
  144819. /**
  144820. * The frame ID
  144821. */
  144822. id: number;
  144823. /**
  144824. * The frames Scale
  144825. */
  144826. scale: Vector2;
  144827. /**
  144828. * The Frames offset
  144829. */
  144830. offset: Vector2;
  144831. }
  144832. /**
  144833. * This is a support class for frame Data on texture packer sets.
  144834. */
  144835. export class TexturePackerFrame implements ITexturePackerFrame {
  144836. /**
  144837. * The frame ID
  144838. */
  144839. id: number;
  144840. /**
  144841. * The frames Scale
  144842. */
  144843. scale: Vector2;
  144844. /**
  144845. * The Frames offset
  144846. */
  144847. offset: Vector2;
  144848. /**
  144849. * Initializes a texture package frame.
  144850. * @param id The numerical frame identifier
  144851. * @param scale Scalar Vector2 for UV frame
  144852. * @param offset Vector2 for the frame position in UV units.
  144853. * @returns TexturePackerFrame
  144854. */
  144855. constructor(id: number, scale: Vector2, offset: Vector2);
  144856. }
  144857. }
  144858. declare module BABYLON {
  144859. /**
  144860. * Defines the basic options interface of a TexturePacker
  144861. */
  144862. export interface ITexturePackerOptions {
  144863. /**
  144864. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  144865. */
  144866. map?: string[];
  144867. /**
  144868. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  144869. */
  144870. uvsIn?: string;
  144871. /**
  144872. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  144873. */
  144874. uvsOut?: string;
  144875. /**
  144876. * number representing the layout style. Defaults to LAYOUT_STRIP
  144877. */
  144878. layout?: number;
  144879. /**
  144880. * number of columns if using custom column count layout(2). This defaults to 4.
  144881. */
  144882. colnum?: number;
  144883. /**
  144884. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  144885. */
  144886. updateInputMeshes?: boolean;
  144887. /**
  144888. * boolean flag to dispose all the source textures. Defaults to true.
  144889. */
  144890. disposeSources?: boolean;
  144891. /**
  144892. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  144893. */
  144894. fillBlanks?: boolean;
  144895. /**
  144896. * string value representing the context fill style color. Defaults to 'black'.
  144897. */
  144898. customFillColor?: string;
  144899. /**
  144900. * Width and Height Value of each Frame in the TexturePacker Sets
  144901. */
  144902. frameSize?: number;
  144903. /**
  144904. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  144905. */
  144906. paddingRatio?: number;
  144907. /**
  144908. * Number that declares the fill method for the padding gutter.
  144909. */
  144910. paddingMode?: number;
  144911. /**
  144912. * If in SUBUV_COLOR padding mode what color to use.
  144913. */
  144914. paddingColor?: Color3 | Color4;
  144915. }
  144916. /**
  144917. * Defines the basic interface of a TexturePacker JSON File
  144918. */
  144919. export interface ITexturePackerJSON {
  144920. /**
  144921. * The frame ID
  144922. */
  144923. name: string;
  144924. /**
  144925. * The base64 channel data
  144926. */
  144927. sets: any;
  144928. /**
  144929. * The options of the Packer
  144930. */
  144931. options: ITexturePackerOptions;
  144932. /**
  144933. * The frame data of the Packer
  144934. */
  144935. frames: Array<number>;
  144936. }
  144937. /**
  144938. * This is a support class that generates a series of packed texture sets.
  144939. * @see https://doc.babylonjs.com/babylon101/materials
  144940. */
  144941. export class TexturePacker {
  144942. /** Packer Layout Constant 0 */
  144943. static readonly LAYOUT_STRIP: number;
  144944. /** Packer Layout Constant 1 */
  144945. static readonly LAYOUT_POWER2: number;
  144946. /** Packer Layout Constant 2 */
  144947. static readonly LAYOUT_COLNUM: number;
  144948. /** Packer Layout Constant 0 */
  144949. static readonly SUBUV_WRAP: number;
  144950. /** Packer Layout Constant 1 */
  144951. static readonly SUBUV_EXTEND: number;
  144952. /** Packer Layout Constant 2 */
  144953. static readonly SUBUV_COLOR: number;
  144954. /** The Name of the Texture Package */
  144955. name: string;
  144956. /** The scene scope of the TexturePacker */
  144957. scene: Scene;
  144958. /** The Meshes to target */
  144959. meshes: AbstractMesh[];
  144960. /** Arguments passed with the Constructor */
  144961. options: ITexturePackerOptions;
  144962. /** The promise that is started upon initialization */
  144963. promise: Nullable<Promise<TexturePacker | string>>;
  144964. /** The Container object for the channel sets that are generated */
  144965. sets: object;
  144966. /** The Container array for the frames that are generated */
  144967. frames: TexturePackerFrame[];
  144968. /** The expected number of textures the system is parsing. */
  144969. private _expecting;
  144970. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  144971. private _paddingValue;
  144972. /**
  144973. * Initializes a texture package series from an array of meshes or a single mesh.
  144974. * @param name The name of the package
  144975. * @param meshes The target meshes to compose the package from
  144976. * @param options The arguments that texture packer should follow while building.
  144977. * @param scene The scene which the textures are scoped to.
  144978. * @returns TexturePacker
  144979. */
  144980. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  144981. /**
  144982. * Starts the package process
  144983. * @param resolve The promises resolution function
  144984. * @returns TexturePacker
  144985. */
  144986. private _createFrames;
  144987. /**
  144988. * Calculates the Size of the Channel Sets
  144989. * @returns Vector2
  144990. */
  144991. private _calculateSize;
  144992. /**
  144993. * Calculates the UV data for the frames.
  144994. * @param baseSize the base frameSize
  144995. * @param padding the base frame padding
  144996. * @param dtSize size of the Dynamic Texture for that channel
  144997. * @param dtUnits is 1/dtSize
  144998. * @param update flag to update the input meshes
  144999. */
  145000. private _calculateMeshUVFrames;
  145001. /**
  145002. * Calculates the frames Offset.
  145003. * @param index of the frame
  145004. * @returns Vector2
  145005. */
  145006. private _getFrameOffset;
  145007. /**
  145008. * Updates a Mesh to the frame data
  145009. * @param mesh that is the target
  145010. * @param frameID or the frame index
  145011. */
  145012. private _updateMeshUV;
  145013. /**
  145014. * Updates a Meshes materials to use the texture packer channels
  145015. * @param m is the mesh to target
  145016. * @param force all channels on the packer to be set.
  145017. */
  145018. private _updateTextureReferences;
  145019. /**
  145020. * Public method to set a Mesh to a frame
  145021. * @param m that is the target
  145022. * @param frameID or the frame index
  145023. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  145024. */
  145025. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  145026. /**
  145027. * Starts the async promise to compile the texture packer.
  145028. * @returns Promise<void>
  145029. */
  145030. processAsync(): Promise<void>;
  145031. /**
  145032. * Disposes all textures associated with this packer
  145033. */
  145034. dispose(): void;
  145035. /**
  145036. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  145037. * @param imageType is the image type to use.
  145038. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  145039. */
  145040. download(imageType?: string, quality?: number): void;
  145041. /**
  145042. * Public method to load a texturePacker JSON file.
  145043. * @param data of the JSON file in string format.
  145044. */
  145045. updateFromJSON(data: string): void;
  145046. }
  145047. }
  145048. declare module BABYLON {
  145049. /**
  145050. * 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.
  145051. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  145052. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  145053. */
  145054. export class CustomProceduralTexture extends ProceduralTexture {
  145055. private _animate;
  145056. private _time;
  145057. private _config;
  145058. private _texturePath;
  145059. /**
  145060. * Instantiates a new Custom Procedural Texture.
  145061. * 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.
  145062. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  145063. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  145064. * @param name Define the name of the texture
  145065. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  145066. * @param size Define the size of the texture to create
  145067. * @param scene Define the scene the texture belongs to
  145068. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  145069. * @param generateMipMaps Define if the texture should creates mip maps or not
  145070. */
  145071. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  145072. private _loadJson;
  145073. /**
  145074. * Is the texture ready to be used ? (rendered at least once)
  145075. * @returns true if ready, otherwise, false.
  145076. */
  145077. isReady(): boolean;
  145078. /**
  145079. * Render the texture to its associated render target.
  145080. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  145081. */
  145082. render(useCameraPostProcess?: boolean): void;
  145083. /**
  145084. * Update the list of dependant textures samplers in the shader.
  145085. */
  145086. updateTextures(): void;
  145087. /**
  145088. * Update the uniform values of the procedural texture in the shader.
  145089. */
  145090. updateShaderUniforms(): void;
  145091. /**
  145092. * Define if the texture animates or not.
  145093. */
  145094. get animate(): boolean;
  145095. set animate(value: boolean);
  145096. }
  145097. }
  145098. declare module BABYLON {
  145099. /** @hidden */
  145100. export var noisePixelShader: {
  145101. name: string;
  145102. shader: string;
  145103. };
  145104. }
  145105. declare module BABYLON {
  145106. /**
  145107. * Class used to generate noise procedural textures
  145108. */
  145109. export class NoiseProceduralTexture extends ProceduralTexture {
  145110. /** Gets or sets the start time (default is 0) */
  145111. time: number;
  145112. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  145113. brightness: number;
  145114. /** Defines the number of octaves to process */
  145115. octaves: number;
  145116. /** Defines the level of persistence (0.8 by default) */
  145117. persistence: number;
  145118. /** Gets or sets animation speed factor (default is 1) */
  145119. animationSpeedFactor: number;
  145120. /**
  145121. * Creates a new NoiseProceduralTexture
  145122. * @param name defines the name fo the texture
  145123. * @param size defines the size of the texture (default is 256)
  145124. * @param scene defines the hosting scene
  145125. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  145126. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  145127. */
  145128. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  145129. private _updateShaderUniforms;
  145130. protected _getDefines(): string;
  145131. /** Generate the current state of the procedural texture */
  145132. render(useCameraPostProcess?: boolean): void;
  145133. /**
  145134. * Serializes this noise procedural texture
  145135. * @returns a serialized noise procedural texture object
  145136. */
  145137. serialize(): any;
  145138. /**
  145139. * Clone the texture.
  145140. * @returns the cloned texture
  145141. */
  145142. clone(): NoiseProceduralTexture;
  145143. /**
  145144. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  145145. * @param parsedTexture defines parsed texture data
  145146. * @param scene defines the current scene
  145147. * @param rootUrl defines the root URL containing noise procedural texture information
  145148. * @returns a parsed NoiseProceduralTexture
  145149. */
  145150. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  145151. }
  145152. }
  145153. declare module BABYLON {
  145154. /**
  145155. * Raw cube texture where the raw buffers are passed in
  145156. */
  145157. export class RawCubeTexture extends CubeTexture {
  145158. /**
  145159. * Creates a cube texture where the raw buffers are passed in.
  145160. * @param scene defines the scene the texture is attached to
  145161. * @param data defines the array of data to use to create each face
  145162. * @param size defines the size of the textures
  145163. * @param format defines the format of the data
  145164. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  145165. * @param generateMipMaps defines if the engine should generate the mip levels
  145166. * @param invertY defines if data must be stored with Y axis inverted
  145167. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  145168. * @param compression defines the compression used (null by default)
  145169. */
  145170. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  145171. /**
  145172. * Updates the raw cube texture.
  145173. * @param data defines the data to store
  145174. * @param format defines the data format
  145175. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  145176. * @param invertY defines if data must be stored with Y axis inverted
  145177. * @param compression defines the compression used (null by default)
  145178. * @param level defines which level of the texture to update
  145179. */
  145180. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  145181. /**
  145182. * Updates a raw cube texture with RGBD encoded data.
  145183. * @param data defines the array of data [mipmap][face] to use to create each face
  145184. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  145185. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  145186. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  145187. * @returns a promsie that resolves when the operation is complete
  145188. */
  145189. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  145190. /**
  145191. * Clones the raw cube texture.
  145192. * @return a new cube texture
  145193. */
  145194. clone(): CubeTexture;
  145195. /** @hidden */
  145196. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  145197. }
  145198. }
  145199. declare module BABYLON {
  145200. /**
  145201. * Class used to store 2D array textures containing user data
  145202. */
  145203. export class RawTexture2DArray extends Texture {
  145204. /** Gets or sets the texture format to use */
  145205. format: number;
  145206. /**
  145207. * Create a new RawTexture2DArray
  145208. * @param data defines the data of the texture
  145209. * @param width defines the width of the texture
  145210. * @param height defines the height of the texture
  145211. * @param depth defines the number of layers of the texture
  145212. * @param format defines the texture format to use
  145213. * @param scene defines the hosting scene
  145214. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  145215. * @param invertY defines if texture must be stored with Y axis inverted
  145216. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  145217. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  145218. */
  145219. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  145220. /** Gets or sets the texture format to use */
  145221. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  145222. /**
  145223. * Update the texture with new data
  145224. * @param data defines the data to store in the texture
  145225. */
  145226. update(data: ArrayBufferView): void;
  145227. }
  145228. }
  145229. declare module BABYLON {
  145230. /**
  145231. * Class used to store 3D textures containing user data
  145232. */
  145233. export class RawTexture3D extends Texture {
  145234. /** Gets or sets the texture format to use */
  145235. format: number;
  145236. /**
  145237. * Create a new RawTexture3D
  145238. * @param data defines the data of the texture
  145239. * @param width defines the width of the texture
  145240. * @param height defines the height of the texture
  145241. * @param depth defines the depth of the texture
  145242. * @param format defines the texture format to use
  145243. * @param scene defines the hosting scene
  145244. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  145245. * @param invertY defines if texture must be stored with Y axis inverted
  145246. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  145247. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  145248. */
  145249. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  145250. /** Gets or sets the texture format to use */
  145251. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  145252. /**
  145253. * Update the texture with new data
  145254. * @param data defines the data to store in the texture
  145255. */
  145256. update(data: ArrayBufferView): void;
  145257. }
  145258. }
  145259. declare module BABYLON {
  145260. /**
  145261. * Creates a refraction texture used by refraction channel of the standard material.
  145262. * It is like a mirror but to see through a material.
  145263. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  145264. */
  145265. export class RefractionTexture extends RenderTargetTexture {
  145266. /**
  145267. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  145268. * 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.
  145269. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  145270. */
  145271. refractionPlane: Plane;
  145272. /**
  145273. * Define how deep under the surface we should see.
  145274. */
  145275. depth: number;
  145276. /**
  145277. * Creates a refraction texture used by refraction channel of the standard material.
  145278. * It is like a mirror but to see through a material.
  145279. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  145280. * @param name Define the texture name
  145281. * @param size Define the size of the underlying texture
  145282. * @param scene Define the scene the refraction belongs to
  145283. * @param generateMipMaps Define if we need to generate mips level for the refraction
  145284. */
  145285. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  145286. /**
  145287. * Clone the refraction texture.
  145288. * @returns the cloned texture
  145289. */
  145290. clone(): RefractionTexture;
  145291. /**
  145292. * Serialize the texture to a JSON representation you could use in Parse later on
  145293. * @returns the serialized JSON representation
  145294. */
  145295. serialize(): any;
  145296. }
  145297. }
  145298. declare module BABYLON {
  145299. /**
  145300. * Block used to add support for vertex skinning (bones)
  145301. */
  145302. export class BonesBlock extends NodeMaterialBlock {
  145303. /**
  145304. * Creates a new BonesBlock
  145305. * @param name defines the block name
  145306. */
  145307. constructor(name: string);
  145308. /**
  145309. * Initialize the block and prepare the context for build
  145310. * @param state defines the state that will be used for the build
  145311. */
  145312. initialize(state: NodeMaterialBuildState): void;
  145313. /**
  145314. * Gets the current class name
  145315. * @returns the class name
  145316. */
  145317. getClassName(): string;
  145318. /**
  145319. * Gets the matrix indices input component
  145320. */
  145321. get matricesIndices(): NodeMaterialConnectionPoint;
  145322. /**
  145323. * Gets the matrix weights input component
  145324. */
  145325. get matricesWeights(): NodeMaterialConnectionPoint;
  145326. /**
  145327. * Gets the extra matrix indices input component
  145328. */
  145329. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  145330. /**
  145331. * Gets the extra matrix weights input component
  145332. */
  145333. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  145334. /**
  145335. * Gets the world input component
  145336. */
  145337. get world(): NodeMaterialConnectionPoint;
  145338. /**
  145339. * Gets the output component
  145340. */
  145341. get output(): NodeMaterialConnectionPoint;
  145342. autoConfigure(material: NodeMaterial): void;
  145343. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  145344. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145345. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145346. protected _buildBlock(state: NodeMaterialBuildState): this;
  145347. }
  145348. }
  145349. declare module BABYLON {
  145350. /**
  145351. * Block used to add support for instances
  145352. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  145353. */
  145354. export class InstancesBlock extends NodeMaterialBlock {
  145355. /**
  145356. * Creates a new InstancesBlock
  145357. * @param name defines the block name
  145358. */
  145359. constructor(name: string);
  145360. /**
  145361. * Gets the current class name
  145362. * @returns the class name
  145363. */
  145364. getClassName(): string;
  145365. /**
  145366. * Gets the first world row input component
  145367. */
  145368. get world0(): NodeMaterialConnectionPoint;
  145369. /**
  145370. * Gets the second world row input component
  145371. */
  145372. get world1(): NodeMaterialConnectionPoint;
  145373. /**
  145374. * Gets the third world row input component
  145375. */
  145376. get world2(): NodeMaterialConnectionPoint;
  145377. /**
  145378. * Gets the forth world row input component
  145379. */
  145380. get world3(): NodeMaterialConnectionPoint;
  145381. /**
  145382. * Gets the world input component
  145383. */
  145384. get world(): NodeMaterialConnectionPoint;
  145385. /**
  145386. * Gets the output component
  145387. */
  145388. get output(): NodeMaterialConnectionPoint;
  145389. /**
  145390. * Gets the isntanceID component
  145391. */
  145392. get instanceID(): NodeMaterialConnectionPoint;
  145393. autoConfigure(material: NodeMaterial): void;
  145394. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  145395. protected _buildBlock(state: NodeMaterialBuildState): this;
  145396. }
  145397. }
  145398. declare module BABYLON {
  145399. /**
  145400. * Block used to add morph targets support to vertex shader
  145401. */
  145402. export class MorphTargetsBlock extends NodeMaterialBlock {
  145403. private _repeatableContentAnchor;
  145404. /**
  145405. * Create a new MorphTargetsBlock
  145406. * @param name defines the block name
  145407. */
  145408. constructor(name: string);
  145409. /**
  145410. * Gets the current class name
  145411. * @returns the class name
  145412. */
  145413. getClassName(): string;
  145414. /**
  145415. * Gets the position input component
  145416. */
  145417. get position(): NodeMaterialConnectionPoint;
  145418. /**
  145419. * Gets the normal input component
  145420. */
  145421. get normal(): NodeMaterialConnectionPoint;
  145422. /**
  145423. * Gets the tangent input component
  145424. */
  145425. get tangent(): NodeMaterialConnectionPoint;
  145426. /**
  145427. * Gets the tangent input component
  145428. */
  145429. get uv(): NodeMaterialConnectionPoint;
  145430. /**
  145431. * Gets the position output component
  145432. */
  145433. get positionOutput(): NodeMaterialConnectionPoint;
  145434. /**
  145435. * Gets the normal output component
  145436. */
  145437. get normalOutput(): NodeMaterialConnectionPoint;
  145438. /**
  145439. * Gets the tangent output component
  145440. */
  145441. get tangentOutput(): NodeMaterialConnectionPoint;
  145442. /**
  145443. * Gets the tangent output component
  145444. */
  145445. get uvOutput(): NodeMaterialConnectionPoint;
  145446. initialize(state: NodeMaterialBuildState): void;
  145447. autoConfigure(material: NodeMaterial): void;
  145448. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145449. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145450. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  145451. protected _buildBlock(state: NodeMaterialBuildState): this;
  145452. }
  145453. }
  145454. declare module BABYLON {
  145455. /**
  145456. * Block used to get data information from a light
  145457. */
  145458. export class LightInformationBlock extends NodeMaterialBlock {
  145459. private _lightDataUniformName;
  145460. private _lightColorUniformName;
  145461. private _lightTypeDefineName;
  145462. /**
  145463. * Gets or sets the light associated with this block
  145464. */
  145465. light: Nullable<Light>;
  145466. /**
  145467. * Creates a new LightInformationBlock
  145468. * @param name defines the block name
  145469. */
  145470. constructor(name: string);
  145471. /**
  145472. * Gets the current class name
  145473. * @returns the class name
  145474. */
  145475. getClassName(): string;
  145476. /**
  145477. * Gets the world position input component
  145478. */
  145479. get worldPosition(): NodeMaterialConnectionPoint;
  145480. /**
  145481. * Gets the direction output component
  145482. */
  145483. get direction(): NodeMaterialConnectionPoint;
  145484. /**
  145485. * Gets the direction output component
  145486. */
  145487. get color(): NodeMaterialConnectionPoint;
  145488. /**
  145489. * Gets the direction output component
  145490. */
  145491. get intensity(): NodeMaterialConnectionPoint;
  145492. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145493. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145494. protected _buildBlock(state: NodeMaterialBuildState): this;
  145495. serialize(): any;
  145496. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145497. }
  145498. }
  145499. declare module BABYLON {
  145500. /**
  145501. * Block used to add image processing support to fragment shader
  145502. */
  145503. export class ImageProcessingBlock extends NodeMaterialBlock {
  145504. /**
  145505. * Create a new ImageProcessingBlock
  145506. * @param name defines the block name
  145507. */
  145508. constructor(name: string);
  145509. /**
  145510. * Gets the current class name
  145511. * @returns the class name
  145512. */
  145513. getClassName(): string;
  145514. /**
  145515. * Gets the color input component
  145516. */
  145517. get color(): NodeMaterialConnectionPoint;
  145518. /**
  145519. * Gets the output component
  145520. */
  145521. get output(): NodeMaterialConnectionPoint;
  145522. /**
  145523. * Initialize the block and prepare the context for build
  145524. * @param state defines the state that will be used for the build
  145525. */
  145526. initialize(state: NodeMaterialBuildState): void;
  145527. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  145528. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145529. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145530. protected _buildBlock(state: NodeMaterialBuildState): this;
  145531. }
  145532. }
  145533. declare module BABYLON {
  145534. /**
  145535. * Block used to pertub normals based on a normal map
  145536. */
  145537. export class PerturbNormalBlock extends NodeMaterialBlock {
  145538. private _tangentSpaceParameterName;
  145539. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  145540. invertX: boolean;
  145541. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  145542. invertY: boolean;
  145543. /**
  145544. * Create a new PerturbNormalBlock
  145545. * @param name defines the block name
  145546. */
  145547. constructor(name: string);
  145548. /**
  145549. * Gets the current class name
  145550. * @returns the class name
  145551. */
  145552. getClassName(): string;
  145553. /**
  145554. * Gets the world position input component
  145555. */
  145556. get worldPosition(): NodeMaterialConnectionPoint;
  145557. /**
  145558. * Gets the world normal input component
  145559. */
  145560. get worldNormal(): NodeMaterialConnectionPoint;
  145561. /**
  145562. * Gets the world tangent input component
  145563. */
  145564. get worldTangent(): NodeMaterialConnectionPoint;
  145565. /**
  145566. * Gets the uv input component
  145567. */
  145568. get uv(): NodeMaterialConnectionPoint;
  145569. /**
  145570. * Gets the normal map color input component
  145571. */
  145572. get normalMapColor(): NodeMaterialConnectionPoint;
  145573. /**
  145574. * Gets the strength input component
  145575. */
  145576. get strength(): NodeMaterialConnectionPoint;
  145577. /**
  145578. * Gets the output component
  145579. */
  145580. get output(): NodeMaterialConnectionPoint;
  145581. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145582. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145583. autoConfigure(material: NodeMaterial): void;
  145584. protected _buildBlock(state: NodeMaterialBuildState): this;
  145585. protected _dumpPropertiesCode(): string;
  145586. serialize(): any;
  145587. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145588. }
  145589. }
  145590. declare module BABYLON {
  145591. /**
  145592. * Block used to discard a pixel if a value is smaller than a cutoff
  145593. */
  145594. export class DiscardBlock extends NodeMaterialBlock {
  145595. /**
  145596. * Create a new DiscardBlock
  145597. * @param name defines the block name
  145598. */
  145599. constructor(name: string);
  145600. /**
  145601. * Gets the current class name
  145602. * @returns the class name
  145603. */
  145604. getClassName(): string;
  145605. /**
  145606. * Gets the color input component
  145607. */
  145608. get value(): NodeMaterialConnectionPoint;
  145609. /**
  145610. * Gets the cutoff input component
  145611. */
  145612. get cutoff(): NodeMaterialConnectionPoint;
  145613. protected _buildBlock(state: NodeMaterialBuildState): this;
  145614. }
  145615. }
  145616. declare module BABYLON {
  145617. /**
  145618. * Block used to test if the fragment shader is front facing
  145619. */
  145620. export class FrontFacingBlock extends NodeMaterialBlock {
  145621. /**
  145622. * Creates a new FrontFacingBlock
  145623. * @param name defines the block name
  145624. */
  145625. constructor(name: string);
  145626. /**
  145627. * Gets the current class name
  145628. * @returns the class name
  145629. */
  145630. getClassName(): string;
  145631. /**
  145632. * Gets the output component
  145633. */
  145634. get output(): NodeMaterialConnectionPoint;
  145635. protected _buildBlock(state: NodeMaterialBuildState): this;
  145636. }
  145637. }
  145638. declare module BABYLON {
  145639. /**
  145640. * Block used to get the derivative value on x and y of a given input
  145641. */
  145642. export class DerivativeBlock extends NodeMaterialBlock {
  145643. /**
  145644. * Create a new DerivativeBlock
  145645. * @param name defines the block name
  145646. */
  145647. constructor(name: string);
  145648. /**
  145649. * Gets the current class name
  145650. * @returns the class name
  145651. */
  145652. getClassName(): string;
  145653. /**
  145654. * Gets the input component
  145655. */
  145656. get input(): NodeMaterialConnectionPoint;
  145657. /**
  145658. * Gets the derivative output on x
  145659. */
  145660. get dx(): NodeMaterialConnectionPoint;
  145661. /**
  145662. * Gets the derivative output on y
  145663. */
  145664. get dy(): NodeMaterialConnectionPoint;
  145665. protected _buildBlock(state: NodeMaterialBuildState): this;
  145666. }
  145667. }
  145668. declare module BABYLON {
  145669. /**
  145670. * Block used to make gl_FragCoord available
  145671. */
  145672. export class FragCoordBlock extends NodeMaterialBlock {
  145673. /**
  145674. * Creates a new FragCoordBlock
  145675. * @param name defines the block name
  145676. */
  145677. constructor(name: string);
  145678. /**
  145679. * Gets the current class name
  145680. * @returns the class name
  145681. */
  145682. getClassName(): string;
  145683. /**
  145684. * Gets the xy component
  145685. */
  145686. get xy(): NodeMaterialConnectionPoint;
  145687. /**
  145688. * Gets the xyz component
  145689. */
  145690. get xyz(): NodeMaterialConnectionPoint;
  145691. /**
  145692. * Gets the xyzw component
  145693. */
  145694. get xyzw(): NodeMaterialConnectionPoint;
  145695. /**
  145696. * Gets the x component
  145697. */
  145698. get x(): NodeMaterialConnectionPoint;
  145699. /**
  145700. * Gets the y component
  145701. */
  145702. get y(): NodeMaterialConnectionPoint;
  145703. /**
  145704. * Gets the z component
  145705. */
  145706. get z(): NodeMaterialConnectionPoint;
  145707. /**
  145708. * Gets the w component
  145709. */
  145710. get output(): NodeMaterialConnectionPoint;
  145711. protected writeOutputs(state: NodeMaterialBuildState): string;
  145712. protected _buildBlock(state: NodeMaterialBuildState): this;
  145713. }
  145714. }
  145715. declare module BABYLON {
  145716. /**
  145717. * Block used to get the screen sizes
  145718. */
  145719. export class ScreenSizeBlock extends NodeMaterialBlock {
  145720. private _varName;
  145721. private _scene;
  145722. /**
  145723. * Creates a new ScreenSizeBlock
  145724. * @param name defines the block name
  145725. */
  145726. constructor(name: string);
  145727. /**
  145728. * Gets the current class name
  145729. * @returns the class name
  145730. */
  145731. getClassName(): string;
  145732. /**
  145733. * Gets the xy component
  145734. */
  145735. get xy(): NodeMaterialConnectionPoint;
  145736. /**
  145737. * Gets the x component
  145738. */
  145739. get x(): NodeMaterialConnectionPoint;
  145740. /**
  145741. * Gets the y component
  145742. */
  145743. get y(): NodeMaterialConnectionPoint;
  145744. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145745. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  145746. protected _buildBlock(state: NodeMaterialBuildState): this;
  145747. }
  145748. }
  145749. declare module BABYLON {
  145750. /**
  145751. * Block used to add support for scene fog
  145752. */
  145753. export class FogBlock extends NodeMaterialBlock {
  145754. private _fogDistanceName;
  145755. private _fogParameters;
  145756. /**
  145757. * Create a new FogBlock
  145758. * @param name defines the block name
  145759. */
  145760. constructor(name: string);
  145761. /**
  145762. * Gets the current class name
  145763. * @returns the class name
  145764. */
  145765. getClassName(): string;
  145766. /**
  145767. * Gets the world position input component
  145768. */
  145769. get worldPosition(): NodeMaterialConnectionPoint;
  145770. /**
  145771. * Gets the view input component
  145772. */
  145773. get view(): NodeMaterialConnectionPoint;
  145774. /**
  145775. * Gets the color input component
  145776. */
  145777. get input(): NodeMaterialConnectionPoint;
  145778. /**
  145779. * Gets the fog color input component
  145780. */
  145781. get fogColor(): NodeMaterialConnectionPoint;
  145782. /**
  145783. * Gets the output component
  145784. */
  145785. get output(): NodeMaterialConnectionPoint;
  145786. autoConfigure(material: NodeMaterial): void;
  145787. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145788. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145789. protected _buildBlock(state: NodeMaterialBuildState): this;
  145790. }
  145791. }
  145792. declare module BABYLON {
  145793. /**
  145794. * Block used to add light in the fragment shader
  145795. */
  145796. export class LightBlock extends NodeMaterialBlock {
  145797. private _lightId;
  145798. /**
  145799. * Gets or sets the light associated with this block
  145800. */
  145801. light: Nullable<Light>;
  145802. /**
  145803. * Create a new LightBlock
  145804. * @param name defines the block name
  145805. */
  145806. constructor(name: string);
  145807. /**
  145808. * Gets the current class name
  145809. * @returns the class name
  145810. */
  145811. getClassName(): string;
  145812. /**
  145813. * Gets the world position input component
  145814. */
  145815. get worldPosition(): NodeMaterialConnectionPoint;
  145816. /**
  145817. * Gets the world normal input component
  145818. */
  145819. get worldNormal(): NodeMaterialConnectionPoint;
  145820. /**
  145821. * Gets the camera (or eye) position component
  145822. */
  145823. get cameraPosition(): NodeMaterialConnectionPoint;
  145824. /**
  145825. * Gets the glossiness component
  145826. */
  145827. get glossiness(): NodeMaterialConnectionPoint;
  145828. /**
  145829. * Gets the glossinness power component
  145830. */
  145831. get glossPower(): NodeMaterialConnectionPoint;
  145832. /**
  145833. * Gets the diffuse color component
  145834. */
  145835. get diffuseColor(): NodeMaterialConnectionPoint;
  145836. /**
  145837. * Gets the specular color component
  145838. */
  145839. get specularColor(): NodeMaterialConnectionPoint;
  145840. /**
  145841. * Gets the view matrix component
  145842. */
  145843. get view(): NodeMaterialConnectionPoint;
  145844. /**
  145845. * Gets the diffuse output component
  145846. */
  145847. get diffuseOutput(): NodeMaterialConnectionPoint;
  145848. /**
  145849. * Gets the specular output component
  145850. */
  145851. get specularOutput(): NodeMaterialConnectionPoint;
  145852. /**
  145853. * Gets the shadow output component
  145854. */
  145855. get shadow(): NodeMaterialConnectionPoint;
  145856. autoConfigure(material: NodeMaterial): void;
  145857. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145858. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  145859. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145860. private _injectVertexCode;
  145861. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145862. serialize(): any;
  145863. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145864. }
  145865. }
  145866. declare module BABYLON {
  145867. /**
  145868. * Block used to read a reflection texture from a sampler
  145869. */
  145870. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  145871. /**
  145872. * Create a new ReflectionTextureBlock
  145873. * @param name defines the block name
  145874. */
  145875. constructor(name: string);
  145876. /**
  145877. * Gets the current class name
  145878. * @returns the class name
  145879. */
  145880. getClassName(): string;
  145881. /**
  145882. * Gets the world position input component
  145883. */
  145884. get position(): NodeMaterialConnectionPoint;
  145885. /**
  145886. * Gets the world position input component
  145887. */
  145888. get worldPosition(): NodeMaterialConnectionPoint;
  145889. /**
  145890. * Gets the world normal input component
  145891. */
  145892. get worldNormal(): NodeMaterialConnectionPoint;
  145893. /**
  145894. * Gets the world input component
  145895. */
  145896. get world(): NodeMaterialConnectionPoint;
  145897. /**
  145898. * Gets the camera (or eye) position component
  145899. */
  145900. get cameraPosition(): NodeMaterialConnectionPoint;
  145901. /**
  145902. * Gets the view input component
  145903. */
  145904. get view(): NodeMaterialConnectionPoint;
  145905. /**
  145906. * Gets the rgb output component
  145907. */
  145908. get rgb(): NodeMaterialConnectionPoint;
  145909. /**
  145910. * Gets the rgba output component
  145911. */
  145912. get rgba(): NodeMaterialConnectionPoint;
  145913. /**
  145914. * Gets the r output component
  145915. */
  145916. get r(): NodeMaterialConnectionPoint;
  145917. /**
  145918. * Gets the g output component
  145919. */
  145920. get g(): NodeMaterialConnectionPoint;
  145921. /**
  145922. * Gets the b output component
  145923. */
  145924. get b(): NodeMaterialConnectionPoint;
  145925. /**
  145926. * Gets the a output component
  145927. */
  145928. get a(): NodeMaterialConnectionPoint;
  145929. autoConfigure(material: NodeMaterial): void;
  145930. protected _buildBlock(state: NodeMaterialBuildState): this;
  145931. }
  145932. }
  145933. declare module BABYLON {
  145934. /**
  145935. * Block used to add 2 vectors
  145936. */
  145937. export class AddBlock extends NodeMaterialBlock {
  145938. /**
  145939. * Creates a new AddBlock
  145940. * @param name defines the block name
  145941. */
  145942. constructor(name: string);
  145943. /**
  145944. * Gets the current class name
  145945. * @returns the class name
  145946. */
  145947. getClassName(): string;
  145948. /**
  145949. * Gets the left operand input component
  145950. */
  145951. get left(): NodeMaterialConnectionPoint;
  145952. /**
  145953. * Gets the right operand input component
  145954. */
  145955. get right(): NodeMaterialConnectionPoint;
  145956. /**
  145957. * Gets the output component
  145958. */
  145959. get output(): NodeMaterialConnectionPoint;
  145960. protected _buildBlock(state: NodeMaterialBuildState): this;
  145961. }
  145962. }
  145963. declare module BABYLON {
  145964. /**
  145965. * Block used to scale a vector by a float
  145966. */
  145967. export class ScaleBlock extends NodeMaterialBlock {
  145968. /**
  145969. * Creates a new ScaleBlock
  145970. * @param name defines the block name
  145971. */
  145972. constructor(name: string);
  145973. /**
  145974. * Gets the current class name
  145975. * @returns the class name
  145976. */
  145977. getClassName(): string;
  145978. /**
  145979. * Gets the input component
  145980. */
  145981. get input(): NodeMaterialConnectionPoint;
  145982. /**
  145983. * Gets the factor input component
  145984. */
  145985. get factor(): NodeMaterialConnectionPoint;
  145986. /**
  145987. * Gets the output component
  145988. */
  145989. get output(): NodeMaterialConnectionPoint;
  145990. protected _buildBlock(state: NodeMaterialBuildState): this;
  145991. }
  145992. }
  145993. declare module BABYLON {
  145994. /**
  145995. * Block used to clamp a float
  145996. */
  145997. export class ClampBlock extends NodeMaterialBlock {
  145998. /** Gets or sets the minimum range */
  145999. minimum: number;
  146000. /** Gets or sets the maximum range */
  146001. maximum: number;
  146002. /**
  146003. * Creates a new ClampBlock
  146004. * @param name defines the block name
  146005. */
  146006. constructor(name: string);
  146007. /**
  146008. * Gets the current class name
  146009. * @returns the class name
  146010. */
  146011. getClassName(): string;
  146012. /**
  146013. * Gets the value input component
  146014. */
  146015. get value(): NodeMaterialConnectionPoint;
  146016. /**
  146017. * Gets the output component
  146018. */
  146019. get output(): NodeMaterialConnectionPoint;
  146020. protected _buildBlock(state: NodeMaterialBuildState): this;
  146021. protected _dumpPropertiesCode(): string;
  146022. serialize(): any;
  146023. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146024. }
  146025. }
  146026. declare module BABYLON {
  146027. /**
  146028. * Block used to apply a cross product between 2 vectors
  146029. */
  146030. export class CrossBlock extends NodeMaterialBlock {
  146031. /**
  146032. * Creates a new CrossBlock
  146033. * @param name defines the block name
  146034. */
  146035. constructor(name: string);
  146036. /**
  146037. * Gets the current class name
  146038. * @returns the class name
  146039. */
  146040. getClassName(): string;
  146041. /**
  146042. * Gets the left operand input component
  146043. */
  146044. get left(): NodeMaterialConnectionPoint;
  146045. /**
  146046. * Gets the right operand input component
  146047. */
  146048. get right(): NodeMaterialConnectionPoint;
  146049. /**
  146050. * Gets the output component
  146051. */
  146052. get output(): NodeMaterialConnectionPoint;
  146053. protected _buildBlock(state: NodeMaterialBuildState): this;
  146054. }
  146055. }
  146056. declare module BABYLON {
  146057. /**
  146058. * Block used to apply a dot product between 2 vectors
  146059. */
  146060. export class DotBlock extends NodeMaterialBlock {
  146061. /**
  146062. * Creates a new DotBlock
  146063. * @param name defines the block name
  146064. */
  146065. constructor(name: string);
  146066. /**
  146067. * Gets the current class name
  146068. * @returns the class name
  146069. */
  146070. getClassName(): string;
  146071. /**
  146072. * Gets the left operand input component
  146073. */
  146074. get left(): NodeMaterialConnectionPoint;
  146075. /**
  146076. * Gets the right operand input component
  146077. */
  146078. get right(): NodeMaterialConnectionPoint;
  146079. /**
  146080. * Gets the output component
  146081. */
  146082. get output(): NodeMaterialConnectionPoint;
  146083. protected _buildBlock(state: NodeMaterialBuildState): this;
  146084. }
  146085. }
  146086. declare module BABYLON {
  146087. /**
  146088. * Block used to normalize a vector
  146089. */
  146090. export class NormalizeBlock extends NodeMaterialBlock {
  146091. /**
  146092. * Creates a new NormalizeBlock
  146093. * @param name defines the block name
  146094. */
  146095. constructor(name: string);
  146096. /**
  146097. * Gets the current class name
  146098. * @returns the class name
  146099. */
  146100. getClassName(): string;
  146101. /**
  146102. * Gets the input component
  146103. */
  146104. get input(): NodeMaterialConnectionPoint;
  146105. /**
  146106. * Gets the output component
  146107. */
  146108. get output(): NodeMaterialConnectionPoint;
  146109. protected _buildBlock(state: NodeMaterialBuildState): this;
  146110. }
  146111. }
  146112. declare module BABYLON {
  146113. /**
  146114. * Block used to create a Color3/4 out of individual inputs (one for each component)
  146115. */
  146116. export class ColorMergerBlock extends NodeMaterialBlock {
  146117. /**
  146118. * Create a new ColorMergerBlock
  146119. * @param name defines the block name
  146120. */
  146121. constructor(name: string);
  146122. /**
  146123. * Gets the current class name
  146124. * @returns the class name
  146125. */
  146126. getClassName(): string;
  146127. /**
  146128. * Gets the rgb component (input)
  146129. */
  146130. get rgbIn(): NodeMaterialConnectionPoint;
  146131. /**
  146132. * Gets the r component (input)
  146133. */
  146134. get r(): NodeMaterialConnectionPoint;
  146135. /**
  146136. * Gets the g component (input)
  146137. */
  146138. get g(): NodeMaterialConnectionPoint;
  146139. /**
  146140. * Gets the b component (input)
  146141. */
  146142. get b(): NodeMaterialConnectionPoint;
  146143. /**
  146144. * Gets the a component (input)
  146145. */
  146146. get a(): NodeMaterialConnectionPoint;
  146147. /**
  146148. * Gets the rgba component (output)
  146149. */
  146150. get rgba(): NodeMaterialConnectionPoint;
  146151. /**
  146152. * Gets the rgb component (output)
  146153. */
  146154. get rgbOut(): NodeMaterialConnectionPoint;
  146155. /**
  146156. * Gets the rgb component (output)
  146157. * @deprecated Please use rgbOut instead.
  146158. */
  146159. get rgb(): NodeMaterialConnectionPoint;
  146160. protected _buildBlock(state: NodeMaterialBuildState): this;
  146161. }
  146162. }
  146163. declare module BABYLON {
  146164. /**
  146165. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  146166. */
  146167. export class VectorSplitterBlock extends NodeMaterialBlock {
  146168. /**
  146169. * Create a new VectorSplitterBlock
  146170. * @param name defines the block name
  146171. */
  146172. constructor(name: string);
  146173. /**
  146174. * Gets the current class name
  146175. * @returns the class name
  146176. */
  146177. getClassName(): string;
  146178. /**
  146179. * Gets the xyzw component (input)
  146180. */
  146181. get xyzw(): NodeMaterialConnectionPoint;
  146182. /**
  146183. * Gets the xyz component (input)
  146184. */
  146185. get xyzIn(): NodeMaterialConnectionPoint;
  146186. /**
  146187. * Gets the xy component (input)
  146188. */
  146189. get xyIn(): NodeMaterialConnectionPoint;
  146190. /**
  146191. * Gets the xyz component (output)
  146192. */
  146193. get xyzOut(): NodeMaterialConnectionPoint;
  146194. /**
  146195. * Gets the xy component (output)
  146196. */
  146197. get xyOut(): NodeMaterialConnectionPoint;
  146198. /**
  146199. * Gets the x component (output)
  146200. */
  146201. get x(): NodeMaterialConnectionPoint;
  146202. /**
  146203. * Gets the y component (output)
  146204. */
  146205. get y(): NodeMaterialConnectionPoint;
  146206. /**
  146207. * Gets the z component (output)
  146208. */
  146209. get z(): NodeMaterialConnectionPoint;
  146210. /**
  146211. * Gets the w component (output)
  146212. */
  146213. get w(): NodeMaterialConnectionPoint;
  146214. protected _inputRename(name: string): string;
  146215. protected _outputRename(name: string): string;
  146216. protected _buildBlock(state: NodeMaterialBuildState): this;
  146217. }
  146218. }
  146219. declare module BABYLON {
  146220. /**
  146221. * Block used to lerp between 2 values
  146222. */
  146223. export class LerpBlock extends NodeMaterialBlock {
  146224. /**
  146225. * Creates a new LerpBlock
  146226. * @param name defines the block name
  146227. */
  146228. constructor(name: string);
  146229. /**
  146230. * Gets the current class name
  146231. * @returns the class name
  146232. */
  146233. getClassName(): string;
  146234. /**
  146235. * Gets the left operand input component
  146236. */
  146237. get left(): NodeMaterialConnectionPoint;
  146238. /**
  146239. * Gets the right operand input component
  146240. */
  146241. get right(): NodeMaterialConnectionPoint;
  146242. /**
  146243. * Gets the gradient operand input component
  146244. */
  146245. get gradient(): NodeMaterialConnectionPoint;
  146246. /**
  146247. * Gets the output component
  146248. */
  146249. get output(): NodeMaterialConnectionPoint;
  146250. protected _buildBlock(state: NodeMaterialBuildState): this;
  146251. }
  146252. }
  146253. declare module BABYLON {
  146254. /**
  146255. * Block used to divide 2 vectors
  146256. */
  146257. export class DivideBlock extends NodeMaterialBlock {
  146258. /**
  146259. * Creates a new DivideBlock
  146260. * @param name defines the block name
  146261. */
  146262. constructor(name: string);
  146263. /**
  146264. * Gets the current class name
  146265. * @returns the class name
  146266. */
  146267. getClassName(): string;
  146268. /**
  146269. * Gets the left operand input component
  146270. */
  146271. get left(): NodeMaterialConnectionPoint;
  146272. /**
  146273. * Gets the right operand input component
  146274. */
  146275. get right(): NodeMaterialConnectionPoint;
  146276. /**
  146277. * Gets the output component
  146278. */
  146279. get output(): NodeMaterialConnectionPoint;
  146280. protected _buildBlock(state: NodeMaterialBuildState): this;
  146281. }
  146282. }
  146283. declare module BABYLON {
  146284. /**
  146285. * Block used to subtract 2 vectors
  146286. */
  146287. export class SubtractBlock extends NodeMaterialBlock {
  146288. /**
  146289. * Creates a new SubtractBlock
  146290. * @param name defines the block name
  146291. */
  146292. constructor(name: string);
  146293. /**
  146294. * Gets the current class name
  146295. * @returns the class name
  146296. */
  146297. getClassName(): string;
  146298. /**
  146299. * Gets the left operand input component
  146300. */
  146301. get left(): NodeMaterialConnectionPoint;
  146302. /**
  146303. * Gets the right operand input component
  146304. */
  146305. get right(): NodeMaterialConnectionPoint;
  146306. /**
  146307. * Gets the output component
  146308. */
  146309. get output(): NodeMaterialConnectionPoint;
  146310. protected _buildBlock(state: NodeMaterialBuildState): this;
  146311. }
  146312. }
  146313. declare module BABYLON {
  146314. /**
  146315. * Block used to step a value
  146316. */
  146317. export class StepBlock extends NodeMaterialBlock {
  146318. /**
  146319. * Creates a new StepBlock
  146320. * @param name defines the block name
  146321. */
  146322. constructor(name: string);
  146323. /**
  146324. * Gets the current class name
  146325. * @returns the class name
  146326. */
  146327. getClassName(): string;
  146328. /**
  146329. * Gets the value operand input component
  146330. */
  146331. get value(): NodeMaterialConnectionPoint;
  146332. /**
  146333. * Gets the edge operand input component
  146334. */
  146335. get edge(): NodeMaterialConnectionPoint;
  146336. /**
  146337. * Gets the output component
  146338. */
  146339. get output(): NodeMaterialConnectionPoint;
  146340. protected _buildBlock(state: NodeMaterialBuildState): this;
  146341. }
  146342. }
  146343. declare module BABYLON {
  146344. /**
  146345. * Block used to get the opposite (1 - x) of a value
  146346. */
  146347. export class OneMinusBlock extends NodeMaterialBlock {
  146348. /**
  146349. * Creates a new OneMinusBlock
  146350. * @param name defines the block name
  146351. */
  146352. constructor(name: string);
  146353. /**
  146354. * Gets the current class name
  146355. * @returns the class name
  146356. */
  146357. getClassName(): string;
  146358. /**
  146359. * Gets the input component
  146360. */
  146361. get input(): NodeMaterialConnectionPoint;
  146362. /**
  146363. * Gets the output component
  146364. */
  146365. get output(): NodeMaterialConnectionPoint;
  146366. protected _buildBlock(state: NodeMaterialBuildState): this;
  146367. }
  146368. }
  146369. declare module BABYLON {
  146370. /**
  146371. * Block used to get the view direction
  146372. */
  146373. export class ViewDirectionBlock extends NodeMaterialBlock {
  146374. /**
  146375. * Creates a new ViewDirectionBlock
  146376. * @param name defines the block name
  146377. */
  146378. constructor(name: string);
  146379. /**
  146380. * Gets the current class name
  146381. * @returns the class name
  146382. */
  146383. getClassName(): string;
  146384. /**
  146385. * Gets the world position component
  146386. */
  146387. get worldPosition(): NodeMaterialConnectionPoint;
  146388. /**
  146389. * Gets the camera position component
  146390. */
  146391. get cameraPosition(): NodeMaterialConnectionPoint;
  146392. /**
  146393. * Gets the output component
  146394. */
  146395. get output(): NodeMaterialConnectionPoint;
  146396. autoConfigure(material: NodeMaterial): void;
  146397. protected _buildBlock(state: NodeMaterialBuildState): this;
  146398. }
  146399. }
  146400. declare module BABYLON {
  146401. /**
  146402. * Block used to compute fresnel value
  146403. */
  146404. export class FresnelBlock extends NodeMaterialBlock {
  146405. /**
  146406. * Create a new FresnelBlock
  146407. * @param name defines the block name
  146408. */
  146409. constructor(name: string);
  146410. /**
  146411. * Gets the current class name
  146412. * @returns the class name
  146413. */
  146414. getClassName(): string;
  146415. /**
  146416. * Gets the world normal input component
  146417. */
  146418. get worldNormal(): NodeMaterialConnectionPoint;
  146419. /**
  146420. * Gets the view direction input component
  146421. */
  146422. get viewDirection(): NodeMaterialConnectionPoint;
  146423. /**
  146424. * Gets the bias input component
  146425. */
  146426. get bias(): NodeMaterialConnectionPoint;
  146427. /**
  146428. * Gets the camera (or eye) position component
  146429. */
  146430. get power(): NodeMaterialConnectionPoint;
  146431. /**
  146432. * Gets the fresnel output component
  146433. */
  146434. get fresnel(): NodeMaterialConnectionPoint;
  146435. autoConfigure(material: NodeMaterial): void;
  146436. protected _buildBlock(state: NodeMaterialBuildState): this;
  146437. }
  146438. }
  146439. declare module BABYLON {
  146440. /**
  146441. * Block used to get the max of 2 values
  146442. */
  146443. export class MaxBlock extends NodeMaterialBlock {
  146444. /**
  146445. * Creates a new MaxBlock
  146446. * @param name defines the block name
  146447. */
  146448. constructor(name: string);
  146449. /**
  146450. * Gets the current class name
  146451. * @returns the class name
  146452. */
  146453. getClassName(): string;
  146454. /**
  146455. * Gets the left operand input component
  146456. */
  146457. get left(): NodeMaterialConnectionPoint;
  146458. /**
  146459. * Gets the right operand input component
  146460. */
  146461. get right(): NodeMaterialConnectionPoint;
  146462. /**
  146463. * Gets the output component
  146464. */
  146465. get output(): NodeMaterialConnectionPoint;
  146466. protected _buildBlock(state: NodeMaterialBuildState): this;
  146467. }
  146468. }
  146469. declare module BABYLON {
  146470. /**
  146471. * Block used to get the min of 2 values
  146472. */
  146473. export class MinBlock extends NodeMaterialBlock {
  146474. /**
  146475. * Creates a new MinBlock
  146476. * @param name defines the block name
  146477. */
  146478. constructor(name: string);
  146479. /**
  146480. * Gets the current class name
  146481. * @returns the class name
  146482. */
  146483. getClassName(): string;
  146484. /**
  146485. * Gets the left operand input component
  146486. */
  146487. get left(): NodeMaterialConnectionPoint;
  146488. /**
  146489. * Gets the right operand input component
  146490. */
  146491. get right(): NodeMaterialConnectionPoint;
  146492. /**
  146493. * Gets the output component
  146494. */
  146495. get output(): NodeMaterialConnectionPoint;
  146496. protected _buildBlock(state: NodeMaterialBuildState): this;
  146497. }
  146498. }
  146499. declare module BABYLON {
  146500. /**
  146501. * Block used to get the distance between 2 values
  146502. */
  146503. export class DistanceBlock extends NodeMaterialBlock {
  146504. /**
  146505. * Creates a new DistanceBlock
  146506. * @param name defines the block name
  146507. */
  146508. constructor(name: string);
  146509. /**
  146510. * Gets the current class name
  146511. * @returns the class name
  146512. */
  146513. getClassName(): string;
  146514. /**
  146515. * Gets the left operand input component
  146516. */
  146517. get left(): NodeMaterialConnectionPoint;
  146518. /**
  146519. * Gets the right operand input component
  146520. */
  146521. get right(): NodeMaterialConnectionPoint;
  146522. /**
  146523. * Gets the output component
  146524. */
  146525. get output(): NodeMaterialConnectionPoint;
  146526. protected _buildBlock(state: NodeMaterialBuildState): this;
  146527. }
  146528. }
  146529. declare module BABYLON {
  146530. /**
  146531. * Block used to get the length of a vector
  146532. */
  146533. export class LengthBlock extends NodeMaterialBlock {
  146534. /**
  146535. * Creates a new LengthBlock
  146536. * @param name defines the block name
  146537. */
  146538. constructor(name: string);
  146539. /**
  146540. * Gets the current class name
  146541. * @returns the class name
  146542. */
  146543. getClassName(): string;
  146544. /**
  146545. * Gets the value input component
  146546. */
  146547. get value(): NodeMaterialConnectionPoint;
  146548. /**
  146549. * Gets the output component
  146550. */
  146551. get output(): NodeMaterialConnectionPoint;
  146552. protected _buildBlock(state: NodeMaterialBuildState): this;
  146553. }
  146554. }
  146555. declare module BABYLON {
  146556. /**
  146557. * Block used to get negative version of a value (i.e. x * -1)
  146558. */
  146559. export class NegateBlock extends NodeMaterialBlock {
  146560. /**
  146561. * Creates a new NegateBlock
  146562. * @param name defines the block name
  146563. */
  146564. constructor(name: string);
  146565. /**
  146566. * Gets the current class name
  146567. * @returns the class name
  146568. */
  146569. getClassName(): string;
  146570. /**
  146571. * Gets the value input component
  146572. */
  146573. get value(): NodeMaterialConnectionPoint;
  146574. /**
  146575. * Gets the output component
  146576. */
  146577. get output(): NodeMaterialConnectionPoint;
  146578. protected _buildBlock(state: NodeMaterialBuildState): this;
  146579. }
  146580. }
  146581. declare module BABYLON {
  146582. /**
  146583. * Block used to get the value of the first parameter raised to the power of the second
  146584. */
  146585. export class PowBlock extends NodeMaterialBlock {
  146586. /**
  146587. * Creates a new PowBlock
  146588. * @param name defines the block name
  146589. */
  146590. constructor(name: string);
  146591. /**
  146592. * Gets the current class name
  146593. * @returns the class name
  146594. */
  146595. getClassName(): string;
  146596. /**
  146597. * Gets the value operand input component
  146598. */
  146599. get value(): NodeMaterialConnectionPoint;
  146600. /**
  146601. * Gets the power operand input component
  146602. */
  146603. get power(): NodeMaterialConnectionPoint;
  146604. /**
  146605. * Gets the output component
  146606. */
  146607. get output(): NodeMaterialConnectionPoint;
  146608. protected _buildBlock(state: NodeMaterialBuildState): this;
  146609. }
  146610. }
  146611. declare module BABYLON {
  146612. /**
  146613. * Block used to get a random number
  146614. */
  146615. export class RandomNumberBlock extends NodeMaterialBlock {
  146616. /**
  146617. * Creates a new RandomNumberBlock
  146618. * @param name defines the block name
  146619. */
  146620. constructor(name: string);
  146621. /**
  146622. * Gets the current class name
  146623. * @returns the class name
  146624. */
  146625. getClassName(): string;
  146626. /**
  146627. * Gets the seed input component
  146628. */
  146629. get seed(): NodeMaterialConnectionPoint;
  146630. /**
  146631. * Gets the output component
  146632. */
  146633. get output(): NodeMaterialConnectionPoint;
  146634. protected _buildBlock(state: NodeMaterialBuildState): this;
  146635. }
  146636. }
  146637. declare module BABYLON {
  146638. /**
  146639. * Block used to compute arc tangent of 2 values
  146640. */
  146641. export class ArcTan2Block extends NodeMaterialBlock {
  146642. /**
  146643. * Creates a new ArcTan2Block
  146644. * @param name defines the block name
  146645. */
  146646. constructor(name: string);
  146647. /**
  146648. * Gets the current class name
  146649. * @returns the class name
  146650. */
  146651. getClassName(): string;
  146652. /**
  146653. * Gets the x operand input component
  146654. */
  146655. get x(): NodeMaterialConnectionPoint;
  146656. /**
  146657. * Gets the y operand input component
  146658. */
  146659. get y(): NodeMaterialConnectionPoint;
  146660. /**
  146661. * Gets the output component
  146662. */
  146663. get output(): NodeMaterialConnectionPoint;
  146664. protected _buildBlock(state: NodeMaterialBuildState): this;
  146665. }
  146666. }
  146667. declare module BABYLON {
  146668. /**
  146669. * Block used to smooth step a value
  146670. */
  146671. export class SmoothStepBlock extends NodeMaterialBlock {
  146672. /**
  146673. * Creates a new SmoothStepBlock
  146674. * @param name defines the block name
  146675. */
  146676. constructor(name: string);
  146677. /**
  146678. * Gets the current class name
  146679. * @returns the class name
  146680. */
  146681. getClassName(): string;
  146682. /**
  146683. * Gets the value operand input component
  146684. */
  146685. get value(): NodeMaterialConnectionPoint;
  146686. /**
  146687. * Gets the first edge operand input component
  146688. */
  146689. get edge0(): NodeMaterialConnectionPoint;
  146690. /**
  146691. * Gets the second edge operand input component
  146692. */
  146693. get edge1(): NodeMaterialConnectionPoint;
  146694. /**
  146695. * Gets the output component
  146696. */
  146697. get output(): NodeMaterialConnectionPoint;
  146698. protected _buildBlock(state: NodeMaterialBuildState): this;
  146699. }
  146700. }
  146701. declare module BABYLON {
  146702. /**
  146703. * Block used to get the reciprocal (1 / x) of a value
  146704. */
  146705. export class ReciprocalBlock extends NodeMaterialBlock {
  146706. /**
  146707. * Creates a new ReciprocalBlock
  146708. * @param name defines the block name
  146709. */
  146710. constructor(name: string);
  146711. /**
  146712. * Gets the current class name
  146713. * @returns the class name
  146714. */
  146715. getClassName(): string;
  146716. /**
  146717. * Gets the input component
  146718. */
  146719. get input(): NodeMaterialConnectionPoint;
  146720. /**
  146721. * Gets the output component
  146722. */
  146723. get output(): NodeMaterialConnectionPoint;
  146724. protected _buildBlock(state: NodeMaterialBuildState): this;
  146725. }
  146726. }
  146727. declare module BABYLON {
  146728. /**
  146729. * Block used to replace a color by another one
  146730. */
  146731. export class ReplaceColorBlock extends NodeMaterialBlock {
  146732. /**
  146733. * Creates a new ReplaceColorBlock
  146734. * @param name defines the block name
  146735. */
  146736. constructor(name: string);
  146737. /**
  146738. * Gets the current class name
  146739. * @returns the class name
  146740. */
  146741. getClassName(): string;
  146742. /**
  146743. * Gets the value input component
  146744. */
  146745. get value(): NodeMaterialConnectionPoint;
  146746. /**
  146747. * Gets the reference input component
  146748. */
  146749. get reference(): NodeMaterialConnectionPoint;
  146750. /**
  146751. * Gets the distance input component
  146752. */
  146753. get distance(): NodeMaterialConnectionPoint;
  146754. /**
  146755. * Gets the replacement input component
  146756. */
  146757. get replacement(): NodeMaterialConnectionPoint;
  146758. /**
  146759. * Gets the output component
  146760. */
  146761. get output(): NodeMaterialConnectionPoint;
  146762. protected _buildBlock(state: NodeMaterialBuildState): this;
  146763. }
  146764. }
  146765. declare module BABYLON {
  146766. /**
  146767. * Block used to posterize a value
  146768. * @see https://en.wikipedia.org/wiki/Posterization
  146769. */
  146770. export class PosterizeBlock extends NodeMaterialBlock {
  146771. /**
  146772. * Creates a new PosterizeBlock
  146773. * @param name defines the block name
  146774. */
  146775. constructor(name: string);
  146776. /**
  146777. * Gets the current class name
  146778. * @returns the class name
  146779. */
  146780. getClassName(): string;
  146781. /**
  146782. * Gets the value input component
  146783. */
  146784. get value(): NodeMaterialConnectionPoint;
  146785. /**
  146786. * Gets the steps input component
  146787. */
  146788. get steps(): NodeMaterialConnectionPoint;
  146789. /**
  146790. * Gets the output component
  146791. */
  146792. get output(): NodeMaterialConnectionPoint;
  146793. protected _buildBlock(state: NodeMaterialBuildState): this;
  146794. }
  146795. }
  146796. declare module BABYLON {
  146797. /**
  146798. * Operations supported by the Wave block
  146799. */
  146800. export enum WaveBlockKind {
  146801. /** SawTooth */
  146802. SawTooth = 0,
  146803. /** Square */
  146804. Square = 1,
  146805. /** Triangle */
  146806. Triangle = 2
  146807. }
  146808. /**
  146809. * Block used to apply wave operation to floats
  146810. */
  146811. export class WaveBlock extends NodeMaterialBlock {
  146812. /**
  146813. * Gets or sets the kibnd of wave to be applied by the block
  146814. */
  146815. kind: WaveBlockKind;
  146816. /**
  146817. * Creates a new WaveBlock
  146818. * @param name defines the block name
  146819. */
  146820. constructor(name: string);
  146821. /**
  146822. * Gets the current class name
  146823. * @returns the class name
  146824. */
  146825. getClassName(): string;
  146826. /**
  146827. * Gets the input component
  146828. */
  146829. get input(): NodeMaterialConnectionPoint;
  146830. /**
  146831. * Gets the output component
  146832. */
  146833. get output(): NodeMaterialConnectionPoint;
  146834. protected _buildBlock(state: NodeMaterialBuildState): this;
  146835. serialize(): any;
  146836. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146837. }
  146838. }
  146839. declare module BABYLON {
  146840. /**
  146841. * Class used to store a color step for the GradientBlock
  146842. */
  146843. export class GradientBlockColorStep {
  146844. private _step;
  146845. /**
  146846. * Gets value indicating which step this color is associated with (between 0 and 1)
  146847. */
  146848. get step(): number;
  146849. /**
  146850. * Sets a value indicating which step this color is associated with (between 0 and 1)
  146851. */
  146852. set step(val: number);
  146853. private _color;
  146854. /**
  146855. * Gets the color associated with this step
  146856. */
  146857. get color(): Color3;
  146858. /**
  146859. * Sets the color associated with this step
  146860. */
  146861. set color(val: Color3);
  146862. /**
  146863. * Creates a new GradientBlockColorStep
  146864. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  146865. * @param color defines the color associated with this step
  146866. */
  146867. constructor(step: number, color: Color3);
  146868. }
  146869. /**
  146870. * Block used to return a color from a gradient based on an input value between 0 and 1
  146871. */
  146872. export class GradientBlock extends NodeMaterialBlock {
  146873. /**
  146874. * Gets or sets the list of color steps
  146875. */
  146876. colorSteps: GradientBlockColorStep[];
  146877. /** Gets an observable raised when the value is changed */
  146878. onValueChangedObservable: Observable<GradientBlock>;
  146879. /** calls observable when the value is changed*/
  146880. colorStepsUpdated(): void;
  146881. /**
  146882. * Creates a new GradientBlock
  146883. * @param name defines the block name
  146884. */
  146885. constructor(name: string);
  146886. /**
  146887. * Gets the current class name
  146888. * @returns the class name
  146889. */
  146890. getClassName(): string;
  146891. /**
  146892. * Gets the gradient input component
  146893. */
  146894. get gradient(): NodeMaterialConnectionPoint;
  146895. /**
  146896. * Gets the output component
  146897. */
  146898. get output(): NodeMaterialConnectionPoint;
  146899. private _writeColorConstant;
  146900. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  146901. serialize(): any;
  146902. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146903. protected _dumpPropertiesCode(): string;
  146904. }
  146905. }
  146906. declare module BABYLON {
  146907. /**
  146908. * Block used to normalize lerp between 2 values
  146909. */
  146910. export class NLerpBlock extends NodeMaterialBlock {
  146911. /**
  146912. * Creates a new NLerpBlock
  146913. * @param name defines the block name
  146914. */
  146915. constructor(name: string);
  146916. /**
  146917. * Gets the current class name
  146918. * @returns the class name
  146919. */
  146920. getClassName(): string;
  146921. /**
  146922. * Gets the left operand input component
  146923. */
  146924. get left(): NodeMaterialConnectionPoint;
  146925. /**
  146926. * Gets the right operand input component
  146927. */
  146928. get right(): NodeMaterialConnectionPoint;
  146929. /**
  146930. * Gets the gradient operand input component
  146931. */
  146932. get gradient(): NodeMaterialConnectionPoint;
  146933. /**
  146934. * Gets the output component
  146935. */
  146936. get output(): NodeMaterialConnectionPoint;
  146937. protected _buildBlock(state: NodeMaterialBuildState): this;
  146938. }
  146939. }
  146940. declare module BABYLON {
  146941. /**
  146942. * block used to Generate a Worley Noise 3D Noise Pattern
  146943. */
  146944. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  146945. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  146946. manhattanDistance: boolean;
  146947. /**
  146948. * Creates a new WorleyNoise3DBlock
  146949. * @param name defines the block name
  146950. */
  146951. constructor(name: string);
  146952. /**
  146953. * Gets the current class name
  146954. * @returns the class name
  146955. */
  146956. getClassName(): string;
  146957. /**
  146958. * Gets the seed input component
  146959. */
  146960. get seed(): NodeMaterialConnectionPoint;
  146961. /**
  146962. * Gets the jitter input component
  146963. */
  146964. get jitter(): NodeMaterialConnectionPoint;
  146965. /**
  146966. * Gets the output component
  146967. */
  146968. get output(): NodeMaterialConnectionPoint;
  146969. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  146970. /**
  146971. * Exposes the properties to the UI?
  146972. */
  146973. protected _dumpPropertiesCode(): string;
  146974. /**
  146975. * Exposes the properties to the Seralize?
  146976. */
  146977. serialize(): any;
  146978. /**
  146979. * Exposes the properties to the deseralize?
  146980. */
  146981. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146982. }
  146983. }
  146984. declare module BABYLON {
  146985. /**
  146986. * block used to Generate a Simplex Perlin 3d Noise Pattern
  146987. */
  146988. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  146989. /**
  146990. * Creates a new SimplexPerlin3DBlock
  146991. * @param name defines the block name
  146992. */
  146993. constructor(name: string);
  146994. /**
  146995. * Gets the current class name
  146996. * @returns the class name
  146997. */
  146998. getClassName(): string;
  146999. /**
  147000. * Gets the seed operand input component
  147001. */
  147002. get seed(): NodeMaterialConnectionPoint;
  147003. /**
  147004. * Gets the output component
  147005. */
  147006. get output(): NodeMaterialConnectionPoint;
  147007. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  147008. }
  147009. }
  147010. declare module BABYLON {
  147011. /**
  147012. * Block used to blend normals
  147013. */
  147014. export class NormalBlendBlock extends NodeMaterialBlock {
  147015. /**
  147016. * Creates a new NormalBlendBlock
  147017. * @param name defines the block name
  147018. */
  147019. constructor(name: string);
  147020. /**
  147021. * Gets the current class name
  147022. * @returns the class name
  147023. */
  147024. getClassName(): string;
  147025. /**
  147026. * Gets the first input component
  147027. */
  147028. get normalMap0(): NodeMaterialConnectionPoint;
  147029. /**
  147030. * Gets the second input component
  147031. */
  147032. get normalMap1(): NodeMaterialConnectionPoint;
  147033. /**
  147034. * Gets the output component
  147035. */
  147036. get output(): NodeMaterialConnectionPoint;
  147037. protected _buildBlock(state: NodeMaterialBuildState): this;
  147038. }
  147039. }
  147040. declare module BABYLON {
  147041. /**
  147042. * Block used to rotate a 2d vector by a given angle
  147043. */
  147044. export class Rotate2dBlock extends NodeMaterialBlock {
  147045. /**
  147046. * Creates a new Rotate2dBlock
  147047. * @param name defines the block name
  147048. */
  147049. constructor(name: string);
  147050. /**
  147051. * Gets the current class name
  147052. * @returns the class name
  147053. */
  147054. getClassName(): string;
  147055. /**
  147056. * Gets the input vector
  147057. */
  147058. get input(): NodeMaterialConnectionPoint;
  147059. /**
  147060. * Gets the input angle
  147061. */
  147062. get angle(): NodeMaterialConnectionPoint;
  147063. /**
  147064. * Gets the output component
  147065. */
  147066. get output(): NodeMaterialConnectionPoint;
  147067. autoConfigure(material: NodeMaterial): void;
  147068. protected _buildBlock(state: NodeMaterialBuildState): this;
  147069. }
  147070. }
  147071. declare module BABYLON {
  147072. /**
  147073. * Block used to get the reflected vector from a direction and a normal
  147074. */
  147075. export class ReflectBlock extends NodeMaterialBlock {
  147076. /**
  147077. * Creates a new ReflectBlock
  147078. * @param name defines the block name
  147079. */
  147080. constructor(name: string);
  147081. /**
  147082. * Gets the current class name
  147083. * @returns the class name
  147084. */
  147085. getClassName(): string;
  147086. /**
  147087. * Gets the incident component
  147088. */
  147089. get incident(): NodeMaterialConnectionPoint;
  147090. /**
  147091. * Gets the normal component
  147092. */
  147093. get normal(): NodeMaterialConnectionPoint;
  147094. /**
  147095. * Gets the output component
  147096. */
  147097. get output(): NodeMaterialConnectionPoint;
  147098. protected _buildBlock(state: NodeMaterialBuildState): this;
  147099. }
  147100. }
  147101. declare module BABYLON {
  147102. /**
  147103. * Block used to get the refracted vector from a direction and a normal
  147104. */
  147105. export class RefractBlock extends NodeMaterialBlock {
  147106. /**
  147107. * Creates a new RefractBlock
  147108. * @param name defines the block name
  147109. */
  147110. constructor(name: string);
  147111. /**
  147112. * Gets the current class name
  147113. * @returns the class name
  147114. */
  147115. getClassName(): string;
  147116. /**
  147117. * Gets the incident component
  147118. */
  147119. get incident(): NodeMaterialConnectionPoint;
  147120. /**
  147121. * Gets the normal component
  147122. */
  147123. get normal(): NodeMaterialConnectionPoint;
  147124. /**
  147125. * Gets the index of refraction component
  147126. */
  147127. get ior(): NodeMaterialConnectionPoint;
  147128. /**
  147129. * Gets the output component
  147130. */
  147131. get output(): NodeMaterialConnectionPoint;
  147132. protected _buildBlock(state: NodeMaterialBuildState): this;
  147133. }
  147134. }
  147135. declare module BABYLON {
  147136. /**
  147137. * Block used to desaturate a color
  147138. */
  147139. export class DesaturateBlock extends NodeMaterialBlock {
  147140. /**
  147141. * Creates a new DesaturateBlock
  147142. * @param name defines the block name
  147143. */
  147144. constructor(name: string);
  147145. /**
  147146. * Gets the current class name
  147147. * @returns the class name
  147148. */
  147149. getClassName(): string;
  147150. /**
  147151. * Gets the color operand input component
  147152. */
  147153. get color(): NodeMaterialConnectionPoint;
  147154. /**
  147155. * Gets the level operand input component
  147156. */
  147157. get level(): NodeMaterialConnectionPoint;
  147158. /**
  147159. * Gets the output component
  147160. */
  147161. get output(): NodeMaterialConnectionPoint;
  147162. protected _buildBlock(state: NodeMaterialBuildState): this;
  147163. }
  147164. }
  147165. declare module BABYLON {
  147166. /**
  147167. * Block used to implement the reflection module of the PBR material
  147168. */
  147169. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  147170. /** @hidden */
  147171. _defineLODReflectionAlpha: string;
  147172. /** @hidden */
  147173. _defineLinearSpecularReflection: string;
  147174. private _vEnvironmentIrradianceName;
  147175. /** @hidden */
  147176. _vReflectionMicrosurfaceInfosName: string;
  147177. /** @hidden */
  147178. _vReflectionInfosName: string;
  147179. /** @hidden */
  147180. _vReflectionFilteringInfoName: string;
  147181. private _scene;
  147182. /**
  147183. * The properties below are set by the main PBR block prior to calling methods of this class.
  147184. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  147185. * It's less burden on the user side in the editor part.
  147186. */
  147187. /** @hidden */
  147188. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  147189. /** @hidden */
  147190. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  147191. /** @hidden */
  147192. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  147193. /** @hidden */
  147194. viewConnectionPoint: NodeMaterialConnectionPoint;
  147195. /**
  147196. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  147197. * diffuse part of the IBL.
  147198. */
  147199. useSphericalHarmonics: boolean;
  147200. /**
  147201. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  147202. */
  147203. forceIrradianceInFragment: boolean;
  147204. /**
  147205. * Create a new ReflectionBlock
  147206. * @param name defines the block name
  147207. */
  147208. constructor(name: string);
  147209. /**
  147210. * Gets the current class name
  147211. * @returns the class name
  147212. */
  147213. getClassName(): string;
  147214. /**
  147215. * Gets the position input component
  147216. */
  147217. get position(): NodeMaterialConnectionPoint;
  147218. /**
  147219. * Gets the world position input component
  147220. */
  147221. get worldPosition(): NodeMaterialConnectionPoint;
  147222. /**
  147223. * Gets the world normal input component
  147224. */
  147225. get worldNormal(): NodeMaterialConnectionPoint;
  147226. /**
  147227. * Gets the world input component
  147228. */
  147229. get world(): NodeMaterialConnectionPoint;
  147230. /**
  147231. * Gets the camera (or eye) position component
  147232. */
  147233. get cameraPosition(): NodeMaterialConnectionPoint;
  147234. /**
  147235. * Gets the view input component
  147236. */
  147237. get view(): NodeMaterialConnectionPoint;
  147238. /**
  147239. * Gets the color input component
  147240. */
  147241. get color(): NodeMaterialConnectionPoint;
  147242. /**
  147243. * Gets the reflection object output component
  147244. */
  147245. get reflection(): NodeMaterialConnectionPoint;
  147246. /**
  147247. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  147248. */
  147249. get hasTexture(): boolean;
  147250. /**
  147251. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  147252. */
  147253. get reflectionColor(): string;
  147254. protected _getTexture(): Nullable<BaseTexture>;
  147255. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147256. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  147257. /**
  147258. * Gets the code to inject in the vertex shader
  147259. * @param state current state of the node material building
  147260. * @returns the shader code
  147261. */
  147262. handleVertexSide(state: NodeMaterialBuildState): string;
  147263. /**
  147264. * Gets the main code of the block (fragment side)
  147265. * @param state current state of the node material building
  147266. * @param normalVarName name of the existing variable corresponding to the normal
  147267. * @returns the shader code
  147268. */
  147269. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  147270. protected _buildBlock(state: NodeMaterialBuildState): this;
  147271. protected _dumpPropertiesCode(): string;
  147272. serialize(): any;
  147273. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147274. }
  147275. }
  147276. declare module BABYLON {
  147277. /**
  147278. * Block used to implement the sheen module of the PBR material
  147279. */
  147280. export class SheenBlock extends NodeMaterialBlock {
  147281. /**
  147282. * Create a new SheenBlock
  147283. * @param name defines the block name
  147284. */
  147285. constructor(name: string);
  147286. /**
  147287. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  147288. * It allows the strength of the sheen effect to not depend on the base color of the material,
  147289. * making it easier to setup and tweak the effect
  147290. */
  147291. albedoScaling: boolean;
  147292. /**
  147293. * Defines if the sheen is linked to the sheen color.
  147294. */
  147295. linkSheenWithAlbedo: boolean;
  147296. /**
  147297. * Initialize the block and prepare the context for build
  147298. * @param state defines the state that will be used for the build
  147299. */
  147300. initialize(state: NodeMaterialBuildState): void;
  147301. /**
  147302. * Gets the current class name
  147303. * @returns the class name
  147304. */
  147305. getClassName(): string;
  147306. /**
  147307. * Gets the intensity input component
  147308. */
  147309. get intensity(): NodeMaterialConnectionPoint;
  147310. /**
  147311. * Gets the color input component
  147312. */
  147313. get color(): NodeMaterialConnectionPoint;
  147314. /**
  147315. * Gets the roughness input component
  147316. */
  147317. get roughness(): NodeMaterialConnectionPoint;
  147318. /**
  147319. * Gets the sheen object output component
  147320. */
  147321. get sheen(): NodeMaterialConnectionPoint;
  147322. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147323. /**
  147324. * Gets the main code of the block (fragment side)
  147325. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  147326. * @returns the shader code
  147327. */
  147328. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  147329. protected _buildBlock(state: NodeMaterialBuildState): this;
  147330. protected _dumpPropertiesCode(): string;
  147331. serialize(): any;
  147332. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147333. }
  147334. }
  147335. declare module BABYLON {
  147336. /**
  147337. * Block used to implement the anisotropy module of the PBR material
  147338. */
  147339. export class AnisotropyBlock extends NodeMaterialBlock {
  147340. /**
  147341. * The two properties below are set by the main PBR block prior to calling methods of this class.
  147342. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  147343. * It's less burden on the user side in the editor part.
  147344. */
  147345. /** @hidden */
  147346. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  147347. /** @hidden */
  147348. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  147349. /**
  147350. * Create a new AnisotropyBlock
  147351. * @param name defines the block name
  147352. */
  147353. constructor(name: string);
  147354. /**
  147355. * Initialize the block and prepare the context for build
  147356. * @param state defines the state that will be used for the build
  147357. */
  147358. initialize(state: NodeMaterialBuildState): void;
  147359. /**
  147360. * Gets the current class name
  147361. * @returns the class name
  147362. */
  147363. getClassName(): string;
  147364. /**
  147365. * Gets the intensity input component
  147366. */
  147367. get intensity(): NodeMaterialConnectionPoint;
  147368. /**
  147369. * Gets the direction input component
  147370. */
  147371. get direction(): NodeMaterialConnectionPoint;
  147372. /**
  147373. * Gets the uv input component
  147374. */
  147375. get uv(): NodeMaterialConnectionPoint;
  147376. /**
  147377. * Gets the worldTangent input component
  147378. */
  147379. get worldTangent(): NodeMaterialConnectionPoint;
  147380. /**
  147381. * Gets the anisotropy object output component
  147382. */
  147383. get anisotropy(): NodeMaterialConnectionPoint;
  147384. private _generateTBNSpace;
  147385. /**
  147386. * Gets the main code of the block (fragment side)
  147387. * @param state current state of the node material building
  147388. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  147389. * @returns the shader code
  147390. */
  147391. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  147392. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147393. protected _buildBlock(state: NodeMaterialBuildState): this;
  147394. }
  147395. }
  147396. declare module BABYLON {
  147397. /**
  147398. * Block used to implement the clear coat module of the PBR material
  147399. */
  147400. export class ClearCoatBlock extends NodeMaterialBlock {
  147401. private _scene;
  147402. /**
  147403. * Create a new ClearCoatBlock
  147404. * @param name defines the block name
  147405. */
  147406. constructor(name: string);
  147407. /**
  147408. * Defines if the F0 value should be remapped to account for the interface change in the material.
  147409. */
  147410. remapF0OnInterfaceChange: boolean;
  147411. /**
  147412. * Initialize the block and prepare the context for build
  147413. * @param state defines the state that will be used for the build
  147414. */
  147415. initialize(state: NodeMaterialBuildState): void;
  147416. /**
  147417. * Gets the current class name
  147418. * @returns the class name
  147419. */
  147420. getClassName(): string;
  147421. /**
  147422. * Gets the intensity input component
  147423. */
  147424. get intensity(): NodeMaterialConnectionPoint;
  147425. /**
  147426. * Gets the roughness input component
  147427. */
  147428. get roughness(): NodeMaterialConnectionPoint;
  147429. /**
  147430. * Gets the ior input component
  147431. */
  147432. get indexOfRefraction(): NodeMaterialConnectionPoint;
  147433. /**
  147434. * Gets the bump texture input component
  147435. */
  147436. get normalMapColor(): NodeMaterialConnectionPoint;
  147437. /**
  147438. * Gets the uv input component
  147439. */
  147440. get uv(): NodeMaterialConnectionPoint;
  147441. /**
  147442. * Gets the tint color input component
  147443. */
  147444. get tintColor(): NodeMaterialConnectionPoint;
  147445. /**
  147446. * Gets the tint "at distance" input component
  147447. */
  147448. get tintAtDistance(): NodeMaterialConnectionPoint;
  147449. /**
  147450. * Gets the tint thickness input component
  147451. */
  147452. get tintThickness(): NodeMaterialConnectionPoint;
  147453. /**
  147454. * Gets the world tangent input component
  147455. */
  147456. get worldTangent(): NodeMaterialConnectionPoint;
  147457. /**
  147458. * Gets the clear coat object output component
  147459. */
  147460. get clearcoat(): NodeMaterialConnectionPoint;
  147461. autoConfigure(material: NodeMaterial): void;
  147462. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147463. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  147464. private _generateTBNSpace;
  147465. /**
  147466. * Gets the main code of the block (fragment side)
  147467. * @param state current state of the node material building
  147468. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  147469. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  147470. * @param worldPosVarName name of the variable holding the world position
  147471. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  147472. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  147473. * @param worldNormalVarName name of the variable holding the world normal
  147474. * @returns the shader code
  147475. */
  147476. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  147477. protected _buildBlock(state: NodeMaterialBuildState): this;
  147478. protected _dumpPropertiesCode(): string;
  147479. serialize(): any;
  147480. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147481. }
  147482. }
  147483. declare module BABYLON {
  147484. /**
  147485. * Block used to implement the sub surface module of the PBR material
  147486. */
  147487. export class SubSurfaceBlock extends NodeMaterialBlock {
  147488. /**
  147489. * Create a new SubSurfaceBlock
  147490. * @param name defines the block name
  147491. */
  147492. constructor(name: string);
  147493. /**
  147494. * Initialize the block and prepare the context for build
  147495. * @param state defines the state that will be used for the build
  147496. */
  147497. initialize(state: NodeMaterialBuildState): void;
  147498. /**
  147499. * Gets the current class name
  147500. * @returns the class name
  147501. */
  147502. getClassName(): string;
  147503. /**
  147504. * Gets the thickness component
  147505. */
  147506. get thickness(): NodeMaterialConnectionPoint;
  147507. /**
  147508. * Gets the tint color input component
  147509. */
  147510. get tintColor(): NodeMaterialConnectionPoint;
  147511. /**
  147512. * Gets the translucency intensity input component
  147513. */
  147514. get translucencyIntensity(): NodeMaterialConnectionPoint;
  147515. /**
  147516. * Gets the translucency diffusion distance input component
  147517. */
  147518. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  147519. /**
  147520. * Gets the refraction object parameters
  147521. */
  147522. get refraction(): NodeMaterialConnectionPoint;
  147523. /**
  147524. * Gets the sub surface object output component
  147525. */
  147526. get subsurface(): NodeMaterialConnectionPoint;
  147527. autoConfigure(material: NodeMaterial): void;
  147528. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147529. /**
  147530. * Gets the main code of the block (fragment side)
  147531. * @param state current state of the node material building
  147532. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  147533. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  147534. * @param worldPosVarName name of the variable holding the world position
  147535. * @returns the shader code
  147536. */
  147537. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  147538. protected _buildBlock(state: NodeMaterialBuildState): this;
  147539. }
  147540. }
  147541. declare module BABYLON {
  147542. /**
  147543. * Block used to implement the PBR metallic/roughness model
  147544. */
  147545. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  147546. /**
  147547. * Gets or sets the light associated with this block
  147548. */
  147549. light: Nullable<Light>;
  147550. private _lightId;
  147551. private _scene;
  147552. private _environmentBRDFTexture;
  147553. private _environmentBrdfSamplerName;
  147554. private _vNormalWName;
  147555. private _invertNormalName;
  147556. private _metallicReflectanceColor;
  147557. private _metallicF0Factor;
  147558. private _vMetallicReflectanceFactorsName;
  147559. /**
  147560. * Create a new ReflectionBlock
  147561. * @param name defines the block name
  147562. */
  147563. constructor(name: string);
  147564. /**
  147565. * Intensity of the direct lights e.g. the four lights available in your scene.
  147566. * This impacts both the direct diffuse and specular highlights.
  147567. */
  147568. directIntensity: number;
  147569. /**
  147570. * Intensity of the environment e.g. how much the environment will light the object
  147571. * either through harmonics for rough material or through the refelction for shiny ones.
  147572. */
  147573. environmentIntensity: number;
  147574. /**
  147575. * This is a special control allowing the reduction of the specular highlights coming from the
  147576. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  147577. */
  147578. specularIntensity: number;
  147579. /**
  147580. * Defines the falloff type used in this material.
  147581. * It by default is Physical.
  147582. */
  147583. lightFalloff: number;
  147584. /**
  147585. * Specifies that alpha test should be used
  147586. */
  147587. useAlphaTest: boolean;
  147588. /**
  147589. * Defines the alpha limits in alpha test mode.
  147590. */
  147591. alphaTestCutoff: number;
  147592. /**
  147593. * Specifies that alpha blending should be used
  147594. */
  147595. useAlphaBlending: boolean;
  147596. /**
  147597. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  147598. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  147599. */
  147600. useRadianceOverAlpha: boolean;
  147601. /**
  147602. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  147603. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  147604. */
  147605. useSpecularOverAlpha: boolean;
  147606. /**
  147607. * Enables specular anti aliasing in the PBR shader.
  147608. * It will both interacts on the Geometry for analytical and IBL lighting.
  147609. * It also prefilter the roughness map based on the bump values.
  147610. */
  147611. enableSpecularAntiAliasing: boolean;
  147612. /**
  147613. * Enables realtime filtering on the texture.
  147614. */
  147615. realTimeFiltering: boolean;
  147616. /**
  147617. * Quality switch for realtime filtering
  147618. */
  147619. realTimeFilteringQuality: number;
  147620. /**
  147621. * Defines if the material uses energy conservation.
  147622. */
  147623. useEnergyConservation: boolean;
  147624. /**
  147625. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  147626. * too much the area relying on ambient texture to define their ambient occlusion.
  147627. */
  147628. useRadianceOcclusion: boolean;
  147629. /**
  147630. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  147631. * makes the reflect vector face the model (under horizon).
  147632. */
  147633. useHorizonOcclusion: boolean;
  147634. /**
  147635. * If set to true, no lighting calculations will be applied.
  147636. */
  147637. unlit: boolean;
  147638. /**
  147639. * Force normal to face away from face.
  147640. */
  147641. forceNormalForward: boolean;
  147642. /**
  147643. * Defines the material debug mode.
  147644. * It helps seeing only some components of the material while troubleshooting.
  147645. */
  147646. debugMode: number;
  147647. /**
  147648. * Specify from where on screen the debug mode should start.
  147649. * The value goes from -1 (full screen) to 1 (not visible)
  147650. * It helps with side by side comparison against the final render
  147651. * This defaults to 0
  147652. */
  147653. debugLimit: number;
  147654. /**
  147655. * As the default viewing range might not be enough (if the ambient is really small for instance)
  147656. * You can use the factor to better multiply the final value.
  147657. */
  147658. debugFactor: number;
  147659. /**
  147660. * Initialize the block and prepare the context for build
  147661. * @param state defines the state that will be used for the build
  147662. */
  147663. initialize(state: NodeMaterialBuildState): void;
  147664. /**
  147665. * Gets the current class name
  147666. * @returns the class name
  147667. */
  147668. getClassName(): string;
  147669. /**
  147670. * Gets the world position input component
  147671. */
  147672. get worldPosition(): NodeMaterialConnectionPoint;
  147673. /**
  147674. * Gets the world normal input component
  147675. */
  147676. get worldNormal(): NodeMaterialConnectionPoint;
  147677. /**
  147678. * Gets the view matrix parameter
  147679. */
  147680. get view(): NodeMaterialConnectionPoint;
  147681. /**
  147682. * Gets the camera position input component
  147683. */
  147684. get cameraPosition(): NodeMaterialConnectionPoint;
  147685. /**
  147686. * Gets the perturbed normal input component
  147687. */
  147688. get perturbedNormal(): NodeMaterialConnectionPoint;
  147689. /**
  147690. * Gets the base color input component
  147691. */
  147692. get baseColor(): NodeMaterialConnectionPoint;
  147693. /**
  147694. * Gets the metallic input component
  147695. */
  147696. get metallic(): NodeMaterialConnectionPoint;
  147697. /**
  147698. * Gets the roughness input component
  147699. */
  147700. get roughness(): NodeMaterialConnectionPoint;
  147701. /**
  147702. * Gets the ambient occlusion input component
  147703. */
  147704. get ambientOcc(): NodeMaterialConnectionPoint;
  147705. /**
  147706. * Gets the opacity input component
  147707. */
  147708. get opacity(): NodeMaterialConnectionPoint;
  147709. /**
  147710. * Gets the index of refraction input component
  147711. */
  147712. get indexOfRefraction(): NodeMaterialConnectionPoint;
  147713. /**
  147714. * Gets the ambient color input component
  147715. */
  147716. get ambientColor(): NodeMaterialConnectionPoint;
  147717. /**
  147718. * Gets the reflection object parameters
  147719. */
  147720. get reflection(): NodeMaterialConnectionPoint;
  147721. /**
  147722. * Gets the clear coat object parameters
  147723. */
  147724. get clearcoat(): NodeMaterialConnectionPoint;
  147725. /**
  147726. * Gets the sheen object parameters
  147727. */
  147728. get sheen(): NodeMaterialConnectionPoint;
  147729. /**
  147730. * Gets the sub surface object parameters
  147731. */
  147732. get subsurface(): NodeMaterialConnectionPoint;
  147733. /**
  147734. * Gets the anisotropy object parameters
  147735. */
  147736. get anisotropy(): NodeMaterialConnectionPoint;
  147737. /**
  147738. * Gets the ambient output component
  147739. */
  147740. get ambientClr(): NodeMaterialConnectionPoint;
  147741. /**
  147742. * Gets the diffuse output component
  147743. */
  147744. get diffuseDir(): NodeMaterialConnectionPoint;
  147745. /**
  147746. * Gets the specular output component
  147747. */
  147748. get specularDir(): NodeMaterialConnectionPoint;
  147749. /**
  147750. * Gets the clear coat output component
  147751. */
  147752. get clearcoatDir(): NodeMaterialConnectionPoint;
  147753. /**
  147754. * Gets the sheen output component
  147755. */
  147756. get sheenDir(): NodeMaterialConnectionPoint;
  147757. /**
  147758. * Gets the indirect diffuse output component
  147759. */
  147760. get diffuseIndirect(): NodeMaterialConnectionPoint;
  147761. /**
  147762. * Gets the indirect specular output component
  147763. */
  147764. get specularIndirect(): NodeMaterialConnectionPoint;
  147765. /**
  147766. * Gets the indirect clear coat output component
  147767. */
  147768. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  147769. /**
  147770. * Gets the indirect sheen output component
  147771. */
  147772. get sheenIndirect(): NodeMaterialConnectionPoint;
  147773. /**
  147774. * Gets the refraction output component
  147775. */
  147776. get refraction(): NodeMaterialConnectionPoint;
  147777. /**
  147778. * Gets the global lighting output component
  147779. */
  147780. get lighting(): NodeMaterialConnectionPoint;
  147781. /**
  147782. * Gets the shadow output component
  147783. */
  147784. get shadow(): NodeMaterialConnectionPoint;
  147785. /**
  147786. * Gets the alpha output component
  147787. */
  147788. get alpha(): NodeMaterialConnectionPoint;
  147789. autoConfigure(material: NodeMaterial): void;
  147790. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147791. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  147792. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  147793. private _injectVertexCode;
  147794. private _getAlbedoOpacityCode;
  147795. private _getAmbientOcclusionCode;
  147796. private _getReflectivityCode;
  147797. protected _buildBlock(state: NodeMaterialBuildState): this;
  147798. protected _dumpPropertiesCode(): string;
  147799. serialize(): any;
  147800. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147801. }
  147802. }
  147803. declare module BABYLON {
  147804. /**
  147805. * Block used to compute value of one parameter modulo another
  147806. */
  147807. export class ModBlock extends NodeMaterialBlock {
  147808. /**
  147809. * Creates a new ModBlock
  147810. * @param name defines the block name
  147811. */
  147812. constructor(name: string);
  147813. /**
  147814. * Gets the current class name
  147815. * @returns the class name
  147816. */
  147817. getClassName(): string;
  147818. /**
  147819. * Gets the left operand input component
  147820. */
  147821. get left(): NodeMaterialConnectionPoint;
  147822. /**
  147823. * Gets the right operand input component
  147824. */
  147825. get right(): NodeMaterialConnectionPoint;
  147826. /**
  147827. * Gets the output component
  147828. */
  147829. get output(): NodeMaterialConnectionPoint;
  147830. protected _buildBlock(state: NodeMaterialBuildState): this;
  147831. }
  147832. }
  147833. declare module BABYLON {
  147834. /**
  147835. * Configuration for Draco compression
  147836. */
  147837. export interface IDracoCompressionConfiguration {
  147838. /**
  147839. * Configuration for the decoder.
  147840. */
  147841. decoder: {
  147842. /**
  147843. * The url to the WebAssembly module.
  147844. */
  147845. wasmUrl?: string;
  147846. /**
  147847. * The url to the WebAssembly binary.
  147848. */
  147849. wasmBinaryUrl?: string;
  147850. /**
  147851. * The url to the fallback JavaScript module.
  147852. */
  147853. fallbackUrl?: string;
  147854. };
  147855. }
  147856. /**
  147857. * Draco compression (https://google.github.io/draco/)
  147858. *
  147859. * This class wraps the Draco module.
  147860. *
  147861. * **Encoder**
  147862. *
  147863. * The encoder is not currently implemented.
  147864. *
  147865. * **Decoder**
  147866. *
  147867. * 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.
  147868. *
  147869. * To update the configuration, use the following code:
  147870. * ```javascript
  147871. * DracoCompression.Configuration = {
  147872. * decoder: {
  147873. * wasmUrl: "<url to the WebAssembly library>",
  147874. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  147875. * fallbackUrl: "<url to the fallback JavaScript library>",
  147876. * }
  147877. * };
  147878. * ```
  147879. *
  147880. * 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.
  147881. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  147882. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  147883. *
  147884. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  147885. * ```javascript
  147886. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  147887. * ```
  147888. *
  147889. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  147890. */
  147891. export class DracoCompression implements IDisposable {
  147892. private _workerPoolPromise?;
  147893. private _decoderModulePromise?;
  147894. /**
  147895. * The configuration. Defaults to the following urls:
  147896. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  147897. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  147898. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  147899. */
  147900. static Configuration: IDracoCompressionConfiguration;
  147901. /**
  147902. * Returns true if the decoder configuration is available.
  147903. */
  147904. static get DecoderAvailable(): boolean;
  147905. /**
  147906. * Default number of workers to create when creating the draco compression object.
  147907. */
  147908. static DefaultNumWorkers: number;
  147909. private static GetDefaultNumWorkers;
  147910. private static _Default;
  147911. /**
  147912. * Default instance for the draco compression object.
  147913. */
  147914. static get Default(): DracoCompression;
  147915. /**
  147916. * Constructor
  147917. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  147918. */
  147919. constructor(numWorkers?: number);
  147920. /**
  147921. * Stop all async operations and release resources.
  147922. */
  147923. dispose(): void;
  147924. /**
  147925. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  147926. * @returns a promise that resolves when ready
  147927. */
  147928. whenReadyAsync(): Promise<void>;
  147929. /**
  147930. * Decode Draco compressed mesh data to vertex data.
  147931. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  147932. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  147933. * @returns A promise that resolves with the decoded vertex data
  147934. */
  147935. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  147936. [kind: string]: number;
  147937. }): Promise<VertexData>;
  147938. }
  147939. }
  147940. declare module BABYLON {
  147941. /**
  147942. * Class for building Constructive Solid Geometry
  147943. */
  147944. export class CSG {
  147945. private polygons;
  147946. /**
  147947. * The world matrix
  147948. */
  147949. matrix: Matrix;
  147950. /**
  147951. * Stores the position
  147952. */
  147953. position: Vector3;
  147954. /**
  147955. * Stores the rotation
  147956. */
  147957. rotation: Vector3;
  147958. /**
  147959. * Stores the rotation quaternion
  147960. */
  147961. rotationQuaternion: Nullable<Quaternion>;
  147962. /**
  147963. * Stores the scaling vector
  147964. */
  147965. scaling: Vector3;
  147966. /**
  147967. * Convert the Mesh to CSG
  147968. * @param mesh The Mesh to convert to CSG
  147969. * @returns A new CSG from the Mesh
  147970. */
  147971. static FromMesh(mesh: Mesh): CSG;
  147972. /**
  147973. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  147974. * @param polygons Polygons used to construct a CSG solid
  147975. */
  147976. private static FromPolygons;
  147977. /**
  147978. * Clones, or makes a deep copy, of the CSG
  147979. * @returns A new CSG
  147980. */
  147981. clone(): CSG;
  147982. /**
  147983. * Unions this CSG with another CSG
  147984. * @param csg The CSG to union against this CSG
  147985. * @returns The unioned CSG
  147986. */
  147987. union(csg: CSG): CSG;
  147988. /**
  147989. * Unions this CSG with another CSG in place
  147990. * @param csg The CSG to union against this CSG
  147991. */
  147992. unionInPlace(csg: CSG): void;
  147993. /**
  147994. * Subtracts this CSG with another CSG
  147995. * @param csg The CSG to subtract against this CSG
  147996. * @returns A new CSG
  147997. */
  147998. subtract(csg: CSG): CSG;
  147999. /**
  148000. * Subtracts this CSG with another CSG in place
  148001. * @param csg The CSG to subtact against this CSG
  148002. */
  148003. subtractInPlace(csg: CSG): void;
  148004. /**
  148005. * Intersect this CSG with another CSG
  148006. * @param csg The CSG to intersect against this CSG
  148007. * @returns A new CSG
  148008. */
  148009. intersect(csg: CSG): CSG;
  148010. /**
  148011. * Intersects this CSG with another CSG in place
  148012. * @param csg The CSG to intersect against this CSG
  148013. */
  148014. intersectInPlace(csg: CSG): void;
  148015. /**
  148016. * Return a new CSG solid with solid and empty space switched. This solid is
  148017. * not modified.
  148018. * @returns A new CSG solid with solid and empty space switched
  148019. */
  148020. inverse(): CSG;
  148021. /**
  148022. * Inverses the CSG in place
  148023. */
  148024. inverseInPlace(): void;
  148025. /**
  148026. * This is used to keep meshes transformations so they can be restored
  148027. * when we build back a Babylon Mesh
  148028. * NB : All CSG operations are performed in world coordinates
  148029. * @param csg The CSG to copy the transform attributes from
  148030. * @returns This CSG
  148031. */
  148032. copyTransformAttributes(csg: CSG): CSG;
  148033. /**
  148034. * Build Raw mesh from CSG
  148035. * Coordinates here are in world space
  148036. * @param name The name of the mesh geometry
  148037. * @param scene The Scene
  148038. * @param keepSubMeshes Specifies if the submeshes should be kept
  148039. * @returns A new Mesh
  148040. */
  148041. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  148042. /**
  148043. * Build Mesh from CSG taking material and transforms into account
  148044. * @param name The name of the Mesh
  148045. * @param material The material of the Mesh
  148046. * @param scene The Scene
  148047. * @param keepSubMeshes Specifies if submeshes should be kept
  148048. * @returns The new Mesh
  148049. */
  148050. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  148051. }
  148052. }
  148053. declare module BABYLON {
  148054. /**
  148055. * Class used to create a trail following a mesh
  148056. */
  148057. export class TrailMesh extends Mesh {
  148058. private _generator;
  148059. private _autoStart;
  148060. private _running;
  148061. private _diameter;
  148062. private _length;
  148063. private _sectionPolygonPointsCount;
  148064. private _sectionVectors;
  148065. private _sectionNormalVectors;
  148066. private _beforeRenderObserver;
  148067. /**
  148068. * @constructor
  148069. * @param name The value used by scene.getMeshByName() to do a lookup.
  148070. * @param generator The mesh or transform node to generate a trail.
  148071. * @param scene The scene to add this mesh to.
  148072. * @param diameter Diameter of trailing mesh. Default is 1.
  148073. * @param length Length of trailing mesh. Default is 60.
  148074. * @param autoStart Automatically start trailing mesh. Default true.
  148075. */
  148076. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  148077. /**
  148078. * "TrailMesh"
  148079. * @returns "TrailMesh"
  148080. */
  148081. getClassName(): string;
  148082. private _createMesh;
  148083. /**
  148084. * Start trailing mesh.
  148085. */
  148086. start(): void;
  148087. /**
  148088. * Stop trailing mesh.
  148089. */
  148090. stop(): void;
  148091. /**
  148092. * Update trailing mesh geometry.
  148093. */
  148094. update(): void;
  148095. /**
  148096. * Returns a new TrailMesh object.
  148097. * @param name is a string, the name given to the new mesh
  148098. * @param newGenerator use new generator object for cloned trail mesh
  148099. * @returns a new mesh
  148100. */
  148101. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  148102. /**
  148103. * Serializes this trail mesh
  148104. * @param serializationObject object to write serialization to
  148105. */
  148106. serialize(serializationObject: any): void;
  148107. /**
  148108. * Parses a serialized trail mesh
  148109. * @param parsedMesh the serialized mesh
  148110. * @param scene the scene to create the trail mesh in
  148111. * @returns the created trail mesh
  148112. */
  148113. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  148114. }
  148115. }
  148116. declare module BABYLON {
  148117. /**
  148118. * Class containing static functions to help procedurally build meshes
  148119. */
  148120. export class TiledBoxBuilder {
  148121. /**
  148122. * Creates a box mesh
  148123. * 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)
  148124. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  148125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148126. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148128. * @param name defines the name of the mesh
  148129. * @param options defines the options used to create the mesh
  148130. * @param scene defines the hosting scene
  148131. * @returns the box mesh
  148132. */
  148133. static CreateTiledBox(name: string, options: {
  148134. pattern?: number;
  148135. width?: number;
  148136. height?: number;
  148137. depth?: number;
  148138. tileSize?: number;
  148139. tileWidth?: number;
  148140. tileHeight?: number;
  148141. alignHorizontal?: number;
  148142. alignVertical?: number;
  148143. faceUV?: Vector4[];
  148144. faceColors?: Color4[];
  148145. sideOrientation?: number;
  148146. updatable?: boolean;
  148147. }, scene?: Nullable<Scene>): Mesh;
  148148. }
  148149. }
  148150. declare module BABYLON {
  148151. /**
  148152. * Class containing static functions to help procedurally build meshes
  148153. */
  148154. export class TorusKnotBuilder {
  148155. /**
  148156. * Creates a torus knot mesh
  148157. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  148158. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  148159. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  148160. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  148161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148162. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148164. * @param name defines the name of the mesh
  148165. * @param options defines the options used to create the mesh
  148166. * @param scene defines the hosting scene
  148167. * @returns the torus knot mesh
  148168. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  148169. */
  148170. static CreateTorusKnot(name: string, options: {
  148171. radius?: number;
  148172. tube?: number;
  148173. radialSegments?: number;
  148174. tubularSegments?: number;
  148175. p?: number;
  148176. q?: number;
  148177. updatable?: boolean;
  148178. sideOrientation?: number;
  148179. frontUVs?: Vector4;
  148180. backUVs?: Vector4;
  148181. }, scene: any): Mesh;
  148182. }
  148183. }
  148184. declare module BABYLON {
  148185. /**
  148186. * Polygon
  148187. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  148188. */
  148189. export class Polygon {
  148190. /**
  148191. * Creates a rectangle
  148192. * @param xmin bottom X coord
  148193. * @param ymin bottom Y coord
  148194. * @param xmax top X coord
  148195. * @param ymax top Y coord
  148196. * @returns points that make the resulting rectation
  148197. */
  148198. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  148199. /**
  148200. * Creates a circle
  148201. * @param radius radius of circle
  148202. * @param cx scale in x
  148203. * @param cy scale in y
  148204. * @param numberOfSides number of sides that make up the circle
  148205. * @returns points that make the resulting circle
  148206. */
  148207. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  148208. /**
  148209. * Creates a polygon from input string
  148210. * @param input Input polygon data
  148211. * @returns the parsed points
  148212. */
  148213. static Parse(input: string): Vector2[];
  148214. /**
  148215. * Starts building a polygon from x and y coordinates
  148216. * @param x x coordinate
  148217. * @param y y coordinate
  148218. * @returns the started path2
  148219. */
  148220. static StartingAt(x: number, y: number): Path2;
  148221. }
  148222. /**
  148223. * Builds a polygon
  148224. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  148225. */
  148226. export class PolygonMeshBuilder {
  148227. private _points;
  148228. private _outlinepoints;
  148229. private _holes;
  148230. private _name;
  148231. private _scene;
  148232. private _epoints;
  148233. private _eholes;
  148234. private _addToepoint;
  148235. /**
  148236. * Babylon reference to the earcut plugin.
  148237. */
  148238. bjsEarcut: any;
  148239. /**
  148240. * Creates a PolygonMeshBuilder
  148241. * @param name name of the builder
  148242. * @param contours Path of the polygon
  148243. * @param scene scene to add to when creating the mesh
  148244. * @param earcutInjection can be used to inject your own earcut reference
  148245. */
  148246. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  148247. /**
  148248. * Adds a whole within the polygon
  148249. * @param hole Array of points defining the hole
  148250. * @returns this
  148251. */
  148252. addHole(hole: Vector2[]): PolygonMeshBuilder;
  148253. /**
  148254. * Creates the polygon
  148255. * @param updatable If the mesh should be updatable
  148256. * @param depth The depth of the mesh created
  148257. * @returns the created mesh
  148258. */
  148259. build(updatable?: boolean, depth?: number): Mesh;
  148260. /**
  148261. * Creates the polygon
  148262. * @param depth The depth of the mesh created
  148263. * @returns the created VertexData
  148264. */
  148265. buildVertexData(depth?: number): VertexData;
  148266. /**
  148267. * Adds a side to the polygon
  148268. * @param positions points that make the polygon
  148269. * @param normals normals of the polygon
  148270. * @param uvs uvs of the polygon
  148271. * @param indices indices of the polygon
  148272. * @param bounds bounds of the polygon
  148273. * @param points points of the polygon
  148274. * @param depth depth of the polygon
  148275. * @param flip flip of the polygon
  148276. */
  148277. private addSide;
  148278. }
  148279. }
  148280. declare module BABYLON {
  148281. /**
  148282. * Class containing static functions to help procedurally build meshes
  148283. */
  148284. export class PolygonBuilder {
  148285. /**
  148286. * Creates a polygon mesh
  148287. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  148288. * * 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
  148289. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  148290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148291. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  148292. * * Remember you can only change the shape positions, not their number when updating a polygon
  148293. * @param name defines the name of the mesh
  148294. * @param options defines the options used to create the mesh
  148295. * @param scene defines the hosting scene
  148296. * @param earcutInjection can be used to inject your own earcut reference
  148297. * @returns the polygon mesh
  148298. */
  148299. static CreatePolygon(name: string, options: {
  148300. shape: Vector3[];
  148301. holes?: Vector3[][];
  148302. depth?: number;
  148303. faceUV?: Vector4[];
  148304. faceColors?: Color4[];
  148305. updatable?: boolean;
  148306. sideOrientation?: number;
  148307. frontUVs?: Vector4;
  148308. backUVs?: Vector4;
  148309. wrap?: boolean;
  148310. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  148311. /**
  148312. * Creates an extruded polygon mesh, with depth in the Y direction.
  148313. * * 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)
  148314. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  148315. * @param name defines the name of the mesh
  148316. * @param options defines the options used to create the mesh
  148317. * @param scene defines the hosting scene
  148318. * @param earcutInjection can be used to inject your own earcut reference
  148319. * @returns the polygon mesh
  148320. */
  148321. static ExtrudePolygon(name: string, options: {
  148322. shape: Vector3[];
  148323. holes?: Vector3[][];
  148324. depth?: number;
  148325. faceUV?: Vector4[];
  148326. faceColors?: Color4[];
  148327. updatable?: boolean;
  148328. sideOrientation?: number;
  148329. frontUVs?: Vector4;
  148330. backUVs?: Vector4;
  148331. wrap?: boolean;
  148332. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  148333. }
  148334. }
  148335. declare module BABYLON {
  148336. /**
  148337. * Class containing static functions to help procedurally build meshes
  148338. */
  148339. export class LatheBuilder {
  148340. /**
  148341. * Creates lathe mesh.
  148342. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  148343. * * 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
  148344. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  148345. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  148346. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  148347. * * 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
  148348. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  148349. * * 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
  148350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148351. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148352. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148354. * @param name defines the name of the mesh
  148355. * @param options defines the options used to create the mesh
  148356. * @param scene defines the hosting scene
  148357. * @returns the lathe mesh
  148358. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  148359. */
  148360. static CreateLathe(name: string, options: {
  148361. shape: Vector3[];
  148362. radius?: number;
  148363. tessellation?: number;
  148364. clip?: number;
  148365. arc?: number;
  148366. closed?: boolean;
  148367. updatable?: boolean;
  148368. sideOrientation?: number;
  148369. frontUVs?: Vector4;
  148370. backUVs?: Vector4;
  148371. cap?: number;
  148372. invertUV?: boolean;
  148373. }, scene?: Nullable<Scene>): Mesh;
  148374. }
  148375. }
  148376. declare module BABYLON {
  148377. /**
  148378. * Class containing static functions to help procedurally build meshes
  148379. */
  148380. export class TiledPlaneBuilder {
  148381. /**
  148382. * Creates a tiled plane mesh
  148383. * * The parameter `pattern` will, depending on value, do nothing or
  148384. * * * flip (reflect about central vertical) alternate tiles across and up
  148385. * * * flip every tile on alternate rows
  148386. * * * rotate (180 degs) alternate tiles across and up
  148387. * * * rotate every tile on alternate rows
  148388. * * * flip and rotate alternate tiles across and up
  148389. * * * flip and rotate every tile on alternate rows
  148390. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  148391. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  148392. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148393. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  148394. * * 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)
  148395. * * 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)
  148396. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  148397. * @param name defines the name of the mesh
  148398. * @param options defines the options used to create the mesh
  148399. * @param scene defines the hosting scene
  148400. * @returns the box mesh
  148401. */
  148402. static CreateTiledPlane(name: string, options: {
  148403. pattern?: number;
  148404. tileSize?: number;
  148405. tileWidth?: number;
  148406. tileHeight?: number;
  148407. size?: number;
  148408. width?: number;
  148409. height?: number;
  148410. alignHorizontal?: number;
  148411. alignVertical?: number;
  148412. sideOrientation?: number;
  148413. frontUVs?: Vector4;
  148414. backUVs?: Vector4;
  148415. updatable?: boolean;
  148416. }, scene?: Nullable<Scene>): Mesh;
  148417. }
  148418. }
  148419. declare module BABYLON {
  148420. /**
  148421. * Class containing static functions to help procedurally build meshes
  148422. */
  148423. export class TubeBuilder {
  148424. /**
  148425. * Creates a tube mesh.
  148426. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  148427. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  148428. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  148429. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  148430. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  148431. * * 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)
  148432. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  148433. * * 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
  148434. * * 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
  148435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148436. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148437. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148439. * @param name defines the name of the mesh
  148440. * @param options defines the options used to create the mesh
  148441. * @param scene defines the hosting scene
  148442. * @returns the tube mesh
  148443. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148444. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  148445. */
  148446. static CreateTube(name: string, options: {
  148447. path: Vector3[];
  148448. radius?: number;
  148449. tessellation?: number;
  148450. radiusFunction?: {
  148451. (i: number, distance: number): number;
  148452. };
  148453. cap?: number;
  148454. arc?: number;
  148455. updatable?: boolean;
  148456. sideOrientation?: number;
  148457. frontUVs?: Vector4;
  148458. backUVs?: Vector4;
  148459. instance?: Mesh;
  148460. invertUV?: boolean;
  148461. }, scene?: Nullable<Scene>): Mesh;
  148462. }
  148463. }
  148464. declare module BABYLON {
  148465. /**
  148466. * Class containing static functions to help procedurally build meshes
  148467. */
  148468. export class IcoSphereBuilder {
  148469. /**
  148470. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  148471. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  148472. * * 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`)
  148473. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  148474. * * 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
  148475. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148476. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148478. * @param name defines the name of the mesh
  148479. * @param options defines the options used to create the mesh
  148480. * @param scene defines the hosting scene
  148481. * @returns the icosahedron mesh
  148482. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  148483. */
  148484. static CreateIcoSphere(name: string, options: {
  148485. radius?: number;
  148486. radiusX?: number;
  148487. radiusY?: number;
  148488. radiusZ?: number;
  148489. flat?: boolean;
  148490. subdivisions?: number;
  148491. sideOrientation?: number;
  148492. frontUVs?: Vector4;
  148493. backUVs?: Vector4;
  148494. updatable?: boolean;
  148495. }, scene?: Nullable<Scene>): Mesh;
  148496. }
  148497. }
  148498. declare module BABYLON {
  148499. /**
  148500. * Class containing static functions to help procedurally build meshes
  148501. */
  148502. export class DecalBuilder {
  148503. /**
  148504. * Creates a decal mesh.
  148505. * 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
  148506. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  148507. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  148508. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  148509. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  148510. * @param name defines the name of the mesh
  148511. * @param sourceMesh defines the mesh where the decal must be applied
  148512. * @param options defines the options used to create the mesh
  148513. * @param scene defines the hosting scene
  148514. * @returns the decal mesh
  148515. * @see https://doc.babylonjs.com/how_to/decals
  148516. */
  148517. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  148518. position?: Vector3;
  148519. normal?: Vector3;
  148520. size?: Vector3;
  148521. angle?: number;
  148522. }): Mesh;
  148523. }
  148524. }
  148525. declare module BABYLON {
  148526. /**
  148527. * Class containing static functions to help procedurally build meshes
  148528. */
  148529. export class MeshBuilder {
  148530. /**
  148531. * Creates a box mesh
  148532. * * The parameter `size` sets the size (float) of each box side (default 1)
  148533. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  148534. * * 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)
  148535. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  148536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148537. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148539. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  148540. * @param name defines the name of the mesh
  148541. * @param options defines the options used to create the mesh
  148542. * @param scene defines the hosting scene
  148543. * @returns the box mesh
  148544. */
  148545. static CreateBox(name: string, options: {
  148546. size?: number;
  148547. width?: number;
  148548. height?: number;
  148549. depth?: number;
  148550. faceUV?: Vector4[];
  148551. faceColors?: Color4[];
  148552. sideOrientation?: number;
  148553. frontUVs?: Vector4;
  148554. backUVs?: Vector4;
  148555. wrap?: boolean;
  148556. topBaseAt?: number;
  148557. bottomBaseAt?: number;
  148558. updatable?: boolean;
  148559. }, scene?: Nullable<Scene>): Mesh;
  148560. /**
  148561. * Creates a tiled box mesh
  148562. * * faceTiles sets the pattern, tile size and number of tiles for a face
  148563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148564. * @param name defines the name of the mesh
  148565. * @param options defines the options used to create the mesh
  148566. * @param scene defines the hosting scene
  148567. * @returns the tiled box mesh
  148568. */
  148569. static CreateTiledBox(name: string, options: {
  148570. pattern?: number;
  148571. size?: number;
  148572. width?: number;
  148573. height?: number;
  148574. depth: number;
  148575. tileSize?: number;
  148576. tileWidth?: number;
  148577. tileHeight?: number;
  148578. faceUV?: Vector4[];
  148579. faceColors?: Color4[];
  148580. alignHorizontal?: number;
  148581. alignVertical?: number;
  148582. sideOrientation?: number;
  148583. updatable?: boolean;
  148584. }, scene?: Nullable<Scene>): Mesh;
  148585. /**
  148586. * Creates a sphere mesh
  148587. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  148588. * * 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`)
  148589. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  148590. * * 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
  148591. * * 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)
  148592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148593. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148595. * @param name defines the name of the mesh
  148596. * @param options defines the options used to create the mesh
  148597. * @param scene defines the hosting scene
  148598. * @returns the sphere mesh
  148599. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  148600. */
  148601. static CreateSphere(name: string, options: {
  148602. segments?: number;
  148603. diameter?: number;
  148604. diameterX?: number;
  148605. diameterY?: number;
  148606. diameterZ?: number;
  148607. arc?: number;
  148608. slice?: number;
  148609. sideOrientation?: number;
  148610. frontUVs?: Vector4;
  148611. backUVs?: Vector4;
  148612. updatable?: boolean;
  148613. }, scene?: Nullable<Scene>): Mesh;
  148614. /**
  148615. * Creates a plane polygonal mesh. By default, this is a disc
  148616. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  148617. * * 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
  148618. * * 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
  148619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148620. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148622. * @param name defines the name of the mesh
  148623. * @param options defines the options used to create the mesh
  148624. * @param scene defines the hosting scene
  148625. * @returns the plane polygonal mesh
  148626. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  148627. */
  148628. static CreateDisc(name: string, options: {
  148629. radius?: number;
  148630. tessellation?: number;
  148631. arc?: number;
  148632. updatable?: boolean;
  148633. sideOrientation?: number;
  148634. frontUVs?: Vector4;
  148635. backUVs?: Vector4;
  148636. }, scene?: Nullable<Scene>): Mesh;
  148637. /**
  148638. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  148639. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  148640. * * 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`)
  148641. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  148642. * * 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
  148643. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148644. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148646. * @param name defines the name of the mesh
  148647. * @param options defines the options used to create the mesh
  148648. * @param scene defines the hosting scene
  148649. * @returns the icosahedron mesh
  148650. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  148651. */
  148652. static CreateIcoSphere(name: string, options: {
  148653. radius?: number;
  148654. radiusX?: number;
  148655. radiusY?: number;
  148656. radiusZ?: number;
  148657. flat?: boolean;
  148658. subdivisions?: number;
  148659. sideOrientation?: number;
  148660. frontUVs?: Vector4;
  148661. backUVs?: Vector4;
  148662. updatable?: boolean;
  148663. }, scene?: Nullable<Scene>): Mesh;
  148664. /**
  148665. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  148666. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  148667. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  148668. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  148669. * * 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
  148670. * * 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
  148671. * * 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
  148672. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148673. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148674. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148675. * * 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
  148676. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  148677. * * 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
  148678. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  148679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148680. * @param name defines the name of the mesh
  148681. * @param options defines the options used to create the mesh
  148682. * @param scene defines the hosting scene
  148683. * @returns the ribbon mesh
  148684. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  148685. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148686. */
  148687. static CreateRibbon(name: string, options: {
  148688. pathArray: Vector3[][];
  148689. closeArray?: boolean;
  148690. closePath?: boolean;
  148691. offset?: number;
  148692. updatable?: boolean;
  148693. sideOrientation?: number;
  148694. frontUVs?: Vector4;
  148695. backUVs?: Vector4;
  148696. instance?: Mesh;
  148697. invertUV?: boolean;
  148698. uvs?: Vector2[];
  148699. colors?: Color4[];
  148700. }, scene?: Nullable<Scene>): Mesh;
  148701. /**
  148702. * Creates a cylinder or a cone mesh
  148703. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  148704. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  148705. * * 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.
  148706. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  148707. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  148708. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  148709. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  148710. * * 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).
  148711. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  148712. * * 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).
  148713. * * 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
  148714. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  148715. * * 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
  148716. * * 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.
  148717. * * If `enclose` is false, a ring surface is one element.
  148718. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  148719. * * 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
  148720. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148721. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148723. * @param name defines the name of the mesh
  148724. * @param options defines the options used to create the mesh
  148725. * @param scene defines the hosting scene
  148726. * @returns the cylinder mesh
  148727. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  148728. */
  148729. static CreateCylinder(name: string, options: {
  148730. height?: number;
  148731. diameterTop?: number;
  148732. diameterBottom?: number;
  148733. diameter?: number;
  148734. tessellation?: number;
  148735. subdivisions?: number;
  148736. arc?: number;
  148737. faceColors?: Color4[];
  148738. faceUV?: Vector4[];
  148739. updatable?: boolean;
  148740. hasRings?: boolean;
  148741. enclose?: boolean;
  148742. cap?: number;
  148743. sideOrientation?: number;
  148744. frontUVs?: Vector4;
  148745. backUVs?: Vector4;
  148746. }, scene?: Nullable<Scene>): Mesh;
  148747. /**
  148748. * Creates a torus mesh
  148749. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  148750. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  148751. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  148752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148753. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148755. * @param name defines the name of the mesh
  148756. * @param options defines the options used to create the mesh
  148757. * @param scene defines the hosting scene
  148758. * @returns the torus mesh
  148759. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  148760. */
  148761. static CreateTorus(name: string, options: {
  148762. diameter?: number;
  148763. thickness?: number;
  148764. tessellation?: number;
  148765. updatable?: boolean;
  148766. sideOrientation?: number;
  148767. frontUVs?: Vector4;
  148768. backUVs?: Vector4;
  148769. }, scene?: Nullable<Scene>): Mesh;
  148770. /**
  148771. * Creates a torus knot mesh
  148772. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  148773. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  148774. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  148775. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  148776. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148777. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148779. * @param name defines the name of the mesh
  148780. * @param options defines the options used to create the mesh
  148781. * @param scene defines the hosting scene
  148782. * @returns the torus knot mesh
  148783. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  148784. */
  148785. static CreateTorusKnot(name: string, options: {
  148786. radius?: number;
  148787. tube?: number;
  148788. radialSegments?: number;
  148789. tubularSegments?: number;
  148790. p?: number;
  148791. q?: number;
  148792. updatable?: boolean;
  148793. sideOrientation?: number;
  148794. frontUVs?: Vector4;
  148795. backUVs?: Vector4;
  148796. }, scene?: Nullable<Scene>): Mesh;
  148797. /**
  148798. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  148799. * * 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
  148800. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  148801. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  148802. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  148803. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  148804. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  148805. * * 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
  148806. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  148807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148808. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  148809. * @param name defines the name of the new line system
  148810. * @param options defines the options used to create the line system
  148811. * @param scene defines the hosting scene
  148812. * @returns a new line system mesh
  148813. */
  148814. static CreateLineSystem(name: string, options: {
  148815. lines: Vector3[][];
  148816. updatable?: boolean;
  148817. instance?: Nullable<LinesMesh>;
  148818. colors?: Nullable<Color4[][]>;
  148819. useVertexAlpha?: boolean;
  148820. }, scene: Nullable<Scene>): LinesMesh;
  148821. /**
  148822. * Creates a line mesh
  148823. * 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
  148824. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  148825. * * The parameter `points` is an array successive Vector3
  148826. * * 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
  148827. * * The optional parameter `colors` is an array of successive Color4, one per line point
  148828. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  148829. * * When updating an instance, remember that only point positions can change, not the number of points
  148830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148831. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  148832. * @param name defines the name of the new line system
  148833. * @param options defines the options used to create the line system
  148834. * @param scene defines the hosting scene
  148835. * @returns a new line mesh
  148836. */
  148837. static CreateLines(name: string, options: {
  148838. points: Vector3[];
  148839. updatable?: boolean;
  148840. instance?: Nullable<LinesMesh>;
  148841. colors?: Color4[];
  148842. useVertexAlpha?: boolean;
  148843. }, scene?: Nullable<Scene>): LinesMesh;
  148844. /**
  148845. * Creates a dashed line mesh
  148846. * * 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
  148847. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  148848. * * The parameter `points` is an array successive Vector3
  148849. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  148850. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  148851. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  148852. * * 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
  148853. * * When updating an instance, remember that only point positions can change, not the number of points
  148854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148855. * @param name defines the name of the mesh
  148856. * @param options defines the options used to create the mesh
  148857. * @param scene defines the hosting scene
  148858. * @returns the dashed line mesh
  148859. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  148860. */
  148861. static CreateDashedLines(name: string, options: {
  148862. points: Vector3[];
  148863. dashSize?: number;
  148864. gapSize?: number;
  148865. dashNb?: number;
  148866. updatable?: boolean;
  148867. instance?: LinesMesh;
  148868. }, scene?: Nullable<Scene>): LinesMesh;
  148869. /**
  148870. * 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.
  148871. * * 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.
  148872. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  148873. * * 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.
  148874. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  148875. * * 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
  148876. * * 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
  148877. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  148878. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148879. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148880. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  148881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148882. * @param name defines the name of the mesh
  148883. * @param options defines the options used to create the mesh
  148884. * @param scene defines the hosting scene
  148885. * @returns the extruded shape mesh
  148886. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148887. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  148888. */
  148889. static ExtrudeShape(name: string, options: {
  148890. shape: Vector3[];
  148891. path: Vector3[];
  148892. scale?: number;
  148893. rotation?: number;
  148894. cap?: number;
  148895. updatable?: boolean;
  148896. sideOrientation?: number;
  148897. frontUVs?: Vector4;
  148898. backUVs?: Vector4;
  148899. instance?: Mesh;
  148900. invertUV?: boolean;
  148901. }, scene?: Nullable<Scene>): Mesh;
  148902. /**
  148903. * Creates an custom extruded shape mesh.
  148904. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  148905. * * 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.
  148906. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  148907. * * 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
  148908. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  148909. * * 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
  148910. * * It must returns a float value that will be the scale value applied to the shape on each path point
  148911. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  148912. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  148913. * * 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
  148914. * * 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
  148915. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  148916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148917. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148918. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148920. * @param name defines the name of the mesh
  148921. * @param options defines the options used to create the mesh
  148922. * @param scene defines the hosting scene
  148923. * @returns the custom extruded shape mesh
  148924. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  148925. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148926. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  148927. */
  148928. static ExtrudeShapeCustom(name: string, options: {
  148929. shape: Vector3[];
  148930. path: Vector3[];
  148931. scaleFunction?: any;
  148932. rotationFunction?: any;
  148933. ribbonCloseArray?: boolean;
  148934. ribbonClosePath?: boolean;
  148935. cap?: number;
  148936. updatable?: boolean;
  148937. sideOrientation?: number;
  148938. frontUVs?: Vector4;
  148939. backUVs?: Vector4;
  148940. instance?: Mesh;
  148941. invertUV?: boolean;
  148942. }, scene?: Nullable<Scene>): Mesh;
  148943. /**
  148944. * Creates lathe mesh.
  148945. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  148946. * * 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
  148947. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  148948. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  148949. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  148950. * * 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
  148951. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  148952. * * 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
  148953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148954. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148955. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148957. * @param name defines the name of the mesh
  148958. * @param options defines the options used to create the mesh
  148959. * @param scene defines the hosting scene
  148960. * @returns the lathe mesh
  148961. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  148962. */
  148963. static CreateLathe(name: string, options: {
  148964. shape: Vector3[];
  148965. radius?: number;
  148966. tessellation?: number;
  148967. clip?: number;
  148968. arc?: number;
  148969. closed?: boolean;
  148970. updatable?: boolean;
  148971. sideOrientation?: number;
  148972. frontUVs?: Vector4;
  148973. backUVs?: Vector4;
  148974. cap?: number;
  148975. invertUV?: boolean;
  148976. }, scene?: Nullable<Scene>): Mesh;
  148977. /**
  148978. * Creates a tiled plane mesh
  148979. * * You can set a limited pattern arrangement with the tiles
  148980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148981. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148983. * @param name defines the name of the mesh
  148984. * @param options defines the options used to create the mesh
  148985. * @param scene defines the hosting scene
  148986. * @returns the plane mesh
  148987. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  148988. */
  148989. static CreateTiledPlane(name: string, options: {
  148990. pattern?: number;
  148991. tileSize?: number;
  148992. tileWidth?: number;
  148993. tileHeight?: number;
  148994. size?: number;
  148995. width?: number;
  148996. height?: number;
  148997. alignHorizontal?: number;
  148998. alignVertical?: number;
  148999. sideOrientation?: number;
  149000. frontUVs?: Vector4;
  149001. backUVs?: Vector4;
  149002. updatable?: boolean;
  149003. }, scene?: Nullable<Scene>): Mesh;
  149004. /**
  149005. * Creates a plane mesh
  149006. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  149007. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  149008. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  149009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149012. * @param name defines the name of the mesh
  149013. * @param options defines the options used to create the mesh
  149014. * @param scene defines the hosting scene
  149015. * @returns the plane mesh
  149016. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  149017. */
  149018. static CreatePlane(name: string, options: {
  149019. size?: number;
  149020. width?: number;
  149021. height?: number;
  149022. sideOrientation?: number;
  149023. frontUVs?: Vector4;
  149024. backUVs?: Vector4;
  149025. updatable?: boolean;
  149026. sourcePlane?: Plane;
  149027. }, scene?: Nullable<Scene>): Mesh;
  149028. /**
  149029. * Creates a ground mesh
  149030. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  149031. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  149032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149033. * @param name defines the name of the mesh
  149034. * @param options defines the options used to create the mesh
  149035. * @param scene defines the hosting scene
  149036. * @returns the ground mesh
  149037. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  149038. */
  149039. static CreateGround(name: string, options: {
  149040. width?: number;
  149041. height?: number;
  149042. subdivisions?: number;
  149043. subdivisionsX?: number;
  149044. subdivisionsY?: number;
  149045. updatable?: boolean;
  149046. }, scene?: Nullable<Scene>): Mesh;
  149047. /**
  149048. * Creates a tiled ground mesh
  149049. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  149050. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  149051. * * 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
  149052. * * 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
  149053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  149054. * @param name defines the name of the mesh
  149055. * @param options defines the options used to create the mesh
  149056. * @param scene defines the hosting scene
  149057. * @returns the tiled ground mesh
  149058. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  149059. */
  149060. static CreateTiledGround(name: string, options: {
  149061. xmin: number;
  149062. zmin: number;
  149063. xmax: number;
  149064. zmax: number;
  149065. subdivisions?: {
  149066. w: number;
  149067. h: number;
  149068. };
  149069. precision?: {
  149070. w: number;
  149071. h: number;
  149072. };
  149073. updatable?: boolean;
  149074. }, scene?: Nullable<Scene>): Mesh;
  149075. /**
  149076. * Creates a ground mesh from a height map
  149077. * * The parameter `url` sets the URL of the height map image resource.
  149078. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  149079. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  149080. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  149081. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  149082. * * 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.
  149083. * * 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).
  149084. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  149085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  149086. * @param name defines the name of the mesh
  149087. * @param url defines the url to the height map
  149088. * @param options defines the options used to create the mesh
  149089. * @param scene defines the hosting scene
  149090. * @returns the ground mesh
  149091. * @see https://doc.babylonjs.com/babylon101/height_map
  149092. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  149093. */
  149094. static CreateGroundFromHeightMap(name: string, url: string, options: {
  149095. width?: number;
  149096. height?: number;
  149097. subdivisions?: number;
  149098. minHeight?: number;
  149099. maxHeight?: number;
  149100. colorFilter?: Color3;
  149101. alphaFilter?: number;
  149102. updatable?: boolean;
  149103. onReady?: (mesh: GroundMesh) => void;
  149104. }, scene?: Nullable<Scene>): GroundMesh;
  149105. /**
  149106. * Creates a polygon mesh
  149107. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  149108. * * 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
  149109. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  149110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  149112. * * Remember you can only change the shape positions, not their number when updating a polygon
  149113. * @param name defines the name of the mesh
  149114. * @param options defines the options used to create the mesh
  149115. * @param scene defines the hosting scene
  149116. * @param earcutInjection can be used to inject your own earcut reference
  149117. * @returns the polygon mesh
  149118. */
  149119. static CreatePolygon(name: string, options: {
  149120. shape: Vector3[];
  149121. holes?: Vector3[][];
  149122. depth?: number;
  149123. faceUV?: Vector4[];
  149124. faceColors?: Color4[];
  149125. updatable?: boolean;
  149126. sideOrientation?: number;
  149127. frontUVs?: Vector4;
  149128. backUVs?: Vector4;
  149129. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  149130. /**
  149131. * Creates an extruded polygon mesh, with depth in the Y direction.
  149132. * * 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)
  149133. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  149134. * @param name defines the name of the mesh
  149135. * @param options defines the options used to create the mesh
  149136. * @param scene defines the hosting scene
  149137. * @param earcutInjection can be used to inject your own earcut reference
  149138. * @returns the polygon mesh
  149139. */
  149140. static ExtrudePolygon(name: string, options: {
  149141. shape: Vector3[];
  149142. holes?: Vector3[][];
  149143. depth?: number;
  149144. faceUV?: Vector4[];
  149145. faceColors?: Color4[];
  149146. updatable?: boolean;
  149147. sideOrientation?: number;
  149148. frontUVs?: Vector4;
  149149. backUVs?: Vector4;
  149150. wrap?: boolean;
  149151. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  149152. /**
  149153. * Creates a tube mesh.
  149154. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  149155. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  149156. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  149157. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  149158. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  149159. * * 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)
  149160. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  149161. * * 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
  149162. * * 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
  149163. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149164. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149165. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  149166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149167. * @param name defines the name of the mesh
  149168. * @param options defines the options used to create the mesh
  149169. * @param scene defines the hosting scene
  149170. * @returns the tube mesh
  149171. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  149172. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  149173. */
  149174. static CreateTube(name: string, options: {
  149175. path: Vector3[];
  149176. radius?: number;
  149177. tessellation?: number;
  149178. radiusFunction?: {
  149179. (i: number, distance: number): number;
  149180. };
  149181. cap?: number;
  149182. arc?: number;
  149183. updatable?: boolean;
  149184. sideOrientation?: number;
  149185. frontUVs?: Vector4;
  149186. backUVs?: Vector4;
  149187. instance?: Mesh;
  149188. invertUV?: boolean;
  149189. }, scene?: Nullable<Scene>): Mesh;
  149190. /**
  149191. * Creates a polyhedron mesh
  149192. * * 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
  149193. * * The parameter `size` (positive float, default 1) sets the polygon size
  149194. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  149195. * * 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`
  149196. * * 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
  149197. * * 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)`)
  149198. * * 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
  149199. * * 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
  149200. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149201. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149203. * @param name defines the name of the mesh
  149204. * @param options defines the options used to create the mesh
  149205. * @param scene defines the hosting scene
  149206. * @returns the polyhedron mesh
  149207. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  149208. */
  149209. static CreatePolyhedron(name: string, options: {
  149210. type?: number;
  149211. size?: number;
  149212. sizeX?: number;
  149213. sizeY?: number;
  149214. sizeZ?: number;
  149215. custom?: any;
  149216. faceUV?: Vector4[];
  149217. faceColors?: Color4[];
  149218. flat?: boolean;
  149219. updatable?: boolean;
  149220. sideOrientation?: number;
  149221. frontUVs?: Vector4;
  149222. backUVs?: Vector4;
  149223. }, scene?: Nullable<Scene>): Mesh;
  149224. /**
  149225. * Creates a decal mesh.
  149226. * 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
  149227. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  149228. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  149229. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  149230. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  149231. * @param name defines the name of the mesh
  149232. * @param sourceMesh defines the mesh where the decal must be applied
  149233. * @param options defines the options used to create the mesh
  149234. * @param scene defines the hosting scene
  149235. * @returns the decal mesh
  149236. * @see https://doc.babylonjs.com/how_to/decals
  149237. */
  149238. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  149239. position?: Vector3;
  149240. normal?: Vector3;
  149241. size?: Vector3;
  149242. angle?: number;
  149243. }): Mesh;
  149244. /**
  149245. * Creates a Capsule Mesh
  149246. * @param name defines the name of the mesh.
  149247. * @param options the constructors options used to shape the mesh.
  149248. * @param scene defines the scene the mesh is scoped to.
  149249. * @returns the capsule mesh
  149250. * @see https://doc.babylonjs.com/how_to/capsule_shape
  149251. */
  149252. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  149253. }
  149254. }
  149255. declare module BABYLON {
  149256. /**
  149257. * A simplifier interface for future simplification implementations
  149258. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149259. */
  149260. export interface ISimplifier {
  149261. /**
  149262. * Simplification of a given mesh according to the given settings.
  149263. * Since this requires computation, it is assumed that the function runs async.
  149264. * @param settings The settings of the simplification, including quality and distance
  149265. * @param successCallback A callback that will be called after the mesh was simplified.
  149266. * @param errorCallback in case of an error, this callback will be called. optional.
  149267. */
  149268. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  149269. }
  149270. /**
  149271. * Expected simplification settings.
  149272. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  149273. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149274. */
  149275. export interface ISimplificationSettings {
  149276. /**
  149277. * Gets or sets the expected quality
  149278. */
  149279. quality: number;
  149280. /**
  149281. * Gets or sets the distance when this optimized version should be used
  149282. */
  149283. distance: number;
  149284. /**
  149285. * Gets an already optimized mesh
  149286. */
  149287. optimizeMesh?: boolean;
  149288. }
  149289. /**
  149290. * Class used to specify simplification options
  149291. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149292. */
  149293. export class SimplificationSettings implements ISimplificationSettings {
  149294. /** expected quality */
  149295. quality: number;
  149296. /** distance when this optimized version should be used */
  149297. distance: number;
  149298. /** already optimized mesh */
  149299. optimizeMesh?: boolean | undefined;
  149300. /**
  149301. * Creates a SimplificationSettings
  149302. * @param quality expected quality
  149303. * @param distance distance when this optimized version should be used
  149304. * @param optimizeMesh already optimized mesh
  149305. */
  149306. constructor(
  149307. /** expected quality */
  149308. quality: number,
  149309. /** distance when this optimized version should be used */
  149310. distance: number,
  149311. /** already optimized mesh */
  149312. optimizeMesh?: boolean | undefined);
  149313. }
  149314. /**
  149315. * Interface used to define a simplification task
  149316. */
  149317. export interface ISimplificationTask {
  149318. /**
  149319. * Array of settings
  149320. */
  149321. settings: Array<ISimplificationSettings>;
  149322. /**
  149323. * Simplification type
  149324. */
  149325. simplificationType: SimplificationType;
  149326. /**
  149327. * Mesh to simplify
  149328. */
  149329. mesh: Mesh;
  149330. /**
  149331. * Callback called on success
  149332. */
  149333. successCallback?: () => void;
  149334. /**
  149335. * Defines if parallel processing can be used
  149336. */
  149337. parallelProcessing: boolean;
  149338. }
  149339. /**
  149340. * Queue used to order the simplification tasks
  149341. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149342. */
  149343. export class SimplificationQueue {
  149344. private _simplificationArray;
  149345. /**
  149346. * Gets a boolean indicating that the process is still running
  149347. */
  149348. running: boolean;
  149349. /**
  149350. * Creates a new queue
  149351. */
  149352. constructor();
  149353. /**
  149354. * Adds a new simplification task
  149355. * @param task defines a task to add
  149356. */
  149357. addTask(task: ISimplificationTask): void;
  149358. /**
  149359. * Execute next task
  149360. */
  149361. executeNext(): void;
  149362. /**
  149363. * Execute a simplification task
  149364. * @param task defines the task to run
  149365. */
  149366. runSimplification(task: ISimplificationTask): void;
  149367. private getSimplifier;
  149368. }
  149369. /**
  149370. * The implemented types of simplification
  149371. * At the moment only Quadratic Error Decimation is implemented
  149372. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149373. */
  149374. export enum SimplificationType {
  149375. /** Quadratic error decimation */
  149376. QUADRATIC = 0
  149377. }
  149378. /**
  149379. * An implementation of the Quadratic Error simplification algorithm.
  149380. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  149381. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  149382. * @author RaananW
  149383. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149384. */
  149385. export class QuadraticErrorSimplification implements ISimplifier {
  149386. private _mesh;
  149387. private triangles;
  149388. private vertices;
  149389. private references;
  149390. private _reconstructedMesh;
  149391. /** Gets or sets the number pf sync interations */
  149392. syncIterations: number;
  149393. /** Gets or sets the aggressiveness of the simplifier */
  149394. aggressiveness: number;
  149395. /** Gets or sets the number of allowed iterations for decimation */
  149396. decimationIterations: number;
  149397. /** Gets or sets the espilon to use for bounding box computation */
  149398. boundingBoxEpsilon: number;
  149399. /**
  149400. * Creates a new QuadraticErrorSimplification
  149401. * @param _mesh defines the target mesh
  149402. */
  149403. constructor(_mesh: Mesh);
  149404. /**
  149405. * Simplification of a given mesh according to the given settings.
  149406. * Since this requires computation, it is assumed that the function runs async.
  149407. * @param settings The settings of the simplification, including quality and distance
  149408. * @param successCallback A callback that will be called after the mesh was simplified.
  149409. */
  149410. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  149411. private runDecimation;
  149412. private initWithMesh;
  149413. private init;
  149414. private reconstructMesh;
  149415. private initDecimatedMesh;
  149416. private isFlipped;
  149417. private updateTriangles;
  149418. private identifyBorder;
  149419. private updateMesh;
  149420. private vertexError;
  149421. private calculateError;
  149422. }
  149423. }
  149424. declare module BABYLON {
  149425. interface Scene {
  149426. /** @hidden (Backing field) */
  149427. _simplificationQueue: SimplificationQueue;
  149428. /**
  149429. * Gets or sets the simplification queue attached to the scene
  149430. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149431. */
  149432. simplificationQueue: SimplificationQueue;
  149433. }
  149434. interface Mesh {
  149435. /**
  149436. * Simplify the mesh according to the given array of settings.
  149437. * Function will return immediately and will simplify async
  149438. * @param settings a collection of simplification settings
  149439. * @param parallelProcessing should all levels calculate parallel or one after the other
  149440. * @param simplificationType the type of simplification to run
  149441. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  149442. * @returns the current mesh
  149443. */
  149444. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  149445. }
  149446. /**
  149447. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  149448. * created in a scene
  149449. */
  149450. export class SimplicationQueueSceneComponent implements ISceneComponent {
  149451. /**
  149452. * The component name helpfull to identify the component in the list of scene components.
  149453. */
  149454. readonly name: string;
  149455. /**
  149456. * The scene the component belongs to.
  149457. */
  149458. scene: Scene;
  149459. /**
  149460. * Creates a new instance of the component for the given scene
  149461. * @param scene Defines the scene to register the component in
  149462. */
  149463. constructor(scene: Scene);
  149464. /**
  149465. * Registers the component in a given scene
  149466. */
  149467. register(): void;
  149468. /**
  149469. * Rebuilds the elements related to this component in case of
  149470. * context lost for instance.
  149471. */
  149472. rebuild(): void;
  149473. /**
  149474. * Disposes the component and the associated ressources
  149475. */
  149476. dispose(): void;
  149477. private _beforeCameraUpdate;
  149478. }
  149479. }
  149480. declare module BABYLON {
  149481. interface Mesh {
  149482. /**
  149483. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  149484. */
  149485. thinInstanceEnablePicking: boolean;
  149486. /**
  149487. * Creates a new thin instance
  149488. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  149489. * @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
  149490. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  149491. */
  149492. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  149493. /**
  149494. * Adds the transformation (matrix) of the current mesh as a thin instance
  149495. * @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
  149496. * @returns the thin instance index number
  149497. */
  149498. thinInstanceAddSelf(refresh: boolean): number;
  149499. /**
  149500. * Registers a custom attribute to be used with thin instances
  149501. * @param kind name of the attribute
  149502. * @param stride size in floats of the attribute
  149503. */
  149504. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  149505. /**
  149506. * Sets the matrix of a thin instance
  149507. * @param index index of the thin instance
  149508. * @param matrix matrix to set
  149509. * @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
  149510. */
  149511. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  149512. /**
  149513. * Sets the value of a custom attribute for a thin instance
  149514. * @param kind name of the attribute
  149515. * @param index index of the thin instance
  149516. * @param value value to set
  149517. * @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
  149518. */
  149519. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  149520. /**
  149521. * 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.
  149522. */
  149523. thinInstanceCount: number;
  149524. /**
  149525. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  149526. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  149527. * @param buffer buffer to set
  149528. * @param stride size in floats of each value of the buffer
  149529. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  149530. */
  149531. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  149532. /**
  149533. * Gets the list of world matrices
  149534. * @return an array containing all the world matrices from the thin instances
  149535. */
  149536. thinInstanceGetWorldMatrices(): Matrix[];
  149537. /**
  149538. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  149539. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  149540. */
  149541. thinInstanceBufferUpdated(kind: string): void;
  149542. /**
  149543. * Applies a partial update to a buffer directly on the GPU
  149544. * 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
  149545. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  149546. * @param data the data to set in the GPU buffer
  149547. * @param offset the offset in the GPU buffer where to update the data
  149548. */
  149549. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  149550. /**
  149551. * Refreshes the bounding info, taking into account all the thin instances defined
  149552. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  149553. */
  149554. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  149555. /** @hidden */
  149556. _thinInstanceInitializeUserStorage(): void;
  149557. /** @hidden */
  149558. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  149559. /** @hidden */
  149560. _userThinInstanceBuffersStorage: {
  149561. data: {
  149562. [key: string]: Float32Array;
  149563. };
  149564. sizes: {
  149565. [key: string]: number;
  149566. };
  149567. vertexBuffers: {
  149568. [key: string]: Nullable<VertexBuffer>;
  149569. };
  149570. strides: {
  149571. [key: string]: number;
  149572. };
  149573. };
  149574. }
  149575. }
  149576. declare module BABYLON {
  149577. /**
  149578. * Navigation plugin interface to add navigation constrained by a navigation mesh
  149579. */
  149580. export interface INavigationEnginePlugin {
  149581. /**
  149582. * plugin name
  149583. */
  149584. name: string;
  149585. /**
  149586. * Creates a navigation mesh
  149587. * @param meshes array of all the geometry used to compute the navigatio mesh
  149588. * @param parameters bunch of parameters used to filter geometry
  149589. */
  149590. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  149591. /**
  149592. * Create a navigation mesh debug mesh
  149593. * @param scene is where the mesh will be added
  149594. * @returns debug display mesh
  149595. */
  149596. createDebugNavMesh(scene: Scene): Mesh;
  149597. /**
  149598. * Get a navigation mesh constrained position, closest to the parameter position
  149599. * @param position world position
  149600. * @returns the closest point to position constrained by the navigation mesh
  149601. */
  149602. getClosestPoint(position: Vector3): Vector3;
  149603. /**
  149604. * Get a navigation mesh constrained position, closest to the parameter position
  149605. * @param position world position
  149606. * @param result output the closest point to position constrained by the navigation mesh
  149607. */
  149608. getClosestPointToRef(position: Vector3, result: Vector3): void;
  149609. /**
  149610. * Get a navigation mesh constrained position, within a particular radius
  149611. * @param position world position
  149612. * @param maxRadius the maximum distance to the constrained world position
  149613. * @returns the closest point to position constrained by the navigation mesh
  149614. */
  149615. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  149616. /**
  149617. * Get a navigation mesh constrained position, within a particular radius
  149618. * @param position world position
  149619. * @param maxRadius the maximum distance to the constrained world position
  149620. * @param result output the closest point to position constrained by the navigation mesh
  149621. */
  149622. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  149623. /**
  149624. * Compute the final position from a segment made of destination-position
  149625. * @param position world position
  149626. * @param destination world position
  149627. * @returns the resulting point along the navmesh
  149628. */
  149629. moveAlong(position: Vector3, destination: Vector3): Vector3;
  149630. /**
  149631. * Compute the final position from a segment made of destination-position
  149632. * @param position world position
  149633. * @param destination world position
  149634. * @param result output the resulting point along the navmesh
  149635. */
  149636. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  149637. /**
  149638. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  149639. * @param start world position
  149640. * @param end world position
  149641. * @returns array containing world position composing the path
  149642. */
  149643. computePath(start: Vector3, end: Vector3): Vector3[];
  149644. /**
  149645. * If this plugin is supported
  149646. * @returns true if plugin is supported
  149647. */
  149648. isSupported(): boolean;
  149649. /**
  149650. * Create a new Crowd so you can add agents
  149651. * @param maxAgents the maximum agent count in the crowd
  149652. * @param maxAgentRadius the maximum radius an agent can have
  149653. * @param scene to attach the crowd to
  149654. * @returns the crowd you can add agents to
  149655. */
  149656. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  149657. /**
  149658. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149659. * The queries will try to find a solution within those bounds
  149660. * default is (1,1,1)
  149661. * @param extent x,y,z value that define the extent around the queries point of reference
  149662. */
  149663. setDefaultQueryExtent(extent: Vector3): void;
  149664. /**
  149665. * Get the Bounding box extent specified by setDefaultQueryExtent
  149666. * @returns the box extent values
  149667. */
  149668. getDefaultQueryExtent(): Vector3;
  149669. /**
  149670. * build the navmesh from a previously saved state using getNavmeshData
  149671. * @param data the Uint8Array returned by getNavmeshData
  149672. */
  149673. buildFromNavmeshData(data: Uint8Array): void;
  149674. /**
  149675. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  149676. * @returns data the Uint8Array that can be saved and reused
  149677. */
  149678. getNavmeshData(): Uint8Array;
  149679. /**
  149680. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149681. * @param result output the box extent values
  149682. */
  149683. getDefaultQueryExtentToRef(result: Vector3): void;
  149684. /**
  149685. * Release all resources
  149686. */
  149687. dispose(): void;
  149688. }
  149689. /**
  149690. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  149691. */
  149692. export interface ICrowd {
  149693. /**
  149694. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  149695. * You can attach anything to that node. The node position is updated in the scene update tick.
  149696. * @param pos world position that will be constrained by the navigation mesh
  149697. * @param parameters agent parameters
  149698. * @param transform hooked to the agent that will be update by the scene
  149699. * @returns agent index
  149700. */
  149701. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  149702. /**
  149703. * Returns the agent position in world space
  149704. * @param index agent index returned by addAgent
  149705. * @returns world space position
  149706. */
  149707. getAgentPosition(index: number): Vector3;
  149708. /**
  149709. * Gets the agent position result in world space
  149710. * @param index agent index returned by addAgent
  149711. * @param result output world space position
  149712. */
  149713. getAgentPositionToRef(index: number, result: Vector3): void;
  149714. /**
  149715. * Gets the agent velocity in world space
  149716. * @param index agent index returned by addAgent
  149717. * @returns world space velocity
  149718. */
  149719. getAgentVelocity(index: number): Vector3;
  149720. /**
  149721. * Gets the agent velocity result in world space
  149722. * @param index agent index returned by addAgent
  149723. * @param result output world space velocity
  149724. */
  149725. getAgentVelocityToRef(index: number, result: Vector3): void;
  149726. /**
  149727. * Gets the agent next target point on the path
  149728. * @param index agent index returned by addAgent
  149729. * @returns world space position
  149730. */
  149731. getAgentNextTargetPath(index: number): Vector3;
  149732. /**
  149733. * Gets the agent state
  149734. * @param index agent index returned by addAgent
  149735. * @returns agent state
  149736. */
  149737. getAgentState(index: number): number;
  149738. /**
  149739. * returns true if the agent in over an off mesh link connection
  149740. * @param index agent index returned by addAgent
  149741. * @returns true if over an off mesh link connection
  149742. */
  149743. overOffmeshConnection(index: number): boolean;
  149744. /**
  149745. * Gets the agent next target point on the path
  149746. * @param index agent index returned by addAgent
  149747. * @param result output world space position
  149748. */
  149749. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  149750. /**
  149751. * remove a particular agent previously created
  149752. * @param index agent index returned by addAgent
  149753. */
  149754. removeAgent(index: number): void;
  149755. /**
  149756. * get the list of all agents attached to this crowd
  149757. * @returns list of agent indices
  149758. */
  149759. getAgents(): number[];
  149760. /**
  149761. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  149762. * @param deltaTime in seconds
  149763. */
  149764. update(deltaTime: number): void;
  149765. /**
  149766. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  149767. * @param index agent index returned by addAgent
  149768. * @param destination targeted world position
  149769. */
  149770. agentGoto(index: number, destination: Vector3): void;
  149771. /**
  149772. * Teleport the agent to a new position
  149773. * @param index agent index returned by addAgent
  149774. * @param destination targeted world position
  149775. */
  149776. agentTeleport(index: number, destination: Vector3): void;
  149777. /**
  149778. * Update agent parameters
  149779. * @param index agent index returned by addAgent
  149780. * @param parameters agent parameters
  149781. */
  149782. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  149783. /**
  149784. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149785. * The queries will try to find a solution within those bounds
  149786. * default is (1,1,1)
  149787. * @param extent x,y,z value that define the extent around the queries point of reference
  149788. */
  149789. setDefaultQueryExtent(extent: Vector3): void;
  149790. /**
  149791. * Get the Bounding box extent specified by setDefaultQueryExtent
  149792. * @returns the box extent values
  149793. */
  149794. getDefaultQueryExtent(): Vector3;
  149795. /**
  149796. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149797. * @param result output the box extent values
  149798. */
  149799. getDefaultQueryExtentToRef(result: Vector3): void;
  149800. /**
  149801. * Release all resources
  149802. */
  149803. dispose(): void;
  149804. }
  149805. /**
  149806. * Configures an agent
  149807. */
  149808. export interface IAgentParameters {
  149809. /**
  149810. * Agent radius. [Limit: >= 0]
  149811. */
  149812. radius: number;
  149813. /**
  149814. * Agent height. [Limit: > 0]
  149815. */
  149816. height: number;
  149817. /**
  149818. * Maximum allowed acceleration. [Limit: >= 0]
  149819. */
  149820. maxAcceleration: number;
  149821. /**
  149822. * Maximum allowed speed. [Limit: >= 0]
  149823. */
  149824. maxSpeed: number;
  149825. /**
  149826. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  149827. */
  149828. collisionQueryRange: number;
  149829. /**
  149830. * The path visibility optimization range. [Limit: > 0]
  149831. */
  149832. pathOptimizationRange: number;
  149833. /**
  149834. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  149835. */
  149836. separationWeight: number;
  149837. }
  149838. /**
  149839. * Configures the navigation mesh creation
  149840. */
  149841. export interface INavMeshParameters {
  149842. /**
  149843. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  149844. */
  149845. cs: number;
  149846. /**
  149847. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  149848. */
  149849. ch: number;
  149850. /**
  149851. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  149852. */
  149853. walkableSlopeAngle: number;
  149854. /**
  149855. * Minimum floor to 'ceiling' height that will still allow the floor area to
  149856. * be considered walkable. [Limit: >= 3] [Units: vx]
  149857. */
  149858. walkableHeight: number;
  149859. /**
  149860. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  149861. */
  149862. walkableClimb: number;
  149863. /**
  149864. * The distance to erode/shrink the walkable area of the heightfield away from
  149865. * obstructions. [Limit: >=0] [Units: vx]
  149866. */
  149867. walkableRadius: number;
  149868. /**
  149869. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  149870. */
  149871. maxEdgeLen: number;
  149872. /**
  149873. * The maximum distance a simplfied contour's border edges should deviate
  149874. * the original raw contour. [Limit: >=0] [Units: vx]
  149875. */
  149876. maxSimplificationError: number;
  149877. /**
  149878. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  149879. */
  149880. minRegionArea: number;
  149881. /**
  149882. * Any regions with a span count smaller than this value will, if possible,
  149883. * be merged with larger regions. [Limit: >=0] [Units: vx]
  149884. */
  149885. mergeRegionArea: number;
  149886. /**
  149887. * The maximum number of vertices allowed for polygons generated during the
  149888. * contour to polygon conversion process. [Limit: >= 3]
  149889. */
  149890. maxVertsPerPoly: number;
  149891. /**
  149892. * Sets the sampling distance to use when generating the detail mesh.
  149893. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  149894. */
  149895. detailSampleDist: number;
  149896. /**
  149897. * The maximum distance the detail mesh surface should deviate from heightfield
  149898. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  149899. */
  149900. detailSampleMaxError: number;
  149901. }
  149902. }
  149903. declare module BABYLON {
  149904. /**
  149905. * RecastJS navigation plugin
  149906. */
  149907. export class RecastJSPlugin implements INavigationEnginePlugin {
  149908. /**
  149909. * Reference to the Recast library
  149910. */
  149911. bjsRECAST: any;
  149912. /**
  149913. * plugin name
  149914. */
  149915. name: string;
  149916. /**
  149917. * the first navmesh created. We might extend this to support multiple navmeshes
  149918. */
  149919. navMesh: any;
  149920. /**
  149921. * Initializes the recastJS plugin
  149922. * @param recastInjection can be used to inject your own recast reference
  149923. */
  149924. constructor(recastInjection?: any);
  149925. /**
  149926. * Creates a navigation mesh
  149927. * @param meshes array of all the geometry used to compute the navigatio mesh
  149928. * @param parameters bunch of parameters used to filter geometry
  149929. */
  149930. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  149931. /**
  149932. * Create a navigation mesh debug mesh
  149933. * @param scene is where the mesh will be added
  149934. * @returns debug display mesh
  149935. */
  149936. createDebugNavMesh(scene: Scene): Mesh;
  149937. /**
  149938. * Get a navigation mesh constrained position, closest to the parameter position
  149939. * @param position world position
  149940. * @returns the closest point to position constrained by the navigation mesh
  149941. */
  149942. getClosestPoint(position: Vector3): Vector3;
  149943. /**
  149944. * Get a navigation mesh constrained position, closest to the parameter position
  149945. * @param position world position
  149946. * @param result output the closest point to position constrained by the navigation mesh
  149947. */
  149948. getClosestPointToRef(position: Vector3, result: Vector3): void;
  149949. /**
  149950. * Get a navigation mesh constrained position, within a particular radius
  149951. * @param position world position
  149952. * @param maxRadius the maximum distance to the constrained world position
  149953. * @returns the closest point to position constrained by the navigation mesh
  149954. */
  149955. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  149956. /**
  149957. * Get a navigation mesh constrained position, within a particular radius
  149958. * @param position world position
  149959. * @param maxRadius the maximum distance to the constrained world position
  149960. * @param result output the closest point to position constrained by the navigation mesh
  149961. */
  149962. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  149963. /**
  149964. * Compute the final position from a segment made of destination-position
  149965. * @param position world position
  149966. * @param destination world position
  149967. * @returns the resulting point along the navmesh
  149968. */
  149969. moveAlong(position: Vector3, destination: Vector3): Vector3;
  149970. /**
  149971. * Compute the final position from a segment made of destination-position
  149972. * @param position world position
  149973. * @param destination world position
  149974. * @param result output the resulting point along the navmesh
  149975. */
  149976. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  149977. /**
  149978. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  149979. * @param start world position
  149980. * @param end world position
  149981. * @returns array containing world position composing the path
  149982. */
  149983. computePath(start: Vector3, end: Vector3): Vector3[];
  149984. /**
  149985. * Create a new Crowd so you can add agents
  149986. * @param maxAgents the maximum agent count in the crowd
  149987. * @param maxAgentRadius the maximum radius an agent can have
  149988. * @param scene to attach the crowd to
  149989. * @returns the crowd you can add agents to
  149990. */
  149991. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  149992. /**
  149993. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149994. * The queries will try to find a solution within those bounds
  149995. * default is (1,1,1)
  149996. * @param extent x,y,z value that define the extent around the queries point of reference
  149997. */
  149998. setDefaultQueryExtent(extent: Vector3): void;
  149999. /**
  150000. * Get the Bounding box extent specified by setDefaultQueryExtent
  150001. * @returns the box extent values
  150002. */
  150003. getDefaultQueryExtent(): Vector3;
  150004. /**
  150005. * build the navmesh from a previously saved state using getNavmeshData
  150006. * @param data the Uint8Array returned by getNavmeshData
  150007. */
  150008. buildFromNavmeshData(data: Uint8Array): void;
  150009. /**
  150010. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  150011. * @returns data the Uint8Array that can be saved and reused
  150012. */
  150013. getNavmeshData(): Uint8Array;
  150014. /**
  150015. * Get the Bounding box extent result specified by setDefaultQueryExtent
  150016. * @param result output the box extent values
  150017. */
  150018. getDefaultQueryExtentToRef(result: Vector3): void;
  150019. /**
  150020. * Disposes
  150021. */
  150022. dispose(): void;
  150023. /**
  150024. * If this plugin is supported
  150025. * @returns true if plugin is supported
  150026. */
  150027. isSupported(): boolean;
  150028. }
  150029. /**
  150030. * Recast detour crowd implementation
  150031. */
  150032. export class RecastJSCrowd implements ICrowd {
  150033. /**
  150034. * Recast/detour plugin
  150035. */
  150036. bjsRECASTPlugin: RecastJSPlugin;
  150037. /**
  150038. * Link to the detour crowd
  150039. */
  150040. recastCrowd: any;
  150041. /**
  150042. * One transform per agent
  150043. */
  150044. transforms: TransformNode[];
  150045. /**
  150046. * All agents created
  150047. */
  150048. agents: number[];
  150049. /**
  150050. * Link to the scene is kept to unregister the crowd from the scene
  150051. */
  150052. private _scene;
  150053. /**
  150054. * Observer for crowd updates
  150055. */
  150056. private _onBeforeAnimationsObserver;
  150057. /**
  150058. * Constructor
  150059. * @param plugin recastJS plugin
  150060. * @param maxAgents the maximum agent count in the crowd
  150061. * @param maxAgentRadius the maximum radius an agent can have
  150062. * @param scene to attach the crowd to
  150063. * @returns the crowd you can add agents to
  150064. */
  150065. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  150066. /**
  150067. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  150068. * You can attach anything to that node. The node position is updated in the scene update tick.
  150069. * @param pos world position that will be constrained by the navigation mesh
  150070. * @param parameters agent parameters
  150071. * @param transform hooked to the agent that will be update by the scene
  150072. * @returns agent index
  150073. */
  150074. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  150075. /**
  150076. * Returns the agent position in world space
  150077. * @param index agent index returned by addAgent
  150078. * @returns world space position
  150079. */
  150080. getAgentPosition(index: number): Vector3;
  150081. /**
  150082. * Returns the agent position result in world space
  150083. * @param index agent index returned by addAgent
  150084. * @param result output world space position
  150085. */
  150086. getAgentPositionToRef(index: number, result: Vector3): void;
  150087. /**
  150088. * Returns the agent velocity in world space
  150089. * @param index agent index returned by addAgent
  150090. * @returns world space velocity
  150091. */
  150092. getAgentVelocity(index: number): Vector3;
  150093. /**
  150094. * Returns the agent velocity result in world space
  150095. * @param index agent index returned by addAgent
  150096. * @param result output world space velocity
  150097. */
  150098. getAgentVelocityToRef(index: number, result: Vector3): void;
  150099. /**
  150100. * Returns the agent next target point on the path
  150101. * @param index agent index returned by addAgent
  150102. * @returns world space position
  150103. */
  150104. getAgentNextTargetPath(index: number): Vector3;
  150105. /**
  150106. * Returns the agent next target point on the path
  150107. * @param index agent index returned by addAgent
  150108. * @param result output world space position
  150109. */
  150110. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  150111. /**
  150112. * Gets the agent state
  150113. * @param index agent index returned by addAgent
  150114. * @returns agent state
  150115. */
  150116. getAgentState(index: number): number;
  150117. /**
  150118. * returns true if the agent in over an off mesh link connection
  150119. * @param index agent index returned by addAgent
  150120. * @returns true if over an off mesh link connection
  150121. */
  150122. overOffmeshConnection(index: number): boolean;
  150123. /**
  150124. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  150125. * @param index agent index returned by addAgent
  150126. * @param destination targeted world position
  150127. */
  150128. agentGoto(index: number, destination: Vector3): void;
  150129. /**
  150130. * Teleport the agent to a new position
  150131. * @param index agent index returned by addAgent
  150132. * @param destination targeted world position
  150133. */
  150134. agentTeleport(index: number, destination: Vector3): void;
  150135. /**
  150136. * Update agent parameters
  150137. * @param index agent index returned by addAgent
  150138. * @param parameters agent parameters
  150139. */
  150140. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  150141. /**
  150142. * remove a particular agent previously created
  150143. * @param index agent index returned by addAgent
  150144. */
  150145. removeAgent(index: number): void;
  150146. /**
  150147. * get the list of all agents attached to this crowd
  150148. * @returns list of agent indices
  150149. */
  150150. getAgents(): number[];
  150151. /**
  150152. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  150153. * @param deltaTime in seconds
  150154. */
  150155. update(deltaTime: number): void;
  150156. /**
  150157. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  150158. * The queries will try to find a solution within those bounds
  150159. * default is (1,1,1)
  150160. * @param extent x,y,z value that define the extent around the queries point of reference
  150161. */
  150162. setDefaultQueryExtent(extent: Vector3): void;
  150163. /**
  150164. * Get the Bounding box extent specified by setDefaultQueryExtent
  150165. * @returns the box extent values
  150166. */
  150167. getDefaultQueryExtent(): Vector3;
  150168. /**
  150169. * Get the Bounding box extent result specified by setDefaultQueryExtent
  150170. * @param result output the box extent values
  150171. */
  150172. getDefaultQueryExtentToRef(result: Vector3): void;
  150173. /**
  150174. * Release all resources
  150175. */
  150176. dispose(): void;
  150177. }
  150178. }
  150179. declare module BABYLON {
  150180. /**
  150181. * Class used to enable access to IndexedDB
  150182. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  150183. */
  150184. export class Database implements IOfflineProvider {
  150185. private _callbackManifestChecked;
  150186. private _currentSceneUrl;
  150187. private _db;
  150188. private _enableSceneOffline;
  150189. private _enableTexturesOffline;
  150190. private _manifestVersionFound;
  150191. private _mustUpdateRessources;
  150192. private _hasReachedQuota;
  150193. private _isSupported;
  150194. private _idbFactory;
  150195. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  150196. private static IsUASupportingBlobStorage;
  150197. /**
  150198. * Gets a boolean indicating if Database storate is enabled (off by default)
  150199. */
  150200. static IDBStorageEnabled: boolean;
  150201. /**
  150202. * Gets a boolean indicating if scene must be saved in the database
  150203. */
  150204. get enableSceneOffline(): boolean;
  150205. /**
  150206. * Gets a boolean indicating if textures must be saved in the database
  150207. */
  150208. get enableTexturesOffline(): boolean;
  150209. /**
  150210. * Creates a new Database
  150211. * @param urlToScene defines the url to load the scene
  150212. * @param callbackManifestChecked defines the callback to use when manifest is checked
  150213. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  150214. */
  150215. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  150216. private static _ParseURL;
  150217. private static _ReturnFullUrlLocation;
  150218. private _checkManifestFile;
  150219. /**
  150220. * Open the database and make it available
  150221. * @param successCallback defines the callback to call on success
  150222. * @param errorCallback defines the callback to call on error
  150223. */
  150224. open(successCallback: () => void, errorCallback: () => void): void;
  150225. /**
  150226. * Loads an image from the database
  150227. * @param url defines the url to load from
  150228. * @param image defines the target DOM image
  150229. */
  150230. loadImage(url: string, image: HTMLImageElement): void;
  150231. private _loadImageFromDBAsync;
  150232. private _saveImageIntoDBAsync;
  150233. private _checkVersionFromDB;
  150234. private _loadVersionFromDBAsync;
  150235. private _saveVersionIntoDBAsync;
  150236. /**
  150237. * Loads a file from database
  150238. * @param url defines the URL to load from
  150239. * @param sceneLoaded defines a callback to call on success
  150240. * @param progressCallBack defines a callback to call when progress changed
  150241. * @param errorCallback defines a callback to call on error
  150242. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  150243. */
  150244. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  150245. private _loadFileAsync;
  150246. private _saveFileAsync;
  150247. /**
  150248. * Validates if xhr data is correct
  150249. * @param xhr defines the request to validate
  150250. * @param dataType defines the expected data type
  150251. * @returns true if data is correct
  150252. */
  150253. private static _ValidateXHRData;
  150254. }
  150255. }
  150256. declare module BABYLON {
  150257. /** @hidden */
  150258. export var gpuUpdateParticlesPixelShader: {
  150259. name: string;
  150260. shader: string;
  150261. };
  150262. }
  150263. declare module BABYLON {
  150264. /** @hidden */
  150265. export var gpuUpdateParticlesVertexShader: {
  150266. name: string;
  150267. shader: string;
  150268. };
  150269. }
  150270. declare module BABYLON {
  150271. /** @hidden */
  150272. export var clipPlaneFragmentDeclaration2: {
  150273. name: string;
  150274. shader: string;
  150275. };
  150276. }
  150277. declare module BABYLON {
  150278. /** @hidden */
  150279. export var gpuRenderParticlesPixelShader: {
  150280. name: string;
  150281. shader: string;
  150282. };
  150283. }
  150284. declare module BABYLON {
  150285. /** @hidden */
  150286. export var clipPlaneVertexDeclaration2: {
  150287. name: string;
  150288. shader: string;
  150289. };
  150290. }
  150291. declare module BABYLON {
  150292. /** @hidden */
  150293. export var gpuRenderParticlesVertexShader: {
  150294. name: string;
  150295. shader: string;
  150296. };
  150297. }
  150298. declare module BABYLON {
  150299. /**
  150300. * This represents a GPU particle system in Babylon
  150301. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  150302. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  150303. */
  150304. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  150305. /**
  150306. * The layer mask we are rendering the particles through.
  150307. */
  150308. layerMask: number;
  150309. private _capacity;
  150310. private _activeCount;
  150311. private _currentActiveCount;
  150312. private _accumulatedCount;
  150313. private _renderEffect;
  150314. private _updateEffect;
  150315. private _buffer0;
  150316. private _buffer1;
  150317. private _spriteBuffer;
  150318. private _updateVAO;
  150319. private _renderVAO;
  150320. private _targetIndex;
  150321. private _sourceBuffer;
  150322. private _targetBuffer;
  150323. private _currentRenderId;
  150324. private _started;
  150325. private _stopped;
  150326. private _timeDelta;
  150327. private _randomTexture;
  150328. private _randomTexture2;
  150329. private _attributesStrideSize;
  150330. private _updateEffectOptions;
  150331. private _randomTextureSize;
  150332. private _actualFrame;
  150333. private _customEffect;
  150334. private readonly _rawTextureWidth;
  150335. /**
  150336. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  150337. */
  150338. static get IsSupported(): boolean;
  150339. /**
  150340. * An event triggered when the system is disposed.
  150341. */
  150342. onDisposeObservable: Observable<IParticleSystem>;
  150343. /**
  150344. * An event triggered when the system is stopped
  150345. */
  150346. onStoppedObservable: Observable<IParticleSystem>;
  150347. /**
  150348. * Gets the maximum number of particles active at the same time.
  150349. * @returns The max number of active particles.
  150350. */
  150351. getCapacity(): number;
  150352. /**
  150353. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  150354. * to override the particles.
  150355. */
  150356. forceDepthWrite: boolean;
  150357. /**
  150358. * Gets or set the number of active particles
  150359. */
  150360. get activeParticleCount(): number;
  150361. set activeParticleCount(value: number);
  150362. private _preWarmDone;
  150363. /**
  150364. * Specifies if the particles are updated in emitter local space or world space.
  150365. */
  150366. isLocal: boolean;
  150367. /** Gets or sets a matrix to use to compute projection */
  150368. defaultProjectionMatrix: Matrix;
  150369. /**
  150370. * Is this system ready to be used/rendered
  150371. * @return true if the system is ready
  150372. */
  150373. isReady(): boolean;
  150374. /**
  150375. * Gets if the system has been started. (Note: this will still be true after stop is called)
  150376. * @returns True if it has been started, otherwise false.
  150377. */
  150378. isStarted(): boolean;
  150379. /**
  150380. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  150381. * @returns True if it has been stopped, otherwise false.
  150382. */
  150383. isStopped(): boolean;
  150384. /**
  150385. * Gets a boolean indicating that the system is stopping
  150386. * @returns true if the system is currently stopping
  150387. */
  150388. isStopping(): boolean;
  150389. /**
  150390. * Gets the number of particles active at the same time.
  150391. * @returns The number of active particles.
  150392. */
  150393. getActiveCount(): number;
  150394. /**
  150395. * Starts the particle system and begins to emit
  150396. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  150397. */
  150398. start(delay?: number): void;
  150399. /**
  150400. * Stops the particle system.
  150401. */
  150402. stop(): void;
  150403. /**
  150404. * Remove all active particles
  150405. */
  150406. reset(): void;
  150407. /**
  150408. * Returns the string "GPUParticleSystem"
  150409. * @returns a string containing the class name
  150410. */
  150411. getClassName(): string;
  150412. /**
  150413. * Gets the custom effect used to render the particles
  150414. * @param blendMode Blend mode for which the effect should be retrieved
  150415. * @returns The effect
  150416. */
  150417. getCustomEffect(blendMode?: number): Nullable<Effect>;
  150418. /**
  150419. * Sets the custom effect used to render the particles
  150420. * @param effect The effect to set
  150421. * @param blendMode Blend mode for which the effect should be set
  150422. */
  150423. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  150424. /** @hidden */
  150425. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  150426. /**
  150427. * Observable that will be called just before the particles are drawn
  150428. */
  150429. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  150430. /**
  150431. * Gets the name of the particle vertex shader
  150432. */
  150433. get vertexShaderName(): string;
  150434. private _colorGradientsTexture;
  150435. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  150436. /**
  150437. * Adds a new color gradient
  150438. * @param gradient defines the gradient to use (between 0 and 1)
  150439. * @param color1 defines the color to affect to the specified gradient
  150440. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  150441. * @returns the current particle system
  150442. */
  150443. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  150444. private _refreshColorGradient;
  150445. /** Force the system to rebuild all gradients that need to be resync */
  150446. forceRefreshGradients(): void;
  150447. /**
  150448. * Remove a specific color gradient
  150449. * @param gradient defines the gradient to remove
  150450. * @returns the current particle system
  150451. */
  150452. removeColorGradient(gradient: number): GPUParticleSystem;
  150453. private _angularSpeedGradientsTexture;
  150454. private _sizeGradientsTexture;
  150455. private _velocityGradientsTexture;
  150456. private _limitVelocityGradientsTexture;
  150457. private _dragGradientsTexture;
  150458. private _addFactorGradient;
  150459. /**
  150460. * Adds a new size gradient
  150461. * @param gradient defines the gradient to use (between 0 and 1)
  150462. * @param factor defines the size factor to affect to the specified gradient
  150463. * @returns the current particle system
  150464. */
  150465. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  150466. /**
  150467. * Remove a specific size gradient
  150468. * @param gradient defines the gradient to remove
  150469. * @returns the current particle system
  150470. */
  150471. removeSizeGradient(gradient: number): GPUParticleSystem;
  150472. private _refreshFactorGradient;
  150473. /**
  150474. * Adds a new angular speed gradient
  150475. * @param gradient defines the gradient to use (between 0 and 1)
  150476. * @param factor defines the angular speed to affect to the specified gradient
  150477. * @returns the current particle system
  150478. */
  150479. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  150480. /**
  150481. * Remove a specific angular speed gradient
  150482. * @param gradient defines the gradient to remove
  150483. * @returns the current particle system
  150484. */
  150485. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  150486. /**
  150487. * Adds a new velocity gradient
  150488. * @param gradient defines the gradient to use (between 0 and 1)
  150489. * @param factor defines the velocity to affect to the specified gradient
  150490. * @returns the current particle system
  150491. */
  150492. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  150493. /**
  150494. * Remove a specific velocity gradient
  150495. * @param gradient defines the gradient to remove
  150496. * @returns the current particle system
  150497. */
  150498. removeVelocityGradient(gradient: number): GPUParticleSystem;
  150499. /**
  150500. * Adds a new limit velocity gradient
  150501. * @param gradient defines the gradient to use (between 0 and 1)
  150502. * @param factor defines the limit velocity value to affect to the specified gradient
  150503. * @returns the current particle system
  150504. */
  150505. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  150506. /**
  150507. * Remove a specific limit velocity gradient
  150508. * @param gradient defines the gradient to remove
  150509. * @returns the current particle system
  150510. */
  150511. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  150512. /**
  150513. * Adds a new drag gradient
  150514. * @param gradient defines the gradient to use (between 0 and 1)
  150515. * @param factor defines the drag value to affect to the specified gradient
  150516. * @returns the current particle system
  150517. */
  150518. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  150519. /**
  150520. * Remove a specific drag gradient
  150521. * @param gradient defines the gradient to remove
  150522. * @returns the current particle system
  150523. */
  150524. removeDragGradient(gradient: number): GPUParticleSystem;
  150525. /**
  150526. * Not supported by GPUParticleSystem
  150527. * @param gradient defines the gradient to use (between 0 and 1)
  150528. * @param factor defines the emit rate value to affect to the specified gradient
  150529. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150530. * @returns the current particle system
  150531. */
  150532. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150533. /**
  150534. * Not supported by GPUParticleSystem
  150535. * @param gradient defines the gradient to remove
  150536. * @returns the current particle system
  150537. */
  150538. removeEmitRateGradient(gradient: number): IParticleSystem;
  150539. /**
  150540. * Not supported by GPUParticleSystem
  150541. * @param gradient defines the gradient to use (between 0 and 1)
  150542. * @param factor defines the start size value to affect to the specified gradient
  150543. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150544. * @returns the current particle system
  150545. */
  150546. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150547. /**
  150548. * Not supported by GPUParticleSystem
  150549. * @param gradient defines the gradient to remove
  150550. * @returns the current particle system
  150551. */
  150552. removeStartSizeGradient(gradient: number): IParticleSystem;
  150553. /**
  150554. * Not supported by GPUParticleSystem
  150555. * @param gradient defines the gradient to use (between 0 and 1)
  150556. * @param min defines the color remap minimal range
  150557. * @param max defines the color remap maximal range
  150558. * @returns the current particle system
  150559. */
  150560. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  150561. /**
  150562. * Not supported by GPUParticleSystem
  150563. * @param gradient defines the gradient to remove
  150564. * @returns the current particle system
  150565. */
  150566. removeColorRemapGradient(): IParticleSystem;
  150567. /**
  150568. * Not supported by GPUParticleSystem
  150569. * @param gradient defines the gradient to use (between 0 and 1)
  150570. * @param min defines the alpha remap minimal range
  150571. * @param max defines the alpha remap maximal range
  150572. * @returns the current particle system
  150573. */
  150574. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  150575. /**
  150576. * Not supported by GPUParticleSystem
  150577. * @param gradient defines the gradient to remove
  150578. * @returns the current particle system
  150579. */
  150580. removeAlphaRemapGradient(): IParticleSystem;
  150581. /**
  150582. * Not supported by GPUParticleSystem
  150583. * @param gradient defines the gradient to use (between 0 and 1)
  150584. * @param color defines the color to affect to the specified gradient
  150585. * @returns the current particle system
  150586. */
  150587. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  150588. /**
  150589. * Not supported by GPUParticleSystem
  150590. * @param gradient defines the gradient to remove
  150591. * @returns the current particle system
  150592. */
  150593. removeRampGradient(): IParticleSystem;
  150594. /**
  150595. * Not supported by GPUParticleSystem
  150596. * @returns the list of ramp gradients
  150597. */
  150598. getRampGradients(): Nullable<Array<Color3Gradient>>;
  150599. /**
  150600. * Not supported by GPUParticleSystem
  150601. * Gets or sets a boolean indicating that ramp gradients must be used
  150602. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  150603. */
  150604. get useRampGradients(): boolean;
  150605. set useRampGradients(value: boolean);
  150606. /**
  150607. * Not supported by GPUParticleSystem
  150608. * @param gradient defines the gradient to use (between 0 and 1)
  150609. * @param factor defines the life time factor to affect to the specified gradient
  150610. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150611. * @returns the current particle system
  150612. */
  150613. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150614. /**
  150615. * Not supported by GPUParticleSystem
  150616. * @param gradient defines the gradient to remove
  150617. * @returns the current particle system
  150618. */
  150619. removeLifeTimeGradient(gradient: number): IParticleSystem;
  150620. /**
  150621. * Instantiates a GPU particle system.
  150622. * 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.
  150623. * @param name The name of the particle system
  150624. * @param options The options used to create the system
  150625. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  150626. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  150627. * @param customEffect a custom effect used to change the way particles are rendered by default
  150628. */
  150629. constructor(name: string, options: Partial<{
  150630. capacity: number;
  150631. randomTextureSize: number;
  150632. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  150633. protected _reset(): void;
  150634. private _createUpdateVAO;
  150635. private _createRenderVAO;
  150636. private _initialize;
  150637. /** @hidden */
  150638. _recreateUpdateEffect(): void;
  150639. private _getEffect;
  150640. /**
  150641. * Fill the defines array according to the current settings of the particle system
  150642. * @param defines Array to be updated
  150643. * @param blendMode blend mode to take into account when updating the array
  150644. */
  150645. fillDefines(defines: Array<string>, blendMode?: number): void;
  150646. /**
  150647. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  150648. * @param uniforms Uniforms array to fill
  150649. * @param attributes Attributes array to fill
  150650. * @param samplers Samplers array to fill
  150651. */
  150652. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  150653. /** @hidden */
  150654. _recreateRenderEffect(): Effect;
  150655. /**
  150656. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  150657. * @param preWarm defines if we are in the pre-warmimg phase
  150658. */
  150659. animate(preWarm?: boolean): void;
  150660. private _createFactorGradientTexture;
  150661. private _createSizeGradientTexture;
  150662. private _createAngularSpeedGradientTexture;
  150663. private _createVelocityGradientTexture;
  150664. private _createLimitVelocityGradientTexture;
  150665. private _createDragGradientTexture;
  150666. private _createColorGradientTexture;
  150667. /**
  150668. * Renders the particle system in its current state
  150669. * @param preWarm defines if the system should only update the particles but not render them
  150670. * @returns the current number of particles
  150671. */
  150672. render(preWarm?: boolean): number;
  150673. /**
  150674. * Rebuilds the particle system
  150675. */
  150676. rebuild(): void;
  150677. private _releaseBuffers;
  150678. private _releaseVAOs;
  150679. /**
  150680. * Disposes the particle system and free the associated resources
  150681. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  150682. */
  150683. dispose(disposeTexture?: boolean): void;
  150684. /**
  150685. * Clones the particle system.
  150686. * @param name The name of the cloned object
  150687. * @param newEmitter The new emitter to use
  150688. * @returns the cloned particle system
  150689. */
  150690. clone(name: string, newEmitter: any): GPUParticleSystem;
  150691. /**
  150692. * Serializes the particle system to a JSON object
  150693. * @param serializeTexture defines if the texture must be serialized as well
  150694. * @returns the JSON object
  150695. */
  150696. serialize(serializeTexture?: boolean): any;
  150697. /**
  150698. * Parses a JSON object to create a GPU particle system.
  150699. * @param parsedParticleSystem The JSON object to parse
  150700. * @param sceneOrEngine The scene or the engine to create the particle system in
  150701. * @param rootUrl The root url to use to load external dependencies like texture
  150702. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  150703. * @returns the parsed GPU particle system
  150704. */
  150705. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  150706. }
  150707. }
  150708. declare module BABYLON {
  150709. /**
  150710. * Represents a set of particle systems working together to create a specific effect
  150711. */
  150712. export class ParticleSystemSet implements IDisposable {
  150713. /**
  150714. * Gets or sets base Assets URL
  150715. */
  150716. static BaseAssetsUrl: string;
  150717. private _emitterCreationOptions;
  150718. private _emitterNode;
  150719. /**
  150720. * Gets the particle system list
  150721. */
  150722. systems: IParticleSystem[];
  150723. /**
  150724. * Gets the emitter node used with this set
  150725. */
  150726. get emitterNode(): Nullable<TransformNode>;
  150727. /**
  150728. * Creates a new emitter mesh as a sphere
  150729. * @param options defines the options used to create the sphere
  150730. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  150731. * @param scene defines the hosting scene
  150732. */
  150733. setEmitterAsSphere(options: {
  150734. diameter: number;
  150735. segments: number;
  150736. color: Color3;
  150737. }, renderingGroupId: number, scene: Scene): void;
  150738. /**
  150739. * Starts all particle systems of the set
  150740. * @param emitter defines an optional mesh to use as emitter for the particle systems
  150741. */
  150742. start(emitter?: AbstractMesh): void;
  150743. /**
  150744. * Release all associated resources
  150745. */
  150746. dispose(): void;
  150747. /**
  150748. * Serialize the set into a JSON compatible object
  150749. * @param serializeTexture defines if the texture must be serialized as well
  150750. * @returns a JSON compatible representation of the set
  150751. */
  150752. serialize(serializeTexture?: boolean): any;
  150753. /**
  150754. * Parse a new ParticleSystemSet from a serialized source
  150755. * @param data defines a JSON compatible representation of the set
  150756. * @param scene defines the hosting scene
  150757. * @param gpu defines if we want GPU particles or CPU particles
  150758. * @returns a new ParticleSystemSet
  150759. */
  150760. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  150761. }
  150762. }
  150763. declare module BABYLON {
  150764. /**
  150765. * This class is made for on one-liner static method to help creating particle system set.
  150766. */
  150767. export class ParticleHelper {
  150768. /**
  150769. * Gets or sets base Assets URL
  150770. */
  150771. static BaseAssetsUrl: string;
  150772. /** Define the Url to load snippets */
  150773. static SnippetUrl: string;
  150774. /**
  150775. * Create a default particle system that you can tweak
  150776. * @param emitter defines the emitter to use
  150777. * @param capacity defines the system capacity (default is 500 particles)
  150778. * @param scene defines the hosting scene
  150779. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  150780. * @returns the new Particle system
  150781. */
  150782. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  150783. /**
  150784. * This is the main static method (one-liner) of this helper to create different particle systems
  150785. * @param type This string represents the type to the particle system to create
  150786. * @param scene The scene where the particle system should live
  150787. * @param gpu If the system will use gpu
  150788. * @returns the ParticleSystemSet created
  150789. */
  150790. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  150791. /**
  150792. * Static function used to export a particle system to a ParticleSystemSet variable.
  150793. * Please note that the emitter shape is not exported
  150794. * @param systems defines the particle systems to export
  150795. * @returns the created particle system set
  150796. */
  150797. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  150798. /**
  150799. * Creates a particle system from a snippet saved in a remote file
  150800. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  150801. * @param url defines the url to load from
  150802. * @param scene defines the hosting scene
  150803. * @param gpu If the system will use gpu
  150804. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  150805. * @returns a promise that will resolve to the new particle system
  150806. */
  150807. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  150808. /**
  150809. * Creates a particle system from a snippet saved by the particle system editor
  150810. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  150811. * @param scene defines the hosting scene
  150812. * @param gpu If the system will use gpu
  150813. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  150814. * @returns a promise that will resolve to the new particle system
  150815. */
  150816. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  150817. }
  150818. }
  150819. declare module BABYLON {
  150820. interface Engine {
  150821. /**
  150822. * Create an effect to use with particle systems.
  150823. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  150824. * the particle system for which you want to create a custom effect in the last parameter
  150825. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  150826. * @param uniformsNames defines a list of attribute names
  150827. * @param samplers defines an array of string used to represent textures
  150828. * @param defines defines the string containing the defines to use to compile the shaders
  150829. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  150830. * @param onCompiled defines a function to call when the effect creation is successful
  150831. * @param onError defines a function to call when the effect creation has failed
  150832. * @param particleSystem the particle system you want to create the effect for
  150833. * @returns the new Effect
  150834. */
  150835. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  150836. }
  150837. interface Mesh {
  150838. /**
  150839. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  150840. * @returns an array of IParticleSystem
  150841. */
  150842. getEmittedParticleSystems(): IParticleSystem[];
  150843. /**
  150844. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  150845. * @returns an array of IParticleSystem
  150846. */
  150847. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  150848. }
  150849. }
  150850. declare module BABYLON {
  150851. /** Defines the 4 color options */
  150852. export enum PointColor {
  150853. /** color value */
  150854. Color = 2,
  150855. /** uv value */
  150856. UV = 1,
  150857. /** random value */
  150858. Random = 0,
  150859. /** stated value */
  150860. Stated = 3
  150861. }
  150862. /**
  150863. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  150864. * 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.
  150865. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  150866. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  150867. *
  150868. * Full documentation here : TO BE ENTERED
  150869. */
  150870. export class PointsCloudSystem implements IDisposable {
  150871. /**
  150872. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  150873. * Example : var p = SPS.particles[i];
  150874. */
  150875. particles: CloudPoint[];
  150876. /**
  150877. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  150878. */
  150879. nbParticles: number;
  150880. /**
  150881. * This a counter for your own usage. It's not set by any SPS functions.
  150882. */
  150883. counter: number;
  150884. /**
  150885. * The PCS name. This name is also given to the underlying mesh.
  150886. */
  150887. name: string;
  150888. /**
  150889. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  150890. */
  150891. mesh: Mesh;
  150892. /**
  150893. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  150894. * Please read :
  150895. */
  150896. vars: any;
  150897. /**
  150898. * @hidden
  150899. */
  150900. _size: number;
  150901. private _scene;
  150902. private _promises;
  150903. private _positions;
  150904. private _indices;
  150905. private _normals;
  150906. private _colors;
  150907. private _uvs;
  150908. private _indices32;
  150909. private _positions32;
  150910. private _colors32;
  150911. private _uvs32;
  150912. private _updatable;
  150913. private _isVisibilityBoxLocked;
  150914. private _alwaysVisible;
  150915. private _groups;
  150916. private _groupCounter;
  150917. private _computeParticleColor;
  150918. private _computeParticleTexture;
  150919. private _computeParticleRotation;
  150920. private _computeBoundingBox;
  150921. private _isReady;
  150922. /**
  150923. * Creates a PCS (Points Cloud System) object
  150924. * @param name (String) is the PCS name, this will be the underlying mesh name
  150925. * @param pointSize (number) is the size for each point
  150926. * @param scene (Scene) is the scene in which the PCS is added
  150927. * @param options defines the options of the PCS e.g.
  150928. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  150929. */
  150930. constructor(name: string, pointSize: number, scene: Scene, options?: {
  150931. updatable?: boolean;
  150932. });
  150933. /**
  150934. * Builds the PCS underlying mesh. Returns a standard Mesh.
  150935. * If no points were added to the PCS, the returned mesh is just a single point.
  150936. * @returns a promise for the created mesh
  150937. */
  150938. buildMeshAsync(): Promise<Mesh>;
  150939. /**
  150940. * @hidden
  150941. */
  150942. private _buildMesh;
  150943. private _addParticle;
  150944. private _randomUnitVector;
  150945. private _getColorIndicesForCoord;
  150946. private _setPointsColorOrUV;
  150947. private _colorFromTexture;
  150948. private _calculateDensity;
  150949. /**
  150950. * Adds points to the PCS in random positions within a unit sphere
  150951. * @param nb (positive integer) the number of particles to be created from this model
  150952. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  150953. * @returns the number of groups in the system
  150954. */
  150955. addPoints(nb: number, pointFunction?: any): number;
  150956. /**
  150957. * Adds points to the PCS from the surface of the model shape
  150958. * @param mesh is any Mesh object that will be used as a surface model for the points
  150959. * @param nb (positive integer) the number of particles to be created from this model
  150960. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  150961. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  150962. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  150963. * @returns the number of groups in the system
  150964. */
  150965. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  150966. /**
  150967. * Adds points to the PCS inside the model shape
  150968. * @param mesh is any Mesh object that will be used as a surface model for the points
  150969. * @param nb (positive integer) the number of particles to be created from this model
  150970. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  150971. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  150972. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  150973. * @returns the number of groups in the system
  150974. */
  150975. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  150976. /**
  150977. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  150978. * This method calls `updateParticle()` for each particle of the SPS.
  150979. * For an animated SPS, it is usually called within the render loop.
  150980. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  150981. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  150982. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  150983. * @returns the PCS.
  150984. */
  150985. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  150986. /**
  150987. * Disposes the PCS.
  150988. */
  150989. dispose(): void;
  150990. /**
  150991. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  150992. * doc :
  150993. * @returns the PCS.
  150994. */
  150995. refreshVisibleSize(): PointsCloudSystem;
  150996. /**
  150997. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  150998. * @param size the size (float) of the visibility box
  150999. * note : this doesn't lock the PCS mesh bounding box.
  151000. * doc :
  151001. */
  151002. setVisibilityBox(size: number): void;
  151003. /**
  151004. * Gets whether the PCS is always visible or not
  151005. * doc :
  151006. */
  151007. get isAlwaysVisible(): boolean;
  151008. /**
  151009. * Sets the PCS as always visible or not
  151010. * doc :
  151011. */
  151012. set isAlwaysVisible(val: boolean);
  151013. /**
  151014. * Tells to `setParticles()` to compute the particle rotations or not
  151015. * Default value : false. The PCS is faster when it's set to false
  151016. * Note : particle rotations are only applied to parent particles
  151017. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  151018. */
  151019. set computeParticleRotation(val: boolean);
  151020. /**
  151021. * Tells to `setParticles()` to compute the particle colors or not.
  151022. * Default value : true. The PCS is faster when it's set to false.
  151023. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  151024. */
  151025. set computeParticleColor(val: boolean);
  151026. set computeParticleTexture(val: boolean);
  151027. /**
  151028. * Gets if `setParticles()` computes the particle colors or not.
  151029. * Default value : false. The PCS is faster when it's set to false.
  151030. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  151031. */
  151032. get computeParticleColor(): boolean;
  151033. /**
  151034. * Gets if `setParticles()` computes the particle textures or not.
  151035. * Default value : false. The PCS is faster when it's set to false.
  151036. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  151037. */
  151038. get computeParticleTexture(): boolean;
  151039. /**
  151040. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  151041. */
  151042. set computeBoundingBox(val: boolean);
  151043. /**
  151044. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  151045. */
  151046. get computeBoundingBox(): boolean;
  151047. /**
  151048. * This function does nothing. It may be overwritten to set all the particle first values.
  151049. * The PCS doesn't call this function, you may have to call it by your own.
  151050. * doc :
  151051. */
  151052. initParticles(): void;
  151053. /**
  151054. * This function does nothing. It may be overwritten to recycle a particle
  151055. * The PCS doesn't call this function, you can to call it
  151056. * doc :
  151057. * @param particle The particle to recycle
  151058. * @returns the recycled particle
  151059. */
  151060. recycleParticle(particle: CloudPoint): CloudPoint;
  151061. /**
  151062. * Updates a particle : this function should be overwritten by the user.
  151063. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  151064. * doc :
  151065. * @example : just set a particle position or velocity and recycle conditions
  151066. * @param particle The particle to update
  151067. * @returns the updated particle
  151068. */
  151069. updateParticle(particle: CloudPoint): CloudPoint;
  151070. /**
  151071. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  151072. * This does nothing and may be overwritten by the user.
  151073. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  151074. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  151075. * @param update the boolean update value actually passed to setParticles()
  151076. */
  151077. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  151078. /**
  151079. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  151080. * This will be passed three parameters.
  151081. * This does nothing and may be overwritten by the user.
  151082. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  151083. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  151084. * @param update the boolean update value actually passed to setParticles()
  151085. */
  151086. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  151087. }
  151088. }
  151089. declare module BABYLON {
  151090. /**
  151091. * Represents one particle of a points cloud system.
  151092. */
  151093. export class CloudPoint {
  151094. /**
  151095. * particle global index
  151096. */
  151097. idx: number;
  151098. /**
  151099. * The color of the particle
  151100. */
  151101. color: Nullable<Color4>;
  151102. /**
  151103. * The world space position of the particle.
  151104. */
  151105. position: Vector3;
  151106. /**
  151107. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  151108. */
  151109. rotation: Vector3;
  151110. /**
  151111. * The world space rotation quaternion of the particle.
  151112. */
  151113. rotationQuaternion: Nullable<Quaternion>;
  151114. /**
  151115. * The uv of the particle.
  151116. */
  151117. uv: Nullable<Vector2>;
  151118. /**
  151119. * The current speed of the particle.
  151120. */
  151121. velocity: Vector3;
  151122. /**
  151123. * The pivot point in the particle local space.
  151124. */
  151125. pivot: Vector3;
  151126. /**
  151127. * Must the particle be translated from its pivot point in its local space ?
  151128. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  151129. * Default : false
  151130. */
  151131. translateFromPivot: boolean;
  151132. /**
  151133. * Index of this particle in the global "positions" array (Internal use)
  151134. * @hidden
  151135. */
  151136. _pos: number;
  151137. /**
  151138. * @hidden Index of this particle in the global "indices" array (Internal use)
  151139. */
  151140. _ind: number;
  151141. /**
  151142. * Group this particle belongs to
  151143. */
  151144. _group: PointsGroup;
  151145. /**
  151146. * Group id of this particle
  151147. */
  151148. groupId: number;
  151149. /**
  151150. * Index of the particle in its group id (Internal use)
  151151. */
  151152. idxInGroup: number;
  151153. /**
  151154. * @hidden Particle BoundingInfo object (Internal use)
  151155. */
  151156. _boundingInfo: BoundingInfo;
  151157. /**
  151158. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  151159. */
  151160. _pcs: PointsCloudSystem;
  151161. /**
  151162. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  151163. */
  151164. _stillInvisible: boolean;
  151165. /**
  151166. * @hidden Last computed particle rotation matrix
  151167. */
  151168. _rotationMatrix: number[];
  151169. /**
  151170. * Parent particle Id, if any.
  151171. * Default null.
  151172. */
  151173. parentId: Nullable<number>;
  151174. /**
  151175. * @hidden Internal global position in the PCS.
  151176. */
  151177. _globalPosition: Vector3;
  151178. /**
  151179. * Creates a Point Cloud object.
  151180. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  151181. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  151182. * @param group (PointsGroup) is the group the particle belongs to
  151183. * @param groupId (integer) is the group identifier in the PCS.
  151184. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  151185. * @param pcs defines the PCS it is associated to
  151186. */
  151187. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  151188. /**
  151189. * get point size
  151190. */
  151191. get size(): Vector3;
  151192. /**
  151193. * Set point size
  151194. */
  151195. set size(scale: Vector3);
  151196. /**
  151197. * Legacy support, changed quaternion to rotationQuaternion
  151198. */
  151199. get quaternion(): Nullable<Quaternion>;
  151200. /**
  151201. * Legacy support, changed quaternion to rotationQuaternion
  151202. */
  151203. set quaternion(q: Nullable<Quaternion>);
  151204. /**
  151205. * Returns a boolean. True if the particle intersects a mesh, else false
  151206. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  151207. * @param target is the object (point or mesh) what the intersection is computed against
  151208. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  151209. * @returns true if it intersects
  151210. */
  151211. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  151212. /**
  151213. * get the rotation matrix of the particle
  151214. * @hidden
  151215. */
  151216. getRotationMatrix(m: Matrix): void;
  151217. }
  151218. /**
  151219. * Represents a group of points in a points cloud system
  151220. * * PCS internal tool, don't use it manually.
  151221. */
  151222. export class PointsGroup {
  151223. /**
  151224. * The group id
  151225. * @hidden
  151226. */
  151227. groupID: number;
  151228. /**
  151229. * image data for group (internal use)
  151230. * @hidden
  151231. */
  151232. _groupImageData: Nullable<ArrayBufferView>;
  151233. /**
  151234. * Image Width (internal use)
  151235. * @hidden
  151236. */
  151237. _groupImgWidth: number;
  151238. /**
  151239. * Image Height (internal use)
  151240. * @hidden
  151241. */
  151242. _groupImgHeight: number;
  151243. /**
  151244. * Custom position function (internal use)
  151245. * @hidden
  151246. */
  151247. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  151248. /**
  151249. * density per facet for surface points
  151250. * @hidden
  151251. */
  151252. _groupDensity: number[];
  151253. /**
  151254. * Only when points are colored by texture carries pointer to texture list array
  151255. * @hidden
  151256. */
  151257. _textureNb: number;
  151258. /**
  151259. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  151260. * PCS internal tool, don't use it manually.
  151261. * @hidden
  151262. */
  151263. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  151264. }
  151265. }
  151266. declare module BABYLON {
  151267. interface Scene {
  151268. /** @hidden (Backing field) */
  151269. _physicsEngine: Nullable<IPhysicsEngine>;
  151270. /** @hidden */
  151271. _physicsTimeAccumulator: number;
  151272. /**
  151273. * Gets the current physics engine
  151274. * @returns a IPhysicsEngine or null if none attached
  151275. */
  151276. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  151277. /**
  151278. * Enables physics to the current scene
  151279. * @param gravity defines the scene's gravity for the physics engine
  151280. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  151281. * @return a boolean indicating if the physics engine was initialized
  151282. */
  151283. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  151284. /**
  151285. * Disables and disposes the physics engine associated with the scene
  151286. */
  151287. disablePhysicsEngine(): void;
  151288. /**
  151289. * Gets a boolean indicating if there is an active physics engine
  151290. * @returns a boolean indicating if there is an active physics engine
  151291. */
  151292. isPhysicsEnabled(): boolean;
  151293. /**
  151294. * Deletes a physics compound impostor
  151295. * @param compound defines the compound to delete
  151296. */
  151297. deleteCompoundImpostor(compound: any): void;
  151298. /**
  151299. * An event triggered when physic simulation is about to be run
  151300. */
  151301. onBeforePhysicsObservable: Observable<Scene>;
  151302. /**
  151303. * An event triggered when physic simulation has been done
  151304. */
  151305. onAfterPhysicsObservable: Observable<Scene>;
  151306. }
  151307. interface AbstractMesh {
  151308. /** @hidden */
  151309. _physicsImpostor: Nullable<PhysicsImpostor>;
  151310. /**
  151311. * Gets or sets impostor used for physic simulation
  151312. * @see https://doc.babylonjs.com/features/physics_engine
  151313. */
  151314. physicsImpostor: Nullable<PhysicsImpostor>;
  151315. /**
  151316. * Gets the current physics impostor
  151317. * @see https://doc.babylonjs.com/features/physics_engine
  151318. * @returns a physics impostor or null
  151319. */
  151320. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  151321. /** Apply a physic impulse to the mesh
  151322. * @param force defines the force to apply
  151323. * @param contactPoint defines where to apply the force
  151324. * @returns the current mesh
  151325. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  151326. */
  151327. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  151328. /**
  151329. * Creates a physic joint between two meshes
  151330. * @param otherMesh defines the other mesh to use
  151331. * @param pivot1 defines the pivot to use on this mesh
  151332. * @param pivot2 defines the pivot to use on the other mesh
  151333. * @param options defines additional options (can be plugin dependent)
  151334. * @returns the current mesh
  151335. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  151336. */
  151337. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  151338. /** @hidden */
  151339. _disposePhysicsObserver: Nullable<Observer<Node>>;
  151340. }
  151341. /**
  151342. * Defines the physics engine scene component responsible to manage a physics engine
  151343. */
  151344. export class PhysicsEngineSceneComponent implements ISceneComponent {
  151345. /**
  151346. * The component name helpful to identify the component in the list of scene components.
  151347. */
  151348. readonly name: string;
  151349. /**
  151350. * The scene the component belongs to.
  151351. */
  151352. scene: Scene;
  151353. /**
  151354. * Creates a new instance of the component for the given scene
  151355. * @param scene Defines the scene to register the component in
  151356. */
  151357. constructor(scene: Scene);
  151358. /**
  151359. * Registers the component in a given scene
  151360. */
  151361. register(): void;
  151362. /**
  151363. * Rebuilds the elements related to this component in case of
  151364. * context lost for instance.
  151365. */
  151366. rebuild(): void;
  151367. /**
  151368. * Disposes the component and the associated ressources
  151369. */
  151370. dispose(): void;
  151371. }
  151372. }
  151373. declare module BABYLON {
  151374. /**
  151375. * A helper for physics simulations
  151376. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151377. */
  151378. export class PhysicsHelper {
  151379. private _scene;
  151380. private _physicsEngine;
  151381. /**
  151382. * Initializes the Physics helper
  151383. * @param scene Babylon.js scene
  151384. */
  151385. constructor(scene: Scene);
  151386. /**
  151387. * Applies a radial explosion impulse
  151388. * @param origin the origin of the explosion
  151389. * @param radiusOrEventOptions the radius or the options of radial explosion
  151390. * @param strength the explosion strength
  151391. * @param falloff possible options: Constant & Linear. Defaults to Constant
  151392. * @returns A physics radial explosion event, or null
  151393. */
  151394. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  151395. /**
  151396. * Applies a radial explosion force
  151397. * @param origin the origin of the explosion
  151398. * @param radiusOrEventOptions the radius or the options of radial explosion
  151399. * @param strength the explosion strength
  151400. * @param falloff possible options: Constant & Linear. Defaults to Constant
  151401. * @returns A physics radial explosion event, or null
  151402. */
  151403. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  151404. /**
  151405. * Creates a gravitational field
  151406. * @param origin the origin of the explosion
  151407. * @param radiusOrEventOptions the radius or the options of radial explosion
  151408. * @param strength the explosion strength
  151409. * @param falloff possible options: Constant & Linear. Defaults to Constant
  151410. * @returns A physics gravitational field event, or null
  151411. */
  151412. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  151413. /**
  151414. * Creates a physics updraft event
  151415. * @param origin the origin of the updraft
  151416. * @param radiusOrEventOptions the radius or the options of the updraft
  151417. * @param strength the strength of the updraft
  151418. * @param height the height of the updraft
  151419. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  151420. * @returns A physics updraft event, or null
  151421. */
  151422. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  151423. /**
  151424. * Creates a physics vortex event
  151425. * @param origin the of the vortex
  151426. * @param radiusOrEventOptions the radius or the options of the vortex
  151427. * @param strength the strength of the vortex
  151428. * @param height the height of the vortex
  151429. * @returns a Physics vortex event, or null
  151430. * A physics vortex event or null
  151431. */
  151432. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  151433. }
  151434. /**
  151435. * Represents a physics radial explosion event
  151436. */
  151437. class PhysicsRadialExplosionEvent {
  151438. private _scene;
  151439. private _options;
  151440. private _sphere;
  151441. private _dataFetched;
  151442. /**
  151443. * Initializes a radial explosioin event
  151444. * @param _scene BabylonJS scene
  151445. * @param _options The options for the vortex event
  151446. */
  151447. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  151448. /**
  151449. * Returns the data related to the radial explosion event (sphere).
  151450. * @returns The radial explosion event data
  151451. */
  151452. getData(): PhysicsRadialExplosionEventData;
  151453. /**
  151454. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  151455. * @param impostor A physics imposter
  151456. * @param origin the origin of the explosion
  151457. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  151458. */
  151459. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  151460. /**
  151461. * Triggers affecterd impostors callbacks
  151462. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  151463. */
  151464. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  151465. /**
  151466. * Disposes the sphere.
  151467. * @param force Specifies if the sphere should be disposed by force
  151468. */
  151469. dispose(force?: boolean): void;
  151470. /*** Helpers ***/
  151471. private _prepareSphere;
  151472. private _intersectsWithSphere;
  151473. }
  151474. /**
  151475. * Represents a gravitational field event
  151476. */
  151477. class PhysicsGravitationalFieldEvent {
  151478. private _physicsHelper;
  151479. private _scene;
  151480. private _origin;
  151481. private _options;
  151482. private _tickCallback;
  151483. private _sphere;
  151484. private _dataFetched;
  151485. /**
  151486. * Initializes the physics gravitational field event
  151487. * @param _physicsHelper A physics helper
  151488. * @param _scene BabylonJS scene
  151489. * @param _origin The origin position of the gravitational field event
  151490. * @param _options The options for the vortex event
  151491. */
  151492. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  151493. /**
  151494. * Returns the data related to the gravitational field event (sphere).
  151495. * @returns A gravitational field event
  151496. */
  151497. getData(): PhysicsGravitationalFieldEventData;
  151498. /**
  151499. * Enables the gravitational field.
  151500. */
  151501. enable(): void;
  151502. /**
  151503. * Disables the gravitational field.
  151504. */
  151505. disable(): void;
  151506. /**
  151507. * Disposes the sphere.
  151508. * @param force The force to dispose from the gravitational field event
  151509. */
  151510. dispose(force?: boolean): void;
  151511. private _tick;
  151512. }
  151513. /**
  151514. * Represents a physics updraft event
  151515. */
  151516. class PhysicsUpdraftEvent {
  151517. private _scene;
  151518. private _origin;
  151519. private _options;
  151520. private _physicsEngine;
  151521. private _originTop;
  151522. private _originDirection;
  151523. private _tickCallback;
  151524. private _cylinder;
  151525. private _cylinderPosition;
  151526. private _dataFetched;
  151527. /**
  151528. * Initializes the physics updraft event
  151529. * @param _scene BabylonJS scene
  151530. * @param _origin The origin position of the updraft
  151531. * @param _options The options for the updraft event
  151532. */
  151533. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  151534. /**
  151535. * Returns the data related to the updraft event (cylinder).
  151536. * @returns A physics updraft event
  151537. */
  151538. getData(): PhysicsUpdraftEventData;
  151539. /**
  151540. * Enables the updraft.
  151541. */
  151542. enable(): void;
  151543. /**
  151544. * Disables the updraft.
  151545. */
  151546. disable(): void;
  151547. /**
  151548. * Disposes the cylinder.
  151549. * @param force Specifies if the updraft should be disposed by force
  151550. */
  151551. dispose(force?: boolean): void;
  151552. private getImpostorHitData;
  151553. private _tick;
  151554. /*** Helpers ***/
  151555. private _prepareCylinder;
  151556. private _intersectsWithCylinder;
  151557. }
  151558. /**
  151559. * Represents a physics vortex event
  151560. */
  151561. class PhysicsVortexEvent {
  151562. private _scene;
  151563. private _origin;
  151564. private _options;
  151565. private _physicsEngine;
  151566. private _originTop;
  151567. private _tickCallback;
  151568. private _cylinder;
  151569. private _cylinderPosition;
  151570. private _dataFetched;
  151571. /**
  151572. * Initializes the physics vortex event
  151573. * @param _scene The BabylonJS scene
  151574. * @param _origin The origin position of the vortex
  151575. * @param _options The options for the vortex event
  151576. */
  151577. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  151578. /**
  151579. * Returns the data related to the vortex event (cylinder).
  151580. * @returns The physics vortex event data
  151581. */
  151582. getData(): PhysicsVortexEventData;
  151583. /**
  151584. * Enables the vortex.
  151585. */
  151586. enable(): void;
  151587. /**
  151588. * Disables the cortex.
  151589. */
  151590. disable(): void;
  151591. /**
  151592. * Disposes the sphere.
  151593. * @param force
  151594. */
  151595. dispose(force?: boolean): void;
  151596. private getImpostorHitData;
  151597. private _tick;
  151598. /*** Helpers ***/
  151599. private _prepareCylinder;
  151600. private _intersectsWithCylinder;
  151601. }
  151602. /**
  151603. * Options fot the radial explosion event
  151604. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151605. */
  151606. export class PhysicsRadialExplosionEventOptions {
  151607. /**
  151608. * The radius of the sphere for the radial explosion.
  151609. */
  151610. radius: number;
  151611. /**
  151612. * The strenth of the explosion.
  151613. */
  151614. strength: number;
  151615. /**
  151616. * The strenght of the force in correspondence to the distance of the affected object
  151617. */
  151618. falloff: PhysicsRadialImpulseFalloff;
  151619. /**
  151620. * Sphere options for the radial explosion.
  151621. */
  151622. sphere: {
  151623. segments: number;
  151624. diameter: number;
  151625. };
  151626. /**
  151627. * Sphere options for the radial explosion.
  151628. */
  151629. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  151630. }
  151631. /**
  151632. * Options fot the updraft event
  151633. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151634. */
  151635. export class PhysicsUpdraftEventOptions {
  151636. /**
  151637. * The radius of the cylinder for the vortex
  151638. */
  151639. radius: number;
  151640. /**
  151641. * The strenth of the updraft.
  151642. */
  151643. strength: number;
  151644. /**
  151645. * The height of the cylinder for the updraft.
  151646. */
  151647. height: number;
  151648. /**
  151649. * The mode for the the updraft.
  151650. */
  151651. updraftMode: PhysicsUpdraftMode;
  151652. }
  151653. /**
  151654. * Options fot the vortex event
  151655. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151656. */
  151657. export class PhysicsVortexEventOptions {
  151658. /**
  151659. * The radius of the cylinder for the vortex
  151660. */
  151661. radius: number;
  151662. /**
  151663. * The strenth of the vortex.
  151664. */
  151665. strength: number;
  151666. /**
  151667. * The height of the cylinder for the vortex.
  151668. */
  151669. height: number;
  151670. /**
  151671. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  151672. */
  151673. centripetalForceThreshold: number;
  151674. /**
  151675. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  151676. */
  151677. centripetalForceMultiplier: number;
  151678. /**
  151679. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  151680. */
  151681. centrifugalForceMultiplier: number;
  151682. /**
  151683. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  151684. */
  151685. updraftForceMultiplier: number;
  151686. }
  151687. /**
  151688. * The strenght of the force in correspondence to the distance of the affected object
  151689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151690. */
  151691. export enum PhysicsRadialImpulseFalloff {
  151692. /** Defines that impulse is constant in strength across it's whole radius */
  151693. Constant = 0,
  151694. /** Defines that impulse gets weaker if it's further from the origin */
  151695. Linear = 1
  151696. }
  151697. /**
  151698. * The strength of the force in correspondence to the distance of the affected object
  151699. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151700. */
  151701. export enum PhysicsUpdraftMode {
  151702. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  151703. Center = 0,
  151704. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  151705. Perpendicular = 1
  151706. }
  151707. /**
  151708. * Interface for a physics hit data
  151709. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151710. */
  151711. export interface PhysicsHitData {
  151712. /**
  151713. * The force applied at the contact point
  151714. */
  151715. force: Vector3;
  151716. /**
  151717. * The contact point
  151718. */
  151719. contactPoint: Vector3;
  151720. /**
  151721. * The distance from the origin to the contact point
  151722. */
  151723. distanceFromOrigin: number;
  151724. }
  151725. /**
  151726. * Interface for radial explosion event data
  151727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151728. */
  151729. export interface PhysicsRadialExplosionEventData {
  151730. /**
  151731. * A sphere used for the radial explosion event
  151732. */
  151733. sphere: Mesh;
  151734. }
  151735. /**
  151736. * Interface for gravitational field event data
  151737. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151738. */
  151739. export interface PhysicsGravitationalFieldEventData {
  151740. /**
  151741. * A sphere mesh used for the gravitational field event
  151742. */
  151743. sphere: Mesh;
  151744. }
  151745. /**
  151746. * Interface for updraft event data
  151747. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151748. */
  151749. export interface PhysicsUpdraftEventData {
  151750. /**
  151751. * A cylinder used for the updraft event
  151752. */
  151753. cylinder: Mesh;
  151754. }
  151755. /**
  151756. * Interface for vortex event data
  151757. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151758. */
  151759. export interface PhysicsVortexEventData {
  151760. /**
  151761. * A cylinder used for the vortex event
  151762. */
  151763. cylinder: Mesh;
  151764. }
  151765. /**
  151766. * Interface for an affected physics impostor
  151767. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151768. */
  151769. export interface PhysicsAffectedImpostorWithData {
  151770. /**
  151771. * The impostor affected by the effect
  151772. */
  151773. impostor: PhysicsImpostor;
  151774. /**
  151775. * The data about the hit/horce from the explosion
  151776. */
  151777. hitData: PhysicsHitData;
  151778. }
  151779. }
  151780. declare module BABYLON {
  151781. /** @hidden */
  151782. export var blackAndWhitePixelShader: {
  151783. name: string;
  151784. shader: string;
  151785. };
  151786. }
  151787. declare module BABYLON {
  151788. /**
  151789. * Post process used to render in black and white
  151790. */
  151791. export class BlackAndWhitePostProcess extends PostProcess {
  151792. /**
  151793. * Linear about to convert he result to black and white (default: 1)
  151794. */
  151795. degree: number;
  151796. /**
  151797. * Gets a string identifying the name of the class
  151798. * @returns "BlackAndWhitePostProcess" string
  151799. */
  151800. getClassName(): string;
  151801. /**
  151802. * Creates a black and white post process
  151803. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  151804. * @param name The name of the effect.
  151805. * @param options The required width/height ratio to downsize to before computing the render pass.
  151806. * @param camera The camera to apply the render pass to.
  151807. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151808. * @param engine The engine which the post process will be applied. (default: current engine)
  151809. * @param reusable If the post process can be reused on the same frame. (default: false)
  151810. */
  151811. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151812. /** @hidden */
  151813. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  151814. }
  151815. }
  151816. declare module BABYLON {
  151817. /**
  151818. * This represents a set of one or more post processes in Babylon.
  151819. * A post process can be used to apply a shader to a texture after it is rendered.
  151820. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151821. */
  151822. export class PostProcessRenderEffect {
  151823. private _postProcesses;
  151824. private _getPostProcesses;
  151825. private _singleInstance;
  151826. private _cameras;
  151827. private _indicesForCamera;
  151828. /**
  151829. * Name of the effect
  151830. * @hidden
  151831. */
  151832. _name: string;
  151833. /**
  151834. * Instantiates a post process render effect.
  151835. * A post process can be used to apply a shader to a texture after it is rendered.
  151836. * @param engine The engine the effect is tied to
  151837. * @param name The name of the effect
  151838. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  151839. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  151840. */
  151841. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  151842. /**
  151843. * Checks if all the post processes in the effect are supported.
  151844. */
  151845. get isSupported(): boolean;
  151846. /**
  151847. * Updates the current state of the effect
  151848. * @hidden
  151849. */
  151850. _update(): void;
  151851. /**
  151852. * Attaches the effect on cameras
  151853. * @param cameras The camera to attach to.
  151854. * @hidden
  151855. */
  151856. _attachCameras(cameras: Camera): void;
  151857. /**
  151858. * Attaches the effect on cameras
  151859. * @param cameras The camera to attach to.
  151860. * @hidden
  151861. */
  151862. _attachCameras(cameras: Camera[]): void;
  151863. /**
  151864. * Detaches the effect on cameras
  151865. * @param cameras The camera to detatch from.
  151866. * @hidden
  151867. */
  151868. _detachCameras(cameras: Camera): void;
  151869. /**
  151870. * Detatches the effect on cameras
  151871. * @param cameras The camera to detatch from.
  151872. * @hidden
  151873. */
  151874. _detachCameras(cameras: Camera[]): void;
  151875. /**
  151876. * Enables the effect on given cameras
  151877. * @param cameras The camera to enable.
  151878. * @hidden
  151879. */
  151880. _enable(cameras: Camera): void;
  151881. /**
  151882. * Enables the effect on given cameras
  151883. * @param cameras The camera to enable.
  151884. * @hidden
  151885. */
  151886. _enable(cameras: Nullable<Camera[]>): void;
  151887. /**
  151888. * Disables the effect on the given cameras
  151889. * @param cameras The camera to disable.
  151890. * @hidden
  151891. */
  151892. _disable(cameras: Camera): void;
  151893. /**
  151894. * Disables the effect on the given cameras
  151895. * @param cameras The camera to disable.
  151896. * @hidden
  151897. */
  151898. _disable(cameras: Nullable<Camera[]>): void;
  151899. /**
  151900. * Gets a list of the post processes contained in the effect.
  151901. * @param camera The camera to get the post processes on.
  151902. * @returns The list of the post processes in the effect.
  151903. */
  151904. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  151905. }
  151906. }
  151907. declare module BABYLON {
  151908. /** @hidden */
  151909. export var extractHighlightsPixelShader: {
  151910. name: string;
  151911. shader: string;
  151912. };
  151913. }
  151914. declare module BABYLON {
  151915. /**
  151916. * 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.
  151917. */
  151918. export class ExtractHighlightsPostProcess extends PostProcess {
  151919. /**
  151920. * The luminance threshold, pixels below this value will be set to black.
  151921. */
  151922. threshold: number;
  151923. /** @hidden */
  151924. _exposure: number;
  151925. /**
  151926. * Post process which has the input texture to be used when performing highlight extraction
  151927. * @hidden
  151928. */
  151929. _inputPostProcess: Nullable<PostProcess>;
  151930. /**
  151931. * Gets a string identifying the name of the class
  151932. * @returns "ExtractHighlightsPostProcess" string
  151933. */
  151934. getClassName(): string;
  151935. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151936. }
  151937. }
  151938. declare module BABYLON {
  151939. /** @hidden */
  151940. export var bloomMergePixelShader: {
  151941. name: string;
  151942. shader: string;
  151943. };
  151944. }
  151945. declare module BABYLON {
  151946. /**
  151947. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  151948. */
  151949. export class BloomMergePostProcess extends PostProcess {
  151950. /** Weight of the bloom to be added to the original input. */
  151951. weight: number;
  151952. /**
  151953. * Gets a string identifying the name of the class
  151954. * @returns "BloomMergePostProcess" string
  151955. */
  151956. getClassName(): string;
  151957. /**
  151958. * Creates a new instance of @see BloomMergePostProcess
  151959. * @param name The name of the effect.
  151960. * @param originalFromInput Post process which's input will be used for the merge.
  151961. * @param blurred Blurred highlights post process which's output will be used.
  151962. * @param weight Weight of the bloom to be added to the original input.
  151963. * @param options The required width/height ratio to downsize to before computing the render pass.
  151964. * @param camera The camera to apply the render pass to.
  151965. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151966. * @param engine The engine which the post process will be applied. (default: current engine)
  151967. * @param reusable If the post process can be reused on the same frame. (default: false)
  151968. * @param textureType Type of textures used when performing the post process. (default: 0)
  151969. * @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)
  151970. */
  151971. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  151972. /** Weight of the bloom to be added to the original input. */
  151973. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151974. }
  151975. }
  151976. declare module BABYLON {
  151977. /**
  151978. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  151979. */
  151980. export class BloomEffect extends PostProcessRenderEffect {
  151981. private bloomScale;
  151982. /**
  151983. * @hidden Internal
  151984. */
  151985. _effects: Array<PostProcess>;
  151986. /**
  151987. * @hidden Internal
  151988. */
  151989. _downscale: ExtractHighlightsPostProcess;
  151990. private _blurX;
  151991. private _blurY;
  151992. private _merge;
  151993. /**
  151994. * The luminance threshold to find bright areas of the image to bloom.
  151995. */
  151996. get threshold(): number;
  151997. set threshold(value: number);
  151998. /**
  151999. * The strength of the bloom.
  152000. */
  152001. get weight(): number;
  152002. set weight(value: number);
  152003. /**
  152004. * Specifies the size of the bloom blur kernel, relative to the final output size
  152005. */
  152006. get kernel(): number;
  152007. set kernel(value: number);
  152008. /**
  152009. * Creates a new instance of @see BloomEffect
  152010. * @param scene The scene the effect belongs to.
  152011. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  152012. * @param bloomKernel The size of the kernel to be used when applying the blur.
  152013. * @param bloomWeight The the strength of bloom.
  152014. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  152015. * @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)
  152016. */
  152017. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  152018. /**
  152019. * Disposes each of the internal effects for a given camera.
  152020. * @param camera The camera to dispose the effect on.
  152021. */
  152022. disposeEffects(camera: Camera): void;
  152023. /**
  152024. * @hidden Internal
  152025. */
  152026. _updateEffects(): void;
  152027. /**
  152028. * Internal
  152029. * @returns if all the contained post processes are ready.
  152030. * @hidden
  152031. */
  152032. _isReady(): boolean;
  152033. }
  152034. }
  152035. declare module BABYLON {
  152036. /** @hidden */
  152037. export var chromaticAberrationPixelShader: {
  152038. name: string;
  152039. shader: string;
  152040. };
  152041. }
  152042. declare module BABYLON {
  152043. /**
  152044. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  152045. */
  152046. export class ChromaticAberrationPostProcess extends PostProcess {
  152047. /**
  152048. * The amount of seperation of rgb channels (default: 30)
  152049. */
  152050. aberrationAmount: number;
  152051. /**
  152052. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  152053. */
  152054. radialIntensity: number;
  152055. /**
  152056. * 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))
  152057. */
  152058. direction: Vector2;
  152059. /**
  152060. * 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))
  152061. */
  152062. centerPosition: Vector2;
  152063. /** The width of the screen to apply the effect on */
  152064. screenWidth: number;
  152065. /** The height of the screen to apply the effect on */
  152066. screenHeight: number;
  152067. /**
  152068. * Gets a string identifying the name of the class
  152069. * @returns "ChromaticAberrationPostProcess" string
  152070. */
  152071. getClassName(): string;
  152072. /**
  152073. * Creates a new instance ChromaticAberrationPostProcess
  152074. * @param name The name of the effect.
  152075. * @param screenWidth The width of the screen to apply the effect on.
  152076. * @param screenHeight The height of the screen to apply the effect on.
  152077. * @param options The required width/height ratio to downsize to before computing the render pass.
  152078. * @param camera The camera to apply the render pass to.
  152079. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152080. * @param engine The engine which the post process will be applied. (default: current engine)
  152081. * @param reusable If the post process can be reused on the same frame. (default: false)
  152082. * @param textureType Type of textures used when performing the post process. (default: 0)
  152083. * @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)
  152084. */
  152085. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152086. /** @hidden */
  152087. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  152088. }
  152089. }
  152090. declare module BABYLON {
  152091. /** @hidden */
  152092. export var circleOfConfusionPixelShader: {
  152093. name: string;
  152094. shader: string;
  152095. };
  152096. }
  152097. declare module BABYLON {
  152098. /**
  152099. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  152100. */
  152101. export class CircleOfConfusionPostProcess extends PostProcess {
  152102. /**
  152103. * 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.
  152104. */
  152105. lensSize: number;
  152106. /**
  152107. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  152108. */
  152109. fStop: number;
  152110. /**
  152111. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  152112. */
  152113. focusDistance: number;
  152114. /**
  152115. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  152116. */
  152117. focalLength: number;
  152118. /**
  152119. * Gets a string identifying the name of the class
  152120. * @returns "CircleOfConfusionPostProcess" string
  152121. */
  152122. getClassName(): string;
  152123. private _depthTexture;
  152124. /**
  152125. * Creates a new instance CircleOfConfusionPostProcess
  152126. * @param name The name of the effect.
  152127. * @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.
  152128. * @param options The required width/height ratio to downsize to before computing the render pass.
  152129. * @param camera The camera to apply the render pass to.
  152130. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152131. * @param engine The engine which the post process will be applied. (default: current engine)
  152132. * @param reusable If the post process can be reused on the same frame. (default: false)
  152133. * @param textureType Type of textures used when performing the post process. (default: 0)
  152134. * @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)
  152135. */
  152136. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152137. /**
  152138. * 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.
  152139. */
  152140. set depthTexture(value: RenderTargetTexture);
  152141. }
  152142. }
  152143. declare module BABYLON {
  152144. /** @hidden */
  152145. export var colorCorrectionPixelShader: {
  152146. name: string;
  152147. shader: string;
  152148. };
  152149. }
  152150. declare module BABYLON {
  152151. /**
  152152. *
  152153. * This post-process allows the modification of rendered colors by using
  152154. * a 'look-up table' (LUT). This effect is also called Color Grading.
  152155. *
  152156. * The object needs to be provided an url to a texture containing the color
  152157. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  152158. * Use an image editing software to tweak the LUT to match your needs.
  152159. *
  152160. * For an example of a color LUT, see here:
  152161. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  152162. * For explanations on color grading, see here:
  152163. * @see http://udn.epicgames.com/Three/ColorGrading.html
  152164. *
  152165. */
  152166. export class ColorCorrectionPostProcess extends PostProcess {
  152167. private _colorTableTexture;
  152168. /**
  152169. * Gets the color table url used to create the LUT texture
  152170. */
  152171. colorTableUrl: string;
  152172. /**
  152173. * Gets a string identifying the name of the class
  152174. * @returns "ColorCorrectionPostProcess" string
  152175. */
  152176. getClassName(): string;
  152177. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152178. /** @hidden */
  152179. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  152180. }
  152181. }
  152182. declare module BABYLON {
  152183. /** @hidden */
  152184. export var convolutionPixelShader: {
  152185. name: string;
  152186. shader: string;
  152187. };
  152188. }
  152189. declare module BABYLON {
  152190. /**
  152191. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  152192. * input texture to perform effects such as edge detection or sharpening
  152193. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  152194. */
  152195. export class ConvolutionPostProcess extends PostProcess {
  152196. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  152197. kernel: number[];
  152198. /**
  152199. * Gets a string identifying the name of the class
  152200. * @returns "ConvolutionPostProcess" string
  152201. */
  152202. getClassName(): string;
  152203. /**
  152204. * Creates a new instance ConvolutionPostProcess
  152205. * @param name The name of the effect.
  152206. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  152207. * @param options The required width/height ratio to downsize to before computing the render pass.
  152208. * @param camera The camera to apply the render pass to.
  152209. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152210. * @param engine The engine which the post process will be applied. (default: current engine)
  152211. * @param reusable If the post process can be reused on the same frame. (default: false)
  152212. * @param textureType Type of textures used when performing the post process. (default: 0)
  152213. */
  152214. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152215. /** @hidden */
  152216. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  152217. /**
  152218. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152219. */
  152220. static EdgeDetect0Kernel: number[];
  152221. /**
  152222. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152223. */
  152224. static EdgeDetect1Kernel: number[];
  152225. /**
  152226. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152227. */
  152228. static EdgeDetect2Kernel: number[];
  152229. /**
  152230. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152231. */
  152232. static SharpenKernel: number[];
  152233. /**
  152234. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152235. */
  152236. static EmbossKernel: number[];
  152237. /**
  152238. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152239. */
  152240. static GaussianKernel: number[];
  152241. }
  152242. }
  152243. declare module BABYLON {
  152244. /**
  152245. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  152246. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  152247. * based on samples that have a large difference in distance than the center pixel.
  152248. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  152249. */
  152250. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  152251. /**
  152252. * The direction the blur should be applied
  152253. */
  152254. direction: Vector2;
  152255. /**
  152256. * Gets a string identifying the name of the class
  152257. * @returns "DepthOfFieldBlurPostProcess" string
  152258. */
  152259. getClassName(): string;
  152260. /**
  152261. * Creates a new instance CircleOfConfusionPostProcess
  152262. * @param name The name of the effect.
  152263. * @param scene The scene the effect belongs to.
  152264. * @param direction The direction the blur should be applied.
  152265. * @param kernel The size of the kernel used to blur.
  152266. * @param options The required width/height ratio to downsize to before computing the render pass.
  152267. * @param camera The camera to apply the render pass to.
  152268. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  152269. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  152270. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152271. * @param engine The engine which the post process will be applied. (default: current engine)
  152272. * @param reusable If the post process can be reused on the same frame. (default: false)
  152273. * @param textureType Type of textures used when performing the post process. (default: 0)
  152274. * @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)
  152275. */
  152276. 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);
  152277. }
  152278. }
  152279. declare module BABYLON {
  152280. /** @hidden */
  152281. export var depthOfFieldMergePixelShader: {
  152282. name: string;
  152283. shader: string;
  152284. };
  152285. }
  152286. declare module BABYLON {
  152287. /**
  152288. * Options to be set when merging outputs from the default pipeline.
  152289. */
  152290. export class DepthOfFieldMergePostProcessOptions {
  152291. /**
  152292. * The original image to merge on top of
  152293. */
  152294. originalFromInput: PostProcess;
  152295. /**
  152296. * Parameters to perform the merge of the depth of field effect
  152297. */
  152298. depthOfField?: {
  152299. circleOfConfusion: PostProcess;
  152300. blurSteps: Array<PostProcess>;
  152301. };
  152302. /**
  152303. * Parameters to perform the merge of bloom effect
  152304. */
  152305. bloom?: {
  152306. blurred: PostProcess;
  152307. weight: number;
  152308. };
  152309. }
  152310. /**
  152311. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  152312. */
  152313. export class DepthOfFieldMergePostProcess extends PostProcess {
  152314. private blurSteps;
  152315. /**
  152316. * Gets a string identifying the name of the class
  152317. * @returns "DepthOfFieldMergePostProcess" string
  152318. */
  152319. getClassName(): string;
  152320. /**
  152321. * Creates a new instance of DepthOfFieldMergePostProcess
  152322. * @param name The name of the effect.
  152323. * @param originalFromInput Post process which's input will be used for the merge.
  152324. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  152325. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  152326. * @param options The required width/height ratio to downsize to before computing the render pass.
  152327. * @param camera The camera to apply the render pass to.
  152328. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152329. * @param engine The engine which the post process will be applied. (default: current engine)
  152330. * @param reusable If the post process can be reused on the same frame. (default: false)
  152331. * @param textureType Type of textures used when performing the post process. (default: 0)
  152332. * @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)
  152333. */
  152334. 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);
  152335. /**
  152336. * Updates the effect with the current post process compile time values and recompiles the shader.
  152337. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  152338. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  152339. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  152340. * @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
  152341. * @param onCompiled Called when the shader has been compiled.
  152342. * @param onError Called if there is an error when compiling a shader.
  152343. */
  152344. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  152345. }
  152346. }
  152347. declare module BABYLON {
  152348. /**
  152349. * Specifies the level of max blur that should be applied when using the depth of field effect
  152350. */
  152351. export enum DepthOfFieldEffectBlurLevel {
  152352. /**
  152353. * Subtle blur
  152354. */
  152355. Low = 0,
  152356. /**
  152357. * Medium blur
  152358. */
  152359. Medium = 1,
  152360. /**
  152361. * Large blur
  152362. */
  152363. High = 2
  152364. }
  152365. /**
  152366. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  152367. */
  152368. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  152369. private _circleOfConfusion;
  152370. /**
  152371. * @hidden Internal, blurs from high to low
  152372. */
  152373. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  152374. private _depthOfFieldBlurY;
  152375. private _dofMerge;
  152376. /**
  152377. * @hidden Internal post processes in depth of field effect
  152378. */
  152379. _effects: Array<PostProcess>;
  152380. /**
  152381. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  152382. */
  152383. set focalLength(value: number);
  152384. get focalLength(): number;
  152385. /**
  152386. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  152387. */
  152388. set fStop(value: number);
  152389. get fStop(): number;
  152390. /**
  152391. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  152392. */
  152393. set focusDistance(value: number);
  152394. get focusDistance(): number;
  152395. /**
  152396. * 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.
  152397. */
  152398. set lensSize(value: number);
  152399. get lensSize(): number;
  152400. /**
  152401. * Creates a new instance DepthOfFieldEffect
  152402. * @param scene The scene the effect belongs to.
  152403. * @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.
  152404. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  152405. * @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)
  152406. */
  152407. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  152408. /**
  152409. * Get the current class name of the current effet
  152410. * @returns "DepthOfFieldEffect"
  152411. */
  152412. getClassName(): string;
  152413. /**
  152414. * 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.
  152415. */
  152416. set depthTexture(value: RenderTargetTexture);
  152417. /**
  152418. * Disposes each of the internal effects for a given camera.
  152419. * @param camera The camera to dispose the effect on.
  152420. */
  152421. disposeEffects(camera: Camera): void;
  152422. /**
  152423. * @hidden Internal
  152424. */
  152425. _updateEffects(): void;
  152426. /**
  152427. * Internal
  152428. * @returns if all the contained post processes are ready.
  152429. * @hidden
  152430. */
  152431. _isReady(): boolean;
  152432. }
  152433. }
  152434. declare module BABYLON {
  152435. /** @hidden */
  152436. export var displayPassPixelShader: {
  152437. name: string;
  152438. shader: string;
  152439. };
  152440. }
  152441. declare module BABYLON {
  152442. /**
  152443. * DisplayPassPostProcess which produces an output the same as it's input
  152444. */
  152445. export class DisplayPassPostProcess extends PostProcess {
  152446. /**
  152447. * Gets a string identifying the name of the class
  152448. * @returns "DisplayPassPostProcess" string
  152449. */
  152450. getClassName(): string;
  152451. /**
  152452. * Creates the DisplayPassPostProcess
  152453. * @param name The name of the effect.
  152454. * @param options The required width/height ratio to downsize to before computing the render pass.
  152455. * @param camera The camera to apply the render pass to.
  152456. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152457. * @param engine The engine which the post process will be applied. (default: current engine)
  152458. * @param reusable If the post process can be reused on the same frame. (default: false)
  152459. */
  152460. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152461. /** @hidden */
  152462. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  152463. }
  152464. }
  152465. declare module BABYLON {
  152466. /** @hidden */
  152467. export var filterPixelShader: {
  152468. name: string;
  152469. shader: string;
  152470. };
  152471. }
  152472. declare module BABYLON {
  152473. /**
  152474. * Applies a kernel filter to the image
  152475. */
  152476. export class FilterPostProcess extends PostProcess {
  152477. /** The matrix to be applied to the image */
  152478. kernelMatrix: Matrix;
  152479. /**
  152480. * Gets a string identifying the name of the class
  152481. * @returns "FilterPostProcess" string
  152482. */
  152483. getClassName(): string;
  152484. /**
  152485. *
  152486. * @param name The name of the effect.
  152487. * @param kernelMatrix The matrix to be applied to the image
  152488. * @param options The required width/height ratio to downsize to before computing the render pass.
  152489. * @param camera The camera to apply the render pass to.
  152490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152491. * @param engine The engine which the post process will be applied. (default: current engine)
  152492. * @param reusable If the post process can be reused on the same frame. (default: false)
  152493. */
  152494. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152495. /** @hidden */
  152496. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  152497. }
  152498. }
  152499. declare module BABYLON {
  152500. /** @hidden */
  152501. export var fxaaPixelShader: {
  152502. name: string;
  152503. shader: string;
  152504. };
  152505. }
  152506. declare module BABYLON {
  152507. /** @hidden */
  152508. export var fxaaVertexShader: {
  152509. name: string;
  152510. shader: string;
  152511. };
  152512. }
  152513. declare module BABYLON {
  152514. /**
  152515. * Fxaa post process
  152516. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  152517. */
  152518. export class FxaaPostProcess extends PostProcess {
  152519. /**
  152520. * Gets a string identifying the name of the class
  152521. * @returns "FxaaPostProcess" string
  152522. */
  152523. getClassName(): string;
  152524. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152525. private _getDefines;
  152526. /** @hidden */
  152527. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  152528. }
  152529. }
  152530. declare module BABYLON {
  152531. /** @hidden */
  152532. export var grainPixelShader: {
  152533. name: string;
  152534. shader: string;
  152535. };
  152536. }
  152537. declare module BABYLON {
  152538. /**
  152539. * The GrainPostProcess adds noise to the image at mid luminance levels
  152540. */
  152541. export class GrainPostProcess extends PostProcess {
  152542. /**
  152543. * The intensity of the grain added (default: 30)
  152544. */
  152545. intensity: number;
  152546. /**
  152547. * If the grain should be randomized on every frame
  152548. */
  152549. animated: boolean;
  152550. /**
  152551. * Gets a string identifying the name of the class
  152552. * @returns "GrainPostProcess" string
  152553. */
  152554. getClassName(): string;
  152555. /**
  152556. * Creates a new instance of @see GrainPostProcess
  152557. * @param name The name of the effect.
  152558. * @param options The required width/height ratio to downsize to before computing the render pass.
  152559. * @param camera The camera to apply the render pass to.
  152560. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152561. * @param engine The engine which the post process will be applied. (default: current engine)
  152562. * @param reusable If the post process can be reused on the same frame. (default: false)
  152563. * @param textureType Type of textures used when performing the post process. (default: 0)
  152564. * @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)
  152565. */
  152566. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152567. /** @hidden */
  152568. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  152569. }
  152570. }
  152571. declare module BABYLON {
  152572. /** @hidden */
  152573. export var highlightsPixelShader: {
  152574. name: string;
  152575. shader: string;
  152576. };
  152577. }
  152578. declare module BABYLON {
  152579. /**
  152580. * Extracts highlights from the image
  152581. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  152582. */
  152583. export class HighlightsPostProcess extends PostProcess {
  152584. /**
  152585. * Gets a string identifying the name of the class
  152586. * @returns "HighlightsPostProcess" string
  152587. */
  152588. getClassName(): string;
  152589. /**
  152590. * Extracts highlights from the image
  152591. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  152592. * @param name The name of the effect.
  152593. * @param options The required width/height ratio to downsize to before computing the render pass.
  152594. * @param camera The camera to apply the render pass to.
  152595. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152596. * @param engine The engine which the post process will be applied. (default: current engine)
  152597. * @param reusable If the post process can be reused on the same frame. (default: false)
  152598. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  152599. */
  152600. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152601. }
  152602. }
  152603. declare module BABYLON {
  152604. /**
  152605. * Contains all parameters needed for the prepass to perform
  152606. * motion blur
  152607. */
  152608. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  152609. /**
  152610. * Is motion blur enabled
  152611. */
  152612. enabled: boolean;
  152613. /**
  152614. * Name of the configuration
  152615. */
  152616. name: string;
  152617. /**
  152618. * Textures that should be present in the MRT for this effect to work
  152619. */
  152620. readonly texturesRequired: number[];
  152621. }
  152622. }
  152623. declare module BABYLON {
  152624. interface Scene {
  152625. /** @hidden (Backing field) */
  152626. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  152627. /**
  152628. * Gets or Sets the current geometry buffer associated to the scene.
  152629. */
  152630. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  152631. /**
  152632. * Enables a GeometryBufferRender and associates it with the scene
  152633. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  152634. * @returns the GeometryBufferRenderer
  152635. */
  152636. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  152637. /**
  152638. * Disables the GeometryBufferRender associated with the scene
  152639. */
  152640. disableGeometryBufferRenderer(): void;
  152641. }
  152642. /**
  152643. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152644. * in several rendering techniques.
  152645. */
  152646. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  152647. /**
  152648. * The component name helpful to identify the component in the list of scene components.
  152649. */
  152650. readonly name: string;
  152651. /**
  152652. * The scene the component belongs to.
  152653. */
  152654. scene: Scene;
  152655. /**
  152656. * Creates a new instance of the component for the given scene
  152657. * @param scene Defines the scene to register the component in
  152658. */
  152659. constructor(scene: Scene);
  152660. /**
  152661. * Registers the component in a given scene
  152662. */
  152663. register(): void;
  152664. /**
  152665. * Rebuilds the elements related to this component in case of
  152666. * context lost for instance.
  152667. */
  152668. rebuild(): void;
  152669. /**
  152670. * Disposes the component and the associated ressources
  152671. */
  152672. dispose(): void;
  152673. private _gatherRenderTargets;
  152674. }
  152675. }
  152676. declare module BABYLON {
  152677. /** @hidden */
  152678. export var motionBlurPixelShader: {
  152679. name: string;
  152680. shader: string;
  152681. };
  152682. }
  152683. declare module BABYLON {
  152684. /**
  152685. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  152686. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  152687. * As an example, all you have to do is to create the post-process:
  152688. * var mb = new BABYLON.MotionBlurPostProcess(
  152689. * 'mb', // The name of the effect.
  152690. * scene, // The scene containing the objects to blur according to their velocity.
  152691. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  152692. * camera // The camera to apply the render pass to.
  152693. * );
  152694. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  152695. */
  152696. export class MotionBlurPostProcess extends PostProcess {
  152697. /**
  152698. * Defines how much the image is blurred by the movement. Default value is equal to 1
  152699. */
  152700. motionStrength: number;
  152701. /**
  152702. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  152703. */
  152704. get motionBlurSamples(): number;
  152705. /**
  152706. * Sets the number of iterations to be used for motion blur quality
  152707. */
  152708. set motionBlurSamples(samples: number);
  152709. private _motionBlurSamples;
  152710. private _forceGeometryBuffer;
  152711. private _geometryBufferRenderer;
  152712. private _prePassRenderer;
  152713. /**
  152714. * Gets a string identifying the name of the class
  152715. * @returns "MotionBlurPostProcess" string
  152716. */
  152717. getClassName(): string;
  152718. /**
  152719. * Creates a new instance MotionBlurPostProcess
  152720. * @param name The name of the effect.
  152721. * @param scene The scene containing the objects to blur according to their velocity.
  152722. * @param options The required width/height ratio to downsize to before computing the render pass.
  152723. * @param camera The camera to apply the render pass to.
  152724. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152725. * @param engine The engine which the post process will be applied. (default: current engine)
  152726. * @param reusable If the post process can be reused on the same frame. (default: false)
  152727. * @param textureType Type of textures used when performing the post process. (default: 0)
  152728. * @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)
  152729. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  152730. */
  152731. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  152732. /**
  152733. * Excludes the given skinned mesh from computing bones velocities.
  152734. * 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.
  152735. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  152736. */
  152737. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  152738. /**
  152739. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  152740. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  152741. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  152742. */
  152743. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  152744. /**
  152745. * Disposes the post process.
  152746. * @param camera The camera to dispose the post process on.
  152747. */
  152748. dispose(camera?: Camera): void;
  152749. /** @hidden */
  152750. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  152751. }
  152752. }
  152753. declare module BABYLON {
  152754. /** @hidden */
  152755. export var refractionPixelShader: {
  152756. name: string;
  152757. shader: string;
  152758. };
  152759. }
  152760. declare module BABYLON {
  152761. /**
  152762. * Post process which applies a refractin texture
  152763. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  152764. */
  152765. export class RefractionPostProcess extends PostProcess {
  152766. private _refTexture;
  152767. private _ownRefractionTexture;
  152768. /** the base color of the refraction (used to taint the rendering) */
  152769. color: Color3;
  152770. /** simulated refraction depth */
  152771. depth: number;
  152772. /** the coefficient of the base color (0 to remove base color tainting) */
  152773. colorLevel: number;
  152774. /** Gets the url used to load the refraction texture */
  152775. refractionTextureUrl: string;
  152776. /**
  152777. * Gets or sets the refraction texture
  152778. * Please note that you are responsible for disposing the texture if you set it manually
  152779. */
  152780. get refractionTexture(): Texture;
  152781. set refractionTexture(value: Texture);
  152782. /**
  152783. * Gets a string identifying the name of the class
  152784. * @returns "RefractionPostProcess" string
  152785. */
  152786. getClassName(): string;
  152787. /**
  152788. * Initializes the RefractionPostProcess
  152789. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  152790. * @param name The name of the effect.
  152791. * @param refractionTextureUrl Url of the refraction texture to use
  152792. * @param color the base color of the refraction (used to taint the rendering)
  152793. * @param depth simulated refraction depth
  152794. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  152795. * @param camera The camera to apply the render pass to.
  152796. * @param options The required width/height ratio to downsize to before computing the render pass.
  152797. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152798. * @param engine The engine which the post process will be applied. (default: current engine)
  152799. * @param reusable If the post process can be reused on the same frame. (default: false)
  152800. */
  152801. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152802. /**
  152803. * Disposes of the post process
  152804. * @param camera Camera to dispose post process on
  152805. */
  152806. dispose(camera: Camera): void;
  152807. /** @hidden */
  152808. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  152809. }
  152810. }
  152811. declare module BABYLON {
  152812. /** @hidden */
  152813. export var sharpenPixelShader: {
  152814. name: string;
  152815. shader: string;
  152816. };
  152817. }
  152818. declare module BABYLON {
  152819. /**
  152820. * The SharpenPostProcess applies a sharpen kernel to every pixel
  152821. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  152822. */
  152823. export class SharpenPostProcess extends PostProcess {
  152824. /**
  152825. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  152826. */
  152827. colorAmount: number;
  152828. /**
  152829. * How much sharpness should be applied (default: 0.3)
  152830. */
  152831. edgeAmount: number;
  152832. /**
  152833. * Gets a string identifying the name of the class
  152834. * @returns "SharpenPostProcess" string
  152835. */
  152836. getClassName(): string;
  152837. /**
  152838. * Creates a new instance ConvolutionPostProcess
  152839. * @param name The name of the effect.
  152840. * @param options The required width/height ratio to downsize to before computing the render pass.
  152841. * @param camera The camera to apply the render pass to.
  152842. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152843. * @param engine The engine which the post process will be applied. (default: current engine)
  152844. * @param reusable If the post process can be reused on the same frame. (default: false)
  152845. * @param textureType Type of textures used when performing the post process. (default: 0)
  152846. * @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)
  152847. */
  152848. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152849. /** @hidden */
  152850. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  152851. }
  152852. }
  152853. declare module BABYLON {
  152854. /**
  152855. * PostProcessRenderPipeline
  152856. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152857. */
  152858. export class PostProcessRenderPipeline {
  152859. private engine;
  152860. private _renderEffects;
  152861. private _renderEffectsForIsolatedPass;
  152862. /**
  152863. * List of inspectable custom properties (used by the Inspector)
  152864. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  152865. */
  152866. inspectableCustomProperties: IInspectable[];
  152867. /**
  152868. * @hidden
  152869. */
  152870. protected _cameras: Camera[];
  152871. /** @hidden */
  152872. _name: string;
  152873. /**
  152874. * Gets pipeline name
  152875. */
  152876. get name(): string;
  152877. /** Gets the list of attached cameras */
  152878. get cameras(): Camera[];
  152879. /**
  152880. * Initializes a PostProcessRenderPipeline
  152881. * @param engine engine to add the pipeline to
  152882. * @param name name of the pipeline
  152883. */
  152884. constructor(engine: Engine, name: string);
  152885. /**
  152886. * Gets the class name
  152887. * @returns "PostProcessRenderPipeline"
  152888. */
  152889. getClassName(): string;
  152890. /**
  152891. * If all the render effects in the pipeline are supported
  152892. */
  152893. get isSupported(): boolean;
  152894. /**
  152895. * Adds an effect to the pipeline
  152896. * @param renderEffect the effect to add
  152897. */
  152898. addEffect(renderEffect: PostProcessRenderEffect): void;
  152899. /** @hidden */
  152900. _rebuild(): void;
  152901. /** @hidden */
  152902. _enableEffect(renderEffectName: string, cameras: Camera): void;
  152903. /** @hidden */
  152904. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  152905. /** @hidden */
  152906. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  152907. /** @hidden */
  152908. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  152909. /** @hidden */
  152910. _attachCameras(cameras: Camera, unique: boolean): void;
  152911. /** @hidden */
  152912. _attachCameras(cameras: Camera[], unique: boolean): void;
  152913. /** @hidden */
  152914. _detachCameras(cameras: Camera): void;
  152915. /** @hidden */
  152916. _detachCameras(cameras: Nullable<Camera[]>): void;
  152917. /** @hidden */
  152918. _update(): void;
  152919. /** @hidden */
  152920. _reset(): void;
  152921. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  152922. /**
  152923. * Sets the required values to the prepass renderer.
  152924. * @param prePassRenderer defines the prepass renderer to setup.
  152925. * @returns true if the pre pass is needed.
  152926. */
  152927. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  152928. /**
  152929. * Disposes of the pipeline
  152930. */
  152931. dispose(): void;
  152932. }
  152933. }
  152934. declare module BABYLON {
  152935. /**
  152936. * PostProcessRenderPipelineManager class
  152937. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152938. */
  152939. export class PostProcessRenderPipelineManager {
  152940. private _renderPipelines;
  152941. /**
  152942. * Initializes a PostProcessRenderPipelineManager
  152943. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152944. */
  152945. constructor();
  152946. /**
  152947. * Gets the list of supported render pipelines
  152948. */
  152949. get supportedPipelines(): PostProcessRenderPipeline[];
  152950. /**
  152951. * Adds a pipeline to the manager
  152952. * @param renderPipeline The pipeline to add
  152953. */
  152954. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  152955. /**
  152956. * Attaches a camera to the pipeline
  152957. * @param renderPipelineName The name of the pipeline to attach to
  152958. * @param cameras the camera to attach
  152959. * @param unique if the camera can be attached multiple times to the pipeline
  152960. */
  152961. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  152962. /**
  152963. * Detaches a camera from the pipeline
  152964. * @param renderPipelineName The name of the pipeline to detach from
  152965. * @param cameras the camera to detach
  152966. */
  152967. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  152968. /**
  152969. * Enables an effect by name on a pipeline
  152970. * @param renderPipelineName the name of the pipeline to enable the effect in
  152971. * @param renderEffectName the name of the effect to enable
  152972. * @param cameras the cameras that the effect should be enabled on
  152973. */
  152974. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  152975. /**
  152976. * Disables an effect by name on a pipeline
  152977. * @param renderPipelineName the name of the pipeline to disable the effect in
  152978. * @param renderEffectName the name of the effect to disable
  152979. * @param cameras the cameras that the effect should be disabled on
  152980. */
  152981. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  152982. /**
  152983. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  152984. */
  152985. update(): void;
  152986. /** @hidden */
  152987. _rebuild(): void;
  152988. /**
  152989. * Disposes of the manager and pipelines
  152990. */
  152991. dispose(): void;
  152992. }
  152993. }
  152994. declare module BABYLON {
  152995. interface Scene {
  152996. /** @hidden (Backing field) */
  152997. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  152998. /**
  152999. * Gets the postprocess render pipeline manager
  153000. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  153001. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  153002. */
  153003. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  153004. }
  153005. /**
  153006. * Defines the Render Pipeline scene component responsible to rendering pipelines
  153007. */
  153008. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  153009. /**
  153010. * The component name helpfull to identify the component in the list of scene components.
  153011. */
  153012. readonly name: string;
  153013. /**
  153014. * The scene the component belongs to.
  153015. */
  153016. scene: Scene;
  153017. /**
  153018. * Creates a new instance of the component for the given scene
  153019. * @param scene Defines the scene to register the component in
  153020. */
  153021. constructor(scene: Scene);
  153022. /**
  153023. * Registers the component in a given scene
  153024. */
  153025. register(): void;
  153026. /**
  153027. * Rebuilds the elements related to this component in case of
  153028. * context lost for instance.
  153029. */
  153030. rebuild(): void;
  153031. /**
  153032. * Disposes the component and the associated ressources
  153033. */
  153034. dispose(): void;
  153035. private _gatherRenderTargets;
  153036. }
  153037. }
  153038. declare module BABYLON {
  153039. /**
  153040. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  153041. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  153042. */
  153043. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  153044. private _scene;
  153045. private _camerasToBeAttached;
  153046. /**
  153047. * ID of the sharpen post process,
  153048. */
  153049. private readonly SharpenPostProcessId;
  153050. /**
  153051. * @ignore
  153052. * ID of the image processing post process;
  153053. */
  153054. readonly ImageProcessingPostProcessId: string;
  153055. /**
  153056. * @ignore
  153057. * ID of the Fast Approximate Anti-Aliasing post process;
  153058. */
  153059. readonly FxaaPostProcessId: string;
  153060. /**
  153061. * ID of the chromatic aberration post process,
  153062. */
  153063. private readonly ChromaticAberrationPostProcessId;
  153064. /**
  153065. * ID of the grain post process
  153066. */
  153067. private readonly GrainPostProcessId;
  153068. /**
  153069. * Sharpen post process which will apply a sharpen convolution to enhance edges
  153070. */
  153071. sharpen: SharpenPostProcess;
  153072. private _sharpenEffect;
  153073. private bloom;
  153074. /**
  153075. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  153076. */
  153077. depthOfField: DepthOfFieldEffect;
  153078. /**
  153079. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  153080. */
  153081. fxaa: FxaaPostProcess;
  153082. /**
  153083. * Image post processing pass used to perform operations such as tone mapping or color grading.
  153084. */
  153085. imageProcessing: ImageProcessingPostProcess;
  153086. /**
  153087. * Chromatic aberration post process which will shift rgb colors in the image
  153088. */
  153089. chromaticAberration: ChromaticAberrationPostProcess;
  153090. private _chromaticAberrationEffect;
  153091. /**
  153092. * Grain post process which add noise to the image
  153093. */
  153094. grain: GrainPostProcess;
  153095. private _grainEffect;
  153096. /**
  153097. * Glow post process which adds a glow to emissive areas of the image
  153098. */
  153099. private _glowLayer;
  153100. /**
  153101. * Animations which can be used to tweak settings over a period of time
  153102. */
  153103. animations: Animation[];
  153104. private _imageProcessingConfigurationObserver;
  153105. private _sharpenEnabled;
  153106. private _bloomEnabled;
  153107. private _depthOfFieldEnabled;
  153108. private _depthOfFieldBlurLevel;
  153109. private _fxaaEnabled;
  153110. private _imageProcessingEnabled;
  153111. private _defaultPipelineTextureType;
  153112. private _bloomScale;
  153113. private _chromaticAberrationEnabled;
  153114. private _grainEnabled;
  153115. private _buildAllowed;
  153116. /**
  153117. * This is triggered each time the pipeline has been built.
  153118. */
  153119. onBuildObservable: Observable<DefaultRenderingPipeline>;
  153120. /**
  153121. * Gets active scene
  153122. */
  153123. get scene(): Scene;
  153124. /**
  153125. * Enable or disable the sharpen process from the pipeline
  153126. */
  153127. set sharpenEnabled(enabled: boolean);
  153128. get sharpenEnabled(): boolean;
  153129. private _resizeObserver;
  153130. private _hardwareScaleLevel;
  153131. private _bloomKernel;
  153132. /**
  153133. * Specifies the size of the bloom blur kernel, relative to the final output size
  153134. */
  153135. get bloomKernel(): number;
  153136. set bloomKernel(value: number);
  153137. /**
  153138. * Specifies the weight of the bloom in the final rendering
  153139. */
  153140. private _bloomWeight;
  153141. /**
  153142. * Specifies the luma threshold for the area that will be blurred by the bloom
  153143. */
  153144. private _bloomThreshold;
  153145. private _hdr;
  153146. /**
  153147. * The strength of the bloom.
  153148. */
  153149. set bloomWeight(value: number);
  153150. get bloomWeight(): number;
  153151. /**
  153152. * The strength of the bloom.
  153153. */
  153154. set bloomThreshold(value: number);
  153155. get bloomThreshold(): number;
  153156. /**
  153157. * The scale of the bloom, lower value will provide better performance.
  153158. */
  153159. set bloomScale(value: number);
  153160. get bloomScale(): number;
  153161. /**
  153162. * Enable or disable the bloom from the pipeline
  153163. */
  153164. set bloomEnabled(enabled: boolean);
  153165. get bloomEnabled(): boolean;
  153166. private _rebuildBloom;
  153167. /**
  153168. * If the depth of field is enabled.
  153169. */
  153170. get depthOfFieldEnabled(): boolean;
  153171. set depthOfFieldEnabled(enabled: boolean);
  153172. /**
  153173. * Blur level of the depth of field effect. (Higher blur will effect performance)
  153174. */
  153175. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  153176. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  153177. /**
  153178. * If the anti aliasing is enabled.
  153179. */
  153180. set fxaaEnabled(enabled: boolean);
  153181. get fxaaEnabled(): boolean;
  153182. private _samples;
  153183. /**
  153184. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  153185. */
  153186. set samples(sampleCount: number);
  153187. get samples(): number;
  153188. /**
  153189. * If image processing is enabled.
  153190. */
  153191. set imageProcessingEnabled(enabled: boolean);
  153192. get imageProcessingEnabled(): boolean;
  153193. /**
  153194. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  153195. */
  153196. set glowLayerEnabled(enabled: boolean);
  153197. get glowLayerEnabled(): boolean;
  153198. /**
  153199. * Gets the glow layer (or null if not defined)
  153200. */
  153201. get glowLayer(): Nullable<GlowLayer>;
  153202. /**
  153203. * Enable or disable the chromaticAberration process from the pipeline
  153204. */
  153205. set chromaticAberrationEnabled(enabled: boolean);
  153206. get chromaticAberrationEnabled(): boolean;
  153207. /**
  153208. * Enable or disable the grain process from the pipeline
  153209. */
  153210. set grainEnabled(enabled: boolean);
  153211. get grainEnabled(): boolean;
  153212. /**
  153213. * @constructor
  153214. * @param name - The rendering pipeline name (default: "")
  153215. * @param hdr - If high dynamic range textures should be used (default: true)
  153216. * @param scene - The scene linked to this pipeline (default: the last created scene)
  153217. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  153218. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  153219. */
  153220. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  153221. /**
  153222. * Get the class name
  153223. * @returns "DefaultRenderingPipeline"
  153224. */
  153225. getClassName(): string;
  153226. /**
  153227. * Force the compilation of the entire pipeline.
  153228. */
  153229. prepare(): void;
  153230. private _hasCleared;
  153231. private _prevPostProcess;
  153232. private _prevPrevPostProcess;
  153233. private _setAutoClearAndTextureSharing;
  153234. private _depthOfFieldSceneObserver;
  153235. private _buildPipeline;
  153236. private _disposePostProcesses;
  153237. /**
  153238. * Adds a camera to the pipeline
  153239. * @param camera the camera to be added
  153240. */
  153241. addCamera(camera: Camera): void;
  153242. /**
  153243. * Removes a camera from the pipeline
  153244. * @param camera the camera to remove
  153245. */
  153246. removeCamera(camera: Camera): void;
  153247. /**
  153248. * Dispose of the pipeline and stop all post processes
  153249. */
  153250. dispose(): void;
  153251. /**
  153252. * Serialize the rendering pipeline (Used when exporting)
  153253. * @returns the serialized object
  153254. */
  153255. serialize(): any;
  153256. /**
  153257. * Parse the serialized pipeline
  153258. * @param source Source pipeline.
  153259. * @param scene The scene to load the pipeline to.
  153260. * @param rootUrl The URL of the serialized pipeline.
  153261. * @returns An instantiated pipeline from the serialized object.
  153262. */
  153263. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  153264. }
  153265. }
  153266. declare module BABYLON {
  153267. /** @hidden */
  153268. export var lensHighlightsPixelShader: {
  153269. name: string;
  153270. shader: string;
  153271. };
  153272. }
  153273. declare module BABYLON {
  153274. /** @hidden */
  153275. export var depthOfFieldPixelShader: {
  153276. name: string;
  153277. shader: string;
  153278. };
  153279. }
  153280. declare module BABYLON {
  153281. /**
  153282. * BABYLON.JS Chromatic Aberration GLSL Shader
  153283. * Author: Olivier Guyot
  153284. * Separates very slightly R, G and B colors on the edges of the screen
  153285. * Inspired by Francois Tarlier & Martins Upitis
  153286. */
  153287. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  153288. /**
  153289. * @ignore
  153290. * The chromatic aberration PostProcess id in the pipeline
  153291. */
  153292. LensChromaticAberrationEffect: string;
  153293. /**
  153294. * @ignore
  153295. * The highlights enhancing PostProcess id in the pipeline
  153296. */
  153297. HighlightsEnhancingEffect: string;
  153298. /**
  153299. * @ignore
  153300. * The depth-of-field PostProcess id in the pipeline
  153301. */
  153302. LensDepthOfFieldEffect: string;
  153303. private _scene;
  153304. private _depthTexture;
  153305. private _grainTexture;
  153306. private _chromaticAberrationPostProcess;
  153307. private _highlightsPostProcess;
  153308. private _depthOfFieldPostProcess;
  153309. private _edgeBlur;
  153310. private _grainAmount;
  153311. private _chromaticAberration;
  153312. private _distortion;
  153313. private _highlightsGain;
  153314. private _highlightsThreshold;
  153315. private _dofDistance;
  153316. private _dofAperture;
  153317. private _dofDarken;
  153318. private _dofPentagon;
  153319. private _blurNoise;
  153320. /**
  153321. * @constructor
  153322. *
  153323. * Effect parameters are as follow:
  153324. * {
  153325. * chromatic_aberration: number; // from 0 to x (1 for realism)
  153326. * edge_blur: number; // from 0 to x (1 for realism)
  153327. * distortion: number; // from 0 to x (1 for realism)
  153328. * grain_amount: number; // from 0 to 1
  153329. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  153330. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  153331. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  153332. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  153333. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  153334. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  153335. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  153336. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  153337. * }
  153338. * Note: if an effect parameter is unset, effect is disabled
  153339. *
  153340. * @param name The rendering pipeline name
  153341. * @param parameters - An object containing all parameters (see above)
  153342. * @param scene The scene linked to this pipeline
  153343. * @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)
  153344. * @param cameras The array of cameras that the rendering pipeline will be attached to
  153345. */
  153346. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  153347. /**
  153348. * Get the class name
  153349. * @returns "LensRenderingPipeline"
  153350. */
  153351. getClassName(): string;
  153352. /**
  153353. * Gets associated scene
  153354. */
  153355. get scene(): Scene;
  153356. /**
  153357. * Gets or sets the edge blur
  153358. */
  153359. get edgeBlur(): number;
  153360. set edgeBlur(value: number);
  153361. /**
  153362. * Gets or sets the grain amount
  153363. */
  153364. get grainAmount(): number;
  153365. set grainAmount(value: number);
  153366. /**
  153367. * Gets or sets the chromatic aberration amount
  153368. */
  153369. get chromaticAberration(): number;
  153370. set chromaticAberration(value: number);
  153371. /**
  153372. * Gets or sets the depth of field aperture
  153373. */
  153374. get dofAperture(): number;
  153375. set dofAperture(value: number);
  153376. /**
  153377. * Gets or sets the edge distortion
  153378. */
  153379. get edgeDistortion(): number;
  153380. set edgeDistortion(value: number);
  153381. /**
  153382. * Gets or sets the depth of field distortion
  153383. */
  153384. get dofDistortion(): number;
  153385. set dofDistortion(value: number);
  153386. /**
  153387. * Gets or sets the darken out of focus amount
  153388. */
  153389. get darkenOutOfFocus(): number;
  153390. set darkenOutOfFocus(value: number);
  153391. /**
  153392. * Gets or sets a boolean indicating if blur noise is enabled
  153393. */
  153394. get blurNoise(): boolean;
  153395. set blurNoise(value: boolean);
  153396. /**
  153397. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  153398. */
  153399. get pentagonBokeh(): boolean;
  153400. set pentagonBokeh(value: boolean);
  153401. /**
  153402. * Gets or sets the highlight grain amount
  153403. */
  153404. get highlightsGain(): number;
  153405. set highlightsGain(value: number);
  153406. /**
  153407. * Gets or sets the highlight threshold
  153408. */
  153409. get highlightsThreshold(): number;
  153410. set highlightsThreshold(value: number);
  153411. /**
  153412. * Sets the amount of blur at the edges
  153413. * @param amount blur amount
  153414. */
  153415. setEdgeBlur(amount: number): void;
  153416. /**
  153417. * Sets edge blur to 0
  153418. */
  153419. disableEdgeBlur(): void;
  153420. /**
  153421. * Sets the amout of grain
  153422. * @param amount Amount of grain
  153423. */
  153424. setGrainAmount(amount: number): void;
  153425. /**
  153426. * Set grain amount to 0
  153427. */
  153428. disableGrain(): void;
  153429. /**
  153430. * Sets the chromatic aberration amount
  153431. * @param amount amount of chromatic aberration
  153432. */
  153433. setChromaticAberration(amount: number): void;
  153434. /**
  153435. * Sets chromatic aberration amount to 0
  153436. */
  153437. disableChromaticAberration(): void;
  153438. /**
  153439. * Sets the EdgeDistortion amount
  153440. * @param amount amount of EdgeDistortion
  153441. */
  153442. setEdgeDistortion(amount: number): void;
  153443. /**
  153444. * Sets edge distortion to 0
  153445. */
  153446. disableEdgeDistortion(): void;
  153447. /**
  153448. * Sets the FocusDistance amount
  153449. * @param amount amount of FocusDistance
  153450. */
  153451. setFocusDistance(amount: number): void;
  153452. /**
  153453. * Disables depth of field
  153454. */
  153455. disableDepthOfField(): void;
  153456. /**
  153457. * Sets the Aperture amount
  153458. * @param amount amount of Aperture
  153459. */
  153460. setAperture(amount: number): void;
  153461. /**
  153462. * Sets the DarkenOutOfFocus amount
  153463. * @param amount amount of DarkenOutOfFocus
  153464. */
  153465. setDarkenOutOfFocus(amount: number): void;
  153466. private _pentagonBokehIsEnabled;
  153467. /**
  153468. * Creates a pentagon bokeh effect
  153469. */
  153470. enablePentagonBokeh(): void;
  153471. /**
  153472. * Disables the pentagon bokeh effect
  153473. */
  153474. disablePentagonBokeh(): void;
  153475. /**
  153476. * Enables noise blur
  153477. */
  153478. enableNoiseBlur(): void;
  153479. /**
  153480. * Disables noise blur
  153481. */
  153482. disableNoiseBlur(): void;
  153483. /**
  153484. * Sets the HighlightsGain amount
  153485. * @param amount amount of HighlightsGain
  153486. */
  153487. setHighlightsGain(amount: number): void;
  153488. /**
  153489. * Sets the HighlightsThreshold amount
  153490. * @param amount amount of HighlightsThreshold
  153491. */
  153492. setHighlightsThreshold(amount: number): void;
  153493. /**
  153494. * Disables highlights
  153495. */
  153496. disableHighlights(): void;
  153497. /**
  153498. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  153499. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  153500. */
  153501. dispose(disableDepthRender?: boolean): void;
  153502. private _createChromaticAberrationPostProcess;
  153503. private _createHighlightsPostProcess;
  153504. private _createDepthOfFieldPostProcess;
  153505. private _createGrainTexture;
  153506. }
  153507. }
  153508. declare module BABYLON {
  153509. /**
  153510. * Contains all parameters needed for the prepass to perform
  153511. * screen space subsurface scattering
  153512. */
  153513. export class SSAO2Configuration implements PrePassEffectConfiguration {
  153514. /**
  153515. * Is subsurface enabled
  153516. */
  153517. enabled: boolean;
  153518. /**
  153519. * Name of the configuration
  153520. */
  153521. name: string;
  153522. /**
  153523. * Textures that should be present in the MRT for this effect to work
  153524. */
  153525. readonly texturesRequired: number[];
  153526. }
  153527. }
  153528. declare module BABYLON {
  153529. /** @hidden */
  153530. export var ssao2PixelShader: {
  153531. name: string;
  153532. shader: string;
  153533. };
  153534. }
  153535. declare module BABYLON {
  153536. /** @hidden */
  153537. export var ssaoCombinePixelShader: {
  153538. name: string;
  153539. shader: string;
  153540. };
  153541. }
  153542. declare module BABYLON {
  153543. /**
  153544. * Render pipeline to produce ssao effect
  153545. */
  153546. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  153547. /**
  153548. * @ignore
  153549. * The PassPostProcess id in the pipeline that contains the original scene color
  153550. */
  153551. SSAOOriginalSceneColorEffect: string;
  153552. /**
  153553. * @ignore
  153554. * The SSAO PostProcess id in the pipeline
  153555. */
  153556. SSAORenderEffect: string;
  153557. /**
  153558. * @ignore
  153559. * The horizontal blur PostProcess id in the pipeline
  153560. */
  153561. SSAOBlurHRenderEffect: string;
  153562. /**
  153563. * @ignore
  153564. * The vertical blur PostProcess id in the pipeline
  153565. */
  153566. SSAOBlurVRenderEffect: string;
  153567. /**
  153568. * @ignore
  153569. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  153570. */
  153571. SSAOCombineRenderEffect: string;
  153572. /**
  153573. * The output strength of the SSAO post-process. Default value is 1.0.
  153574. */
  153575. totalStrength: number;
  153576. /**
  153577. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  153578. */
  153579. maxZ: number;
  153580. /**
  153581. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  153582. */
  153583. minZAspect: number;
  153584. private _samples;
  153585. /**
  153586. * Number of samples used for the SSAO calculations. Default value is 8
  153587. */
  153588. set samples(n: number);
  153589. get samples(): number;
  153590. private _textureSamples;
  153591. /**
  153592. * Number of samples to use for antialiasing
  153593. */
  153594. set textureSamples(n: number);
  153595. get textureSamples(): number;
  153596. /**
  153597. * Force rendering the geometry through geometry buffer
  153598. */
  153599. private _forceGeometryBuffer;
  153600. /**
  153601. * Ratio object used for SSAO ratio and blur ratio
  153602. */
  153603. private _ratio;
  153604. /**
  153605. * Dynamically generated sphere sampler.
  153606. */
  153607. private _sampleSphere;
  153608. /**
  153609. * Blur filter offsets
  153610. */
  153611. private _samplerOffsets;
  153612. private _expensiveBlur;
  153613. /**
  153614. * If bilateral blur should be used
  153615. */
  153616. set expensiveBlur(b: boolean);
  153617. get expensiveBlur(): boolean;
  153618. /**
  153619. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  153620. */
  153621. radius: number;
  153622. /**
  153623. * The base color of the SSAO post-process
  153624. * The final result is "base + ssao" between [0, 1]
  153625. */
  153626. base: number;
  153627. /**
  153628. * Support test.
  153629. */
  153630. static get IsSupported(): boolean;
  153631. private _scene;
  153632. private _randomTexture;
  153633. private _originalColorPostProcess;
  153634. private _ssaoPostProcess;
  153635. private _blurHPostProcess;
  153636. private _blurVPostProcess;
  153637. private _ssaoCombinePostProcess;
  153638. private _prePassRenderer;
  153639. /**
  153640. * Gets active scene
  153641. */
  153642. get scene(): Scene;
  153643. /**
  153644. * @constructor
  153645. * @param name The rendering pipeline name
  153646. * @param scene The scene linked to this pipeline
  153647. * @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 }
  153648. * @param cameras The array of cameras that the rendering pipeline will be attached to
  153649. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  153650. */
  153651. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  153652. /**
  153653. * Get the class name
  153654. * @returns "SSAO2RenderingPipeline"
  153655. */
  153656. getClassName(): string;
  153657. /**
  153658. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  153659. */
  153660. dispose(disableGeometryBufferRenderer?: boolean): void;
  153661. private _createBlurPostProcess;
  153662. /** @hidden */
  153663. _rebuild(): void;
  153664. private _bits;
  153665. private _radicalInverse_VdC;
  153666. private _hammersley;
  153667. private _hemisphereSample_uniform;
  153668. private _generateHemisphere;
  153669. private _getDefinesForSSAO;
  153670. private _createSSAOPostProcess;
  153671. private _createSSAOCombinePostProcess;
  153672. private _createRandomTexture;
  153673. /**
  153674. * Serialize the rendering pipeline (Used when exporting)
  153675. * @returns the serialized object
  153676. */
  153677. serialize(): any;
  153678. /**
  153679. * Parse the serialized pipeline
  153680. * @param source Source pipeline.
  153681. * @param scene The scene to load the pipeline to.
  153682. * @param rootUrl The URL of the serialized pipeline.
  153683. * @returns An instantiated pipeline from the serialized object.
  153684. */
  153685. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  153686. }
  153687. }
  153688. declare module BABYLON {
  153689. /** @hidden */
  153690. export var ssaoPixelShader: {
  153691. name: string;
  153692. shader: string;
  153693. };
  153694. }
  153695. declare module BABYLON {
  153696. /**
  153697. * Render pipeline to produce ssao effect
  153698. */
  153699. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  153700. /**
  153701. * @ignore
  153702. * The PassPostProcess id in the pipeline that contains the original scene color
  153703. */
  153704. SSAOOriginalSceneColorEffect: string;
  153705. /**
  153706. * @ignore
  153707. * The SSAO PostProcess id in the pipeline
  153708. */
  153709. SSAORenderEffect: string;
  153710. /**
  153711. * @ignore
  153712. * The horizontal blur PostProcess id in the pipeline
  153713. */
  153714. SSAOBlurHRenderEffect: string;
  153715. /**
  153716. * @ignore
  153717. * The vertical blur PostProcess id in the pipeline
  153718. */
  153719. SSAOBlurVRenderEffect: string;
  153720. /**
  153721. * @ignore
  153722. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  153723. */
  153724. SSAOCombineRenderEffect: string;
  153725. /**
  153726. * The output strength of the SSAO post-process. Default value is 1.0.
  153727. */
  153728. totalStrength: number;
  153729. /**
  153730. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  153731. */
  153732. radius: number;
  153733. /**
  153734. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  153735. * Must not be equal to fallOff and superior to fallOff.
  153736. * Default value is 0.0075
  153737. */
  153738. area: number;
  153739. /**
  153740. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  153741. * Must not be equal to area and inferior to area.
  153742. * Default value is 0.000001
  153743. */
  153744. fallOff: number;
  153745. /**
  153746. * The base color of the SSAO post-process
  153747. * The final result is "base + ssao" between [0, 1]
  153748. */
  153749. base: number;
  153750. private _scene;
  153751. private _depthTexture;
  153752. private _randomTexture;
  153753. private _originalColorPostProcess;
  153754. private _ssaoPostProcess;
  153755. private _blurHPostProcess;
  153756. private _blurVPostProcess;
  153757. private _ssaoCombinePostProcess;
  153758. private _firstUpdate;
  153759. /**
  153760. * Gets active scene
  153761. */
  153762. get scene(): Scene;
  153763. /**
  153764. * @constructor
  153765. * @param name - The rendering pipeline name
  153766. * @param scene - The scene linked to this pipeline
  153767. * @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 }
  153768. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  153769. */
  153770. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  153771. /**
  153772. * Get the class name
  153773. * @returns "SSAORenderingPipeline"
  153774. */
  153775. getClassName(): string;
  153776. /**
  153777. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  153778. */
  153779. dispose(disableDepthRender?: boolean): void;
  153780. private _createBlurPostProcess;
  153781. /** @hidden */
  153782. _rebuild(): void;
  153783. private _createSSAOPostProcess;
  153784. private _createSSAOCombinePostProcess;
  153785. private _createRandomTexture;
  153786. }
  153787. }
  153788. declare module BABYLON {
  153789. /**
  153790. * Contains all parameters needed for the prepass to perform
  153791. * screen space reflections
  153792. */
  153793. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  153794. /**
  153795. * Is ssr enabled
  153796. */
  153797. enabled: boolean;
  153798. /**
  153799. * Name of the configuration
  153800. */
  153801. name: string;
  153802. /**
  153803. * Textures that should be present in the MRT for this effect to work
  153804. */
  153805. readonly texturesRequired: number[];
  153806. }
  153807. }
  153808. declare module BABYLON {
  153809. /** @hidden */
  153810. export var screenSpaceReflectionPixelShader: {
  153811. name: string;
  153812. shader: string;
  153813. };
  153814. }
  153815. declare module BABYLON {
  153816. /**
  153817. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  153818. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  153819. */
  153820. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  153821. /**
  153822. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  153823. */
  153824. threshold: number;
  153825. /**
  153826. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  153827. */
  153828. strength: number;
  153829. /**
  153830. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  153831. */
  153832. reflectionSpecularFalloffExponent: number;
  153833. /**
  153834. * 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]
  153835. */
  153836. step: number;
  153837. /**
  153838. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  153839. */
  153840. roughnessFactor: number;
  153841. private _forceGeometryBuffer;
  153842. private _geometryBufferRenderer;
  153843. private _prePassRenderer;
  153844. private _enableSmoothReflections;
  153845. private _reflectionSamples;
  153846. private _smoothSteps;
  153847. /**
  153848. * Gets a string identifying the name of the class
  153849. * @returns "ScreenSpaceReflectionPostProcess" string
  153850. */
  153851. getClassName(): string;
  153852. /**
  153853. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  153854. * @param name The name of the effect.
  153855. * @param scene The scene containing the objects to calculate reflections.
  153856. * @param options The required width/height ratio to downsize to before computing the render pass.
  153857. * @param camera The camera to apply the render pass to.
  153858. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153859. * @param engine The engine which the post process will be applied. (default: current engine)
  153860. * @param reusable If the post process can be reused on the same frame. (default: false)
  153861. * @param textureType Type of textures used when performing the post process. (default: 0)
  153862. * @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)
  153863. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  153864. */
  153865. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  153866. /**
  153867. * Gets wether or not smoothing reflections is enabled.
  153868. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  153869. */
  153870. get enableSmoothReflections(): boolean;
  153871. /**
  153872. * Sets wether or not smoothing reflections is enabled.
  153873. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  153874. */
  153875. set enableSmoothReflections(enabled: boolean);
  153876. /**
  153877. * Gets the number of samples taken while computing reflections. More samples count is high,
  153878. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  153879. */
  153880. get reflectionSamples(): number;
  153881. /**
  153882. * Sets the number of samples taken while computing reflections. More samples count is high,
  153883. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  153884. */
  153885. set reflectionSamples(samples: number);
  153886. /**
  153887. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  153888. * more the post-process will require GPU power and can generate a drop in FPS.
  153889. * Default value (5.0) work pretty well in all cases but can be adjusted.
  153890. */
  153891. get smoothSteps(): number;
  153892. set smoothSteps(steps: number);
  153893. private _updateEffectDefines;
  153894. /** @hidden */
  153895. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  153896. }
  153897. }
  153898. declare module BABYLON {
  153899. /** @hidden */
  153900. export var standardPixelShader: {
  153901. name: string;
  153902. shader: string;
  153903. };
  153904. }
  153905. declare module BABYLON {
  153906. /**
  153907. * Standard rendering pipeline
  153908. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  153909. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  153910. */
  153911. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  153912. /**
  153913. * Public members
  153914. */
  153915. /**
  153916. * Post-process which contains the original scene color before the pipeline applies all the effects
  153917. */
  153918. originalPostProcess: Nullable<PostProcess>;
  153919. /**
  153920. * Post-process used to down scale an image x4
  153921. */
  153922. downSampleX4PostProcess: Nullable<PostProcess>;
  153923. /**
  153924. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  153925. */
  153926. brightPassPostProcess: Nullable<PostProcess>;
  153927. /**
  153928. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  153929. */
  153930. blurHPostProcesses: PostProcess[];
  153931. /**
  153932. * Post-process array storing all the vertical blur post-processes used by the pipeline
  153933. */
  153934. blurVPostProcesses: PostProcess[];
  153935. /**
  153936. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  153937. */
  153938. textureAdderPostProcess: Nullable<PostProcess>;
  153939. /**
  153940. * Post-process used to create volumetric lighting effect
  153941. */
  153942. volumetricLightPostProcess: Nullable<PostProcess>;
  153943. /**
  153944. * Post-process used to smooth the previous volumetric light post-process on the X axis
  153945. */
  153946. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  153947. /**
  153948. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  153949. */
  153950. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  153951. /**
  153952. * Post-process used to merge the volumetric light effect and the real scene color
  153953. */
  153954. volumetricLightMergePostProces: Nullable<PostProcess>;
  153955. /**
  153956. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  153957. */
  153958. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  153959. /**
  153960. * Base post-process used to calculate the average luminance of the final image for HDR
  153961. */
  153962. luminancePostProcess: Nullable<PostProcess>;
  153963. /**
  153964. * Post-processes used to create down sample post-processes in order to get
  153965. * the average luminance of the final image for HDR
  153966. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  153967. */
  153968. luminanceDownSamplePostProcesses: PostProcess[];
  153969. /**
  153970. * Post-process used to create a HDR effect (light adaptation)
  153971. */
  153972. hdrPostProcess: Nullable<PostProcess>;
  153973. /**
  153974. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  153975. */
  153976. textureAdderFinalPostProcess: Nullable<PostProcess>;
  153977. /**
  153978. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  153979. */
  153980. lensFlareFinalPostProcess: Nullable<PostProcess>;
  153981. /**
  153982. * Post-process used to merge the final HDR post-process and the real scene color
  153983. */
  153984. hdrFinalPostProcess: Nullable<PostProcess>;
  153985. /**
  153986. * Post-process used to create a lens flare effect
  153987. */
  153988. lensFlarePostProcess: Nullable<PostProcess>;
  153989. /**
  153990. * Post-process that merges the result of the lens flare post-process and the real scene color
  153991. */
  153992. lensFlareComposePostProcess: Nullable<PostProcess>;
  153993. /**
  153994. * Post-process used to create a motion blur effect
  153995. */
  153996. motionBlurPostProcess: Nullable<PostProcess>;
  153997. /**
  153998. * Post-process used to create a depth of field effect
  153999. */
  154000. depthOfFieldPostProcess: Nullable<PostProcess>;
  154001. /**
  154002. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  154003. */
  154004. fxaaPostProcess: Nullable<FxaaPostProcess>;
  154005. /**
  154006. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  154007. */
  154008. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  154009. /**
  154010. * Represents the brightness threshold in order to configure the illuminated surfaces
  154011. */
  154012. brightThreshold: number;
  154013. /**
  154014. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  154015. */
  154016. blurWidth: number;
  154017. /**
  154018. * Sets if the blur for highlighted surfaces must be only horizontal
  154019. */
  154020. horizontalBlur: boolean;
  154021. /**
  154022. * Gets the overall exposure used by the pipeline
  154023. */
  154024. get exposure(): number;
  154025. /**
  154026. * Sets the overall exposure used by the pipeline
  154027. */
  154028. set exposure(value: number);
  154029. /**
  154030. * Texture used typically to simulate "dirty" on camera lens
  154031. */
  154032. lensTexture: Nullable<Texture>;
  154033. /**
  154034. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  154035. */
  154036. volumetricLightCoefficient: number;
  154037. /**
  154038. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  154039. */
  154040. volumetricLightPower: number;
  154041. /**
  154042. * Used the set the blur intensity to smooth the volumetric lights
  154043. */
  154044. volumetricLightBlurScale: number;
  154045. /**
  154046. * Light (spot or directional) used to generate the volumetric lights rays
  154047. * The source light must have a shadow generate so the pipeline can get its
  154048. * depth map
  154049. */
  154050. sourceLight: Nullable<SpotLight | DirectionalLight>;
  154051. /**
  154052. * For eye adaptation, represents the minimum luminance the eye can see
  154053. */
  154054. hdrMinimumLuminance: number;
  154055. /**
  154056. * For eye adaptation, represents the decrease luminance speed
  154057. */
  154058. hdrDecreaseRate: number;
  154059. /**
  154060. * For eye adaptation, represents the increase luminance speed
  154061. */
  154062. hdrIncreaseRate: number;
  154063. /**
  154064. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  154065. */
  154066. get hdrAutoExposure(): boolean;
  154067. /**
  154068. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  154069. */
  154070. set hdrAutoExposure(value: boolean);
  154071. /**
  154072. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  154073. */
  154074. lensColorTexture: Nullable<Texture>;
  154075. /**
  154076. * The overall strengh for the lens flare effect
  154077. */
  154078. lensFlareStrength: number;
  154079. /**
  154080. * Dispersion coefficient for lens flare ghosts
  154081. */
  154082. lensFlareGhostDispersal: number;
  154083. /**
  154084. * Main lens flare halo width
  154085. */
  154086. lensFlareHaloWidth: number;
  154087. /**
  154088. * Based on the lens distortion effect, defines how much the lens flare result
  154089. * is distorted
  154090. */
  154091. lensFlareDistortionStrength: number;
  154092. /**
  154093. * Configures the blur intensity used for for lens flare (halo)
  154094. */
  154095. lensFlareBlurWidth: number;
  154096. /**
  154097. * Lens star texture must be used to simulate rays on the flares and is available
  154098. * in the documentation
  154099. */
  154100. lensStarTexture: Nullable<Texture>;
  154101. /**
  154102. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  154103. * flare effect by taking account of the dirt texture
  154104. */
  154105. lensFlareDirtTexture: Nullable<Texture>;
  154106. /**
  154107. * Represents the focal length for the depth of field effect
  154108. */
  154109. depthOfFieldDistance: number;
  154110. /**
  154111. * Represents the blur intensity for the blurred part of the depth of field effect
  154112. */
  154113. depthOfFieldBlurWidth: number;
  154114. /**
  154115. * Gets how much the image is blurred by the movement while using the motion blur post-process
  154116. */
  154117. get motionStrength(): number;
  154118. /**
  154119. * Sets how much the image is blurred by the movement while using the motion blur post-process
  154120. */
  154121. set motionStrength(strength: number);
  154122. /**
  154123. * Gets wether or not the motion blur post-process is object based or screen based.
  154124. */
  154125. get objectBasedMotionBlur(): boolean;
  154126. /**
  154127. * Sets wether or not the motion blur post-process should be object based or screen based
  154128. */
  154129. set objectBasedMotionBlur(value: boolean);
  154130. /**
  154131. * List of animations for the pipeline (IAnimatable implementation)
  154132. */
  154133. animations: Animation[];
  154134. /**
  154135. * Private members
  154136. */
  154137. private _scene;
  154138. private _currentDepthOfFieldSource;
  154139. private _basePostProcess;
  154140. private _fixedExposure;
  154141. private _currentExposure;
  154142. private _hdrAutoExposure;
  154143. private _hdrCurrentLuminance;
  154144. private _motionStrength;
  154145. private _isObjectBasedMotionBlur;
  154146. private _floatTextureType;
  154147. private _camerasToBeAttached;
  154148. private _ratio;
  154149. private _bloomEnabled;
  154150. private _depthOfFieldEnabled;
  154151. private _vlsEnabled;
  154152. private _lensFlareEnabled;
  154153. private _hdrEnabled;
  154154. private _motionBlurEnabled;
  154155. private _fxaaEnabled;
  154156. private _screenSpaceReflectionsEnabled;
  154157. private _motionBlurSamples;
  154158. private _volumetricLightStepsCount;
  154159. private _samples;
  154160. /**
  154161. * @ignore
  154162. * Specifies if the bloom pipeline is enabled
  154163. */
  154164. get BloomEnabled(): boolean;
  154165. set BloomEnabled(enabled: boolean);
  154166. /**
  154167. * @ignore
  154168. * Specifies if the depth of field pipeline is enabed
  154169. */
  154170. get DepthOfFieldEnabled(): boolean;
  154171. set DepthOfFieldEnabled(enabled: boolean);
  154172. /**
  154173. * @ignore
  154174. * Specifies if the lens flare pipeline is enabed
  154175. */
  154176. get LensFlareEnabled(): boolean;
  154177. set LensFlareEnabled(enabled: boolean);
  154178. /**
  154179. * @ignore
  154180. * Specifies if the HDR pipeline is enabled
  154181. */
  154182. get HDREnabled(): boolean;
  154183. set HDREnabled(enabled: boolean);
  154184. /**
  154185. * @ignore
  154186. * Specifies if the volumetric lights scattering effect is enabled
  154187. */
  154188. get VLSEnabled(): boolean;
  154189. set VLSEnabled(enabled: boolean);
  154190. /**
  154191. * @ignore
  154192. * Specifies if the motion blur effect is enabled
  154193. */
  154194. get MotionBlurEnabled(): boolean;
  154195. set MotionBlurEnabled(enabled: boolean);
  154196. /**
  154197. * Specifies if anti-aliasing is enabled
  154198. */
  154199. get fxaaEnabled(): boolean;
  154200. set fxaaEnabled(enabled: boolean);
  154201. /**
  154202. * Specifies if screen space reflections are enabled.
  154203. */
  154204. get screenSpaceReflectionsEnabled(): boolean;
  154205. set screenSpaceReflectionsEnabled(enabled: boolean);
  154206. /**
  154207. * Specifies the number of steps used to calculate the volumetric lights
  154208. * Typically in interval [50, 200]
  154209. */
  154210. get volumetricLightStepsCount(): number;
  154211. set volumetricLightStepsCount(count: number);
  154212. /**
  154213. * Specifies the number of samples used for the motion blur effect
  154214. * Typically in interval [16, 64]
  154215. */
  154216. get motionBlurSamples(): number;
  154217. set motionBlurSamples(samples: number);
  154218. /**
  154219. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  154220. */
  154221. get samples(): number;
  154222. set samples(sampleCount: number);
  154223. /**
  154224. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  154225. * @constructor
  154226. * @param name The rendering pipeline name
  154227. * @param scene The scene linked to this pipeline
  154228. * @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)
  154229. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  154230. * @param cameras The array of cameras that the rendering pipeline will be attached to
  154231. */
  154232. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  154233. private _buildPipeline;
  154234. private _createDownSampleX4PostProcess;
  154235. private _createBrightPassPostProcess;
  154236. private _createBlurPostProcesses;
  154237. private _createTextureAdderPostProcess;
  154238. private _createVolumetricLightPostProcess;
  154239. private _createLuminancePostProcesses;
  154240. private _createHdrPostProcess;
  154241. private _createLensFlarePostProcess;
  154242. private _createDepthOfFieldPostProcess;
  154243. private _createMotionBlurPostProcess;
  154244. private _getDepthTexture;
  154245. private _disposePostProcesses;
  154246. /**
  154247. * Dispose of the pipeline and stop all post processes
  154248. */
  154249. dispose(): void;
  154250. /**
  154251. * Serialize the rendering pipeline (Used when exporting)
  154252. * @returns the serialized object
  154253. */
  154254. serialize(): any;
  154255. /**
  154256. * Parse the serialized pipeline
  154257. * @param source Source pipeline.
  154258. * @param scene The scene to load the pipeline to.
  154259. * @param rootUrl The URL of the serialized pipeline.
  154260. * @returns An instantiated pipeline from the serialized object.
  154261. */
  154262. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  154263. /**
  154264. * Luminance steps
  154265. */
  154266. static LuminanceSteps: number;
  154267. }
  154268. }
  154269. declare module BABYLON {
  154270. /** @hidden */
  154271. export var stereoscopicInterlacePixelShader: {
  154272. name: string;
  154273. shader: string;
  154274. };
  154275. }
  154276. declare module BABYLON {
  154277. /**
  154278. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  154279. */
  154280. export class StereoscopicInterlacePostProcessI extends PostProcess {
  154281. private _stepSize;
  154282. private _passedProcess;
  154283. /**
  154284. * Gets a string identifying the name of the class
  154285. * @returns "StereoscopicInterlacePostProcessI" string
  154286. */
  154287. getClassName(): string;
  154288. /**
  154289. * Initializes a StereoscopicInterlacePostProcessI
  154290. * @param name The name of the effect.
  154291. * @param rigCameras The rig cameras to be appled to the post process
  154292. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  154293. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  154294. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  154295. * @param engine The engine which the post process will be applied. (default: current engine)
  154296. * @param reusable If the post process can be reused on the same frame. (default: false)
  154297. */
  154298. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  154299. }
  154300. /**
  154301. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  154302. */
  154303. export class StereoscopicInterlacePostProcess extends PostProcess {
  154304. private _stepSize;
  154305. private _passedProcess;
  154306. /**
  154307. * Gets a string identifying the name of the class
  154308. * @returns "StereoscopicInterlacePostProcess" string
  154309. */
  154310. getClassName(): string;
  154311. /**
  154312. * Initializes a StereoscopicInterlacePostProcess
  154313. * @param name The name of the effect.
  154314. * @param rigCameras The rig cameras to be appled to the post process
  154315. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  154316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  154317. * @param engine The engine which the post process will be applied. (default: current engine)
  154318. * @param reusable If the post process can be reused on the same frame. (default: false)
  154319. */
  154320. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  154321. }
  154322. }
  154323. declare module BABYLON {
  154324. /** @hidden */
  154325. export var tonemapPixelShader: {
  154326. name: string;
  154327. shader: string;
  154328. };
  154329. }
  154330. declare module BABYLON {
  154331. /** Defines operator used for tonemapping */
  154332. export enum TonemappingOperator {
  154333. /** Hable */
  154334. Hable = 0,
  154335. /** Reinhard */
  154336. Reinhard = 1,
  154337. /** HejiDawson */
  154338. HejiDawson = 2,
  154339. /** Photographic */
  154340. Photographic = 3
  154341. }
  154342. /**
  154343. * Defines a post process to apply tone mapping
  154344. */
  154345. export class TonemapPostProcess extends PostProcess {
  154346. private _operator;
  154347. /** Defines the required exposure adjustement */
  154348. exposureAdjustment: number;
  154349. /**
  154350. * Gets a string identifying the name of the class
  154351. * @returns "TonemapPostProcess" string
  154352. */
  154353. getClassName(): string;
  154354. /**
  154355. * Creates a new TonemapPostProcess
  154356. * @param name defines the name of the postprocess
  154357. * @param _operator defines the operator to use
  154358. * @param exposureAdjustment defines the required exposure adjustement
  154359. * @param camera defines the camera to use (can be null)
  154360. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  154361. * @param engine defines the hosting engine (can be ignore if camera is set)
  154362. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  154363. */
  154364. constructor(name: string, _operator: TonemappingOperator,
  154365. /** Defines the required exposure adjustement */
  154366. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  154367. }
  154368. }
  154369. declare module BABYLON {
  154370. /** @hidden */
  154371. export var volumetricLightScatteringPixelShader: {
  154372. name: string;
  154373. shader: string;
  154374. };
  154375. }
  154376. declare module BABYLON {
  154377. /** @hidden */
  154378. export var volumetricLightScatteringPassVertexShader: {
  154379. name: string;
  154380. shader: string;
  154381. };
  154382. }
  154383. declare module BABYLON {
  154384. /** @hidden */
  154385. export var volumetricLightScatteringPassPixelShader: {
  154386. name: string;
  154387. shader: string;
  154388. };
  154389. }
  154390. declare module BABYLON {
  154391. /**
  154392. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  154393. */
  154394. export class VolumetricLightScatteringPostProcess extends PostProcess {
  154395. private _volumetricLightScatteringPass;
  154396. private _volumetricLightScatteringRTT;
  154397. private _viewPort;
  154398. private _screenCoordinates;
  154399. private _cachedDefines;
  154400. /**
  154401. * If not undefined, the mesh position is computed from the attached node position
  154402. */
  154403. attachedNode: {
  154404. position: Vector3;
  154405. };
  154406. /**
  154407. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  154408. */
  154409. customMeshPosition: Vector3;
  154410. /**
  154411. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  154412. */
  154413. useCustomMeshPosition: boolean;
  154414. /**
  154415. * If the post-process should inverse the light scattering direction
  154416. */
  154417. invert: boolean;
  154418. /**
  154419. * The internal mesh used by the post-process
  154420. */
  154421. mesh: Mesh;
  154422. /**
  154423. * @hidden
  154424. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  154425. */
  154426. get useDiffuseColor(): boolean;
  154427. set useDiffuseColor(useDiffuseColor: boolean);
  154428. /**
  154429. * Array containing the excluded meshes not rendered in the internal pass
  154430. */
  154431. excludedMeshes: AbstractMesh[];
  154432. /**
  154433. * Controls the overall intensity of the post-process
  154434. */
  154435. exposure: number;
  154436. /**
  154437. * Dissipates each sample's contribution in range [0, 1]
  154438. */
  154439. decay: number;
  154440. /**
  154441. * Controls the overall intensity of each sample
  154442. */
  154443. weight: number;
  154444. /**
  154445. * Controls the density of each sample
  154446. */
  154447. density: number;
  154448. /**
  154449. * @constructor
  154450. * @param name The post-process name
  154451. * @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)
  154452. * @param camera The camera that the post-process will be attached to
  154453. * @param mesh The mesh used to create the light scattering
  154454. * @param samples The post-process quality, default 100
  154455. * @param samplingModeThe post-process filtering mode
  154456. * @param engine The babylon engine
  154457. * @param reusable If the post-process is reusable
  154458. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  154459. */
  154460. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  154461. /**
  154462. * Returns the string "VolumetricLightScatteringPostProcess"
  154463. * @returns "VolumetricLightScatteringPostProcess"
  154464. */
  154465. getClassName(): string;
  154466. private _isReady;
  154467. /**
  154468. * Sets the new light position for light scattering effect
  154469. * @param position The new custom light position
  154470. */
  154471. setCustomMeshPosition(position: Vector3): void;
  154472. /**
  154473. * Returns the light position for light scattering effect
  154474. * @return Vector3 The custom light position
  154475. */
  154476. getCustomMeshPosition(): Vector3;
  154477. /**
  154478. * Disposes the internal assets and detaches the post-process from the camera
  154479. */
  154480. dispose(camera: Camera): void;
  154481. /**
  154482. * Returns the render target texture used by the post-process
  154483. * @return the render target texture used by the post-process
  154484. */
  154485. getPass(): RenderTargetTexture;
  154486. private _meshExcluded;
  154487. private _createPass;
  154488. private _updateMeshScreenCoordinates;
  154489. /**
  154490. * Creates a default mesh for the Volumeric Light Scattering post-process
  154491. * @param name The mesh name
  154492. * @param scene The scene where to create the mesh
  154493. * @return the default mesh
  154494. */
  154495. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  154496. }
  154497. }
  154498. declare module BABYLON {
  154499. /** @hidden */
  154500. export var screenSpaceCurvaturePixelShader: {
  154501. name: string;
  154502. shader: string;
  154503. };
  154504. }
  154505. declare module BABYLON {
  154506. /**
  154507. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  154508. */
  154509. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  154510. /**
  154511. * Defines how much ridge the curvature effect displays.
  154512. */
  154513. ridge: number;
  154514. /**
  154515. * Defines how much valley the curvature effect displays.
  154516. */
  154517. valley: number;
  154518. private _geometryBufferRenderer;
  154519. /**
  154520. * Gets a string identifying the name of the class
  154521. * @returns "ScreenSpaceCurvaturePostProcess" string
  154522. */
  154523. getClassName(): string;
  154524. /**
  154525. * Creates a new instance ScreenSpaceCurvaturePostProcess
  154526. * @param name The name of the effect.
  154527. * @param scene The scene containing the objects to blur according to their velocity.
  154528. * @param options The required width/height ratio to downsize to before computing the render pass.
  154529. * @param camera The camera to apply the render pass to.
  154530. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  154531. * @param engine The engine which the post process will be applied. (default: current engine)
  154532. * @param reusable If the post process can be reused on the same frame. (default: false)
  154533. * @param textureType Type of textures used when performing the post process. (default: 0)
  154534. * @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)
  154535. */
  154536. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  154537. /**
  154538. * Support test.
  154539. */
  154540. static get IsSupported(): boolean;
  154541. /** @hidden */
  154542. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  154543. }
  154544. }
  154545. declare module BABYLON {
  154546. interface Scene {
  154547. /** @hidden (Backing field) */
  154548. _boundingBoxRenderer: BoundingBoxRenderer;
  154549. /** @hidden (Backing field) */
  154550. _forceShowBoundingBoxes: boolean;
  154551. /**
  154552. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  154553. */
  154554. forceShowBoundingBoxes: boolean;
  154555. /**
  154556. * Gets the bounding box renderer associated with the scene
  154557. * @returns a BoundingBoxRenderer
  154558. */
  154559. getBoundingBoxRenderer(): BoundingBoxRenderer;
  154560. }
  154561. interface AbstractMesh {
  154562. /** @hidden (Backing field) */
  154563. _showBoundingBox: boolean;
  154564. /**
  154565. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  154566. */
  154567. showBoundingBox: boolean;
  154568. }
  154569. /**
  154570. * Component responsible of rendering the bounding box of the meshes in a scene.
  154571. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  154572. */
  154573. export class BoundingBoxRenderer implements ISceneComponent {
  154574. /**
  154575. * The component name helpfull to identify the component in the list of scene components.
  154576. */
  154577. readonly name: string;
  154578. /**
  154579. * The scene the component belongs to.
  154580. */
  154581. scene: Scene;
  154582. /**
  154583. * Color of the bounding box lines placed in front of an object
  154584. */
  154585. frontColor: Color3;
  154586. /**
  154587. * Color of the bounding box lines placed behind an object
  154588. */
  154589. backColor: Color3;
  154590. /**
  154591. * Defines if the renderer should show the back lines or not
  154592. */
  154593. showBackLines: boolean;
  154594. /**
  154595. * Observable raised before rendering a bounding box
  154596. */
  154597. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  154598. /**
  154599. * Observable raised after rendering a bounding box
  154600. */
  154601. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  154602. /**
  154603. * Observable raised after resources are created
  154604. */
  154605. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  154606. /**
  154607. * When false, no bounding boxes will be rendered
  154608. */
  154609. enabled: boolean;
  154610. /**
  154611. * @hidden
  154612. */
  154613. renderList: SmartArray<BoundingBox>;
  154614. private _colorShader;
  154615. private _vertexBuffers;
  154616. private _indexBuffer;
  154617. private _fillIndexBuffer;
  154618. private _fillIndexData;
  154619. /**
  154620. * Instantiates a new bounding box renderer in a scene.
  154621. * @param scene the scene the renderer renders in
  154622. */
  154623. constructor(scene: Scene);
  154624. /**
  154625. * Registers the component in a given scene
  154626. */
  154627. register(): void;
  154628. private _evaluateSubMesh;
  154629. private _preActiveMesh;
  154630. private _prepareResources;
  154631. private _createIndexBuffer;
  154632. /**
  154633. * Rebuilds the elements related to this component in case of
  154634. * context lost for instance.
  154635. */
  154636. rebuild(): void;
  154637. /**
  154638. * @hidden
  154639. */
  154640. reset(): void;
  154641. /**
  154642. * Render the bounding boxes of a specific rendering group
  154643. * @param renderingGroupId defines the rendering group to render
  154644. */
  154645. render(renderingGroupId: number): void;
  154646. /**
  154647. * In case of occlusion queries, we can render the occlusion bounding box through this method
  154648. * @param mesh Define the mesh to render the occlusion bounding box for
  154649. */
  154650. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  154651. /**
  154652. * Dispose and release the resources attached to this renderer.
  154653. */
  154654. dispose(): void;
  154655. }
  154656. }
  154657. declare module BABYLON {
  154658. interface Scene {
  154659. /** @hidden (Backing field) */
  154660. _depthRenderer: {
  154661. [id: string]: DepthRenderer;
  154662. };
  154663. /**
  154664. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  154665. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  154666. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  154667. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  154668. * @returns the created depth renderer
  154669. */
  154670. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  154671. /**
  154672. * Disables a depth renderer for a given camera
  154673. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  154674. */
  154675. disableDepthRenderer(camera?: Nullable<Camera>): void;
  154676. }
  154677. /**
  154678. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  154679. * in several rendering techniques.
  154680. */
  154681. export class DepthRendererSceneComponent implements ISceneComponent {
  154682. /**
  154683. * The component name helpfull to identify the component in the list of scene components.
  154684. */
  154685. readonly name: string;
  154686. /**
  154687. * The scene the component belongs to.
  154688. */
  154689. scene: Scene;
  154690. /**
  154691. * Creates a new instance of the component for the given scene
  154692. * @param scene Defines the scene to register the component in
  154693. */
  154694. constructor(scene: Scene);
  154695. /**
  154696. * Registers the component in a given scene
  154697. */
  154698. register(): void;
  154699. /**
  154700. * Rebuilds the elements related to this component in case of
  154701. * context lost for instance.
  154702. */
  154703. rebuild(): void;
  154704. /**
  154705. * Disposes the component and the associated ressources
  154706. */
  154707. dispose(): void;
  154708. private _gatherRenderTargets;
  154709. private _gatherActiveCameraRenderTargets;
  154710. }
  154711. }
  154712. declare module BABYLON {
  154713. interface AbstractScene {
  154714. /** @hidden (Backing field) */
  154715. _prePassRenderer: Nullable<PrePassRenderer>;
  154716. /**
  154717. * Gets or Sets the current prepass renderer associated to the scene.
  154718. */
  154719. prePassRenderer: Nullable<PrePassRenderer>;
  154720. /**
  154721. * Enables the prepass and associates it with the scene
  154722. * @returns the PrePassRenderer
  154723. */
  154724. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  154725. /**
  154726. * Disables the prepass associated with the scene
  154727. */
  154728. disablePrePassRenderer(): void;
  154729. }
  154730. /**
  154731. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  154732. * in several rendering techniques.
  154733. */
  154734. export class PrePassRendererSceneComponent implements ISceneComponent {
  154735. /**
  154736. * The component name helpful to identify the component in the list of scene components.
  154737. */
  154738. readonly name: string;
  154739. /**
  154740. * The scene the component belongs to.
  154741. */
  154742. scene: Scene;
  154743. /**
  154744. * Creates a new instance of the component for the given scene
  154745. * @param scene Defines the scene to register the component in
  154746. */
  154747. constructor(scene: Scene);
  154748. /**
  154749. * Registers the component in a given scene
  154750. */
  154751. register(): void;
  154752. private _beforeCameraDraw;
  154753. private _afterCameraDraw;
  154754. private _beforeClearStage;
  154755. /**
  154756. * Rebuilds the elements related to this component in case of
  154757. * context lost for instance.
  154758. */
  154759. rebuild(): void;
  154760. /**
  154761. * Disposes the component and the associated ressources
  154762. */
  154763. dispose(): void;
  154764. }
  154765. }
  154766. declare module BABYLON {
  154767. /** @hidden */
  154768. export var fibonacci: {
  154769. name: string;
  154770. shader: string;
  154771. };
  154772. }
  154773. declare module BABYLON {
  154774. /** @hidden */
  154775. export var diffusionProfile: {
  154776. name: string;
  154777. shader: string;
  154778. };
  154779. }
  154780. declare module BABYLON {
  154781. /** @hidden */
  154782. export var subSurfaceScatteringPixelShader: {
  154783. name: string;
  154784. shader: string;
  154785. };
  154786. }
  154787. declare module BABYLON {
  154788. /**
  154789. * Sub surface scattering post process
  154790. */
  154791. export class SubSurfaceScatteringPostProcess extends PostProcess {
  154792. /**
  154793. * Gets a string identifying the name of the class
  154794. * @returns "SubSurfaceScatteringPostProcess" string
  154795. */
  154796. getClassName(): string;
  154797. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  154798. }
  154799. }
  154800. declare module BABYLON {
  154801. /**
  154802. * Contains all parameters needed for the prepass to perform
  154803. * screen space subsurface scattering
  154804. */
  154805. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  154806. /** @hidden */
  154807. static _SceneComponentInitialization: (scene: Scene) => void;
  154808. private _ssDiffusionS;
  154809. private _ssFilterRadii;
  154810. private _ssDiffusionD;
  154811. /**
  154812. * Post process to attach for screen space subsurface scattering
  154813. */
  154814. postProcess: SubSurfaceScatteringPostProcess;
  154815. /**
  154816. * Diffusion profile color for subsurface scattering
  154817. */
  154818. get ssDiffusionS(): number[];
  154819. /**
  154820. * Diffusion profile max color channel value for subsurface scattering
  154821. */
  154822. get ssDiffusionD(): number[];
  154823. /**
  154824. * Diffusion profile filter radius for subsurface scattering
  154825. */
  154826. get ssFilterRadii(): number[];
  154827. /**
  154828. * Is subsurface enabled
  154829. */
  154830. enabled: boolean;
  154831. /**
  154832. * Name of the configuration
  154833. */
  154834. name: string;
  154835. /**
  154836. * Diffusion profile colors for subsurface scattering
  154837. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  154838. * See ...
  154839. * Note that you can only store up to 5 of them
  154840. */
  154841. ssDiffusionProfileColors: Color3[];
  154842. /**
  154843. * Defines the ratio real world => scene units.
  154844. * Used for subsurface scattering
  154845. */
  154846. metersPerUnit: number;
  154847. /**
  154848. * Textures that should be present in the MRT for this effect to work
  154849. */
  154850. readonly texturesRequired: number[];
  154851. private _scene;
  154852. /**
  154853. * Builds a subsurface configuration object
  154854. * @param scene The scene
  154855. */
  154856. constructor(scene: Scene);
  154857. /**
  154858. * Adds a new diffusion profile.
  154859. * Useful for more realistic subsurface scattering on diverse materials.
  154860. * @param color The color of the diffusion profile. Should be the average color of the material.
  154861. * @return The index of the diffusion profile for the material subsurface configuration
  154862. */
  154863. addDiffusionProfile(color: Color3): number;
  154864. /**
  154865. * Creates the sss post process
  154866. * @return The created post process
  154867. */
  154868. createPostProcess(): SubSurfaceScatteringPostProcess;
  154869. /**
  154870. * Deletes all diffusion profiles.
  154871. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  154872. */
  154873. clearAllDiffusionProfiles(): void;
  154874. /**
  154875. * Disposes this object
  154876. */
  154877. dispose(): void;
  154878. /**
  154879. * @hidden
  154880. * https://zero-radiance.github.io/post/sampling-diffusion/
  154881. *
  154882. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  154883. * ------------------------------------------------------------------------------------
  154884. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  154885. * PDF[r, phi, s] = r * R[r, phi, s]
  154886. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  154887. * ------------------------------------------------------------------------------------
  154888. * We importance sample the color channel with the widest scattering distance.
  154889. */
  154890. getDiffusionProfileParameters(color: Color3): number;
  154891. /**
  154892. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  154893. * 'u' is the random number (the value of the CDF): [0, 1).
  154894. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  154895. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  154896. */
  154897. private _sampleBurleyDiffusionProfile;
  154898. }
  154899. }
  154900. declare module BABYLON {
  154901. interface AbstractScene {
  154902. /** @hidden (Backing field) */
  154903. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  154904. /**
  154905. * Gets or Sets the current prepass renderer associated to the scene.
  154906. */
  154907. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  154908. /**
  154909. * Enables the subsurface effect for prepass
  154910. * @returns the SubSurfaceConfiguration
  154911. */
  154912. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  154913. /**
  154914. * Disables the subsurface effect for prepass
  154915. */
  154916. disableSubSurfaceForPrePass(): void;
  154917. }
  154918. /**
  154919. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  154920. * in several rendering techniques.
  154921. */
  154922. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  154923. /**
  154924. * The component name helpful to identify the component in the list of scene components.
  154925. */
  154926. readonly name: string;
  154927. /**
  154928. * The scene the component belongs to.
  154929. */
  154930. scene: Scene;
  154931. /**
  154932. * Creates a new instance of the component for the given scene
  154933. * @param scene Defines the scene to register the component in
  154934. */
  154935. constructor(scene: Scene);
  154936. /**
  154937. * Registers the component in a given scene
  154938. */
  154939. register(): void;
  154940. /**
  154941. * Serializes the component data to the specified json object
  154942. * @param serializationObject The object to serialize to
  154943. */
  154944. serialize(serializationObject: any): void;
  154945. /**
  154946. * Adds all the elements from the container to the scene
  154947. * @param container the container holding the elements
  154948. */
  154949. addFromContainer(container: AbstractScene): void;
  154950. /**
  154951. * Removes all the elements in the container from the scene
  154952. * @param container contains the elements to remove
  154953. * @param dispose if the removed element should be disposed (default: false)
  154954. */
  154955. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  154956. /**
  154957. * Rebuilds the elements related to this component in case of
  154958. * context lost for instance.
  154959. */
  154960. rebuild(): void;
  154961. /**
  154962. * Disposes the component and the associated ressources
  154963. */
  154964. dispose(): void;
  154965. }
  154966. }
  154967. declare module BABYLON {
  154968. /** @hidden */
  154969. export var outlinePixelShader: {
  154970. name: string;
  154971. shader: string;
  154972. };
  154973. }
  154974. declare module BABYLON {
  154975. /** @hidden */
  154976. export var outlineVertexShader: {
  154977. name: string;
  154978. shader: string;
  154979. };
  154980. }
  154981. declare module BABYLON {
  154982. interface Scene {
  154983. /** @hidden */
  154984. _outlineRenderer: OutlineRenderer;
  154985. /**
  154986. * Gets the outline renderer associated with the scene
  154987. * @returns a OutlineRenderer
  154988. */
  154989. getOutlineRenderer(): OutlineRenderer;
  154990. }
  154991. interface AbstractMesh {
  154992. /** @hidden (Backing field) */
  154993. _renderOutline: boolean;
  154994. /**
  154995. * Gets or sets a boolean indicating if the outline must be rendered as well
  154996. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  154997. */
  154998. renderOutline: boolean;
  154999. /** @hidden (Backing field) */
  155000. _renderOverlay: boolean;
  155001. /**
  155002. * Gets or sets a boolean indicating if the overlay must be rendered as well
  155003. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  155004. */
  155005. renderOverlay: boolean;
  155006. }
  155007. /**
  155008. * This class is responsible to draw bothe outline/overlay of meshes.
  155009. * It should not be used directly but through the available method on mesh.
  155010. */
  155011. export class OutlineRenderer implements ISceneComponent {
  155012. /**
  155013. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  155014. */
  155015. private static _StencilReference;
  155016. /**
  155017. * The name of the component. Each component must have a unique name.
  155018. */
  155019. name: string;
  155020. /**
  155021. * The scene the component belongs to.
  155022. */
  155023. scene: Scene;
  155024. /**
  155025. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  155026. */
  155027. zOffset: number;
  155028. private _engine;
  155029. private _effect;
  155030. private _cachedDefines;
  155031. private _savedDepthWrite;
  155032. /**
  155033. * Instantiates a new outline renderer. (There could be only one per scene).
  155034. * @param scene Defines the scene it belongs to
  155035. */
  155036. constructor(scene: Scene);
  155037. /**
  155038. * Register the component to one instance of a scene.
  155039. */
  155040. register(): void;
  155041. /**
  155042. * Rebuilds the elements related to this component in case of
  155043. * context lost for instance.
  155044. */
  155045. rebuild(): void;
  155046. /**
  155047. * Disposes the component and the associated ressources.
  155048. */
  155049. dispose(): void;
  155050. /**
  155051. * Renders the outline in the canvas.
  155052. * @param subMesh Defines the sumesh to render
  155053. * @param batch Defines the batch of meshes in case of instances
  155054. * @param useOverlay Defines if the rendering is for the overlay or the outline
  155055. */
  155056. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  155057. /**
  155058. * Returns whether or not the outline renderer is ready for a given submesh.
  155059. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  155060. * @param subMesh Defines the submesh to check readyness for
  155061. * @param useInstances Defines wheter wee are trying to render instances or not
  155062. * @returns true if ready otherwise false
  155063. */
  155064. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  155065. private _beforeRenderingMesh;
  155066. private _afterRenderingMesh;
  155067. }
  155068. }
  155069. declare module BABYLON {
  155070. /**
  155071. * Defines the basic options interface of a Sprite Frame Source Size.
  155072. */
  155073. export interface ISpriteJSONSpriteSourceSize {
  155074. /**
  155075. * number of the original width of the Frame
  155076. */
  155077. w: number;
  155078. /**
  155079. * number of the original height of the Frame
  155080. */
  155081. h: number;
  155082. }
  155083. /**
  155084. * Defines the basic options interface of a Sprite Frame Data.
  155085. */
  155086. export interface ISpriteJSONSpriteFrameData {
  155087. /**
  155088. * number of the x offset of the Frame
  155089. */
  155090. x: number;
  155091. /**
  155092. * number of the y offset of the Frame
  155093. */
  155094. y: number;
  155095. /**
  155096. * number of the width of the Frame
  155097. */
  155098. w: number;
  155099. /**
  155100. * number of the height of the Frame
  155101. */
  155102. h: number;
  155103. }
  155104. /**
  155105. * Defines the basic options interface of a JSON Sprite.
  155106. */
  155107. export interface ISpriteJSONSprite {
  155108. /**
  155109. * string name of the Frame
  155110. */
  155111. filename: string;
  155112. /**
  155113. * ISpriteJSONSpriteFrame basic object of the frame data
  155114. */
  155115. frame: ISpriteJSONSpriteFrameData;
  155116. /**
  155117. * boolean to flag is the frame was rotated.
  155118. */
  155119. rotated: boolean;
  155120. /**
  155121. * boolean to flag is the frame was trimmed.
  155122. */
  155123. trimmed: boolean;
  155124. /**
  155125. * ISpriteJSONSpriteFrame basic object of the source data
  155126. */
  155127. spriteSourceSize: ISpriteJSONSpriteFrameData;
  155128. /**
  155129. * ISpriteJSONSpriteFrame basic object of the source data
  155130. */
  155131. sourceSize: ISpriteJSONSpriteSourceSize;
  155132. }
  155133. /**
  155134. * Defines the basic options interface of a JSON atlas.
  155135. */
  155136. export interface ISpriteJSONAtlas {
  155137. /**
  155138. * Array of objects that contain the frame data.
  155139. */
  155140. frames: Array<ISpriteJSONSprite>;
  155141. /**
  155142. * object basic object containing the sprite meta data.
  155143. */
  155144. meta?: object;
  155145. }
  155146. }
  155147. declare module BABYLON {
  155148. /** @hidden */
  155149. export var spriteMapPixelShader: {
  155150. name: string;
  155151. shader: string;
  155152. };
  155153. }
  155154. declare module BABYLON {
  155155. /** @hidden */
  155156. export var spriteMapVertexShader: {
  155157. name: string;
  155158. shader: string;
  155159. };
  155160. }
  155161. declare module BABYLON {
  155162. /**
  155163. * Defines the basic options interface of a SpriteMap
  155164. */
  155165. export interface ISpriteMapOptions {
  155166. /**
  155167. * Vector2 of the number of cells in the grid.
  155168. */
  155169. stageSize?: Vector2;
  155170. /**
  155171. * Vector2 of the size of the output plane in World Units.
  155172. */
  155173. outputSize?: Vector2;
  155174. /**
  155175. * Vector3 of the position of the output plane in World Units.
  155176. */
  155177. outputPosition?: Vector3;
  155178. /**
  155179. * Vector3 of the rotation of the output plane.
  155180. */
  155181. outputRotation?: Vector3;
  155182. /**
  155183. * number of layers that the system will reserve in resources.
  155184. */
  155185. layerCount?: number;
  155186. /**
  155187. * number of max animation frames a single cell will reserve in resources.
  155188. */
  155189. maxAnimationFrames?: number;
  155190. /**
  155191. * number cell index of the base tile when the system compiles.
  155192. */
  155193. baseTile?: number;
  155194. /**
  155195. * boolean flip the sprite after its been repositioned by the framing data.
  155196. */
  155197. flipU?: boolean;
  155198. /**
  155199. * Vector3 scalar of the global RGB values of the SpriteMap.
  155200. */
  155201. colorMultiply?: Vector3;
  155202. }
  155203. /**
  155204. * Defines the IDisposable interface in order to be cleanable from resources.
  155205. */
  155206. export interface ISpriteMap extends IDisposable {
  155207. /**
  155208. * String name of the SpriteMap.
  155209. */
  155210. name: string;
  155211. /**
  155212. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  155213. */
  155214. atlasJSON: ISpriteJSONAtlas;
  155215. /**
  155216. * Texture of the SpriteMap.
  155217. */
  155218. spriteSheet: Texture;
  155219. /**
  155220. * The parameters to initialize the SpriteMap with.
  155221. */
  155222. options: ISpriteMapOptions;
  155223. }
  155224. /**
  155225. * Class used to manage a grid restricted sprite deployment on an Output plane.
  155226. */
  155227. export class SpriteMap implements ISpriteMap {
  155228. /** The Name of the spriteMap */
  155229. name: string;
  155230. /** The JSON file with the frame and meta data */
  155231. atlasJSON: ISpriteJSONAtlas;
  155232. /** The systems Sprite Sheet Texture */
  155233. spriteSheet: Texture;
  155234. /** Arguments passed with the Constructor */
  155235. options: ISpriteMapOptions;
  155236. /** Public Sprite Storage array, parsed from atlasJSON */
  155237. sprites: Array<ISpriteJSONSprite>;
  155238. /** Returns the Number of Sprites in the System */
  155239. get spriteCount(): number;
  155240. /** Returns the Position of Output Plane*/
  155241. get position(): Vector3;
  155242. /** Returns the Position of Output Plane*/
  155243. set position(v: Vector3);
  155244. /** Returns the Rotation of Output Plane*/
  155245. get rotation(): Vector3;
  155246. /** Returns the Rotation of Output Plane*/
  155247. set rotation(v: Vector3);
  155248. /** Sets the AnimationMap*/
  155249. get animationMap(): RawTexture;
  155250. /** Sets the AnimationMap*/
  155251. set animationMap(v: RawTexture);
  155252. /** Scene that the SpriteMap was created in */
  155253. private _scene;
  155254. /** Texture Buffer of Float32 that holds tile frame data*/
  155255. private _frameMap;
  155256. /** Texture Buffers of Float32 that holds tileMap data*/
  155257. private _tileMaps;
  155258. /** Texture Buffer of Float32 that holds Animation Data*/
  155259. private _animationMap;
  155260. /** Custom ShaderMaterial Central to the System*/
  155261. private _material;
  155262. /** Custom ShaderMaterial Central to the System*/
  155263. private _output;
  155264. /** Systems Time Ticker*/
  155265. private _time;
  155266. /**
  155267. * Creates a new SpriteMap
  155268. * @param name defines the SpriteMaps Name
  155269. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  155270. * @param spriteSheet is the Texture that the Sprites are on.
  155271. * @param options a basic deployment configuration
  155272. * @param scene The Scene that the map is deployed on
  155273. */
  155274. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  155275. /**
  155276. * Returns tileID location
  155277. * @returns Vector2 the cell position ID
  155278. */
  155279. getTileID(): Vector2;
  155280. /**
  155281. * Gets the UV location of the mouse over the SpriteMap.
  155282. * @returns Vector2 the UV position of the mouse interaction
  155283. */
  155284. getMousePosition(): Vector2;
  155285. /**
  155286. * Creates the "frame" texture Buffer
  155287. * -------------------------------------
  155288. * Structure of frames
  155289. * "filename": "Falling-Water-2.png",
  155290. * "frame": {"x":69,"y":103,"w":24,"h":32},
  155291. * "rotated": true,
  155292. * "trimmed": true,
  155293. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  155294. * "sourceSize": {"w":32,"h":32}
  155295. * @returns RawTexture of the frameMap
  155296. */
  155297. private _createFrameBuffer;
  155298. /**
  155299. * Creates the tileMap texture Buffer
  155300. * @param buffer normally and array of numbers, or a false to generate from scratch
  155301. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  155302. * @returns RawTexture of the tileMap
  155303. */
  155304. private _createTileBuffer;
  155305. /**
  155306. * Modifies the data of the tileMaps
  155307. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  155308. * @param pos is the iVector2 Coordinates of the Tile
  155309. * @param tile The SpriteIndex of the new Tile
  155310. */
  155311. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  155312. /**
  155313. * Creates the animationMap texture Buffer
  155314. * @param buffer normally and array of numbers, or a false to generate from scratch
  155315. * @returns RawTexture of the animationMap
  155316. */
  155317. private _createTileAnimationBuffer;
  155318. /**
  155319. * Modifies the data of the animationMap
  155320. * @param cellID is the Index of the Sprite
  155321. * @param _frame is the target Animation frame
  155322. * @param toCell is the Target Index of the next frame of the animation
  155323. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  155324. * @param speed is a global scalar of the time variable on the map.
  155325. */
  155326. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  155327. /**
  155328. * Exports the .tilemaps file
  155329. */
  155330. saveTileMaps(): void;
  155331. /**
  155332. * Imports the .tilemaps file
  155333. * @param url of the .tilemaps file
  155334. */
  155335. loadTileMaps(url: string): void;
  155336. /**
  155337. * Release associated resources
  155338. */
  155339. dispose(): void;
  155340. }
  155341. }
  155342. declare module BABYLON {
  155343. /**
  155344. * Class used to manage multiple sprites of different sizes on the same spritesheet
  155345. * @see https://doc.babylonjs.com/babylon101/sprites
  155346. */
  155347. export class SpritePackedManager extends SpriteManager {
  155348. /** defines the packed manager's name */
  155349. name: string;
  155350. /**
  155351. * Creates a new sprite manager from a packed sprite sheet
  155352. * @param name defines the manager's name
  155353. * @param imgUrl defines the sprite sheet url
  155354. * @param capacity defines the maximum allowed number of sprites
  155355. * @param scene defines the hosting scene
  155356. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  155357. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  155358. * @param samplingMode defines the smapling mode to use with spritesheet
  155359. * @param fromPacked set to true; do not alter
  155360. */
  155361. constructor(
  155362. /** defines the packed manager's name */
  155363. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  155364. }
  155365. }
  155366. declare module BABYLON {
  155367. /**
  155368. * Defines the list of states available for a task inside a AssetsManager
  155369. */
  155370. export enum AssetTaskState {
  155371. /**
  155372. * Initialization
  155373. */
  155374. INIT = 0,
  155375. /**
  155376. * Running
  155377. */
  155378. RUNNING = 1,
  155379. /**
  155380. * Done
  155381. */
  155382. DONE = 2,
  155383. /**
  155384. * Error
  155385. */
  155386. ERROR = 3
  155387. }
  155388. /**
  155389. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  155390. */
  155391. export abstract class AbstractAssetTask {
  155392. /**
  155393. * Task name
  155394. */ name: string;
  155395. /**
  155396. * Callback called when the task is successful
  155397. */
  155398. onSuccess: (task: any) => void;
  155399. /**
  155400. * Callback called when the task is not successful
  155401. */
  155402. onError: (task: any, message?: string, exception?: any) => void;
  155403. /**
  155404. * Creates a new AssetsManager
  155405. * @param name defines the name of the task
  155406. */
  155407. constructor(
  155408. /**
  155409. * Task name
  155410. */ name: string);
  155411. private _isCompleted;
  155412. private _taskState;
  155413. private _errorObject;
  155414. /**
  155415. * Get if the task is completed
  155416. */
  155417. get isCompleted(): boolean;
  155418. /**
  155419. * Gets the current state of the task
  155420. */
  155421. get taskState(): AssetTaskState;
  155422. /**
  155423. * Gets the current error object (if task is in error)
  155424. */
  155425. get errorObject(): {
  155426. message?: string;
  155427. exception?: any;
  155428. };
  155429. /**
  155430. * Internal only
  155431. * @hidden
  155432. */
  155433. _setErrorObject(message?: string, exception?: any): void;
  155434. /**
  155435. * Execute the current task
  155436. * @param scene defines the scene where you want your assets to be loaded
  155437. * @param onSuccess is a callback called when the task is successfully executed
  155438. * @param onError is a callback called if an error occurs
  155439. */
  155440. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155441. /**
  155442. * Execute the current task
  155443. * @param scene defines the scene where you want your assets to be loaded
  155444. * @param onSuccess is a callback called when the task is successfully executed
  155445. * @param onError is a callback called if an error occurs
  155446. */
  155447. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155448. /**
  155449. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  155450. * This can be used with failed tasks that have the reason for failure fixed.
  155451. */
  155452. reset(): void;
  155453. private onErrorCallback;
  155454. private onDoneCallback;
  155455. }
  155456. /**
  155457. * Define the interface used by progress events raised during assets loading
  155458. */
  155459. export interface IAssetsProgressEvent {
  155460. /**
  155461. * Defines the number of remaining tasks to process
  155462. */
  155463. remainingCount: number;
  155464. /**
  155465. * Defines the total number of tasks
  155466. */
  155467. totalCount: number;
  155468. /**
  155469. * Defines the task that was just processed
  155470. */
  155471. task: AbstractAssetTask;
  155472. }
  155473. /**
  155474. * Class used to share progress information about assets loading
  155475. */
  155476. export class AssetsProgressEvent implements IAssetsProgressEvent {
  155477. /**
  155478. * Defines the number of remaining tasks to process
  155479. */
  155480. remainingCount: number;
  155481. /**
  155482. * Defines the total number of tasks
  155483. */
  155484. totalCount: number;
  155485. /**
  155486. * Defines the task that was just processed
  155487. */
  155488. task: AbstractAssetTask;
  155489. /**
  155490. * Creates a AssetsProgressEvent
  155491. * @param remainingCount defines the number of remaining tasks to process
  155492. * @param totalCount defines the total number of tasks
  155493. * @param task defines the task that was just processed
  155494. */
  155495. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  155496. }
  155497. /**
  155498. * Define a task used by AssetsManager to load assets into a container
  155499. */
  155500. export class ContainerAssetTask extends AbstractAssetTask {
  155501. /**
  155502. * Defines the name of the task
  155503. */
  155504. name: string;
  155505. /**
  155506. * Defines the list of mesh's names you want to load
  155507. */
  155508. meshesNames: any;
  155509. /**
  155510. * Defines the root url to use as a base to load your meshes and associated resources
  155511. */
  155512. rootUrl: string;
  155513. /**
  155514. * Defines the filename or File of the scene to load from
  155515. */
  155516. sceneFilename: string | File;
  155517. /**
  155518. * Get the loaded asset container
  155519. */
  155520. loadedContainer: AssetContainer;
  155521. /**
  155522. * Gets the list of loaded meshes
  155523. */
  155524. loadedMeshes: Array<AbstractMesh>;
  155525. /**
  155526. * Gets the list of loaded particle systems
  155527. */
  155528. loadedParticleSystems: Array<IParticleSystem>;
  155529. /**
  155530. * Gets the list of loaded skeletons
  155531. */
  155532. loadedSkeletons: Array<Skeleton>;
  155533. /**
  155534. * Gets the list of loaded animation groups
  155535. */
  155536. loadedAnimationGroups: Array<AnimationGroup>;
  155537. /**
  155538. * Callback called when the task is successful
  155539. */
  155540. onSuccess: (task: ContainerAssetTask) => void;
  155541. /**
  155542. * Callback called when the task is successful
  155543. */
  155544. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  155545. /**
  155546. * Creates a new ContainerAssetTask
  155547. * @param name defines the name of the task
  155548. * @param meshesNames defines the list of mesh's names you want to load
  155549. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  155550. * @param sceneFilename defines the filename or File of the scene to load from
  155551. */
  155552. constructor(
  155553. /**
  155554. * Defines the name of the task
  155555. */
  155556. name: string,
  155557. /**
  155558. * Defines the list of mesh's names you want to load
  155559. */
  155560. meshesNames: any,
  155561. /**
  155562. * Defines the root url to use as a base to load your meshes and associated resources
  155563. */
  155564. rootUrl: string,
  155565. /**
  155566. * Defines the filename or File of the scene to load from
  155567. */
  155568. sceneFilename: string | File);
  155569. /**
  155570. * Execute the current task
  155571. * @param scene defines the scene where you want your assets to be loaded
  155572. * @param onSuccess is a callback called when the task is successfully executed
  155573. * @param onError is a callback called if an error occurs
  155574. */
  155575. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155576. }
  155577. /**
  155578. * Define a task used by AssetsManager to load meshes
  155579. */
  155580. export class MeshAssetTask extends AbstractAssetTask {
  155581. /**
  155582. * Defines the name of the task
  155583. */
  155584. name: string;
  155585. /**
  155586. * Defines the list of mesh's names you want to load
  155587. */
  155588. meshesNames: any;
  155589. /**
  155590. * Defines the root url to use as a base to load your meshes and associated resources
  155591. */
  155592. rootUrl: string;
  155593. /**
  155594. * Defines the filename or File of the scene to load from
  155595. */
  155596. sceneFilename: string | File;
  155597. /**
  155598. * Gets the list of loaded meshes
  155599. */
  155600. loadedMeshes: Array<AbstractMesh>;
  155601. /**
  155602. * Gets the list of loaded particle systems
  155603. */
  155604. loadedParticleSystems: Array<IParticleSystem>;
  155605. /**
  155606. * Gets the list of loaded skeletons
  155607. */
  155608. loadedSkeletons: Array<Skeleton>;
  155609. /**
  155610. * Gets the list of loaded animation groups
  155611. */
  155612. loadedAnimationGroups: Array<AnimationGroup>;
  155613. /**
  155614. * Callback called when the task is successful
  155615. */
  155616. onSuccess: (task: MeshAssetTask) => void;
  155617. /**
  155618. * Callback called when the task is successful
  155619. */
  155620. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  155621. /**
  155622. * Creates a new MeshAssetTask
  155623. * @param name defines the name of the task
  155624. * @param meshesNames defines the list of mesh's names you want to load
  155625. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  155626. * @param sceneFilename defines the filename or File of the scene to load from
  155627. */
  155628. constructor(
  155629. /**
  155630. * Defines the name of the task
  155631. */
  155632. name: string,
  155633. /**
  155634. * Defines the list of mesh's names you want to load
  155635. */
  155636. meshesNames: any,
  155637. /**
  155638. * Defines the root url to use as a base to load your meshes and associated resources
  155639. */
  155640. rootUrl: string,
  155641. /**
  155642. * Defines the filename or File of the scene to load from
  155643. */
  155644. sceneFilename: string | File);
  155645. /**
  155646. * Execute the current task
  155647. * @param scene defines the scene where you want your assets to be loaded
  155648. * @param onSuccess is a callback called when the task is successfully executed
  155649. * @param onError is a callback called if an error occurs
  155650. */
  155651. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155652. }
  155653. /**
  155654. * Define a task used by AssetsManager to load text content
  155655. */
  155656. export class TextFileAssetTask extends AbstractAssetTask {
  155657. /**
  155658. * Defines the name of the task
  155659. */
  155660. name: string;
  155661. /**
  155662. * Defines the location of the file to load
  155663. */
  155664. url: string;
  155665. /**
  155666. * Gets the loaded text string
  155667. */
  155668. text: string;
  155669. /**
  155670. * Callback called when the task is successful
  155671. */
  155672. onSuccess: (task: TextFileAssetTask) => void;
  155673. /**
  155674. * Callback called when the task is successful
  155675. */
  155676. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  155677. /**
  155678. * Creates a new TextFileAssetTask object
  155679. * @param name defines the name of the task
  155680. * @param url defines the location of the file to load
  155681. */
  155682. constructor(
  155683. /**
  155684. * Defines the name of the task
  155685. */
  155686. name: string,
  155687. /**
  155688. * Defines the location of the file to load
  155689. */
  155690. url: string);
  155691. /**
  155692. * Execute the current task
  155693. * @param scene defines the scene where you want your assets to be loaded
  155694. * @param onSuccess is a callback called when the task is successfully executed
  155695. * @param onError is a callback called if an error occurs
  155696. */
  155697. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155698. }
  155699. /**
  155700. * Define a task used by AssetsManager to load binary data
  155701. */
  155702. export class BinaryFileAssetTask extends AbstractAssetTask {
  155703. /**
  155704. * Defines the name of the task
  155705. */
  155706. name: string;
  155707. /**
  155708. * Defines the location of the file to load
  155709. */
  155710. url: string;
  155711. /**
  155712. * Gets the lodaded data (as an array buffer)
  155713. */
  155714. data: ArrayBuffer;
  155715. /**
  155716. * Callback called when the task is successful
  155717. */
  155718. onSuccess: (task: BinaryFileAssetTask) => void;
  155719. /**
  155720. * Callback called when the task is successful
  155721. */
  155722. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  155723. /**
  155724. * Creates a new BinaryFileAssetTask object
  155725. * @param name defines the name of the new task
  155726. * @param url defines the location of the file to load
  155727. */
  155728. constructor(
  155729. /**
  155730. * Defines the name of the task
  155731. */
  155732. name: string,
  155733. /**
  155734. * Defines the location of the file to load
  155735. */
  155736. url: string);
  155737. /**
  155738. * Execute the current task
  155739. * @param scene defines the scene where you want your assets to be loaded
  155740. * @param onSuccess is a callback called when the task is successfully executed
  155741. * @param onError is a callback called if an error occurs
  155742. */
  155743. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155744. }
  155745. /**
  155746. * Define a task used by AssetsManager to load images
  155747. */
  155748. export class ImageAssetTask extends AbstractAssetTask {
  155749. /**
  155750. * Defines the name of the task
  155751. */
  155752. name: string;
  155753. /**
  155754. * Defines the location of the image to load
  155755. */
  155756. url: string;
  155757. /**
  155758. * Gets the loaded images
  155759. */
  155760. image: HTMLImageElement;
  155761. /**
  155762. * Callback called when the task is successful
  155763. */
  155764. onSuccess: (task: ImageAssetTask) => void;
  155765. /**
  155766. * Callback called when the task is successful
  155767. */
  155768. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  155769. /**
  155770. * Creates a new ImageAssetTask
  155771. * @param name defines the name of the task
  155772. * @param url defines the location of the image to load
  155773. */
  155774. constructor(
  155775. /**
  155776. * Defines the name of the task
  155777. */
  155778. name: string,
  155779. /**
  155780. * Defines the location of the image to load
  155781. */
  155782. url: string);
  155783. /**
  155784. * Execute the current task
  155785. * @param scene defines the scene where you want your assets to be loaded
  155786. * @param onSuccess is a callback called when the task is successfully executed
  155787. * @param onError is a callback called if an error occurs
  155788. */
  155789. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155790. }
  155791. /**
  155792. * Defines the interface used by texture loading tasks
  155793. */
  155794. export interface ITextureAssetTask<TEX extends BaseTexture> {
  155795. /**
  155796. * Gets the loaded texture
  155797. */
  155798. texture: TEX;
  155799. }
  155800. /**
  155801. * Define a task used by AssetsManager to load 2D textures
  155802. */
  155803. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  155804. /**
  155805. * Defines the name of the task
  155806. */
  155807. name: string;
  155808. /**
  155809. * Defines the location of the file to load
  155810. */
  155811. url: string;
  155812. /**
  155813. * Defines if mipmap should not be generated (default is false)
  155814. */
  155815. noMipmap?: boolean | undefined;
  155816. /**
  155817. * Defines if texture must be inverted on Y axis (default is true)
  155818. */
  155819. invertY: boolean;
  155820. /**
  155821. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  155822. */
  155823. samplingMode: number;
  155824. /**
  155825. * Gets the loaded texture
  155826. */
  155827. texture: Texture;
  155828. /**
  155829. * Callback called when the task is successful
  155830. */
  155831. onSuccess: (task: TextureAssetTask) => void;
  155832. /**
  155833. * Callback called when the task is successful
  155834. */
  155835. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  155836. /**
  155837. * Creates a new TextureAssetTask object
  155838. * @param name defines the name of the task
  155839. * @param url defines the location of the file to load
  155840. * @param noMipmap defines if mipmap should not be generated (default is false)
  155841. * @param invertY defines if texture must be inverted on Y axis (default is true)
  155842. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  155843. */
  155844. constructor(
  155845. /**
  155846. * Defines the name of the task
  155847. */
  155848. name: string,
  155849. /**
  155850. * Defines the location of the file to load
  155851. */
  155852. url: string,
  155853. /**
  155854. * Defines if mipmap should not be generated (default is false)
  155855. */
  155856. noMipmap?: boolean | undefined,
  155857. /**
  155858. * Defines if texture must be inverted on Y axis (default is true)
  155859. */
  155860. invertY?: boolean,
  155861. /**
  155862. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  155863. */
  155864. samplingMode?: number);
  155865. /**
  155866. * Execute the current task
  155867. * @param scene defines the scene where you want your assets to be loaded
  155868. * @param onSuccess is a callback called when the task is successfully executed
  155869. * @param onError is a callback called if an error occurs
  155870. */
  155871. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155872. }
  155873. /**
  155874. * Define a task used by AssetsManager to load cube textures
  155875. */
  155876. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  155877. /**
  155878. * Defines the name of the task
  155879. */
  155880. name: string;
  155881. /**
  155882. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  155883. */
  155884. url: string;
  155885. /**
  155886. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  155887. */
  155888. extensions?: string[] | undefined;
  155889. /**
  155890. * Defines if mipmaps should not be generated (default is false)
  155891. */
  155892. noMipmap?: boolean | undefined;
  155893. /**
  155894. * Defines the explicit list of files (undefined by default)
  155895. */
  155896. files?: string[] | undefined;
  155897. /**
  155898. * Gets the loaded texture
  155899. */
  155900. texture: CubeTexture;
  155901. /**
  155902. * Callback called when the task is successful
  155903. */
  155904. onSuccess: (task: CubeTextureAssetTask) => void;
  155905. /**
  155906. * Callback called when the task is successful
  155907. */
  155908. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  155909. /**
  155910. * Creates a new CubeTextureAssetTask
  155911. * @param name defines the name of the task
  155912. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  155913. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  155914. * @param noMipmap defines if mipmaps should not be generated (default is false)
  155915. * @param files defines the explicit list of files (undefined by default)
  155916. */
  155917. constructor(
  155918. /**
  155919. * Defines the name of the task
  155920. */
  155921. name: string,
  155922. /**
  155923. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  155924. */
  155925. url: string,
  155926. /**
  155927. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  155928. */
  155929. extensions?: string[] | undefined,
  155930. /**
  155931. * Defines if mipmaps should not be generated (default is false)
  155932. */
  155933. noMipmap?: boolean | undefined,
  155934. /**
  155935. * Defines the explicit list of files (undefined by default)
  155936. */
  155937. files?: string[] | undefined);
  155938. /**
  155939. * Execute the current task
  155940. * @param scene defines the scene where you want your assets to be loaded
  155941. * @param onSuccess is a callback called when the task is successfully executed
  155942. * @param onError is a callback called if an error occurs
  155943. */
  155944. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155945. }
  155946. /**
  155947. * Define a task used by AssetsManager to load HDR cube textures
  155948. */
  155949. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  155950. /**
  155951. * Defines the name of the task
  155952. */
  155953. name: string;
  155954. /**
  155955. * Defines the location of the file to load
  155956. */
  155957. url: string;
  155958. /**
  155959. * Defines the desired size (the more it increases the longer the generation will be)
  155960. */
  155961. size: number;
  155962. /**
  155963. * Defines if mipmaps should not be generated (default is false)
  155964. */
  155965. noMipmap: boolean;
  155966. /**
  155967. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  155968. */
  155969. generateHarmonics: boolean;
  155970. /**
  155971. * 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)
  155972. */
  155973. gammaSpace: boolean;
  155974. /**
  155975. * Internal Use Only
  155976. */
  155977. reserved: boolean;
  155978. /**
  155979. * Gets the loaded texture
  155980. */
  155981. texture: HDRCubeTexture;
  155982. /**
  155983. * Callback called when the task is successful
  155984. */
  155985. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  155986. /**
  155987. * Callback called when the task is successful
  155988. */
  155989. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  155990. /**
  155991. * Creates a new HDRCubeTextureAssetTask object
  155992. * @param name defines the name of the task
  155993. * @param url defines the location of the file to load
  155994. * @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.
  155995. * @param noMipmap defines if mipmaps should not be generated (default is false)
  155996. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  155997. * @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)
  155998. * @param reserved Internal use only
  155999. */
  156000. constructor(
  156001. /**
  156002. * Defines the name of the task
  156003. */
  156004. name: string,
  156005. /**
  156006. * Defines the location of the file to load
  156007. */
  156008. url: string,
  156009. /**
  156010. * Defines the desired size (the more it increases the longer the generation will be)
  156011. */
  156012. size: number,
  156013. /**
  156014. * Defines if mipmaps should not be generated (default is false)
  156015. */
  156016. noMipmap?: boolean,
  156017. /**
  156018. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  156019. */
  156020. generateHarmonics?: boolean,
  156021. /**
  156022. * 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)
  156023. */
  156024. gammaSpace?: boolean,
  156025. /**
  156026. * Internal Use Only
  156027. */
  156028. reserved?: boolean);
  156029. /**
  156030. * Execute the current task
  156031. * @param scene defines the scene where you want your assets to be loaded
  156032. * @param onSuccess is a callback called when the task is successfully executed
  156033. * @param onError is a callback called if an error occurs
  156034. */
  156035. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156036. }
  156037. /**
  156038. * Define a task used by AssetsManager to load Equirectangular cube textures
  156039. */
  156040. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  156041. /**
  156042. * Defines the name of the task
  156043. */
  156044. name: string;
  156045. /**
  156046. * Defines the location of the file to load
  156047. */
  156048. url: string;
  156049. /**
  156050. * Defines the desired size (the more it increases the longer the generation will be)
  156051. */
  156052. size: number;
  156053. /**
  156054. * Defines if mipmaps should not be generated (default is false)
  156055. */
  156056. noMipmap: boolean;
  156057. /**
  156058. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  156059. * but the standard material would require them in Gamma space) (default is true)
  156060. */
  156061. gammaSpace: boolean;
  156062. /**
  156063. * Gets the loaded texture
  156064. */
  156065. texture: EquiRectangularCubeTexture;
  156066. /**
  156067. * Callback called when the task is successful
  156068. */
  156069. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  156070. /**
  156071. * Callback called when the task is successful
  156072. */
  156073. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  156074. /**
  156075. * Creates a new EquiRectangularCubeTextureAssetTask object
  156076. * @param name defines the name of the task
  156077. * @param url defines the location of the file to load
  156078. * @param size defines the desired size (the more it increases the longer the generation will be)
  156079. * If the size is omitted this implies you are using a preprocessed cubemap.
  156080. * @param noMipmap defines if mipmaps should not be generated (default is false)
  156081. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  156082. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  156083. * (default is true)
  156084. */
  156085. constructor(
  156086. /**
  156087. * Defines the name of the task
  156088. */
  156089. name: string,
  156090. /**
  156091. * Defines the location of the file to load
  156092. */
  156093. url: string,
  156094. /**
  156095. * Defines the desired size (the more it increases the longer the generation will be)
  156096. */
  156097. size: number,
  156098. /**
  156099. * Defines if mipmaps should not be generated (default is false)
  156100. */
  156101. noMipmap?: boolean,
  156102. /**
  156103. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  156104. * but the standard material would require them in Gamma space) (default is true)
  156105. */
  156106. gammaSpace?: boolean);
  156107. /**
  156108. * Execute the current task
  156109. * @param scene defines the scene where you want your assets to be loaded
  156110. * @param onSuccess is a callback called when the task is successfully executed
  156111. * @param onError is a callback called if an error occurs
  156112. */
  156113. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156114. }
  156115. /**
  156116. * This class can be used to easily import assets into a scene
  156117. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  156118. */
  156119. export class AssetsManager {
  156120. private _scene;
  156121. private _isLoading;
  156122. protected _tasks: AbstractAssetTask[];
  156123. protected _waitingTasksCount: number;
  156124. protected _totalTasksCount: number;
  156125. /**
  156126. * Callback called when all tasks are processed
  156127. */
  156128. onFinish: (tasks: AbstractAssetTask[]) => void;
  156129. /**
  156130. * Callback called when a task is successful
  156131. */
  156132. onTaskSuccess: (task: AbstractAssetTask) => void;
  156133. /**
  156134. * Callback called when a task had an error
  156135. */
  156136. onTaskError: (task: AbstractAssetTask) => void;
  156137. /**
  156138. * Callback called when a task is done (whatever the result is)
  156139. */
  156140. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  156141. /**
  156142. * Observable called when all tasks are processed
  156143. */
  156144. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  156145. /**
  156146. * Observable called when a task had an error
  156147. */
  156148. onTaskErrorObservable: Observable<AbstractAssetTask>;
  156149. /**
  156150. * Observable called when all tasks were executed
  156151. */
  156152. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  156153. /**
  156154. * Observable called when a task is done (whatever the result is)
  156155. */
  156156. onProgressObservable: Observable<IAssetsProgressEvent>;
  156157. /**
  156158. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  156159. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  156160. */
  156161. useDefaultLoadingScreen: boolean;
  156162. /**
  156163. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  156164. * when all assets have been downloaded.
  156165. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  156166. */
  156167. autoHideLoadingUI: boolean;
  156168. /**
  156169. * Creates a new AssetsManager
  156170. * @param scene defines the scene to work on
  156171. */
  156172. constructor(scene: Scene);
  156173. /**
  156174. * Add a ContainerAssetTask to the list of active tasks
  156175. * @param taskName defines the name of the new task
  156176. * @param meshesNames defines the name of meshes to load
  156177. * @param rootUrl defines the root url to use to locate files
  156178. * @param sceneFilename defines the filename of the scene file
  156179. * @returns a new ContainerAssetTask object
  156180. */
  156181. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  156182. /**
  156183. * Add a MeshAssetTask to the list of active tasks
  156184. * @param taskName defines the name of the new task
  156185. * @param meshesNames defines the name of meshes to load
  156186. * @param rootUrl defines the root url to use to locate files
  156187. * @param sceneFilename defines the filename of the scene file
  156188. * @returns a new MeshAssetTask object
  156189. */
  156190. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  156191. /**
  156192. * Add a TextFileAssetTask to the list of active tasks
  156193. * @param taskName defines the name of the new task
  156194. * @param url defines the url of the file to load
  156195. * @returns a new TextFileAssetTask object
  156196. */
  156197. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  156198. /**
  156199. * Add a BinaryFileAssetTask to the list of active tasks
  156200. * @param taskName defines the name of the new task
  156201. * @param url defines the url of the file to load
  156202. * @returns a new BinaryFileAssetTask object
  156203. */
  156204. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  156205. /**
  156206. * Add a ImageAssetTask to the list of active tasks
  156207. * @param taskName defines the name of the new task
  156208. * @param url defines the url of the file to load
  156209. * @returns a new ImageAssetTask object
  156210. */
  156211. addImageTask(taskName: string, url: string): ImageAssetTask;
  156212. /**
  156213. * Add a TextureAssetTask to the list of active tasks
  156214. * @param taskName defines the name of the new task
  156215. * @param url defines the url of the file to load
  156216. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156217. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  156218. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  156219. * @returns a new TextureAssetTask object
  156220. */
  156221. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  156222. /**
  156223. * Add a CubeTextureAssetTask to the list of active tasks
  156224. * @param taskName defines the name of the new task
  156225. * @param url defines the url of the file to load
  156226. * @param extensions defines the extension to use to load the cube map (can be null)
  156227. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156228. * @param files defines the list of files to load (can be null)
  156229. * @returns a new CubeTextureAssetTask object
  156230. */
  156231. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  156232. /**
  156233. *
  156234. * Add a HDRCubeTextureAssetTask to the list of active tasks
  156235. * @param taskName defines the name of the new task
  156236. * @param url defines the url of the file to load
  156237. * @param size defines the size you want for the cubemap (can be null)
  156238. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156239. * @param generateHarmonics defines if you want to automatically generate (true by default)
  156240. * @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)
  156241. * @param reserved Internal use only
  156242. * @returns a new HDRCubeTextureAssetTask object
  156243. */
  156244. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  156245. /**
  156246. *
  156247. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  156248. * @param taskName defines the name of the new task
  156249. * @param url defines the url of the file to load
  156250. * @param size defines the size you want for the cubemap (can be null)
  156251. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156252. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  156253. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  156254. * @returns a new EquiRectangularCubeTextureAssetTask object
  156255. */
  156256. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  156257. /**
  156258. * Remove a task from the assets manager.
  156259. * @param task the task to remove
  156260. */
  156261. removeTask(task: AbstractAssetTask): void;
  156262. private _decreaseWaitingTasksCount;
  156263. private _runTask;
  156264. /**
  156265. * Reset the AssetsManager and remove all tasks
  156266. * @return the current instance of the AssetsManager
  156267. */
  156268. reset(): AssetsManager;
  156269. /**
  156270. * Start the loading process
  156271. * @return the current instance of the AssetsManager
  156272. */
  156273. load(): AssetsManager;
  156274. /**
  156275. * Start the loading process as an async operation
  156276. * @return a promise returning the list of failed tasks
  156277. */
  156278. loadAsync(): Promise<void>;
  156279. }
  156280. }
  156281. declare module BABYLON {
  156282. /**
  156283. * Wrapper class for promise with external resolve and reject.
  156284. */
  156285. export class Deferred<T> {
  156286. /**
  156287. * The promise associated with this deferred object.
  156288. */
  156289. readonly promise: Promise<T>;
  156290. private _resolve;
  156291. private _reject;
  156292. /**
  156293. * The resolve method of the promise associated with this deferred object.
  156294. */
  156295. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  156296. /**
  156297. * The reject method of the promise associated with this deferred object.
  156298. */
  156299. get reject(): (reason?: any) => void;
  156300. /**
  156301. * Constructor for this deferred object.
  156302. */
  156303. constructor();
  156304. }
  156305. }
  156306. declare module BABYLON {
  156307. /**
  156308. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  156309. */
  156310. export class MeshExploder {
  156311. private _centerMesh;
  156312. private _meshes;
  156313. private _meshesOrigins;
  156314. private _toCenterVectors;
  156315. private _scaledDirection;
  156316. private _newPosition;
  156317. private _centerPosition;
  156318. /**
  156319. * Explodes meshes from a center mesh.
  156320. * @param meshes The meshes to explode.
  156321. * @param centerMesh The mesh to be center of explosion.
  156322. */
  156323. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  156324. private _setCenterMesh;
  156325. /**
  156326. * Get class name
  156327. * @returns "MeshExploder"
  156328. */
  156329. getClassName(): string;
  156330. /**
  156331. * "Exploded meshes"
  156332. * @returns Array of meshes with the centerMesh at index 0.
  156333. */
  156334. getMeshes(): Array<Mesh>;
  156335. /**
  156336. * Explodes meshes giving a specific direction
  156337. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  156338. */
  156339. explode(direction?: number): void;
  156340. }
  156341. }
  156342. declare module BABYLON {
  156343. /**
  156344. * Class used to help managing file picking and drag'n'drop
  156345. */
  156346. export class FilesInput {
  156347. /**
  156348. * List of files ready to be loaded
  156349. */
  156350. static get FilesToLoad(): {
  156351. [key: string]: File;
  156352. };
  156353. /**
  156354. * Callback called when a file is processed
  156355. */
  156356. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  156357. private _engine;
  156358. private _currentScene;
  156359. private _sceneLoadedCallback;
  156360. private _progressCallback;
  156361. private _additionalRenderLoopLogicCallback;
  156362. private _textureLoadingCallback;
  156363. private _startingProcessingFilesCallback;
  156364. private _onReloadCallback;
  156365. private _errorCallback;
  156366. private _elementToMonitor;
  156367. private _sceneFileToLoad;
  156368. private _filesToLoad;
  156369. /**
  156370. * Creates a new FilesInput
  156371. * @param engine defines the rendering engine
  156372. * @param scene defines the hosting scene
  156373. * @param sceneLoadedCallback callback called when scene is loaded
  156374. * @param progressCallback callback called to track progress
  156375. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  156376. * @param textureLoadingCallback callback called when a texture is loading
  156377. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  156378. * @param onReloadCallback callback called when a reload is requested
  156379. * @param errorCallback callback call if an error occurs
  156380. */
  156381. 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>);
  156382. private _dragEnterHandler;
  156383. private _dragOverHandler;
  156384. private _dropHandler;
  156385. /**
  156386. * Calls this function to listen to drag'n'drop events on a specific DOM element
  156387. * @param elementToMonitor defines the DOM element to track
  156388. */
  156389. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  156390. /** Gets the current list of files to load */
  156391. get filesToLoad(): File[];
  156392. /**
  156393. * Release all associated resources
  156394. */
  156395. dispose(): void;
  156396. private renderFunction;
  156397. private drag;
  156398. private drop;
  156399. private _traverseFolder;
  156400. private _processFiles;
  156401. /**
  156402. * Load files from a drop event
  156403. * @param event defines the drop event to use as source
  156404. */
  156405. loadFiles(event: any): void;
  156406. private _processReload;
  156407. /**
  156408. * Reload the current scene from the loaded files
  156409. */
  156410. reload(): void;
  156411. }
  156412. }
  156413. declare module BABYLON {
  156414. /**
  156415. * Defines the root class used to create scene optimization to use with SceneOptimizer
  156416. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156417. */
  156418. export class SceneOptimization {
  156419. /**
  156420. * Defines the priority of this optimization (0 by default which means first in the list)
  156421. */
  156422. priority: number;
  156423. /**
  156424. * Gets a string describing the action executed by the current optimization
  156425. * @returns description string
  156426. */
  156427. getDescription(): string;
  156428. /**
  156429. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156430. * @param scene defines the current scene where to apply this optimization
  156431. * @param optimizer defines the current optimizer
  156432. * @returns true if everything that can be done was applied
  156433. */
  156434. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156435. /**
  156436. * Creates the SceneOptimization object
  156437. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156438. * @param desc defines the description associated with the optimization
  156439. */
  156440. constructor(
  156441. /**
  156442. * Defines the priority of this optimization (0 by default which means first in the list)
  156443. */
  156444. priority?: number);
  156445. }
  156446. /**
  156447. * Defines an optimization used to reduce the size of render target textures
  156448. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156449. */
  156450. export class TextureOptimization extends SceneOptimization {
  156451. /**
  156452. * Defines the priority of this optimization (0 by default which means first in the list)
  156453. */
  156454. priority: number;
  156455. /**
  156456. * 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
  156457. */
  156458. maximumSize: number;
  156459. /**
  156460. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  156461. */
  156462. step: number;
  156463. /**
  156464. * Gets a string describing the action executed by the current optimization
  156465. * @returns description string
  156466. */
  156467. getDescription(): string;
  156468. /**
  156469. * Creates the TextureOptimization object
  156470. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156471. * @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
  156472. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  156473. */
  156474. constructor(
  156475. /**
  156476. * Defines the priority of this optimization (0 by default which means first in the list)
  156477. */
  156478. priority?: number,
  156479. /**
  156480. * 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
  156481. */
  156482. maximumSize?: number,
  156483. /**
  156484. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  156485. */
  156486. step?: number);
  156487. /**
  156488. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156489. * @param scene defines the current scene where to apply this optimization
  156490. * @param optimizer defines the current optimizer
  156491. * @returns true if everything that can be done was applied
  156492. */
  156493. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156494. }
  156495. /**
  156496. * Defines an optimization used to increase or decrease the rendering resolution
  156497. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156498. */
  156499. export class HardwareScalingOptimization extends SceneOptimization {
  156500. /**
  156501. * Defines the priority of this optimization (0 by default which means first in the list)
  156502. */
  156503. priority: number;
  156504. /**
  156505. * Defines the maximum scale to use (2 by default)
  156506. */
  156507. maximumScale: number;
  156508. /**
  156509. * Defines the step to use between two passes (0.5 by default)
  156510. */
  156511. step: number;
  156512. private _currentScale;
  156513. private _directionOffset;
  156514. /**
  156515. * Gets a string describing the action executed by the current optimization
  156516. * @return description string
  156517. */
  156518. getDescription(): string;
  156519. /**
  156520. * Creates the HardwareScalingOptimization object
  156521. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156522. * @param maximumScale defines the maximum scale to use (2 by default)
  156523. * @param step defines the step to use between two passes (0.5 by default)
  156524. */
  156525. constructor(
  156526. /**
  156527. * Defines the priority of this optimization (0 by default which means first in the list)
  156528. */
  156529. priority?: number,
  156530. /**
  156531. * Defines the maximum scale to use (2 by default)
  156532. */
  156533. maximumScale?: number,
  156534. /**
  156535. * Defines the step to use between two passes (0.5 by default)
  156536. */
  156537. step?: number);
  156538. /**
  156539. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156540. * @param scene defines the current scene where to apply this optimization
  156541. * @param optimizer defines the current optimizer
  156542. * @returns true if everything that can be done was applied
  156543. */
  156544. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156545. }
  156546. /**
  156547. * Defines an optimization used to remove shadows
  156548. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156549. */
  156550. export class ShadowsOptimization extends SceneOptimization {
  156551. /**
  156552. * Gets a string describing the action executed by the current optimization
  156553. * @return description string
  156554. */
  156555. getDescription(): string;
  156556. /**
  156557. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156558. * @param scene defines the current scene where to apply this optimization
  156559. * @param optimizer defines the current optimizer
  156560. * @returns true if everything that can be done was applied
  156561. */
  156562. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156563. }
  156564. /**
  156565. * Defines an optimization used to turn post-processes off
  156566. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156567. */
  156568. export class PostProcessesOptimization extends SceneOptimization {
  156569. /**
  156570. * Gets a string describing the action executed by the current optimization
  156571. * @return description string
  156572. */
  156573. getDescription(): string;
  156574. /**
  156575. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156576. * @param scene defines the current scene where to apply this optimization
  156577. * @param optimizer defines the current optimizer
  156578. * @returns true if everything that can be done was applied
  156579. */
  156580. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156581. }
  156582. /**
  156583. * Defines an optimization used to turn lens flares off
  156584. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156585. */
  156586. export class LensFlaresOptimization extends SceneOptimization {
  156587. /**
  156588. * Gets a string describing the action executed by the current optimization
  156589. * @return description string
  156590. */
  156591. getDescription(): string;
  156592. /**
  156593. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156594. * @param scene defines the current scene where to apply this optimization
  156595. * @param optimizer defines the current optimizer
  156596. * @returns true if everything that can be done was applied
  156597. */
  156598. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156599. }
  156600. /**
  156601. * Defines an optimization based on user defined callback.
  156602. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156603. */
  156604. export class CustomOptimization extends SceneOptimization {
  156605. /**
  156606. * Callback called to apply the custom optimization.
  156607. */
  156608. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  156609. /**
  156610. * Callback called to get custom description
  156611. */
  156612. onGetDescription: () => string;
  156613. /**
  156614. * Gets a string describing the action executed by the current optimization
  156615. * @returns description string
  156616. */
  156617. getDescription(): string;
  156618. /**
  156619. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156620. * @param scene defines the current scene where to apply this optimization
  156621. * @param optimizer defines the current optimizer
  156622. * @returns true if everything that can be done was applied
  156623. */
  156624. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156625. }
  156626. /**
  156627. * Defines an optimization used to turn particles off
  156628. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156629. */
  156630. export class ParticlesOptimization extends SceneOptimization {
  156631. /**
  156632. * Gets a string describing the action executed by the current optimization
  156633. * @return description string
  156634. */
  156635. getDescription(): string;
  156636. /**
  156637. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156638. * @param scene defines the current scene where to apply this optimization
  156639. * @param optimizer defines the current optimizer
  156640. * @returns true if everything that can be done was applied
  156641. */
  156642. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156643. }
  156644. /**
  156645. * Defines an optimization used to turn render targets off
  156646. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156647. */
  156648. export class RenderTargetsOptimization extends SceneOptimization {
  156649. /**
  156650. * Gets a string describing the action executed by the current optimization
  156651. * @return description string
  156652. */
  156653. getDescription(): string;
  156654. /**
  156655. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156656. * @param scene defines the current scene where to apply this optimization
  156657. * @param optimizer defines the current optimizer
  156658. * @returns true if everything that can be done was applied
  156659. */
  156660. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156661. }
  156662. /**
  156663. * Defines an optimization used to merge meshes with compatible materials
  156664. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156665. */
  156666. export class MergeMeshesOptimization extends SceneOptimization {
  156667. private static _UpdateSelectionTree;
  156668. /**
  156669. * Gets or sets a boolean which defines if optimization octree has to be updated
  156670. */
  156671. static get UpdateSelectionTree(): boolean;
  156672. /**
  156673. * Gets or sets a boolean which defines if optimization octree has to be updated
  156674. */
  156675. static set UpdateSelectionTree(value: boolean);
  156676. /**
  156677. * Gets a string describing the action executed by the current optimization
  156678. * @return description string
  156679. */
  156680. getDescription(): string;
  156681. private _canBeMerged;
  156682. /**
  156683. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156684. * @param scene defines the current scene where to apply this optimization
  156685. * @param optimizer defines the current optimizer
  156686. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  156687. * @returns true if everything that can be done was applied
  156688. */
  156689. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  156690. }
  156691. /**
  156692. * Defines a list of options used by SceneOptimizer
  156693. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156694. */
  156695. export class SceneOptimizerOptions {
  156696. /**
  156697. * Defines the target frame rate to reach (60 by default)
  156698. */
  156699. targetFrameRate: number;
  156700. /**
  156701. * Defines the interval between two checkes (2000ms by default)
  156702. */
  156703. trackerDuration: number;
  156704. /**
  156705. * Gets the list of optimizations to apply
  156706. */
  156707. optimizations: SceneOptimization[];
  156708. /**
  156709. * Creates a new list of options used by SceneOptimizer
  156710. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  156711. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  156712. */
  156713. constructor(
  156714. /**
  156715. * Defines the target frame rate to reach (60 by default)
  156716. */
  156717. targetFrameRate?: number,
  156718. /**
  156719. * Defines the interval between two checkes (2000ms by default)
  156720. */
  156721. trackerDuration?: number);
  156722. /**
  156723. * Add a new optimization
  156724. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  156725. * @returns the current SceneOptimizerOptions
  156726. */
  156727. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  156728. /**
  156729. * Add a new custom optimization
  156730. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  156731. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  156732. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156733. * @returns the current SceneOptimizerOptions
  156734. */
  156735. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  156736. /**
  156737. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  156738. * @param targetFrameRate defines the target frame rate (60 by default)
  156739. * @returns a SceneOptimizerOptions object
  156740. */
  156741. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  156742. /**
  156743. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  156744. * @param targetFrameRate defines the target frame rate (60 by default)
  156745. * @returns a SceneOptimizerOptions object
  156746. */
  156747. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  156748. /**
  156749. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  156750. * @param targetFrameRate defines the target frame rate (60 by default)
  156751. * @returns a SceneOptimizerOptions object
  156752. */
  156753. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  156754. }
  156755. /**
  156756. * Class used to run optimizations in order to reach a target frame rate
  156757. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156758. */
  156759. export class SceneOptimizer implements IDisposable {
  156760. private _isRunning;
  156761. private _options;
  156762. private _scene;
  156763. private _currentPriorityLevel;
  156764. private _targetFrameRate;
  156765. private _trackerDuration;
  156766. private _currentFrameRate;
  156767. private _sceneDisposeObserver;
  156768. private _improvementMode;
  156769. /**
  156770. * Defines an observable called when the optimizer reaches the target frame rate
  156771. */
  156772. onSuccessObservable: Observable<SceneOptimizer>;
  156773. /**
  156774. * Defines an observable called when the optimizer enables an optimization
  156775. */
  156776. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  156777. /**
  156778. * Defines an observable called when the optimizer is not able to reach the target frame rate
  156779. */
  156780. onFailureObservable: Observable<SceneOptimizer>;
  156781. /**
  156782. * Gets a boolean indicating if the optimizer is in improvement mode
  156783. */
  156784. get isInImprovementMode(): boolean;
  156785. /**
  156786. * Gets the current priority level (0 at start)
  156787. */
  156788. get currentPriorityLevel(): number;
  156789. /**
  156790. * Gets the current frame rate checked by the SceneOptimizer
  156791. */
  156792. get currentFrameRate(): number;
  156793. /**
  156794. * Gets or sets the current target frame rate (60 by default)
  156795. */
  156796. get targetFrameRate(): number;
  156797. /**
  156798. * Gets or sets the current target frame rate (60 by default)
  156799. */
  156800. set targetFrameRate(value: number);
  156801. /**
  156802. * Gets or sets the current interval between two checks (every 2000ms by default)
  156803. */
  156804. get trackerDuration(): number;
  156805. /**
  156806. * Gets or sets the current interval between two checks (every 2000ms by default)
  156807. */
  156808. set trackerDuration(value: number);
  156809. /**
  156810. * Gets the list of active optimizations
  156811. */
  156812. get optimizations(): SceneOptimization[];
  156813. /**
  156814. * Creates a new SceneOptimizer
  156815. * @param scene defines the scene to work on
  156816. * @param options defines the options to use with the SceneOptimizer
  156817. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  156818. * @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)
  156819. */
  156820. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  156821. /**
  156822. * Stops the current optimizer
  156823. */
  156824. stop(): void;
  156825. /**
  156826. * Reset the optimizer to initial step (current priority level = 0)
  156827. */
  156828. reset(): void;
  156829. /**
  156830. * Start the optimizer. By default it will try to reach a specific framerate
  156831. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  156832. */
  156833. start(): void;
  156834. private _checkCurrentState;
  156835. /**
  156836. * Release all resources
  156837. */
  156838. dispose(): void;
  156839. /**
  156840. * Helper function to create a SceneOptimizer with one single line of code
  156841. * @param scene defines the scene to work on
  156842. * @param options defines the options to use with the SceneOptimizer
  156843. * @param onSuccess defines a callback to call on success
  156844. * @param onFailure defines a callback to call on failure
  156845. * @returns the new SceneOptimizer object
  156846. */
  156847. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  156848. }
  156849. }
  156850. declare module BABYLON {
  156851. /**
  156852. * Class used to serialize a scene into a string
  156853. */
  156854. export class SceneSerializer {
  156855. /**
  156856. * Clear cache used by a previous serialization
  156857. */
  156858. static ClearCache(): void;
  156859. /**
  156860. * Serialize a scene into a JSON compatible object
  156861. * @param scene defines the scene to serialize
  156862. * @returns a JSON compatible object
  156863. */
  156864. static Serialize(scene: Scene): any;
  156865. /**
  156866. * Serialize a mesh into a JSON compatible object
  156867. * @param toSerialize defines the mesh to serialize
  156868. * @param withParents defines if parents must be serialized as well
  156869. * @param withChildren defines if children must be serialized as well
  156870. * @returns a JSON compatible object
  156871. */
  156872. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  156873. }
  156874. }
  156875. declare module BABYLON {
  156876. /**
  156877. * Class used to host texture specific utilities
  156878. */
  156879. export class TextureTools {
  156880. /**
  156881. * Uses the GPU to create a copy texture rescaled at a given size
  156882. * @param texture Texture to copy from
  156883. * @param width defines the desired width
  156884. * @param height defines the desired height
  156885. * @param useBilinearMode defines if bilinear mode has to be used
  156886. * @return the generated texture
  156887. */
  156888. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  156889. }
  156890. }
  156891. declare module BABYLON {
  156892. /**
  156893. * This represents the different options available for the video capture.
  156894. */
  156895. export interface VideoRecorderOptions {
  156896. /** Defines the mime type of the video. */
  156897. mimeType: string;
  156898. /** Defines the FPS the video should be recorded at. */
  156899. fps: number;
  156900. /** Defines the chunk size for the recording data. */
  156901. recordChunckSize: number;
  156902. /** The audio tracks to attach to the recording. */
  156903. audioTracks?: MediaStreamTrack[];
  156904. }
  156905. /**
  156906. * This can help with recording videos from BabylonJS.
  156907. * This is based on the available WebRTC functionalities of the browser.
  156908. *
  156909. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  156910. */
  156911. export class VideoRecorder {
  156912. private static readonly _defaultOptions;
  156913. /**
  156914. * Returns whether or not the VideoRecorder is available in your browser.
  156915. * @param engine Defines the Babylon Engine.
  156916. * @returns true if supported otherwise false.
  156917. */
  156918. static IsSupported(engine: Engine): boolean;
  156919. private readonly _options;
  156920. private _canvas;
  156921. private _mediaRecorder;
  156922. private _recordedChunks;
  156923. private _fileName;
  156924. private _resolve;
  156925. private _reject;
  156926. /**
  156927. * True when a recording is already in progress.
  156928. */
  156929. get isRecording(): boolean;
  156930. /**
  156931. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  156932. * @param engine Defines the BabylonJS Engine you wish to record.
  156933. * @param options Defines options that can be used to customize the capture.
  156934. */
  156935. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  156936. /**
  156937. * Stops the current recording before the default capture timeout passed in the startRecording function.
  156938. */
  156939. stopRecording(): void;
  156940. /**
  156941. * Starts recording the canvas for a max duration specified in parameters.
  156942. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  156943. * If null no automatic download will start and you can rely on the promise to get the data back.
  156944. * @param maxDuration Defines the maximum recording time in seconds.
  156945. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  156946. * @return A promise callback at the end of the recording with the video data in Blob.
  156947. */
  156948. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  156949. /**
  156950. * Releases internal resources used during the recording.
  156951. */
  156952. dispose(): void;
  156953. private _handleDataAvailable;
  156954. private _handleError;
  156955. private _handleStop;
  156956. }
  156957. }
  156958. declare module BABYLON {
  156959. /**
  156960. * Class containing a set of static utilities functions for screenshots
  156961. */
  156962. export class ScreenshotTools {
  156963. /**
  156964. * Captures a screenshot of the current rendering
  156965. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  156966. * @param engine defines the rendering engine
  156967. * @param camera defines the source camera
  156968. * @param size This parameter can be set to a single number or to an object with the
  156969. * following (optional) properties: precision, width, height. If a single number is passed,
  156970. * it will be used for both width and height. If an object is passed, the screenshot size
  156971. * will be derived from the parameters. The precision property is a multiplier allowing
  156972. * rendering at a higher or lower resolution
  156973. * @param successCallback defines the callback receives a single parameter which contains the
  156974. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  156975. * src parameter of an <img> to display it
  156976. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  156977. * Check your browser for supported MIME types
  156978. */
  156979. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  156980. /**
  156981. * Captures a screenshot of the current rendering
  156982. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  156983. * @param engine defines the rendering engine
  156984. * @param camera defines the source camera
  156985. * @param size This parameter can be set to a single number or to an object with the
  156986. * following (optional) properties: precision, width, height. If a single number is passed,
  156987. * it will be used for both width and height. If an object is passed, the screenshot size
  156988. * will be derived from the parameters. The precision property is a multiplier allowing
  156989. * rendering at a higher or lower resolution
  156990. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  156991. * Check your browser for supported MIME types
  156992. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  156993. * to the src parameter of an <img> to display it
  156994. */
  156995. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  156996. /**
  156997. * Generates an image screenshot from the specified camera.
  156998. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  156999. * @param engine The engine to use for rendering
  157000. * @param camera The camera to use for rendering
  157001. * @param size This parameter can be set to a single number or to an object with the
  157002. * following (optional) properties: precision, width, height. If a single number is passed,
  157003. * it will be used for both width and height. If an object is passed, the screenshot size
  157004. * will be derived from the parameters. The precision property is a multiplier allowing
  157005. * rendering at a higher or lower resolution
  157006. * @param successCallback The callback receives a single parameter which contains the
  157007. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  157008. * src parameter of an <img> to display it
  157009. * @param mimeType The MIME type of the screenshot image (default: image/png).
  157010. * Check your browser for supported MIME types
  157011. * @param samples Texture samples (default: 1)
  157012. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  157013. * @param fileName A name for for the downloaded file.
  157014. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  157015. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  157016. */
  157017. 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;
  157018. /**
  157019. * Generates an image screenshot from the specified camera.
  157020. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  157021. * @param engine The engine to use for rendering
  157022. * @param camera The camera to use for rendering
  157023. * @param size This parameter can be set to a single number or to an object with the
  157024. * following (optional) properties: precision, width, height. If a single number is passed,
  157025. * it will be used for both width and height. If an object is passed, the screenshot size
  157026. * will be derived from the parameters. The precision property is a multiplier allowing
  157027. * rendering at a higher or lower resolution
  157028. * @param mimeType The MIME type of the screenshot image (default: image/png).
  157029. * Check your browser for supported MIME types
  157030. * @param samples Texture samples (default: 1)
  157031. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  157032. * @param fileName A name for for the downloaded file.
  157033. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  157034. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  157035. * to the src parameter of an <img> to display it
  157036. */
  157037. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  157038. /**
  157039. * Gets height and width for screenshot size
  157040. * @private
  157041. */
  157042. private static _getScreenshotSize;
  157043. }
  157044. }
  157045. declare module BABYLON {
  157046. /**
  157047. * Interface for a data buffer
  157048. */
  157049. export interface IDataBuffer {
  157050. /**
  157051. * Reads bytes from the data buffer.
  157052. * @param byteOffset The byte offset to read
  157053. * @param byteLength The byte length to read
  157054. * @returns A promise that resolves when the bytes are read
  157055. */
  157056. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  157057. /**
  157058. * The byte length of the buffer.
  157059. */
  157060. readonly byteLength: number;
  157061. }
  157062. /**
  157063. * Utility class for reading from a data buffer
  157064. */
  157065. export class DataReader {
  157066. /**
  157067. * The data buffer associated with this data reader.
  157068. */
  157069. readonly buffer: IDataBuffer;
  157070. /**
  157071. * The current byte offset from the beginning of the data buffer.
  157072. */
  157073. byteOffset: number;
  157074. private _dataView;
  157075. private _dataByteOffset;
  157076. /**
  157077. * Constructor
  157078. * @param buffer The buffer to read
  157079. */
  157080. constructor(buffer: IDataBuffer);
  157081. /**
  157082. * Loads the given byte length.
  157083. * @param byteLength The byte length to load
  157084. * @returns A promise that resolves when the load is complete
  157085. */
  157086. loadAsync(byteLength: number): Promise<void>;
  157087. /**
  157088. * Read a unsigned 32-bit integer from the currently loaded data range.
  157089. * @returns The 32-bit integer read
  157090. */
  157091. readUint32(): number;
  157092. /**
  157093. * Read a byte array from the currently loaded data range.
  157094. * @param byteLength The byte length to read
  157095. * @returns The byte array read
  157096. */
  157097. readUint8Array(byteLength: number): Uint8Array;
  157098. /**
  157099. * Read a string from the currently loaded data range.
  157100. * @param byteLength The byte length to read
  157101. * @returns The string read
  157102. */
  157103. readString(byteLength: number): string;
  157104. /**
  157105. * Skips the given byte length the currently loaded data range.
  157106. * @param byteLength The byte length to skip
  157107. */
  157108. skipBytes(byteLength: number): void;
  157109. }
  157110. }
  157111. declare module BABYLON {
  157112. /**
  157113. * Class for storing data to local storage if available or in-memory storage otherwise
  157114. */
  157115. export class DataStorage {
  157116. private static _Storage;
  157117. private static _GetStorage;
  157118. /**
  157119. * Reads a string from the data storage
  157120. * @param key The key to read
  157121. * @param defaultValue The value if the key doesn't exist
  157122. * @returns The string value
  157123. */
  157124. static ReadString(key: string, defaultValue: string): string;
  157125. /**
  157126. * Writes a string to the data storage
  157127. * @param key The key to write
  157128. * @param value The value to write
  157129. */
  157130. static WriteString(key: string, value: string): void;
  157131. /**
  157132. * Reads a boolean from the data storage
  157133. * @param key The key to read
  157134. * @param defaultValue The value if the key doesn't exist
  157135. * @returns The boolean value
  157136. */
  157137. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  157138. /**
  157139. * Writes a boolean to the data storage
  157140. * @param key The key to write
  157141. * @param value The value to write
  157142. */
  157143. static WriteBoolean(key: string, value: boolean): void;
  157144. /**
  157145. * Reads a number from the data storage
  157146. * @param key The key to read
  157147. * @param defaultValue The value if the key doesn't exist
  157148. * @returns The number value
  157149. */
  157150. static ReadNumber(key: string, defaultValue: number): number;
  157151. /**
  157152. * Writes a number to the data storage
  157153. * @param key The key to write
  157154. * @param value The value to write
  157155. */
  157156. static WriteNumber(key: string, value: number): void;
  157157. }
  157158. }
  157159. declare module BABYLON {
  157160. /**
  157161. * Class used to record delta files between 2 scene states
  157162. */
  157163. export class SceneRecorder {
  157164. private _trackedScene;
  157165. private _savedJSON;
  157166. /**
  157167. * Track a given scene. This means the current scene state will be considered the original state
  157168. * @param scene defines the scene to track
  157169. */
  157170. track(scene: Scene): void;
  157171. /**
  157172. * Get the delta between current state and original state
  157173. * @returns a string containing the delta
  157174. */
  157175. getDelta(): any;
  157176. private _compareArray;
  157177. private _compareObjects;
  157178. private _compareCollections;
  157179. private static GetShadowGeneratorById;
  157180. /**
  157181. * Apply a given delta to a given scene
  157182. * @param deltaJSON defines the JSON containing the delta
  157183. * @param scene defines the scene to apply the delta to
  157184. */
  157185. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  157186. private static _ApplyPropertiesToEntity;
  157187. private static _ApplyDeltaForEntity;
  157188. }
  157189. }
  157190. declare module BABYLON {
  157191. /**
  157192. * A 3D trajectory consisting of an order list of vectors describing a
  157193. * path of motion through 3D space.
  157194. */
  157195. export class Trajectory {
  157196. private _points;
  157197. private readonly _segmentLength;
  157198. /**
  157199. * Serialize to JSON.
  157200. * @returns serialized JSON string
  157201. */
  157202. serialize(): string;
  157203. /**
  157204. * Deserialize from JSON.
  157205. * @param json serialized JSON string
  157206. * @returns deserialized Trajectory
  157207. */
  157208. static Deserialize(json: string): Trajectory;
  157209. /**
  157210. * Create a new empty Trajectory.
  157211. * @param segmentLength radius of discretization for Trajectory points
  157212. */
  157213. constructor(segmentLength?: number);
  157214. /**
  157215. * Get the length of the Trajectory.
  157216. * @returns length of the Trajectory
  157217. */
  157218. getLength(): number;
  157219. /**
  157220. * Append a new point to the Trajectory.
  157221. * NOTE: This implementation has many allocations.
  157222. * @param point point to append to the Trajectory
  157223. */
  157224. add(point: DeepImmutable<Vector3>): void;
  157225. /**
  157226. * Create a new Trajectory with a segment length chosen to make it
  157227. * probable that the new Trajectory will have a specified number of
  157228. * segments. This operation is imprecise.
  157229. * @param targetResolution number of segments desired
  157230. * @returns new Trajectory with approximately the requested number of segments
  157231. */
  157232. resampleAtTargetResolution(targetResolution: number): Trajectory;
  157233. /**
  157234. * Convert Trajectory segments into tokenized representation. This
  157235. * representation is an array of numbers where each nth number is the
  157236. * index of the token which is most similar to the nth segment of the
  157237. * Trajectory.
  157238. * @param tokens list of vectors which serve as discrete tokens
  157239. * @returns list of indices of most similar token per segment
  157240. */
  157241. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  157242. private static _forwardDir;
  157243. private static _inverseFromVec;
  157244. private static _upDir;
  157245. private static _fromToVec;
  157246. private static _lookMatrix;
  157247. /**
  157248. * Transform the rotation (i.e., direction) of a segment to isolate
  157249. * the relative transformation represented by the segment. This operation
  157250. * may or may not succeed due to singularities in the equations that define
  157251. * motion relativity in this context.
  157252. * @param priorVec the origin of the prior segment
  157253. * @param fromVec the origin of the current segment
  157254. * @param toVec the destination of the current segment
  157255. * @param result reference to output variable
  157256. * @returns whether or not transformation was successful
  157257. */
  157258. private static _transformSegmentDirToRef;
  157259. private static _bestMatch;
  157260. private static _score;
  157261. private static _bestScore;
  157262. /**
  157263. * Determine which token vector is most similar to the
  157264. * segment vector.
  157265. * @param segment segment vector
  157266. * @param tokens token vector list
  157267. * @returns index of the most similar token to the segment
  157268. */
  157269. private static _tokenizeSegment;
  157270. }
  157271. /**
  157272. * Class representing a set of known, named trajectories to which Trajectories can be
  157273. * added and using which Trajectories can be recognized.
  157274. */
  157275. export class TrajectoryClassifier {
  157276. private _maximumAllowableMatchCost;
  157277. private _vector3Alphabet;
  157278. private _levenshteinAlphabet;
  157279. private _nameToDescribedTrajectory;
  157280. /**
  157281. * Serialize to JSON.
  157282. * @returns JSON serialization
  157283. */
  157284. serialize(): string;
  157285. /**
  157286. * Deserialize from JSON.
  157287. * @param json JSON serialization
  157288. * @returns deserialized TrajectorySet
  157289. */
  157290. static Deserialize(json: string): TrajectoryClassifier;
  157291. /**
  157292. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  157293. * VERY naive, need to be generating these things from known
  157294. * sets. Better version later, probably eliminating this one.
  157295. * @returns auto-generated TrajectorySet
  157296. */
  157297. static Generate(): TrajectoryClassifier;
  157298. private constructor();
  157299. /**
  157300. * Add a new Trajectory to the set with a given name.
  157301. * @param trajectory new Trajectory to be added
  157302. * @param classification name to which to add the Trajectory
  157303. */
  157304. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  157305. /**
  157306. * Remove a known named trajectory and all Trajectories associated with it.
  157307. * @param classification name to remove
  157308. * @returns whether anything was removed
  157309. */
  157310. deleteClassification(classification: string): boolean;
  157311. /**
  157312. * Attempt to recognize a Trajectory from among all the classifications
  157313. * already known to the classifier.
  157314. * @param trajectory Trajectory to be recognized
  157315. * @returns classification of Trajectory if recognized, null otherwise
  157316. */
  157317. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  157318. }
  157319. }
  157320. declare module BABYLON {
  157321. /**
  157322. * An interface for all Hit test features
  157323. */
  157324. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  157325. /**
  157326. * Triggered when new babylon (transformed) hit test results are available
  157327. */
  157328. onHitTestResultObservable: Observable<T[]>;
  157329. }
  157330. /**
  157331. * Options used for hit testing
  157332. */
  157333. export interface IWebXRLegacyHitTestOptions {
  157334. /**
  157335. * Only test when user interacted with the scene. Default - hit test every frame
  157336. */
  157337. testOnPointerDownOnly?: boolean;
  157338. /**
  157339. * The node to use to transform the local results to world coordinates
  157340. */
  157341. worldParentNode?: TransformNode;
  157342. }
  157343. /**
  157344. * Interface defining the babylon result of raycasting/hit-test
  157345. */
  157346. export interface IWebXRLegacyHitResult {
  157347. /**
  157348. * Transformation matrix that can be applied to a node that will put it in the hit point location
  157349. */
  157350. transformationMatrix: Matrix;
  157351. /**
  157352. * The native hit test result
  157353. */
  157354. xrHitResult: XRHitResult | XRHitTestResult;
  157355. }
  157356. /**
  157357. * The currently-working hit-test module.
  157358. * Hit test (or Ray-casting) is used to interact with the real world.
  157359. * For further information read here - https://github.com/immersive-web/hit-test
  157360. */
  157361. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  157362. /**
  157363. * options to use when constructing this feature
  157364. */
  157365. readonly options: IWebXRLegacyHitTestOptions;
  157366. private _direction;
  157367. private _mat;
  157368. private _onSelectEnabled;
  157369. private _origin;
  157370. /**
  157371. * The module's name
  157372. */
  157373. static readonly Name: string;
  157374. /**
  157375. * The (Babylon) version of this module.
  157376. * This is an integer representing the implementation version.
  157377. * This number does not correspond to the WebXR specs version
  157378. */
  157379. static readonly Version: number;
  157380. /**
  157381. * Populated with the last native XR Hit Results
  157382. */
  157383. lastNativeXRHitResults: XRHitResult[];
  157384. /**
  157385. * Triggered when new babylon (transformed) hit test results are available
  157386. */
  157387. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  157388. /**
  157389. * Creates a new instance of the (legacy version) hit test feature
  157390. * @param _xrSessionManager an instance of WebXRSessionManager
  157391. * @param options options to use when constructing this feature
  157392. */
  157393. constructor(_xrSessionManager: WebXRSessionManager,
  157394. /**
  157395. * options to use when constructing this feature
  157396. */
  157397. options?: IWebXRLegacyHitTestOptions);
  157398. /**
  157399. * execute a hit test with an XR Ray
  157400. *
  157401. * @param xrSession a native xrSession that will execute this hit test
  157402. * @param xrRay the ray (position and direction) to use for ray-casting
  157403. * @param referenceSpace native XR reference space to use for the hit-test
  157404. * @param filter filter function that will filter the results
  157405. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  157406. */
  157407. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  157408. /**
  157409. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  157410. * @param event the (select) event to use to select with
  157411. * @param referenceSpace the reference space to use for this hit test
  157412. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  157413. */
  157414. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  157415. /**
  157416. * attach this feature
  157417. * Will usually be called by the features manager
  157418. *
  157419. * @returns true if successful.
  157420. */
  157421. attach(): boolean;
  157422. /**
  157423. * detach this feature.
  157424. * Will usually be called by the features manager
  157425. *
  157426. * @returns true if successful.
  157427. */
  157428. detach(): boolean;
  157429. /**
  157430. * Dispose this feature and all of the resources attached
  157431. */
  157432. dispose(): void;
  157433. protected _onXRFrame(frame: XRFrame): void;
  157434. private _onHitTestResults;
  157435. private _onSelect;
  157436. }
  157437. }
  157438. declare module BABYLON {
  157439. /**
  157440. * Options used for hit testing (version 2)
  157441. */
  157442. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  157443. /**
  157444. * Do not create a permanent hit test. Will usually be used when only
  157445. * transient inputs are needed.
  157446. */
  157447. disablePermanentHitTest?: boolean;
  157448. /**
  157449. * Enable transient (for example touch-based) hit test inspections
  157450. */
  157451. enableTransientHitTest?: boolean;
  157452. /**
  157453. * Offset ray for the permanent hit test
  157454. */
  157455. offsetRay?: Vector3;
  157456. /**
  157457. * Offset ray for the transient hit test
  157458. */
  157459. transientOffsetRay?: Vector3;
  157460. /**
  157461. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  157462. */
  157463. useReferenceSpace?: boolean;
  157464. /**
  157465. * Override the default entity type(s) of the hit-test result
  157466. */
  157467. entityTypes?: XRHitTestTrackableType[];
  157468. }
  157469. /**
  157470. * Interface defining the babylon result of hit-test
  157471. */
  157472. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  157473. /**
  157474. * The input source that generated this hit test (if transient)
  157475. */
  157476. inputSource?: XRInputSource;
  157477. /**
  157478. * Is this a transient hit test
  157479. */
  157480. isTransient?: boolean;
  157481. /**
  157482. * Position of the hit test result
  157483. */
  157484. position: Vector3;
  157485. /**
  157486. * Rotation of the hit test result
  157487. */
  157488. rotationQuaternion: Quaternion;
  157489. /**
  157490. * The native hit test result
  157491. */
  157492. xrHitResult: XRHitTestResult;
  157493. }
  157494. /**
  157495. * The currently-working hit-test module.
  157496. * Hit test (or Ray-casting) is used to interact with the real world.
  157497. * For further information read here - https://github.com/immersive-web/hit-test
  157498. *
  157499. * Tested on chrome (mobile) 80.
  157500. */
  157501. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  157502. /**
  157503. * options to use when constructing this feature
  157504. */
  157505. readonly options: IWebXRHitTestOptions;
  157506. private _tmpMat;
  157507. private _tmpPos;
  157508. private _tmpQuat;
  157509. private _transientXrHitTestSource;
  157510. private _xrHitTestSource;
  157511. private initHitTestSource;
  157512. /**
  157513. * The module's name
  157514. */
  157515. static readonly Name: string;
  157516. /**
  157517. * The (Babylon) version of this module.
  157518. * This is an integer representing the implementation version.
  157519. * This number does not correspond to the WebXR specs version
  157520. */
  157521. static readonly Version: number;
  157522. /**
  157523. * When set to true, each hit test will have its own position/rotation objects
  157524. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  157525. * the developers will clone them or copy them as they see fit.
  157526. */
  157527. autoCloneTransformation: boolean;
  157528. /**
  157529. * Triggered when new babylon (transformed) hit test results are available
  157530. * Note - this will be called when results come back from the device. It can be an empty array!!
  157531. */
  157532. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  157533. /**
  157534. * Use this to temporarily pause hit test checks.
  157535. */
  157536. paused: boolean;
  157537. /**
  157538. * Creates a new instance of the hit test feature
  157539. * @param _xrSessionManager an instance of WebXRSessionManager
  157540. * @param options options to use when constructing this feature
  157541. */
  157542. constructor(_xrSessionManager: WebXRSessionManager,
  157543. /**
  157544. * options to use when constructing this feature
  157545. */
  157546. options?: IWebXRHitTestOptions);
  157547. /**
  157548. * attach this feature
  157549. * Will usually be called by the features manager
  157550. *
  157551. * @returns true if successful.
  157552. */
  157553. attach(): boolean;
  157554. /**
  157555. * detach this feature.
  157556. * Will usually be called by the features manager
  157557. *
  157558. * @returns true if successful.
  157559. */
  157560. detach(): boolean;
  157561. /**
  157562. * Dispose this feature and all of the resources attached
  157563. */
  157564. dispose(): void;
  157565. protected _onXRFrame(frame: XRFrame): void;
  157566. private _processWebXRHitTestResult;
  157567. }
  157568. }
  157569. declare module BABYLON {
  157570. /**
  157571. * Configuration options of the anchor system
  157572. */
  157573. export interface IWebXRAnchorSystemOptions {
  157574. /**
  157575. * a node that will be used to convert local to world coordinates
  157576. */
  157577. worldParentNode?: TransformNode;
  157578. /**
  157579. * If set to true a reference of the created anchors will be kept until the next session starts
  157580. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  157581. */
  157582. doNotRemoveAnchorsOnSessionEnded?: boolean;
  157583. }
  157584. /**
  157585. * A babylon container for an XR Anchor
  157586. */
  157587. export interface IWebXRAnchor {
  157588. /**
  157589. * A babylon-assigned ID for this anchor
  157590. */
  157591. id: number;
  157592. /**
  157593. * Transformation matrix to apply to an object attached to this anchor
  157594. */
  157595. transformationMatrix: Matrix;
  157596. /**
  157597. * The native anchor object
  157598. */
  157599. xrAnchor: XRAnchor;
  157600. /**
  157601. * if defined, this object will be constantly updated by the anchor's position and rotation
  157602. */
  157603. attachedNode?: TransformNode;
  157604. /**
  157605. * Remove this anchor from the scene
  157606. */
  157607. remove(): void;
  157608. }
  157609. /**
  157610. * An implementation of the anchor system for WebXR.
  157611. * For further information see https://github.com/immersive-web/anchors/
  157612. */
  157613. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  157614. private _options;
  157615. private _lastFrameDetected;
  157616. private _trackedAnchors;
  157617. private _referenceSpaceForFrameAnchors;
  157618. private _futureAnchors;
  157619. /**
  157620. * The module's name
  157621. */
  157622. static readonly Name: string;
  157623. /**
  157624. * The (Babylon) version of this module.
  157625. * This is an integer representing the implementation version.
  157626. * This number does not correspond to the WebXR specs version
  157627. */
  157628. static readonly Version: number;
  157629. /**
  157630. * Observers registered here will be executed when a new anchor was added to the session
  157631. */
  157632. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  157633. /**
  157634. * Observers registered here will be executed when an anchor was removed from the session
  157635. */
  157636. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  157637. /**
  157638. * Observers registered here will be executed when an existing anchor updates
  157639. * This can execute N times every frame
  157640. */
  157641. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  157642. /**
  157643. * Set the reference space to use for anchor creation, when not using a hit test.
  157644. * Will default to the session's reference space if not defined
  157645. */
  157646. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  157647. /**
  157648. * constructs a new anchor system
  157649. * @param _xrSessionManager an instance of WebXRSessionManager
  157650. * @param _options configuration object for this feature
  157651. */
  157652. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  157653. private _tmpVector;
  157654. private _tmpQuaternion;
  157655. private _populateTmpTransformation;
  157656. /**
  157657. * Create a new anchor point using a hit test result at a specific point in the scene
  157658. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  157659. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  157660. *
  157661. * @param hitTestResult The hit test result to use for this anchor creation
  157662. * @param position an optional position offset for this anchor
  157663. * @param rotationQuaternion an optional rotation offset for this anchor
  157664. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  157665. */
  157666. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  157667. /**
  157668. * Add a new anchor at a specific position and rotation
  157669. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  157670. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  157671. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  157672. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  157673. *
  157674. * @param position the position in which to add an anchor
  157675. * @param rotationQuaternion an optional rotation for the anchor transformation
  157676. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  157677. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  157678. */
  157679. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  157680. /**
  157681. * Get the list of anchors currently being tracked by the system
  157682. */
  157683. get anchors(): IWebXRAnchor[];
  157684. /**
  157685. * detach this feature.
  157686. * Will usually be called by the features manager
  157687. *
  157688. * @returns true if successful.
  157689. */
  157690. detach(): boolean;
  157691. /**
  157692. * Dispose this feature and all of the resources attached
  157693. */
  157694. dispose(): void;
  157695. protected _onXRFrame(frame: XRFrame): void;
  157696. /**
  157697. * avoiding using Array.find for global support.
  157698. * @param xrAnchor the plane to find in the array
  157699. */
  157700. private _findIndexInAnchorArray;
  157701. private _updateAnchorWithXRFrame;
  157702. private _createAnchorAtTransformation;
  157703. }
  157704. }
  157705. declare module BABYLON {
  157706. /**
  157707. * Options used in the plane detector module
  157708. */
  157709. export interface IWebXRPlaneDetectorOptions {
  157710. /**
  157711. * The node to use to transform the local results to world coordinates
  157712. */
  157713. worldParentNode?: TransformNode;
  157714. /**
  157715. * If set to true a reference of the created planes will be kept until the next session starts
  157716. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  157717. */
  157718. doNotRemovePlanesOnSessionEnded?: boolean;
  157719. }
  157720. /**
  157721. * A babylon interface for a WebXR plane.
  157722. * A Plane is actually a polygon, built from N points in space
  157723. *
  157724. * Supported in chrome 79, not supported in canary 81 ATM
  157725. */
  157726. export interface IWebXRPlane {
  157727. /**
  157728. * a babylon-assigned ID for this polygon
  157729. */
  157730. id: number;
  157731. /**
  157732. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  157733. */
  157734. polygonDefinition: Array<Vector3>;
  157735. /**
  157736. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  157737. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  157738. */
  157739. transformationMatrix: Matrix;
  157740. /**
  157741. * the native xr-plane object
  157742. */
  157743. xrPlane: XRPlane;
  157744. }
  157745. /**
  157746. * The plane detector is used to detect planes in the real world when in AR
  157747. * For more information see https://github.com/immersive-web/real-world-geometry/
  157748. */
  157749. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  157750. private _options;
  157751. private _detectedPlanes;
  157752. private _enabled;
  157753. private _lastFrameDetected;
  157754. /**
  157755. * The module's name
  157756. */
  157757. static readonly Name: string;
  157758. /**
  157759. * The (Babylon) version of this module.
  157760. * This is an integer representing the implementation version.
  157761. * This number does not correspond to the WebXR specs version
  157762. */
  157763. static readonly Version: number;
  157764. /**
  157765. * Observers registered here will be executed when a new plane was added to the session
  157766. */
  157767. onPlaneAddedObservable: Observable<IWebXRPlane>;
  157768. /**
  157769. * Observers registered here will be executed when a plane is no longer detected in the session
  157770. */
  157771. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  157772. /**
  157773. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  157774. * This can execute N times every frame
  157775. */
  157776. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  157777. /**
  157778. * construct a new Plane Detector
  157779. * @param _xrSessionManager an instance of xr Session manager
  157780. * @param _options configuration to use when constructing this feature
  157781. */
  157782. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  157783. /**
  157784. * detach this feature.
  157785. * Will usually be called by the features manager
  157786. *
  157787. * @returns true if successful.
  157788. */
  157789. detach(): boolean;
  157790. /**
  157791. * Dispose this feature and all of the resources attached
  157792. */
  157793. dispose(): void;
  157794. /**
  157795. * Check if the needed objects are defined.
  157796. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  157797. */
  157798. isCompatible(): boolean;
  157799. protected _onXRFrame(frame: XRFrame): void;
  157800. private _init;
  157801. private _updatePlaneWithXRPlane;
  157802. /**
  157803. * avoiding using Array.find for global support.
  157804. * @param xrPlane the plane to find in the array
  157805. */
  157806. private findIndexInPlaneArray;
  157807. }
  157808. }
  157809. declare module BABYLON {
  157810. /**
  157811. * Options interface for the background remover plugin
  157812. */
  157813. export interface IWebXRBackgroundRemoverOptions {
  157814. /**
  157815. * Further background meshes to disable when entering AR
  157816. */
  157817. backgroundMeshes?: AbstractMesh[];
  157818. /**
  157819. * flags to configure the removal of the environment helper.
  157820. * If not set, the entire background will be removed. If set, flags should be set as well.
  157821. */
  157822. environmentHelperRemovalFlags?: {
  157823. /**
  157824. * Should the skybox be removed (default false)
  157825. */
  157826. skyBox?: boolean;
  157827. /**
  157828. * Should the ground be removed (default false)
  157829. */
  157830. ground?: boolean;
  157831. };
  157832. /**
  157833. * don't disable the environment helper
  157834. */
  157835. ignoreEnvironmentHelper?: boolean;
  157836. }
  157837. /**
  157838. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  157839. */
  157840. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  157841. /**
  157842. * read-only options to be used in this module
  157843. */
  157844. readonly options: IWebXRBackgroundRemoverOptions;
  157845. /**
  157846. * The module's name
  157847. */
  157848. static readonly Name: string;
  157849. /**
  157850. * The (Babylon) version of this module.
  157851. * This is an integer representing the implementation version.
  157852. * This number does not correspond to the WebXR specs version
  157853. */
  157854. static readonly Version: number;
  157855. /**
  157856. * registered observers will be triggered when the background state changes
  157857. */
  157858. onBackgroundStateChangedObservable: Observable<boolean>;
  157859. /**
  157860. * constructs a new background remover module
  157861. * @param _xrSessionManager the session manager for this module
  157862. * @param options read-only options to be used in this module
  157863. */
  157864. constructor(_xrSessionManager: WebXRSessionManager,
  157865. /**
  157866. * read-only options to be used in this module
  157867. */
  157868. options?: IWebXRBackgroundRemoverOptions);
  157869. /**
  157870. * attach this feature
  157871. * Will usually be called by the features manager
  157872. *
  157873. * @returns true if successful.
  157874. */
  157875. attach(): boolean;
  157876. /**
  157877. * detach this feature.
  157878. * Will usually be called by the features manager
  157879. *
  157880. * @returns true if successful.
  157881. */
  157882. detach(): boolean;
  157883. /**
  157884. * Dispose this feature and all of the resources attached
  157885. */
  157886. dispose(): void;
  157887. protected _onXRFrame(_xrFrame: XRFrame): void;
  157888. private _setBackgroundState;
  157889. }
  157890. }
  157891. declare module BABYLON {
  157892. /**
  157893. * Options for the controller physics feature
  157894. */
  157895. export class IWebXRControllerPhysicsOptions {
  157896. /**
  157897. * Should the headset get its own impostor
  157898. */
  157899. enableHeadsetImpostor?: boolean;
  157900. /**
  157901. * Optional parameters for the headset impostor
  157902. */
  157903. headsetImpostorParams?: {
  157904. /**
  157905. * The type of impostor to create. Default is sphere
  157906. */
  157907. impostorType: number;
  157908. /**
  157909. * the size of the impostor. Defaults to 10cm
  157910. */
  157911. impostorSize?: number | {
  157912. width: number;
  157913. height: number;
  157914. depth: number;
  157915. };
  157916. /**
  157917. * Friction definitions
  157918. */
  157919. friction?: number;
  157920. /**
  157921. * Restitution
  157922. */
  157923. restitution?: number;
  157924. };
  157925. /**
  157926. * The physics properties of the future impostors
  157927. */
  157928. physicsProperties?: {
  157929. /**
  157930. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  157931. * Note that this requires a physics engine that supports mesh impostors!
  157932. */
  157933. useControllerMesh?: boolean;
  157934. /**
  157935. * The type of impostor to create. Default is sphere
  157936. */
  157937. impostorType?: number;
  157938. /**
  157939. * the size of the impostor. Defaults to 10cm
  157940. */
  157941. impostorSize?: number | {
  157942. width: number;
  157943. height: number;
  157944. depth: number;
  157945. };
  157946. /**
  157947. * Friction definitions
  157948. */
  157949. friction?: number;
  157950. /**
  157951. * Restitution
  157952. */
  157953. restitution?: number;
  157954. };
  157955. /**
  157956. * the xr input to use with this pointer selection
  157957. */
  157958. xrInput: WebXRInput;
  157959. }
  157960. /**
  157961. * Add physics impostor to your webxr controllers,
  157962. * including naive calculation of their linear and angular velocity
  157963. */
  157964. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  157965. private readonly _options;
  157966. private _attachController;
  157967. private _controllers;
  157968. private _debugMode;
  157969. private _delta;
  157970. private _headsetImpostor?;
  157971. private _headsetMesh?;
  157972. private _lastTimestamp;
  157973. private _tmpQuaternion;
  157974. private _tmpVector;
  157975. /**
  157976. * The module's name
  157977. */
  157978. static readonly Name: string;
  157979. /**
  157980. * The (Babylon) version of this module.
  157981. * This is an integer representing the implementation version.
  157982. * This number does not correspond to the webxr specs version
  157983. */
  157984. static readonly Version: number;
  157985. /**
  157986. * Construct a new Controller Physics Feature
  157987. * @param _xrSessionManager the corresponding xr session manager
  157988. * @param _options options to create this feature with
  157989. */
  157990. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  157991. /**
  157992. * @hidden
  157993. * enable debugging - will show console outputs and the impostor mesh
  157994. */
  157995. _enablePhysicsDebug(): void;
  157996. /**
  157997. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  157998. * @param xrController the controller to add
  157999. */
  158000. addController(xrController: WebXRInputSource): void;
  158001. /**
  158002. * attach this feature
  158003. * Will usually be called by the features manager
  158004. *
  158005. * @returns true if successful.
  158006. */
  158007. attach(): boolean;
  158008. /**
  158009. * detach this feature.
  158010. * Will usually be called by the features manager
  158011. *
  158012. * @returns true if successful.
  158013. */
  158014. detach(): boolean;
  158015. /**
  158016. * Get the headset impostor, if enabled
  158017. * @returns the impostor
  158018. */
  158019. getHeadsetImpostor(): PhysicsImpostor | undefined;
  158020. /**
  158021. * Get the physics impostor of a specific controller.
  158022. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  158023. * @param controller the controller or the controller id of which to get the impostor
  158024. * @returns the impostor or null
  158025. */
  158026. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  158027. /**
  158028. * Update the physics properties provided in the constructor
  158029. * @param newProperties the new properties object
  158030. */
  158031. setPhysicsProperties(newProperties: {
  158032. impostorType?: number;
  158033. impostorSize?: number | {
  158034. width: number;
  158035. height: number;
  158036. depth: number;
  158037. };
  158038. friction?: number;
  158039. restitution?: number;
  158040. }): void;
  158041. protected _onXRFrame(_xrFrame: any): void;
  158042. private _detachController;
  158043. }
  158044. }
  158045. declare module BABYLON {
  158046. /**
  158047. * A babylon interface for a "WebXR" feature point.
  158048. * Represents the position and confidence value of a given feature point.
  158049. */
  158050. export interface IWebXRFeaturePoint {
  158051. /**
  158052. * Represents the position of the feature point in world space.
  158053. */
  158054. position: Vector3;
  158055. /**
  158056. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  158057. */
  158058. confidenceValue: number;
  158059. }
  158060. /**
  158061. * The feature point system is used to detect feature points from real world geometry.
  158062. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  158063. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  158064. */
  158065. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  158066. private _enabled;
  158067. private _featurePointCloud;
  158068. /**
  158069. * The module's name
  158070. */
  158071. static readonly Name: string;
  158072. /**
  158073. * The (Babylon) version of this module.
  158074. * This is an integer representing the implementation version.
  158075. * This number does not correspond to the WebXR specs version
  158076. */
  158077. static readonly Version: number;
  158078. /**
  158079. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  158080. * Will notify the observers about which feature points have been added.
  158081. */
  158082. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  158083. /**
  158084. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  158085. * Will notify the observers about which feature points have been updated.
  158086. */
  158087. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  158088. /**
  158089. * The current feature point cloud maintained across frames.
  158090. */
  158091. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  158092. /**
  158093. * construct the feature point system
  158094. * @param _xrSessionManager an instance of xr Session manager
  158095. */
  158096. constructor(_xrSessionManager: WebXRSessionManager);
  158097. /**
  158098. * Detach this feature.
  158099. * Will usually be called by the features manager
  158100. *
  158101. * @returns true if successful.
  158102. */
  158103. detach(): boolean;
  158104. /**
  158105. * Dispose this feature and all of the resources attached
  158106. */
  158107. dispose(): void;
  158108. /**
  158109. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  158110. */
  158111. protected _onXRFrame(frame: XRFrame): void;
  158112. /**
  158113. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  158114. */
  158115. private _init;
  158116. }
  158117. }
  158118. declare module BABYLON {
  158119. /**
  158120. * Configuration interface for the hand tracking feature
  158121. */
  158122. export interface IWebXRHandTrackingOptions {
  158123. /**
  158124. * The xrInput that will be used as source for new hands
  158125. */
  158126. xrInput: WebXRInput;
  158127. /**
  158128. * Configuration object for the joint meshes
  158129. */
  158130. jointMeshes?: {
  158131. /**
  158132. * Should the meshes created be invisible (defaults to false)
  158133. */
  158134. invisible?: boolean;
  158135. /**
  158136. * A source mesh to be used to create instances. Defaults to a sphere.
  158137. * This mesh will be the source for all other (25) meshes.
  158138. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  158139. */
  158140. sourceMesh?: Mesh;
  158141. /**
  158142. * This function will be called after a mesh was created for a specific joint.
  158143. * Using this function you can either manipulate the instance or return a new mesh.
  158144. * When returning a new mesh the instance created before will be disposed
  158145. */
  158146. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  158147. /**
  158148. * Should the source mesh stay visible. Defaults to false
  158149. */
  158150. keepOriginalVisible?: boolean;
  158151. /**
  158152. * Scale factor for all instances (defaults to 2)
  158153. */
  158154. scaleFactor?: number;
  158155. /**
  158156. * Should each instance have its own physics impostor
  158157. */
  158158. enablePhysics?: boolean;
  158159. /**
  158160. * If enabled, override default physics properties
  158161. */
  158162. physicsProps?: {
  158163. friction?: number;
  158164. restitution?: number;
  158165. impostorType?: number;
  158166. };
  158167. /**
  158168. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  158169. */
  158170. handMesh?: AbstractMesh;
  158171. };
  158172. }
  158173. /**
  158174. * Parts of the hands divided to writs and finger names
  158175. */
  158176. export const enum HandPart {
  158177. /**
  158178. * HandPart - Wrist
  158179. */
  158180. WRIST = "wrist",
  158181. /**
  158182. * HandPart - The THumb
  158183. */
  158184. THUMB = "thumb",
  158185. /**
  158186. * HandPart - Index finger
  158187. */
  158188. INDEX = "index",
  158189. /**
  158190. * HandPart - Middle finger
  158191. */
  158192. MIDDLE = "middle",
  158193. /**
  158194. * HandPart - Ring finger
  158195. */
  158196. RING = "ring",
  158197. /**
  158198. * HandPart - Little finger
  158199. */
  158200. LITTLE = "little"
  158201. }
  158202. /**
  158203. * Representing a single hand (with its corresponding native XRHand object)
  158204. */
  158205. export class WebXRHand implements IDisposable {
  158206. /** the controller to which the hand correlates */
  158207. readonly xrController: WebXRInputSource;
  158208. /** the meshes to be used to track the hand joints */
  158209. readonly trackedMeshes: AbstractMesh[];
  158210. /**
  158211. * Hand-parts definition (key is HandPart)
  158212. */
  158213. handPartsDefinition: {
  158214. [key: string]: number[];
  158215. };
  158216. /**
  158217. * Populate the HandPartsDefinition object.
  158218. * This is called as a side effect since certain browsers don't have XRHand defined.
  158219. */
  158220. private generateHandPartsDefinition;
  158221. /**
  158222. * Construct a new hand object
  158223. * @param xrController the controller to which the hand correlates
  158224. * @param trackedMeshes the meshes to be used to track the hand joints
  158225. */
  158226. constructor(
  158227. /** the controller to which the hand correlates */
  158228. xrController: WebXRInputSource,
  158229. /** the meshes to be used to track the hand joints */
  158230. trackedMeshes: AbstractMesh[]);
  158231. /**
  158232. * Update this hand from the latest xr frame
  158233. * @param xrFrame xrFrame to update from
  158234. * @param referenceSpace The current viewer reference space
  158235. * @param scaleFactor optional scale factor for the meshes
  158236. */
  158237. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  158238. /**
  158239. * Get meshes of part of the hand
  158240. * @param part the part of hand to get
  158241. * @returns An array of meshes that correlate to the hand part requested
  158242. */
  158243. getHandPartMeshes(part: HandPart): AbstractMesh[];
  158244. /**
  158245. * Dispose this Hand object
  158246. */
  158247. dispose(): void;
  158248. }
  158249. /**
  158250. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  158251. */
  158252. export class WebXRHandTracking extends WebXRAbstractFeature {
  158253. /**
  158254. * options to use when constructing this feature
  158255. */
  158256. readonly options: IWebXRHandTrackingOptions;
  158257. private static _idCounter;
  158258. /**
  158259. * The module's name
  158260. */
  158261. static readonly Name: string;
  158262. /**
  158263. * The (Babylon) version of this module.
  158264. * This is an integer representing the implementation version.
  158265. * This number does not correspond to the WebXR specs version
  158266. */
  158267. static readonly Version: number;
  158268. /**
  158269. * This observable will notify registered observers when a new hand object was added and initialized
  158270. */
  158271. onHandAddedObservable: Observable<WebXRHand>;
  158272. /**
  158273. * This observable will notify its observers right before the hand object is disposed
  158274. */
  158275. onHandRemovedObservable: Observable<WebXRHand>;
  158276. private _hands;
  158277. /**
  158278. * Creates a new instance of the hit test feature
  158279. * @param _xrSessionManager an instance of WebXRSessionManager
  158280. * @param options options to use when constructing this feature
  158281. */
  158282. constructor(_xrSessionManager: WebXRSessionManager,
  158283. /**
  158284. * options to use when constructing this feature
  158285. */
  158286. options: IWebXRHandTrackingOptions);
  158287. /**
  158288. * Check if the needed objects are defined.
  158289. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  158290. */
  158291. isCompatible(): boolean;
  158292. /**
  158293. * attach this feature
  158294. * Will usually be called by the features manager
  158295. *
  158296. * @returns true if successful.
  158297. */
  158298. attach(): boolean;
  158299. /**
  158300. * detach this feature.
  158301. * Will usually be called by the features manager
  158302. *
  158303. * @returns true if successful.
  158304. */
  158305. detach(): boolean;
  158306. /**
  158307. * Dispose this feature and all of the resources attached
  158308. */
  158309. dispose(): void;
  158310. /**
  158311. * Get the hand object according to the controller id
  158312. * @param controllerId the controller id to which we want to get the hand
  158313. * @returns null if not found or the WebXRHand object if found
  158314. */
  158315. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  158316. /**
  158317. * Get a hand object according to the requested handedness
  158318. * @param handedness the handedness to request
  158319. * @returns null if not found or the WebXRHand object if found
  158320. */
  158321. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  158322. protected _onXRFrame(_xrFrame: XRFrame): void;
  158323. private _attachHand;
  158324. private _detachHand;
  158325. }
  158326. }
  158327. declare module BABYLON {
  158328. /**
  158329. * The motion controller class for all microsoft mixed reality controllers
  158330. */
  158331. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  158332. protected readonly _mapping: {
  158333. defaultButton: {
  158334. valueNodeName: string;
  158335. unpressedNodeName: string;
  158336. pressedNodeName: string;
  158337. };
  158338. defaultAxis: {
  158339. valueNodeName: string;
  158340. minNodeName: string;
  158341. maxNodeName: string;
  158342. };
  158343. buttons: {
  158344. "xr-standard-trigger": {
  158345. rootNodeName: string;
  158346. componentProperty: string;
  158347. states: string[];
  158348. };
  158349. "xr-standard-squeeze": {
  158350. rootNodeName: string;
  158351. componentProperty: string;
  158352. states: string[];
  158353. };
  158354. "xr-standard-touchpad": {
  158355. rootNodeName: string;
  158356. labelAnchorNodeName: string;
  158357. touchPointNodeName: string;
  158358. };
  158359. "xr-standard-thumbstick": {
  158360. rootNodeName: string;
  158361. componentProperty: string;
  158362. states: string[];
  158363. };
  158364. };
  158365. axes: {
  158366. "xr-standard-touchpad": {
  158367. "x-axis": {
  158368. rootNodeName: string;
  158369. };
  158370. "y-axis": {
  158371. rootNodeName: string;
  158372. };
  158373. };
  158374. "xr-standard-thumbstick": {
  158375. "x-axis": {
  158376. rootNodeName: string;
  158377. };
  158378. "y-axis": {
  158379. rootNodeName: string;
  158380. };
  158381. };
  158382. };
  158383. };
  158384. /**
  158385. * The base url used to load the left and right controller models
  158386. */
  158387. static MODEL_BASE_URL: string;
  158388. /**
  158389. * The name of the left controller model file
  158390. */
  158391. static MODEL_LEFT_FILENAME: string;
  158392. /**
  158393. * The name of the right controller model file
  158394. */
  158395. static MODEL_RIGHT_FILENAME: string;
  158396. profileId: string;
  158397. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  158398. protected _getFilenameAndPath(): {
  158399. filename: string;
  158400. path: string;
  158401. };
  158402. protected _getModelLoadingConstraints(): boolean;
  158403. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  158404. protected _setRootMesh(meshes: AbstractMesh[]): void;
  158405. protected _updateModel(): void;
  158406. }
  158407. }
  158408. declare module BABYLON {
  158409. /**
  158410. * The motion controller class for oculus touch (quest, rift).
  158411. * This class supports legacy mapping as well the standard xr mapping
  158412. */
  158413. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  158414. private _forceLegacyControllers;
  158415. private _modelRootNode;
  158416. /**
  158417. * The base url used to load the left and right controller models
  158418. */
  158419. static MODEL_BASE_URL: string;
  158420. /**
  158421. * The name of the left controller model file
  158422. */
  158423. static MODEL_LEFT_FILENAME: string;
  158424. /**
  158425. * The name of the right controller model file
  158426. */
  158427. static MODEL_RIGHT_FILENAME: string;
  158428. /**
  158429. * Base Url for the Quest controller model.
  158430. */
  158431. static QUEST_MODEL_BASE_URL: string;
  158432. profileId: string;
  158433. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  158434. protected _getFilenameAndPath(): {
  158435. filename: string;
  158436. path: string;
  158437. };
  158438. protected _getModelLoadingConstraints(): boolean;
  158439. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  158440. protected _setRootMesh(meshes: AbstractMesh[]): void;
  158441. protected _updateModel(): void;
  158442. /**
  158443. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  158444. * between the touch and touch 2.
  158445. */
  158446. private _isQuest;
  158447. }
  158448. }
  158449. declare module BABYLON {
  158450. /**
  158451. * The motion controller class for the standard HTC-Vive controllers
  158452. */
  158453. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  158454. private _modelRootNode;
  158455. /**
  158456. * The base url used to load the left and right controller models
  158457. */
  158458. static MODEL_BASE_URL: string;
  158459. /**
  158460. * File name for the controller model.
  158461. */
  158462. static MODEL_FILENAME: string;
  158463. profileId: string;
  158464. /**
  158465. * Create a new Vive motion controller object
  158466. * @param scene the scene to use to create this controller
  158467. * @param gamepadObject the corresponding gamepad object
  158468. * @param handedness the handedness of the controller
  158469. */
  158470. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  158471. protected _getFilenameAndPath(): {
  158472. filename: string;
  158473. path: string;
  158474. };
  158475. protected _getModelLoadingConstraints(): boolean;
  158476. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  158477. protected _setRootMesh(meshes: AbstractMesh[]): void;
  158478. protected _updateModel(): void;
  158479. }
  158480. }
  158481. declare module BABYLON {
  158482. /**
  158483. * A cursor which tracks a point on a path
  158484. */
  158485. export class PathCursor {
  158486. private path;
  158487. /**
  158488. * Stores path cursor callbacks for when an onchange event is triggered
  158489. */
  158490. private _onchange;
  158491. /**
  158492. * The value of the path cursor
  158493. */
  158494. value: number;
  158495. /**
  158496. * The animation array of the path cursor
  158497. */
  158498. animations: Animation[];
  158499. /**
  158500. * Initializes the path cursor
  158501. * @param path The path to track
  158502. */
  158503. constructor(path: Path2);
  158504. /**
  158505. * Gets the cursor point on the path
  158506. * @returns A point on the path cursor at the cursor location
  158507. */
  158508. getPoint(): Vector3;
  158509. /**
  158510. * Moves the cursor ahead by the step amount
  158511. * @param step The amount to move the cursor forward
  158512. * @returns This path cursor
  158513. */
  158514. moveAhead(step?: number): PathCursor;
  158515. /**
  158516. * Moves the cursor behind by the step amount
  158517. * @param step The amount to move the cursor back
  158518. * @returns This path cursor
  158519. */
  158520. moveBack(step?: number): PathCursor;
  158521. /**
  158522. * Moves the cursor by the step amount
  158523. * If the step amount is greater than one, an exception is thrown
  158524. * @param step The amount to move the cursor
  158525. * @returns This path cursor
  158526. */
  158527. move(step: number): PathCursor;
  158528. /**
  158529. * Ensures that the value is limited between zero and one
  158530. * @returns This path cursor
  158531. */
  158532. private ensureLimits;
  158533. /**
  158534. * Runs onchange callbacks on change (used by the animation engine)
  158535. * @returns This path cursor
  158536. */
  158537. private raiseOnChange;
  158538. /**
  158539. * Executes a function on change
  158540. * @param f A path cursor onchange callback
  158541. * @returns This path cursor
  158542. */
  158543. onchange(f: (cursor: PathCursor) => void): PathCursor;
  158544. }
  158545. }
  158546. declare module BABYLON {
  158547. /** @hidden */
  158548. export var blurPixelShader: {
  158549. name: string;
  158550. shader: string;
  158551. };
  158552. }
  158553. declare module BABYLON {
  158554. /** @hidden */
  158555. export var pointCloudVertexDeclaration: {
  158556. name: string;
  158557. shader: string;
  158558. };
  158559. }
  158560. // Mixins
  158561. interface Window {
  158562. mozIndexedDB: IDBFactory;
  158563. webkitIndexedDB: IDBFactory;
  158564. msIndexedDB: IDBFactory;
  158565. webkitURL: typeof URL;
  158566. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  158567. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  158568. WebGLRenderingContext: WebGLRenderingContext;
  158569. MSGesture: MSGesture;
  158570. CANNON: any;
  158571. AudioContext: AudioContext;
  158572. webkitAudioContext: AudioContext;
  158573. PointerEvent: any;
  158574. Math: Math;
  158575. Uint8Array: Uint8ArrayConstructor;
  158576. Float32Array: Float32ArrayConstructor;
  158577. mozURL: typeof URL;
  158578. msURL: typeof URL;
  158579. VRFrameData: any; // WebVR, from specs 1.1
  158580. DracoDecoderModule: any;
  158581. setImmediate(handler: (...args: any[]) => void): number;
  158582. }
  158583. interface HTMLCanvasElement {
  158584. requestPointerLock(): void;
  158585. msRequestPointerLock?(): void;
  158586. mozRequestPointerLock?(): void;
  158587. webkitRequestPointerLock?(): void;
  158588. /** Track wether a record is in progress */
  158589. isRecording: boolean;
  158590. /** Capture Stream method defined by some browsers */
  158591. captureStream(fps?: number): MediaStream;
  158592. }
  158593. interface CanvasRenderingContext2D {
  158594. msImageSmoothingEnabled: boolean;
  158595. }
  158596. interface MouseEvent {
  158597. mozMovementX: number;
  158598. mozMovementY: number;
  158599. webkitMovementX: number;
  158600. webkitMovementY: number;
  158601. msMovementX: number;
  158602. msMovementY: number;
  158603. }
  158604. interface Navigator {
  158605. mozGetVRDevices: (any: any) => any;
  158606. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  158607. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  158608. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  158609. webkitGetGamepads(): Gamepad[];
  158610. msGetGamepads(): Gamepad[];
  158611. webkitGamepads(): Gamepad[];
  158612. }
  158613. interface HTMLVideoElement {
  158614. mozSrcObject: any;
  158615. }
  158616. interface Math {
  158617. fround(x: number): number;
  158618. imul(a: number, b: number): number;
  158619. }
  158620. interface WebGLRenderingContext {
  158621. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  158622. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  158623. vertexAttribDivisor(index: number, divisor: number): void;
  158624. createVertexArray(): any;
  158625. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  158626. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  158627. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  158628. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  158629. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  158630. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  158631. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  158632. // Queries
  158633. createQuery(): WebGLQuery;
  158634. deleteQuery(query: WebGLQuery): void;
  158635. beginQuery(target: number, query: WebGLQuery): void;
  158636. endQuery(target: number): void;
  158637. getQueryParameter(query: WebGLQuery, pname: number): any;
  158638. getQuery(target: number, pname: number): any;
  158639. MAX_SAMPLES: number;
  158640. RGBA8: number;
  158641. READ_FRAMEBUFFER: number;
  158642. DRAW_FRAMEBUFFER: number;
  158643. UNIFORM_BUFFER: number;
  158644. HALF_FLOAT_OES: number;
  158645. RGBA16F: number;
  158646. RGBA32F: number;
  158647. R32F: number;
  158648. RG32F: number;
  158649. RGB32F: number;
  158650. R16F: number;
  158651. RG16F: number;
  158652. RGB16F: number;
  158653. RED: number;
  158654. RG: number;
  158655. R8: number;
  158656. RG8: number;
  158657. UNSIGNED_INT_24_8: number;
  158658. DEPTH24_STENCIL8: number;
  158659. MIN: number;
  158660. MAX: number;
  158661. /* Multiple Render Targets */
  158662. drawBuffers(buffers: number[]): void;
  158663. readBuffer(src: number): void;
  158664. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  158665. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  158666. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  158667. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  158668. // Occlusion Query
  158669. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  158670. ANY_SAMPLES_PASSED: number;
  158671. QUERY_RESULT_AVAILABLE: number;
  158672. QUERY_RESULT: number;
  158673. }
  158674. interface WebGLProgram {
  158675. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  158676. }
  158677. interface EXT_disjoint_timer_query {
  158678. QUERY_COUNTER_BITS_EXT: number;
  158679. TIME_ELAPSED_EXT: number;
  158680. TIMESTAMP_EXT: number;
  158681. GPU_DISJOINT_EXT: number;
  158682. QUERY_RESULT_EXT: number;
  158683. QUERY_RESULT_AVAILABLE_EXT: number;
  158684. queryCounterEXT(query: WebGLQuery, target: number): void;
  158685. createQueryEXT(): WebGLQuery;
  158686. beginQueryEXT(target: number, query: WebGLQuery): void;
  158687. endQueryEXT(target: number): void;
  158688. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  158689. deleteQueryEXT(query: WebGLQuery): void;
  158690. }
  158691. interface WebGLUniformLocation {
  158692. _currentState: any;
  158693. }
  158694. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  158695. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  158696. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  158697. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  158698. interface WebGLRenderingContext {
  158699. readonly RASTERIZER_DISCARD: number;
  158700. readonly DEPTH_COMPONENT24: number;
  158701. readonly TEXTURE_3D: number;
  158702. readonly TEXTURE_2D_ARRAY: number;
  158703. readonly TEXTURE_COMPARE_FUNC: number;
  158704. readonly TEXTURE_COMPARE_MODE: number;
  158705. readonly COMPARE_REF_TO_TEXTURE: number;
  158706. readonly TEXTURE_WRAP_R: number;
  158707. readonly HALF_FLOAT: number;
  158708. readonly RGB8: number;
  158709. readonly RED_INTEGER: number;
  158710. readonly RG_INTEGER: number;
  158711. readonly RGB_INTEGER: number;
  158712. readonly RGBA_INTEGER: number;
  158713. readonly R8_SNORM: number;
  158714. readonly RG8_SNORM: number;
  158715. readonly RGB8_SNORM: number;
  158716. readonly RGBA8_SNORM: number;
  158717. readonly R8I: number;
  158718. readonly RG8I: number;
  158719. readonly RGB8I: number;
  158720. readonly RGBA8I: number;
  158721. readonly R8UI: number;
  158722. readonly RG8UI: number;
  158723. readonly RGB8UI: number;
  158724. readonly RGBA8UI: number;
  158725. readonly R16I: number;
  158726. readonly RG16I: number;
  158727. readonly RGB16I: number;
  158728. readonly RGBA16I: number;
  158729. readonly R16UI: number;
  158730. readonly RG16UI: number;
  158731. readonly RGB16UI: number;
  158732. readonly RGBA16UI: number;
  158733. readonly R32I: number;
  158734. readonly RG32I: number;
  158735. readonly RGB32I: number;
  158736. readonly RGBA32I: number;
  158737. readonly R32UI: number;
  158738. readonly RG32UI: number;
  158739. readonly RGB32UI: number;
  158740. readonly RGBA32UI: number;
  158741. readonly RGB10_A2UI: number;
  158742. readonly R11F_G11F_B10F: number;
  158743. readonly RGB9_E5: number;
  158744. readonly RGB10_A2: number;
  158745. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  158746. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  158747. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  158748. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  158749. readonly DEPTH_COMPONENT32F: number;
  158750. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  158751. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  158752. 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;
  158753. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  158754. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  158755. readonly TRANSFORM_FEEDBACK: number;
  158756. readonly INTERLEAVED_ATTRIBS: number;
  158757. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  158758. createTransformFeedback(): WebGLTransformFeedback;
  158759. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  158760. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  158761. beginTransformFeedback(primitiveMode: number): void;
  158762. endTransformFeedback(): void;
  158763. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  158764. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  158765. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  158766. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  158767. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  158768. }
  158769. interface ImageBitmap {
  158770. readonly width: number;
  158771. readonly height: number;
  158772. close(): void;
  158773. }
  158774. interface WebGLQuery extends WebGLObject {
  158775. }
  158776. declare var WebGLQuery: {
  158777. prototype: WebGLQuery;
  158778. new(): WebGLQuery;
  158779. };
  158780. interface WebGLSampler extends WebGLObject {
  158781. }
  158782. declare var WebGLSampler: {
  158783. prototype: WebGLSampler;
  158784. new(): WebGLSampler;
  158785. };
  158786. interface WebGLSync extends WebGLObject {
  158787. }
  158788. declare var WebGLSync: {
  158789. prototype: WebGLSync;
  158790. new(): WebGLSync;
  158791. };
  158792. interface WebGLTransformFeedback extends WebGLObject {
  158793. }
  158794. declare var WebGLTransformFeedback: {
  158795. prototype: WebGLTransformFeedback;
  158796. new(): WebGLTransformFeedback;
  158797. };
  158798. interface WebGLVertexArrayObject extends WebGLObject {
  158799. }
  158800. declare var WebGLVertexArrayObject: {
  158801. prototype: WebGLVertexArrayObject;
  158802. new(): WebGLVertexArrayObject;
  158803. };
  158804. // Type definitions for WebVR API
  158805. // Project: https://w3c.github.io/webvr/
  158806. // Definitions by: six a <https://github.com/lostfictions>
  158807. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  158808. interface VRDisplay extends EventTarget {
  158809. /**
  158810. * Dictionary of capabilities describing the VRDisplay.
  158811. */
  158812. readonly capabilities: VRDisplayCapabilities;
  158813. /**
  158814. * z-depth defining the far plane of the eye view frustum
  158815. * enables mapping of values in the render target depth
  158816. * attachment to scene coordinates. Initially set to 10000.0.
  158817. */
  158818. depthFar: number;
  158819. /**
  158820. * z-depth defining the near plane of the eye view frustum
  158821. * enables mapping of values in the render target depth
  158822. * attachment to scene coordinates. Initially set to 0.01.
  158823. */
  158824. depthNear: number;
  158825. /**
  158826. * An identifier for this distinct VRDisplay. Used as an
  158827. * association point in the Gamepad API.
  158828. */
  158829. readonly displayId: number;
  158830. /**
  158831. * A display name, a user-readable name identifying it.
  158832. */
  158833. readonly displayName: string;
  158834. readonly isConnected: boolean;
  158835. readonly isPresenting: boolean;
  158836. /**
  158837. * If this VRDisplay supports room-scale experiences, the optional
  158838. * stage attribute contains details on the room-scale parameters.
  158839. */
  158840. readonly stageParameters: VRStageParameters | null;
  158841. /**
  158842. * Passing the value returned by `requestAnimationFrame` to
  158843. * `cancelAnimationFrame` will unregister the callback.
  158844. * @param handle Define the hanle of the request to cancel
  158845. */
  158846. cancelAnimationFrame(handle: number): void;
  158847. /**
  158848. * Stops presenting to the VRDisplay.
  158849. * @returns a promise to know when it stopped
  158850. */
  158851. exitPresent(): Promise<void>;
  158852. /**
  158853. * Return the current VREyeParameters for the given eye.
  158854. * @param whichEye Define the eye we want the parameter for
  158855. * @returns the eye parameters
  158856. */
  158857. getEyeParameters(whichEye: string): VREyeParameters;
  158858. /**
  158859. * Populates the passed VRFrameData with the information required to render
  158860. * the current frame.
  158861. * @param frameData Define the data structure to populate
  158862. * @returns true if ok otherwise false
  158863. */
  158864. getFrameData(frameData: VRFrameData): boolean;
  158865. /**
  158866. * Get the layers currently being presented.
  158867. * @returns the list of VR layers
  158868. */
  158869. getLayers(): VRLayer[];
  158870. /**
  158871. * Return a VRPose containing the future predicted pose of the VRDisplay
  158872. * when the current frame will be presented. The value returned will not
  158873. * change until JavaScript has returned control to the browser.
  158874. *
  158875. * The VRPose will contain the position, orientation, velocity,
  158876. * and acceleration of each of these properties.
  158877. * @returns the pose object
  158878. */
  158879. getPose(): VRPose;
  158880. /**
  158881. * Return the current instantaneous pose of the VRDisplay, with no
  158882. * prediction applied.
  158883. * @returns the current instantaneous pose
  158884. */
  158885. getImmediatePose(): VRPose;
  158886. /**
  158887. * The callback passed to `requestAnimationFrame` will be called
  158888. * any time a new frame should be rendered. When the VRDisplay is
  158889. * presenting the callback will be called at the native refresh
  158890. * rate of the HMD. When not presenting this function acts
  158891. * identically to how window.requestAnimationFrame acts. Content should
  158892. * make no assumptions of frame rate or vsync behavior as the HMD runs
  158893. * asynchronously from other displays and at differing refresh rates.
  158894. * @param callback Define the eaction to run next frame
  158895. * @returns the request handle it
  158896. */
  158897. requestAnimationFrame(callback: FrameRequestCallback): number;
  158898. /**
  158899. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  158900. * Repeat calls while already presenting will update the VRLayers being displayed.
  158901. * @param layers Define the list of layer to present
  158902. * @returns a promise to know when the request has been fulfilled
  158903. */
  158904. requestPresent(layers: VRLayer[]): Promise<void>;
  158905. /**
  158906. * Reset the pose for this display, treating its current position and
  158907. * orientation as the "origin/zero" values. VRPose.position,
  158908. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  158909. * updated when calling resetPose(). This should be called in only
  158910. * sitting-space experiences.
  158911. */
  158912. resetPose(): void;
  158913. /**
  158914. * The VRLayer provided to the VRDisplay will be captured and presented
  158915. * in the HMD. Calling this function has the same effect on the source
  158916. * canvas as any other operation that uses its source image, and canvases
  158917. * created without preserveDrawingBuffer set to true will be cleared.
  158918. * @param pose Define the pose to submit
  158919. */
  158920. submitFrame(pose?: VRPose): void;
  158921. }
  158922. declare var VRDisplay: {
  158923. prototype: VRDisplay;
  158924. new(): VRDisplay;
  158925. };
  158926. interface VRLayer {
  158927. leftBounds?: number[] | Float32Array | null;
  158928. rightBounds?: number[] | Float32Array | null;
  158929. source?: HTMLCanvasElement | null;
  158930. }
  158931. interface VRDisplayCapabilities {
  158932. readonly canPresent: boolean;
  158933. readonly hasExternalDisplay: boolean;
  158934. readonly hasOrientation: boolean;
  158935. readonly hasPosition: boolean;
  158936. readonly maxLayers: number;
  158937. }
  158938. interface VREyeParameters {
  158939. /** @deprecated */
  158940. readonly fieldOfView: VRFieldOfView;
  158941. readonly offset: Float32Array;
  158942. readonly renderHeight: number;
  158943. readonly renderWidth: number;
  158944. }
  158945. interface VRFieldOfView {
  158946. readonly downDegrees: number;
  158947. readonly leftDegrees: number;
  158948. readonly rightDegrees: number;
  158949. readonly upDegrees: number;
  158950. }
  158951. interface VRFrameData {
  158952. readonly leftProjectionMatrix: Float32Array;
  158953. readonly leftViewMatrix: Float32Array;
  158954. readonly pose: VRPose;
  158955. readonly rightProjectionMatrix: Float32Array;
  158956. readonly rightViewMatrix: Float32Array;
  158957. readonly timestamp: number;
  158958. }
  158959. interface VRPose {
  158960. readonly angularAcceleration: Float32Array | null;
  158961. readonly angularVelocity: Float32Array | null;
  158962. readonly linearAcceleration: Float32Array | null;
  158963. readonly linearVelocity: Float32Array | null;
  158964. readonly orientation: Float32Array | null;
  158965. readonly position: Float32Array | null;
  158966. readonly timestamp: number;
  158967. }
  158968. interface VRStageParameters {
  158969. sittingToStandingTransform?: Float32Array;
  158970. sizeX?: number;
  158971. sizeY?: number;
  158972. }
  158973. interface Navigator {
  158974. getVRDisplays(): Promise<VRDisplay[]>;
  158975. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  158976. }
  158977. interface Window {
  158978. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  158979. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  158980. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  158981. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  158982. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  158983. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  158984. }
  158985. interface Gamepad {
  158986. readonly displayId: number;
  158987. }
  158988. /**
  158989. * Available session modes
  158990. */
  158991. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  158992. /**
  158993. * Reference space types
  158994. */
  158995. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  158996. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  158997. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  158998. /**
  158999. * Handedness types
  159000. */
  159001. type XRHandedness = "none" | "left" | "right";
  159002. /**
  159003. * InputSource target ray modes
  159004. */
  159005. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  159006. /**
  159007. * Eye types
  159008. */
  159009. type XREye = "none" | "left" | "right";
  159010. /**
  159011. * Type of XR events available
  159012. */
  159013. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  159014. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  159015. type XRPlaneSet = Set<XRPlane>;
  159016. type XRAnchorSet = Set<XRAnchor>;
  159017. type XREventHandler = (callback: any) => void;
  159018. interface XRLayer extends EventTarget {}
  159019. interface XRSessionInit {
  159020. optionalFeatures?: string[];
  159021. requiredFeatures?: string[];
  159022. }
  159023. interface XRSessionEvent extends Event {
  159024. readonly session: XRSession;
  159025. }
  159026. interface XRSystem {
  159027. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  159028. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  159029. }
  159030. interface XRViewport {
  159031. readonly x: number;
  159032. readonly y: number;
  159033. readonly width: number;
  159034. readonly height: number;
  159035. }
  159036. interface XRWebGLLayerInit {
  159037. antialias?: boolean;
  159038. depth?: boolean;
  159039. stencil?: boolean;
  159040. alpha?: boolean;
  159041. multiview?: boolean;
  159042. framebufferScaleFactor?: number;
  159043. }
  159044. declare class XRWebGLLayer {
  159045. static getNativeFramebufferScaleFactor(session: XRSession): number;
  159046. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  159047. readonly antialias: boolean;
  159048. readonly framebuffer: WebGLFramebuffer;
  159049. readonly framebufferWidth: number;
  159050. readonly framebufferHeight: number;
  159051. readonly ignoreDepthValues: boolean;
  159052. getViewport: (view: XRView) => XRViewport;
  159053. }
  159054. // tslint:disable-next-line no-empty-interface
  159055. interface XRSpace extends EventTarget {}
  159056. interface XRRenderState {
  159057. readonly baseLayer?: XRWebGLLayer;
  159058. readonly depthFar: number;
  159059. readonly depthNear: number;
  159060. readonly inlineVerticalFieldOfView?: number;
  159061. }
  159062. interface XRRenderStateInit extends XRRenderState {
  159063. baseLayer: XRWebGLLayer;
  159064. depthFar: number;
  159065. depthNear: number;
  159066. inlineVerticalFieldOfView?: number;
  159067. layers?: XRLayer[];
  159068. }
  159069. interface XRReferenceSpace extends XRSpace {
  159070. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  159071. onreset: XREventHandler;
  159072. }
  159073. interface XRBoundedReferenceSpace extends XRSpace {
  159074. readonly boundsGeometry: DOMPointReadOnly[];
  159075. }
  159076. interface XRInputSource {
  159077. readonly handedness: XRHandedness;
  159078. readonly targetRayMode: XRTargetRayMode;
  159079. readonly targetRaySpace: XRSpace;
  159080. readonly gripSpace?: XRSpace;
  159081. readonly gamepad?: Gamepad;
  159082. readonly profiles: Array<string>;
  159083. readonly hand?: XRHand;
  159084. }
  159085. interface XRPose {
  159086. readonly transform: XRRigidTransform;
  159087. readonly emulatedPosition: boolean;
  159088. }
  159089. interface XRFrame {
  159090. readonly session: XRSession;
  159091. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  159092. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  159093. // AR
  159094. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  159095. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  159096. // Anchors
  159097. trackedAnchors?: XRAnchorSet;
  159098. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  159099. // Planes
  159100. worldInformation?: {
  159101. detectedPlanes?: XRPlaneSet;
  159102. };
  159103. // Hand tracking
  159104. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  159105. }
  159106. interface XRInputSourceEvent extends Event {
  159107. readonly frame: XRFrame;
  159108. readonly inputSource: XRInputSource;
  159109. }
  159110. type XRInputSourceArray = XRInputSource[];
  159111. interface XRSession {
  159112. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  159113. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  159114. /**
  159115. * Returns a list of this session's XRInputSources, each representing an input device
  159116. * used to control the camera and/or scene.
  159117. */
  159118. readonly inputSources: Array<XRInputSource>;
  159119. /**
  159120. * object which contains options affecting how the imagery is rendered.
  159121. * This includes things such as the near and far clipping planes
  159122. */
  159123. readonly renderState: XRRenderState;
  159124. readonly visibilityState: XRVisibilityState;
  159125. /**
  159126. * Removes a callback from the animation frame painting callback from
  159127. * XRSession's set of animation frame rendering callbacks, given the
  159128. * identifying handle returned by a previous call to requestAnimationFrame().
  159129. */
  159130. cancelAnimationFrame: (handle: number) => void;
  159131. /**
  159132. * Ends the WebXR session. Returns a promise which resolves when the
  159133. * session has been shut down.
  159134. */
  159135. end(): Promise<void>;
  159136. /**
  159137. * Schedules the specified method to be called the next time the user agent
  159138. * is working on rendering an animation frame for the WebXR device. Returns an
  159139. * integer value which can be used to identify the request for the purposes of
  159140. * canceling the callback using cancelAnimationFrame(). This method is comparable
  159141. * to the Window.requestAnimationFrame() method.
  159142. */
  159143. requestAnimationFrame: XRFrameRequestCallback;
  159144. /**
  159145. * Requests that a new XRReferenceSpace of the specified type be created.
  159146. * Returns a promise which resolves with the XRReferenceSpace or
  159147. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  159148. * the requested space type isn't supported by the device.
  159149. */
  159150. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  159151. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  159152. onend: XREventHandler;
  159153. oninputsourceschange: XREventHandler;
  159154. onselect: XREventHandler;
  159155. onselectstart: XREventHandler;
  159156. onselectend: XREventHandler;
  159157. onsqueeze: XREventHandler;
  159158. onsqueezestart: XREventHandler;
  159159. onsqueezeend: XREventHandler;
  159160. onvisibilitychange: XREventHandler;
  159161. // hit test
  159162. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  159163. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  159164. // legacy AR hit test
  159165. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  159166. // legacy plane detection
  159167. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  159168. }
  159169. interface XRViewerPose extends XRPose {
  159170. readonly views: Array<XRView>;
  159171. }
  159172. declare class XRRigidTransform {
  159173. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  159174. position: DOMPointReadOnly;
  159175. orientation: DOMPointReadOnly;
  159176. matrix: Float32Array;
  159177. inverse: XRRigidTransform;
  159178. }
  159179. interface XRView {
  159180. readonly eye: XREye;
  159181. readonly projectionMatrix: Float32Array;
  159182. readonly transform: XRRigidTransform;
  159183. readonly recommendedViewportScale?: number;
  159184. requestViewportScale(scale: number): void;
  159185. }
  159186. interface XRInputSourceChangeEvent extends Event {
  159187. session: XRSession;
  159188. removed: Array<XRInputSource>;
  159189. added: Array<XRInputSource>;
  159190. }
  159191. // Experimental/Draft features
  159192. declare class XRRay {
  159193. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  159194. origin: DOMPointReadOnly;
  159195. direction: DOMPointReadOnly;
  159196. matrix: Float32Array;
  159197. }
  159198. declare enum XRHitTestTrackableType {
  159199. "point",
  159200. "plane",
  159201. "mesh",
  159202. }
  159203. interface XRHitResult {
  159204. hitMatrix: Float32Array;
  159205. }
  159206. interface XRTransientInputHitTestResult {
  159207. readonly inputSource: XRInputSource;
  159208. readonly results: Array<XRHitTestResult>;
  159209. }
  159210. interface XRHitTestResult {
  159211. getPose(baseSpace: XRSpace): XRPose | undefined;
  159212. // When anchor system is enabled
  159213. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  159214. }
  159215. interface XRHitTestSource {
  159216. cancel(): void;
  159217. }
  159218. interface XRTransientInputHitTestSource {
  159219. cancel(): void;
  159220. }
  159221. interface XRHitTestOptionsInit {
  159222. space: XRSpace;
  159223. entityTypes?: Array<XRHitTestTrackableType>;
  159224. offsetRay?: XRRay;
  159225. }
  159226. interface XRTransientInputHitTestOptionsInit {
  159227. profile: string;
  159228. entityTypes?: Array<XRHitTestTrackableType>;
  159229. offsetRay?: XRRay;
  159230. }
  159231. interface XRAnchor {
  159232. anchorSpace: XRSpace;
  159233. delete(): void;
  159234. }
  159235. interface XRPlane {
  159236. orientation: "Horizontal" | "Vertical";
  159237. planeSpace: XRSpace;
  159238. polygon: Array<DOMPointReadOnly>;
  159239. lastChangedTime: number;
  159240. }
  159241. interface XRJointSpace extends XRSpace {}
  159242. interface XRJointPose extends XRPose {
  159243. radius: number | undefined;
  159244. }
  159245. interface XRHand extends Iterable<XRJointSpace> {
  159246. readonly length: number;
  159247. [index: number]: XRJointSpace;
  159248. readonly WRIST: number;
  159249. readonly THUMB_METACARPAL: number;
  159250. readonly THUMB_PHALANX_PROXIMAL: number;
  159251. readonly THUMB_PHALANX_DISTAL: number;
  159252. readonly THUMB_PHALANX_TIP: number;
  159253. readonly INDEX_METACARPAL: number;
  159254. readonly INDEX_PHALANX_PROXIMAL: number;
  159255. readonly INDEX_PHALANX_INTERMEDIATE: number;
  159256. readonly INDEX_PHALANX_DISTAL: number;
  159257. readonly INDEX_PHALANX_TIP: number;
  159258. readonly MIDDLE_METACARPAL: number;
  159259. readonly MIDDLE_PHALANX_PROXIMAL: number;
  159260. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  159261. readonly MIDDLE_PHALANX_DISTAL: number;
  159262. readonly MIDDLE_PHALANX_TIP: number;
  159263. readonly RING_METACARPAL: number;
  159264. readonly RING_PHALANX_PROXIMAL: number;
  159265. readonly RING_PHALANX_INTERMEDIATE: number;
  159266. readonly RING_PHALANX_DISTAL: number;
  159267. readonly RING_PHALANX_TIP: number;
  159268. readonly LITTLE_METACARPAL: number;
  159269. readonly LITTLE_PHALANX_PROXIMAL: number;
  159270. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  159271. readonly LITTLE_PHALANX_DISTAL: number;
  159272. readonly LITTLE_PHALANX_TIP: number;
  159273. }
  159274. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  159275. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  159276. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  159277. interface XRSession {
  159278. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  159279. }
  159280. interface XRFrame {
  159281. featurePointCloud? : Array<number>;
  159282. }